]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/tui/tui-command.c
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / tui / tui-command.c
CommitLineData
f377b406 1/* Specific command window processing.
f33c6cbf 2
6aba47ca
DJ
3 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007
4 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
12 the Free Software Foundation; either version 2 of the License, or
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
21 along with this program; if not, write to the Free Software
88d83552
EZ
22 Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 Boston, MA 02110-1301, USA. */
c906108c 24
96ec9981
DJ
25#include "defs.h"
26#include <ctype.h>
d7b2e967
AC
27#include "tui/tui.h"
28#include "tui/tui-data.h"
29#include "tui/tui-win.h"
30#include "tui/tui-io.h"
f33c6cbf 31
6a83354a 32#include "gdb_curses.h"
88289b6e 33#include "gdb_string.h"
4e8f7a8b 34
c906108c
SS
35
36/*****************************************
37** STATIC LOCAL FUNCTIONS FORWARD DECLS **
38******************************************/
39
40
41
42/*****************************************
43** PUBLIC FUNCTIONS **
44******************************************/
45
b0a30fce 46/* Dispatch the correct tui function based upon the control 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
57 assume it is the command window; in this case, pass the
58 character 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
67 /* If this is an xterm, page next/prev keys aren't returned
c5aa993b
JM
68 ** by keypad as a single char, so we must handle them here.
69 ** Seems like a bug in the curses library?
70 */
c906108c 71 term = (char *) getenv ("TERM");
bbe6b987 72 if (term)
c906108c 73 {
bbe6b987
AS
74 for (i = 0; term[i]; i++)
75 term[i] = toupper (term[i]);
76 if ((strcmp (term, "XTERM") == 0) && 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}