GDB (API)
|
00001 /* General window behavior. 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 "tui/tui.h" 00024 #include "tui/tui-data.h" 00025 #include "tui/tui-wingeneral.h" 00026 #include "tui/tui-win.h" 00027 00028 #include "gdb_curses.h" 00029 00030 /*********************** 00031 ** PUBLIC FUNCTIONS 00032 ***********************/ 00033 00034 /* Refresh the window. */ 00035 void 00036 tui_refresh_win (struct tui_gen_win_info *win_info) 00037 { 00038 if (win_info->type == DATA_WIN && win_info->content_size > 0) 00039 { 00040 int i; 00041 00042 for (i = 0; (i < win_info->content_size); i++) 00043 { 00044 struct tui_gen_win_info *data_item_win_ptr; 00045 00046 data_item_win_ptr = &((tui_win_content) 00047 win_info->content)[i]->which_element.data_window; 00048 if (data_item_win_ptr != NULL 00049 && data_item_win_ptr->handle != (WINDOW *) NULL) 00050 wrefresh (data_item_win_ptr->handle); 00051 } 00052 } 00053 else if (win_info->type == CMD_WIN) 00054 { 00055 /* Do nothing. */ 00056 } 00057 else 00058 { 00059 if (win_info->handle != (WINDOW *) NULL) 00060 wrefresh (win_info->handle); 00061 } 00062 00063 return; 00064 } 00065 00066 00067 /* Function to delete the curses window, checking for NULL. */ 00068 void 00069 tui_delete_win (WINDOW *window) 00070 { 00071 if (window != (WINDOW *) NULL) 00072 delwin (window); 00073 00074 return; 00075 } 00076 00077 00078 /* Draw a border arround the window. */ 00079 static void 00080 box_win (struct tui_gen_win_info *win_info, 00081 int highlight_flag) 00082 { 00083 if (win_info && win_info->handle) 00084 { 00085 WINDOW *win; 00086 int attrs; 00087 00088 win = win_info->handle; 00089 if (highlight_flag == HILITE) 00090 attrs = tui_active_border_attrs; 00091 else 00092 attrs = tui_border_attrs; 00093 00094 wattron (win, attrs); 00095 #ifdef HAVE_WBORDER 00096 wborder (win, tui_border_vline, tui_border_vline, 00097 tui_border_hline, tui_border_hline, 00098 tui_border_ulcorner, tui_border_urcorner, 00099 tui_border_llcorner, tui_border_lrcorner); 00100 #else 00101 box (win, tui_border_vline, tui_border_hline); 00102 #endif 00103 if (win_info->title) 00104 mvwaddstr (win, 0, 3, win_info->title); 00105 wattroff (win, attrs); 00106 } 00107 } 00108 00109 00110 void 00111 tui_unhighlight_win (struct tui_win_info *win_info) 00112 { 00113 if (win_info != NULL 00114 && win_info->generic.handle != (WINDOW *) NULL) 00115 { 00116 box_win ((struct tui_gen_win_info *) win_info, NO_HILITE); 00117 wrefresh (win_info->generic.handle); 00118 tui_set_win_highlight (win_info, 0); 00119 } 00120 } 00121 00122 00123 void 00124 tui_highlight_win (struct tui_win_info *win_info) 00125 { 00126 if (win_info != NULL 00127 && win_info->can_highlight 00128 && win_info->generic.handle != (WINDOW *) NULL) 00129 { 00130 box_win ((struct tui_gen_win_info *) win_info, HILITE); 00131 wrefresh (win_info->generic.handle); 00132 tui_set_win_highlight (win_info, 1); 00133 } 00134 } 00135 00136 void 00137 tui_check_and_display_highlight_if_needed (struct tui_win_info *win_info) 00138 { 00139 if (win_info != NULL && win_info->generic.type != CMD_WIN) 00140 { 00141 if (win_info->is_highlighted) 00142 tui_highlight_win (win_info); 00143 else 00144 tui_unhighlight_win (win_info); 00145 00146 } 00147 return; 00148 } 00149 00150 00151 void 00152 tui_make_window (struct tui_gen_win_info *win_info, int box_it) 00153 { 00154 WINDOW *handle; 00155 00156 handle = newwin (win_info->height, 00157 win_info->width, 00158 win_info->origin.y, 00159 win_info->origin.x); 00160 win_info->handle = handle; 00161 if (handle != (WINDOW *) NULL) 00162 { 00163 if (box_it == BOX_WINDOW) 00164 box_win (win_info, NO_HILITE); 00165 win_info->is_visible = TRUE; 00166 scrollok (handle, TRUE); 00167 } 00168 } 00169 00170 00171 /* We can't really make windows visible, or invisible. So we have to 00172 delete the entire window when making it visible, and create it 00173 again when making it visible. */ 00174 static void 00175 make_visible (struct tui_gen_win_info *win_info, int visible) 00176 { 00177 /* Don't tear down/recreate command window. */ 00178 if (win_info->type == CMD_WIN) 00179 return; 00180 00181 if (visible) 00182 { 00183 if (!win_info->is_visible) 00184 { 00185 tui_make_window (win_info, 00186 (win_info->type != CMD_WIN 00187 && !tui_win_is_auxillary (win_info->type))); 00188 win_info->is_visible = TRUE; 00189 } 00190 } 00191 else if (!visible 00192 && win_info->is_visible 00193 && win_info->handle != (WINDOW *) NULL) 00194 { 00195 win_info->is_visible = FALSE; 00196 tui_delete_win (win_info->handle); 00197 win_info->handle = (WINDOW *) NULL; 00198 } 00199 00200 return; 00201 } 00202 00203 void 00204 tui_make_visible (struct tui_gen_win_info *win_info) 00205 { 00206 make_visible (win_info, 1); 00207 } 00208 00209 void 00210 tui_make_invisible (struct tui_gen_win_info *win_info) 00211 { 00212 make_visible (win_info, 0); 00213 } 00214 00215 00216 /* Makes all windows invisible (except the command and locator 00217 windows). */ 00218 static void 00219 make_all_visible (int visible) 00220 { 00221 int i; 00222 00223 for (i = 0; i < MAX_MAJOR_WINDOWS; i++) 00224 { 00225 if (tui_win_list[i] != NULL 00226 && ((tui_win_list[i])->generic.type) != CMD_WIN) 00227 { 00228 if (tui_win_is_source_type ((tui_win_list[i])->generic.type)) 00229 make_visible ((tui_win_list[i])->detail.source_info.execution_info, 00230 visible); 00231 make_visible ((struct tui_gen_win_info *) tui_win_list[i], visible); 00232 } 00233 } 00234 00235 return; 00236 } 00237 00238 void 00239 tui_make_all_visible (void) 00240 { 00241 make_all_visible (1); 00242 } 00243 00244 void 00245 tui_make_all_invisible (void) 00246 { 00247 make_all_visible (0); 00248 } 00249 00250 /* Function to refresh all the windows currently displayed. */ 00251 00252 void 00253 tui_refresh_all (struct tui_win_info **list) 00254 { 00255 enum tui_win_type type; 00256 struct tui_gen_win_info *locator = tui_locator_win_info_ptr (); 00257 00258 for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++) 00259 { 00260 if (list[type] && list[type]->generic.is_visible) 00261 { 00262 if (type == SRC_WIN || type == DISASSEM_WIN) 00263 { 00264 touchwin (list[type]->detail.source_info.execution_info->handle); 00265 tui_refresh_win (list[type]->detail.source_info.execution_info); 00266 } 00267 touchwin (list[type]->generic.handle); 00268 tui_refresh_win (&list[type]->generic); 00269 } 00270 } 00271 if (locator->is_visible) 00272 { 00273 touchwin (locator->handle); 00274 tui_refresh_win (locator); 00275 } 00276 } 00277 00278 00279 /********************************* 00280 ** Local Static Functions 00281 *********************************/