run copyright.sh for 2011.
[deliverable/binutils-gdb.git] / gdb / tui / tui-command.c
CommitLineData
f377b406 1/* Specific command window processing.
f33c6cbf 2
0fb0cc75 3 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008,
7b6bb8da 4 2009, 2010, 2011 Free Software Foundation, Inc.
f33c6cbf 5
f377b406
SC
6 Contributed by Hewlett-Packard Company.
7
8 This file is part of GDB.
9
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
a9762ec7 12 the Free Software Foundation; either version 3 of the License, or
f377b406
SC
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
a9762ec7 21 along with this program. If not, see <http://www.gnu.org/licenses/>. */
c906108c 22
96ec9981
DJ
23#include "defs.h"
24#include <ctype.h>
d7b2e967
AC
25#include "tui/tui.h"
26#include "tui/tui-data.h"
27#include "tui/tui-win.h"
28#include "tui/tui-io.h"
2c0b251b 29#include "tui/tui-command.h"
f33c6cbf 30
6a83354a 31#include "gdb_curses.h"
88289b6e 32#include "gdb_string.h"
4e8f7a8b 33
c906108c
SS
34
35/*****************************************
36** STATIC LOCAL FUNCTIONS FORWARD DECLS **
37******************************************/
38
39
40
41/*****************************************
42** PUBLIC FUNCTIONS **
43******************************************/
44
1cc6d956
MS
45/* Dispatch the correct tui function based upon the control
46 character. */
c906108c 47unsigned int
b0a30fce 48tui_dispatch_ctrl_char (unsigned int ch)
c906108c 49{
6d012f14 50 struct tui_win_info *win_info = tui_win_with_focus ();
c906108c 51
ca9d4aea
SC
52 /* Handle the CTRL-L refresh for each window. */
53 if (ch == '\f')
54 tui_refresh_all_win ();
55
56 /* If the command window has the logical focus, or no-one does
1cc6d956
MS
57 assume it is the command window; in this case, pass the character
58 on through and do nothing here. */
6d012f14 59 if (win_info == NULL || win_info == TUI_CMD_WIN)
c906108c
SS
60 return ch;
61 else
62 {
6ba8e26f 63 unsigned int c = 0, ch_copy = ch;
d02c80cd 64 int i;
c906108c
SS
65 char *term;
66
ef5eab5a
MS
67 /* If this is an xterm, page next/prev keys aren't returned by
68 keypad as a single char, so we must handle them here. Seems
69 like a bug in the curses library? */
c906108c 70 term = (char *) getenv ("TERM");
bbe6b987 71 if (term)
c906108c 72 {
bbe6b987
AS
73 for (i = 0; term[i]; i++)
74 term[i] = toupper (term[i]);
e5908723
MS
75 if ((strcmp (term, "XTERM") == 0)
76 && key_is_start_sequence (ch))
c906108c 77 {
bbe6b987
AS
78 unsigned int page_ch = 0;
79 unsigned int tmp_char;
ca9d4aea 80 WINDOW *w = TUI_CMD_WIN->generic.handle;
bbe6b987
AS
81
82 tmp_char = 0;
83 while (!key_is_end_sequence (tmp_char))
9b2d6cca 84 {
bbe6b987
AS
85 tmp_char = (int) wgetch (w);
86 if (tmp_char == ERR)
87 {
88 return ch;
89 }
90 if (!tmp_char)
91 break;
92 if (tmp_char == 53)
93 page_ch = KEY_PPAGE;
94 else if (tmp_char == 54)
95 page_ch = KEY_NPAGE;
96 else
97 {
98 return 0;
99 }
9b2d6cca 100 }
bbe6b987 101 ch_copy = page_ch;
c906108c 102 }
c906108c
SS
103 }
104
6ba8e26f 105 switch (ch_copy)
c906108c
SS
106 {
107 case KEY_NPAGE:
6d012f14 108 tui_scroll_forward (win_info, 0);
c906108c
SS
109 break;
110 case KEY_PPAGE:
6d012f14 111 tui_scroll_backward (win_info, 0);
c906108c
SS
112 break;
113 case KEY_DOWN:
114 case KEY_SF:
6d012f14 115 tui_scroll_forward (win_info, 1);
c906108c
SS
116 break;
117 case KEY_UP:
118 case KEY_SR:
6d012f14 119 tui_scroll_backward (win_info, 1);
c906108c
SS
120 break;
121 case KEY_RIGHT:
6d012f14 122 tui_scroll_left (win_info, 1);
c906108c
SS
123 break;
124 case KEY_LEFT:
6d012f14 125 tui_scroll_right (win_info, 1);
c906108c
SS
126 break;
127 case '\f':
ca9d4aea 128 break;
c906108c 129 default:
6ba8e26f 130 c = ch_copy;
c906108c
SS
131 break;
132 }
133 return c;
134 }
9b2d6cca 135}
This page took 1.03207 seconds and 4 git commands to generate.