GDB (API)
|
00001 /* Specific command window processing. 00002 00003 Copyright (C) 1998-2013 Free Software Foundation, Inc. 00004 00005 Contributed by Hewlett-Packard Company. 00006 00007 This file is part of GDB. 00008 00009 This program is free software; you can redistribute it and/or modify 00010 it under the terms of the GNU General Public License as published by 00011 the Free Software Foundation; either version 3 of the License, or 00012 (at your option) any later version. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 00021 00022 #include "defs.h" 00023 #include <ctype.h> 00024 #include "tui/tui.h" 00025 #include "tui/tui-data.h" 00026 #include "tui/tui-win.h" 00027 #include "tui/tui-io.h" 00028 #include "tui/tui-command.h" 00029 00030 #include "gdb_curses.h" 00031 #include "gdb_string.h" 00032 00033 00034 /***************************************** 00035 ** STATIC LOCAL FUNCTIONS FORWARD DECLS ** 00036 ******************************************/ 00037 00038 00039 00040 /***************************************** 00041 ** PUBLIC FUNCTIONS ** 00042 ******************************************/ 00043 00044 /* Dispatch the correct tui function based upon the control 00045 character. */ 00046 unsigned int 00047 tui_dispatch_ctrl_char (unsigned int ch) 00048 { 00049 struct tui_win_info *win_info = tui_win_with_focus (); 00050 00051 /* Handle the CTRL-L refresh for each window. */ 00052 if (ch == '\f') 00053 tui_refresh_all_win (); 00054 00055 /* If the command window has the logical focus, or no-one does 00056 assume it is the command window; in this case, pass the character 00057 on through and do nothing here. */ 00058 if (win_info == NULL || win_info == TUI_CMD_WIN) 00059 return ch; 00060 else 00061 { 00062 unsigned int c = 0, ch_copy = ch; 00063 int i; 00064 char *term; 00065 00066 /* If this is an xterm, page next/prev keys aren't returned by 00067 keypad as a single char, so we must handle them here. Seems 00068 like a bug in the curses library? */ 00069 term = (char *) getenv ("TERM"); 00070 if (term) 00071 { 00072 for (i = 0; term[i]; i++) 00073 term[i] = toupper (term[i]); 00074 if ((strcmp (term, "XTERM") == 0) 00075 && key_is_start_sequence (ch)) 00076 { 00077 unsigned int page_ch = 0; 00078 unsigned int tmp_char; 00079 WINDOW *w = TUI_CMD_WIN->generic.handle; 00080 00081 tmp_char = 0; 00082 while (!key_is_end_sequence (tmp_char)) 00083 { 00084 tmp_char = (int) wgetch (w); 00085 if (tmp_char == ERR) 00086 { 00087 return ch; 00088 } 00089 if (!tmp_char) 00090 break; 00091 if (tmp_char == 53) 00092 page_ch = KEY_PPAGE; 00093 else if (tmp_char == 54) 00094 page_ch = KEY_NPAGE; 00095 else 00096 { 00097 return 0; 00098 } 00099 } 00100 ch_copy = page_ch; 00101 } 00102 } 00103 00104 switch (ch_copy) 00105 { 00106 case KEY_NPAGE: 00107 tui_scroll_forward (win_info, 0); 00108 break; 00109 case KEY_PPAGE: 00110 tui_scroll_backward (win_info, 0); 00111 break; 00112 case KEY_DOWN: 00113 case KEY_SF: 00114 tui_scroll_forward (win_info, 1); 00115 break; 00116 case KEY_UP: 00117 case KEY_SR: 00118 tui_scroll_backward (win_info, 1); 00119 break; 00120 case KEY_RIGHT: 00121 tui_scroll_left (win_info, 1); 00122 break; 00123 case KEY_LEFT: 00124 tui_scroll_right (win_info, 1); 00125 break; 00126 case '\f': 00127 break; 00128 default: 00129 c = ch_copy; 00130 break; 00131 } 00132 return c; 00133 } 00134 }