]>
Commit | Line | Data |
---|---|---|
f377b406 SC |
1 | /* TUI window generic functions. |
2 | Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc. | |
3 | Contributed by Hewlett-Packard Company. | |
c906108c | 4 | |
f377b406 SC |
5 | This file is part of GDB. |
6 | ||
7 | This program is free software; you can redistribute it and/or modify | |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2 of the License, or | |
10 | (at your option) any later version. | |
11 | ||
12 | This program is distributed in the hope that it will be useful, | |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
17 | You should have received a copy of the GNU General Public License | |
18 | along with this program; if not, write to the Free Software | |
19 | Foundation, Inc., 59 Temple Place - Suite 330, | |
20 | Boston, MA 02111-1307, USA. */ | |
21 | ||
22 | /* This module contains procedures for handling tui window functions | |
23 | like resize, scrolling, scrolling, changing focus, etc. | |
24 | ||
25 | Author: Susan B. Macchia */ | |
c906108c SS |
26 | |
27 | #include <string.h> | |
84b1e7c7 | 28 | #include <ctype.h> |
c906108c SS |
29 | #include "defs.h" |
30 | #include "command.h" | |
31 | #include "symtab.h" | |
32 | #include "breakpoint.h" | |
33 | #include "frame.h" | |
41783295 | 34 | #include "cli/cli-cmds.h" |
c906108c SS |
35 | |
36 | #include "tui.h" | |
37 | #include "tuiData.h" | |
38 | #include "tuiGeneralWin.h" | |
39 | #include "tuiStack.h" | |
84b1e7c7 SC |
40 | #include "tuiRegs.h" |
41 | #include "tuiDisassem.h" | |
42 | #include "tuiSource.h" | |
c906108c SS |
43 | #include "tuiSourceWin.h" |
44 | #include "tuiDataWin.h" | |
45 | ||
46 | /******************************* | |
47 | ** External Declarations | |
48 | ********************************/ | |
49 | extern void init_page_info (); | |
50 | ||
51 | /******************************* | |
52 | ** Static Local Decls | |
53 | ********************************/ | |
a14ed312 KB |
54 | static void _makeVisibleWithNewHeight (TuiWinInfoPtr); |
55 | static void _makeInvisibleAndSetNewHeight (TuiWinInfoPtr, int); | |
56 | static TuiStatus _tuiAdjustWinHeights (TuiWinInfoPtr, int); | |
57 | static int _newHeightOk (TuiWinInfoPtr, int); | |
58 | static void _tuiSetTabWidth_command (char *, int); | |
59 | static void _tuiRefreshAll_command (char *, int); | |
60 | static void _tuiSetWinHeight_command (char *, int); | |
61 | static void _tuiXDBsetWinHeight_command (char *, int); | |
62 | static void _tuiAllWindowsInfo (char *, int); | |
63 | static void _tuiSetFocus_command (char *, int); | |
64 | static void _tuiScrollForward_command (char *, int); | |
65 | static void _tuiScrollBackward_command (char *, int); | |
66 | static void _tuiScrollLeft_command (char *, int); | |
67 | static void _tuiScrollRight_command (char *, int); | |
68 | static void _parseScrollingArgs (char *, TuiWinInfoPtr *, int *); | |
c906108c SS |
69 | |
70 | ||
71 | /*************************************** | |
72 | ** DEFINITIONS | |
73 | ***************************************/ | |
74 | #define WIN_HEIGHT_USAGE "Usage: winheight <win_name> [+ | -] <#lines>\n" | |
75 | #define XDBWIN_HEIGHT_USAGE "Usage: w <#lines>\n" | |
76 | #define FOCUS_USAGE "Usage: focus {<win> | next | prev}\n" | |
77 | ||
78 | /*************************************** | |
79 | ** PUBLIC FUNCTIONS | |
80 | ***************************************/ | |
81 | ||
82 | /* | |
c5aa993b JM |
83 | ** _initialize_tuiWin(). |
84 | ** Function to initialize gdb commands, for tui window manipulation. | |
85 | */ | |
c906108c | 86 | void |
fba45db2 | 87 | _initialize_tuiWin (void) |
c906108c | 88 | { |
41783295 SC |
89 | /* Define the classes of commands. |
90 | They will appear in the help list in the reverse of this order. */ | |
91 | ||
92 | add_cmd ("tui", class_tui, NO_FUNCTION, | |
93 | "Text User Interface commands.", | |
94 | &cmdlist); | |
95 | ||
96 | add_com ("refresh", class_tui, _tuiRefreshAll_command, | |
97 | "Refresh the terminal display.\n"); | |
98 | if (xdb_commands) | |
99 | add_com_alias ("U", "refresh", class_tui, 0); | |
100 | add_com ("tabset", class_tui, _tuiSetTabWidth_command, | |
101 | "Set the width (in characters) of tab stops.\n\ | |
c906108c | 102 | Usage: tabset <n>\n"); |
41783295 SC |
103 | add_com ("winheight", class_tui, _tuiSetWinHeight_command, |
104 | "Set the height of a specified window.\n\ | |
c906108c SS |
105 | Usage: winheight <win_name> [+ | -] <#lines>\n\ |
106 | Window names are:\n\ | |
107 | src : the source window\n\ | |
108 | cmd : the command window\n\ | |
109 | asm : the disassembly window\n\ | |
110 | regs : the register display\n"); | |
41783295 SC |
111 | add_com_alias ("wh", "winheight", class_tui, 0); |
112 | add_info ("win", _tuiAllWindowsInfo, | |
113 | "List of all displayed windows.\n"); | |
114 | add_com ("focus", class_tui, _tuiSetFocus_command, | |
115 | "Set focus to named window or next/prev window.\n\ | |
c906108c SS |
116 | Usage: focus {<win> | next | prev}\n\ |
117 | Valid Window names are:\n\ | |
118 | src : the source window\n\ | |
119 | asm : the disassembly window\n\ | |
120 | regs : the register display\n\ | |
121 | cmd : the command window\n"); | |
41783295 SC |
122 | add_com_alias ("fs", "focus", class_tui, 0); |
123 | add_com ("+", class_tui, _tuiScrollForward_command, | |
124 | "Scroll window forward.\nUsage: + [win] [n]\n"); | |
125 | add_com ("-", class_tui, _tuiScrollBackward_command, | |
126 | "Scroll window backward.\nUsage: - [win] [n]\n"); | |
127 | add_com ("<", class_tui, _tuiScrollLeft_command, | |
128 | "Scroll window forward.\nUsage: < [win] [n]\n"); | |
129 | add_com (">", class_tui, _tuiScrollRight_command, | |
130 | "Scroll window backward.\nUsage: > [win] [n]\n"); | |
131 | if (xdb_commands) | |
132 | add_com ("w", class_xdb, _tuiXDBsetWinHeight_command, | |
133 | "XDB compatibility command for setting the height of a command window.\n\ | |
c906108c | 134 | Usage: w <#lines>\n"); |
41783295 | 135 | } |
c906108c SS |
136 | |
137 | ||
138 | /* | |
c5aa993b JM |
139 | ** tuiClearWinFocusFrom |
140 | ** Clear the logical focus from winInfo | |
141 | */ | |
c906108c | 142 | void |
eca6576c | 143 | tuiClearWinFocusFrom (TuiWinInfoPtr winInfo) |
c906108c SS |
144 | { |
145 | if (m_winPtrNotNull (winInfo)) | |
146 | { | |
147 | if (winInfo->generic.type != CMD_WIN) | |
148 | unhighlightWin (winInfo); | |
149 | tuiSetWinWithFocus ((TuiWinInfoPtr) NULL); | |
150 | } | |
151 | ||
152 | return; | |
153 | } /* tuiClearWinFocusFrom */ | |
154 | ||
155 | ||
156 | /* | |
c5aa993b JM |
157 | ** tuiClearWinFocus(). |
158 | ** Clear the window that has focus. | |
159 | */ | |
c906108c | 160 | void |
c906108c | 161 | tuiClearWinFocus (void) |
c906108c SS |
162 | { |
163 | tuiClearWinFocusFrom (tuiWinWithFocus ()); | |
164 | ||
165 | return; | |
166 | } /* tuiClearWinFocus */ | |
167 | ||
168 | ||
169 | /* | |
c5aa993b JM |
170 | ** tuiSetWinFocusTo |
171 | ** Set the logical focus to winInfo | |
172 | */ | |
c906108c | 173 | void |
eca6576c | 174 | tuiSetWinFocusTo (TuiWinInfoPtr winInfo) |
c906108c SS |
175 | { |
176 | if (m_winPtrNotNull (winInfo)) | |
177 | { | |
178 | TuiWinInfoPtr winWithFocus = tuiWinWithFocus (); | |
179 | ||
180 | if (m_winPtrNotNull (winWithFocus) && | |
181 | winWithFocus->generic.type != CMD_WIN) | |
182 | unhighlightWin (winWithFocus); | |
183 | tuiSetWinWithFocus (winInfo); | |
184 | if (winInfo->generic.type != CMD_WIN) | |
185 | highlightWin (winInfo); | |
186 | } | |
187 | ||
188 | return; | |
189 | } /* tuiSetWinFocusTo */ | |
190 | ||
191 | ||
192 | char * | |
eca6576c | 193 | tuiStrDup (char *str) |
c906108c SS |
194 | { |
195 | char *newStr = (char *) NULL; | |
196 | ||
197 | if (str != (char *) NULL) | |
198 | { | |
199 | newStr = (char *) xmalloc (strlen (str) + 1); | |
200 | strcpy (newStr, str); | |
201 | } | |
202 | ||
203 | return newStr; | |
204 | } /* tuiStrDup */ | |
205 | ||
206 | ||
207 | /* | |
c5aa993b JM |
208 | ** tuiScrollForward(). |
209 | */ | |
c906108c | 210 | void |
eca6576c | 211 | tuiScrollForward (TuiWinInfoPtr winToScroll, int numToScroll) |
c906108c SS |
212 | { |
213 | if (winToScroll != cmdWin) | |
214 | { | |
215 | int _numToScroll = numToScroll; | |
216 | ||
217 | if (numToScroll == 0) | |
218 | _numToScroll = winToScroll->generic.height - 3; | |
219 | /* | |
c5aa993b JM |
220 | ** If we are scrolling the source or disassembly window, do a |
221 | ** "psuedo" scroll since not all of the source is in memory, | |
222 | ** only what is in the viewport. If winToScroll is the | |
223 | ** command window do nothing since the term should handle it. | |
224 | */ | |
c906108c SS |
225 | if (winToScroll == srcWin) |
226 | tuiVerticalSourceScroll (FORWARD_SCROLL, _numToScroll); | |
227 | else if (winToScroll == disassemWin) | |
228 | tuiVerticalDisassemScroll (FORWARD_SCROLL, _numToScroll); | |
229 | else if (winToScroll == dataWin) | |
230 | tuiVerticalDataScroll (FORWARD_SCROLL, _numToScroll); | |
231 | } | |
232 | ||
233 | return; | |
234 | } /* tuiScrollForward */ | |
235 | ||
236 | ||
237 | /* | |
c5aa993b JM |
238 | ** tuiScrollBackward(). |
239 | */ | |
c906108c | 240 | void |
eca6576c | 241 | tuiScrollBackward (TuiWinInfoPtr winToScroll, int numToScroll) |
c906108c SS |
242 | { |
243 | if (winToScroll != cmdWin) | |
244 | { | |
245 | int _numToScroll = numToScroll; | |
246 | ||
247 | if (numToScroll == 0) | |
248 | _numToScroll = winToScroll->generic.height - 3; | |
249 | /* | |
c5aa993b JM |
250 | ** If we are scrolling the source or disassembly window, do a |
251 | ** "psuedo" scroll since not all of the source is in memory, | |
252 | ** only what is in the viewport. If winToScroll is the | |
253 | ** command window do nothing since the term should handle it. | |
254 | */ | |
c906108c SS |
255 | if (winToScroll == srcWin) |
256 | tuiVerticalSourceScroll (BACKWARD_SCROLL, _numToScroll); | |
257 | else if (winToScroll == disassemWin) | |
258 | tuiVerticalDisassemScroll (BACKWARD_SCROLL, _numToScroll); | |
259 | else if (winToScroll == dataWin) | |
260 | tuiVerticalDataScroll (BACKWARD_SCROLL, _numToScroll); | |
261 | } | |
262 | return; | |
263 | } /* tuiScrollBackward */ | |
264 | ||
265 | ||
266 | /* | |
c5aa993b JM |
267 | ** tuiScrollLeft(). |
268 | */ | |
c906108c | 269 | void |
eca6576c | 270 | tuiScrollLeft (TuiWinInfoPtr winToScroll, int numToScroll) |
c906108c SS |
271 | { |
272 | if (winToScroll != cmdWin) | |
273 | { | |
274 | int _numToScroll = numToScroll; | |
275 | ||
276 | if (_numToScroll == 0) | |
277 | _numToScroll = 1; | |
278 | /* | |
c5aa993b JM |
279 | ** If we are scrolling the source or disassembly window, do a |
280 | ** "psuedo" scroll since not all of the source is in memory, | |
281 | ** only what is in the viewport. If winToScroll is the | |
282 | ** command window do nothing since the term should handle it. | |
283 | */ | |
c906108c SS |
284 | if (winToScroll == srcWin || winToScroll == disassemWin) |
285 | tuiHorizontalSourceScroll (winToScroll, LEFT_SCROLL, _numToScroll); | |
286 | } | |
287 | return; | |
288 | } /* tuiScrollLeft */ | |
289 | ||
290 | ||
291 | /* | |
c5aa993b JM |
292 | ** tuiScrollRight(). |
293 | */ | |
c906108c | 294 | void |
eca6576c | 295 | tuiScrollRight (TuiWinInfoPtr winToScroll, int numToScroll) |
c906108c SS |
296 | { |
297 | if (winToScroll != cmdWin) | |
298 | { | |
299 | int _numToScroll = numToScroll; | |
300 | ||
301 | if (_numToScroll == 0) | |
302 | _numToScroll = 1; | |
303 | /* | |
c5aa993b JM |
304 | ** If we are scrolling the source or disassembly window, do a |
305 | ** "psuedo" scroll since not all of the source is in memory, | |
306 | ** only what is in the viewport. If winToScroll is the | |
307 | ** command window do nothing since the term should handle it. | |
308 | */ | |
c906108c SS |
309 | if (winToScroll == srcWin || winToScroll == disassemWin) |
310 | tuiHorizontalSourceScroll (winToScroll, RIGHT_SCROLL, _numToScroll); | |
311 | } | |
312 | return; | |
313 | } /* tuiScrollRight */ | |
314 | ||
315 | ||
316 | /* | |
e8b915dc | 317 | ** tui_scroll(). |
c5aa993b JM |
318 | ** Scroll a window. Arguments are passed through a va_list. |
319 | */ | |
c906108c | 320 | void |
e8b915dc SC |
321 | tui_scroll (TuiScrollDirection direction, |
322 | TuiWinInfoPtr winToScroll, | |
323 | int numToScroll) | |
c906108c | 324 | { |
c906108c SS |
325 | switch (direction) |
326 | { | |
327 | case FORWARD_SCROLL: | |
328 | tuiScrollForward (winToScroll, numToScroll); | |
329 | break; | |
330 | case BACKWARD_SCROLL: | |
331 | tuiScrollBackward (winToScroll, numToScroll); | |
332 | break; | |
333 | case LEFT_SCROLL: | |
334 | tuiScrollLeft (winToScroll, numToScroll); | |
335 | break; | |
336 | case RIGHT_SCROLL: | |
337 | tuiScrollRight (winToScroll, numToScroll); | |
338 | break; | |
339 | default: | |
340 | break; | |
341 | } | |
e8b915dc | 342 | } |
c906108c SS |
343 | |
344 | ||
345 | /* | |
c5aa993b JM |
346 | ** tuiRefreshAll(). |
347 | */ | |
c906108c | 348 | void |
c906108c | 349 | tuiRefreshAll (void) |
c906108c SS |
350 | { |
351 | TuiWinType type; | |
352 | ||
353 | refreshAll (winList); | |
354 | for (type = SRC_WIN; type < MAX_MAJOR_WINDOWS; type++) | |
355 | { | |
75fd9bc1 | 356 | if (winList[type] && winList[type]->generic.isVisible) |
c906108c SS |
357 | { |
358 | switch (type) | |
359 | { | |
360 | case SRC_WIN: | |
361 | case DISASSEM_WIN: | |
362 | tuiClearWin (&winList[type]->generic); | |
363 | if (winList[type]->detail.sourceInfo.hasLocator) | |
364 | tuiClearLocatorDisplay (); | |
365 | tuiShowSourceContent (winList[type]); | |
366 | checkAndDisplayHighlightIfNeeded (winList[type]); | |
367 | tuiEraseExecInfoContent (winList[type]); | |
368 | tuiUpdateExecInfo (winList[type]); | |
369 | break; | |
370 | case DATA_WIN: | |
371 | tuiRefreshDataWin (); | |
372 | break; | |
373 | default: | |
374 | break; | |
375 | } | |
376 | } | |
377 | } | |
378 | tuiClearLocatorDisplay (); | |
379 | tuiShowLocatorContent (); | |
380 | ||
381 | return; | |
382 | } /* tuiRefreshAll */ | |
383 | ||
384 | ||
385 | /* | |
c5aa993b JM |
386 | ** tuiResizeAll(). |
387 | ** Resize all the windows based on the the terminal size. This | |
388 | ** function gets called from within the readline sinwinch handler. | |
389 | */ | |
c906108c | 390 | void |
c906108c | 391 | tuiResizeAll (void) |
c906108c SS |
392 | { |
393 | int heightDiff, widthDiff; | |
c5aa993b | 394 | extern int screenheight, screenwidth; /* in readline */ |
c906108c SS |
395 | |
396 | widthDiff = screenwidth - termWidth (); | |
397 | heightDiff = screenheight - termHeight (); | |
398 | if (heightDiff || widthDiff) | |
399 | { | |
400 | TuiLayoutType curLayout = currentLayout (); | |
401 | TuiWinInfoPtr winWithFocus = tuiWinWithFocus (); | |
402 | TuiWinInfoPtr firstWin, secondWin; | |
403 | TuiGenWinInfoPtr locator = locatorWinInfoPtr (); | |
404 | TuiWinType winType; | |
405 | int i, newHeight, splitDiff, cmdSplitDiff, numWinsDisplayed = 2; | |
406 | ||
407 | /* turn keypad off while we resize */ | |
408 | if (winWithFocus != cmdWin) | |
409 | keypad (cmdWin->generic.handle, FALSE); | |
410 | init_page_info (); | |
411 | setTermHeightTo (screenheight); | |
412 | setTermWidthTo (screenwidth); | |
413 | if (curLayout == SRC_DISASSEM_COMMAND || | |
414 | curLayout == SRC_DATA_COMMAND || curLayout == DISASSEM_DATA_COMMAND) | |
415 | numWinsDisplayed++; | |
416 | splitDiff = heightDiff / numWinsDisplayed; | |
417 | cmdSplitDiff = splitDiff; | |
418 | if (heightDiff % numWinsDisplayed) | |
419 | { | |
420 | if (heightDiff < 0) | |
421 | cmdSplitDiff--; | |
422 | else | |
423 | cmdSplitDiff++; | |
424 | } | |
425 | /* now adjust each window */ | |
426 | clear (); | |
427 | refresh (); | |
428 | switch (curLayout) | |
429 | { | |
430 | case SRC_COMMAND: | |
431 | case DISASSEM_COMMAND: | |
432 | firstWin = (TuiWinInfoPtr) (sourceWindows ())->list[0]; | |
433 | firstWin->generic.width += widthDiff; | |
434 | locator->width += widthDiff; | |
435 | /* check for invalid heights */ | |
436 | if (heightDiff == 0) | |
437 | newHeight = firstWin->generic.height; | |
438 | else if ((firstWin->generic.height + splitDiff) >= | |
439 | (screenheight - MIN_CMD_WIN_HEIGHT - 1)) | |
440 | newHeight = screenheight - MIN_CMD_WIN_HEIGHT - 1; | |
441 | else if ((firstWin->generic.height + splitDiff) <= 0) | |
442 | newHeight = MIN_WIN_HEIGHT; | |
443 | else | |
444 | newHeight = firstWin->generic.height + splitDiff; | |
445 | ||
446 | _makeInvisibleAndSetNewHeight (firstWin, newHeight); | |
447 | cmdWin->generic.origin.y = locator->origin.y + 1; | |
448 | cmdWin->generic.width += widthDiff; | |
449 | newHeight = screenheight - cmdWin->generic.origin.y; | |
450 | _makeInvisibleAndSetNewHeight (cmdWin, newHeight); | |
451 | _makeVisibleWithNewHeight (firstWin); | |
452 | _makeVisibleWithNewHeight (cmdWin); | |
453 | if (firstWin->generic.contentSize <= 0) | |
454 | tuiEraseSourceContent (firstWin, EMPTY_SOURCE_PROMPT); | |
455 | break; | |
456 | default: | |
457 | if (curLayout == SRC_DISASSEM_COMMAND) | |
458 | { | |
459 | firstWin = srcWin; | |
460 | firstWin->generic.width += widthDiff; | |
461 | secondWin = disassemWin; | |
462 | secondWin->generic.width += widthDiff; | |
463 | } | |
464 | else | |
465 | { | |
466 | firstWin = dataWin; | |
467 | firstWin->generic.width += widthDiff; | |
468 | secondWin = (TuiWinInfoPtr) (sourceWindows ())->list[0]; | |
469 | secondWin->generic.width += widthDiff; | |
470 | } | |
471 | /* Change the first window's height/width */ | |
472 | /* check for invalid heights */ | |
473 | if (heightDiff == 0) | |
474 | newHeight = firstWin->generic.height; | |
475 | else if ((firstWin->generic.height + | |
476 | secondWin->generic.height + (splitDiff * 2)) >= | |
477 | (screenheight - MIN_CMD_WIN_HEIGHT - 1)) | |
478 | newHeight = (screenheight - MIN_CMD_WIN_HEIGHT - 1) / 2; | |
479 | else if ((firstWin->generic.height + splitDiff) <= 0) | |
480 | newHeight = MIN_WIN_HEIGHT; | |
481 | else | |
482 | newHeight = firstWin->generic.height + splitDiff; | |
483 | _makeInvisibleAndSetNewHeight (firstWin, newHeight); | |
484 | ||
485 | if (firstWin == dataWin && widthDiff != 0) | |
486 | firstWin->detail.dataDisplayInfo.regsColumnCount = | |
487 | tuiCalculateRegsColumnCount ( | |
488 | firstWin->detail.dataDisplayInfo.regsDisplayType); | |
489 | locator->width += widthDiff; | |
490 | ||
491 | /* Change the second window's height/width */ | |
492 | /* check for invalid heights */ | |
493 | if (heightDiff == 0) | |
494 | newHeight = secondWin->generic.height; | |
495 | else if ((firstWin->generic.height + | |
496 | secondWin->generic.height + (splitDiff * 2)) >= | |
497 | (screenheight - MIN_CMD_WIN_HEIGHT - 1)) | |
498 | { | |
499 | newHeight = screenheight - MIN_CMD_WIN_HEIGHT - 1; | |
500 | if (newHeight % 2) | |
501 | newHeight = (newHeight / 2) + 1; | |
502 | else | |
503 | newHeight /= 2; | |
504 | } | |
505 | else if ((secondWin->generic.height + splitDiff) <= 0) | |
506 | newHeight = MIN_WIN_HEIGHT; | |
507 | else | |
508 | newHeight = secondWin->generic.height + splitDiff; | |
509 | secondWin->generic.origin.y = firstWin->generic.height - 1; | |
510 | _makeInvisibleAndSetNewHeight (secondWin, newHeight); | |
511 | ||
512 | /* Change the command window's height/width */ | |
513 | cmdWin->generic.origin.y = locator->origin.y + 1; | |
514 | _makeInvisibleAndSetNewHeight ( | |
515 | cmdWin, cmdWin->generic.height + cmdSplitDiff); | |
516 | _makeVisibleWithNewHeight (firstWin); | |
517 | _makeVisibleWithNewHeight (secondWin); | |
518 | _makeVisibleWithNewHeight (cmdWin); | |
519 | if (firstWin->generic.contentSize <= 0) | |
520 | tuiEraseSourceContent (firstWin, EMPTY_SOURCE_PROMPT); | |
521 | if (secondWin->generic.contentSize <= 0) | |
522 | tuiEraseSourceContent (secondWin, EMPTY_SOURCE_PROMPT); | |
523 | break; | |
524 | } | |
525 | /* | |
c5aa993b JM |
526 | ** Now remove all invisible windows, and their content so that they get |
527 | ** created again when called for with the new size | |
528 | */ | |
c906108c SS |
529 | for (winType = SRC_WIN; (winType < MAX_MAJOR_WINDOWS); winType++) |
530 | { | |
531 | if (winType != CMD_WIN && m_winPtrNotNull (winList[winType]) && | |
532 | !winList[winType]->generic.isVisible) | |
533 | { | |
534 | freeWindow (winList[winType]); | |
535 | winList[winType] = (TuiWinInfoPtr) NULL; | |
536 | } | |
537 | } | |
538 | tuiSetWinResizedTo (TRUE); | |
539 | /* turn keypad back on, unless focus is in the command window */ | |
540 | if (winWithFocus != cmdWin) | |
541 | keypad (cmdWin->generic.handle, TRUE); | |
542 | } | |
543 | return; | |
544 | } /* tuiResizeAll */ | |
545 | ||
546 | ||
547 | /* | |
c5aa993b JM |
548 | ** tuiSigwinchHandler() |
549 | ** SIGWINCH signal handler for the tui. This signal handler is | |
550 | ** always called, even when the readline package clears signals | |
551 | ** because it is set as the old_sigwinch() (TUI only) | |
552 | */ | |
c906108c | 553 | void |
eca6576c | 554 | tuiSigwinchHandler (int signal) |
c906108c SS |
555 | { |
556 | /* | |
c5aa993b JM |
557 | ** Say that a resize was done so that the readline can do it |
558 | ** later when appropriate. | |
559 | */ | |
c906108c SS |
560 | tuiSetWinResizedTo (TRUE); |
561 | ||
562 | return; | |
563 | } /* tuiSigwinchHandler */ | |
564 | ||
565 | ||
566 | ||
567 | /************************* | |
568 | ** STATIC LOCAL FUNCTIONS | |
569 | **************************/ | |
570 | ||
571 | ||
572 | /* | |
c5aa993b JM |
573 | ** _tuiScrollForward_command(). |
574 | */ | |
c906108c | 575 | static void |
eca6576c | 576 | _tuiScrollForward_command (char *arg, int fromTTY) |
c906108c SS |
577 | { |
578 | int numToScroll = 1; | |
579 | TuiWinInfoPtr winToScroll; | |
580 | ||
581 | if (arg == (char *) NULL) | |
582 | _parseScrollingArgs (arg, &winToScroll, (int *) NULL); | |
583 | else | |
584 | _parseScrollingArgs (arg, &winToScroll, &numToScroll); | |
e8b915dc SC |
585 | tui_scroll (FORWARD_SCROLL, winToScroll, numToScroll); |
586 | } | |
c906108c SS |
587 | |
588 | ||
589 | /* | |
c5aa993b JM |
590 | ** _tuiScrollBackward_command(). |
591 | */ | |
c906108c | 592 | static void |
eca6576c | 593 | _tuiScrollBackward_command (char *arg, int fromTTY) |
c906108c SS |
594 | { |
595 | int numToScroll = 1; | |
596 | TuiWinInfoPtr winToScroll; | |
597 | ||
598 | if (arg == (char *) NULL) | |
599 | _parseScrollingArgs (arg, &winToScroll, (int *) NULL); | |
600 | else | |
601 | _parseScrollingArgs (arg, &winToScroll, &numToScroll); | |
e8b915dc SC |
602 | tui_scroll (BACKWARD_SCROLL, winToScroll, numToScroll); |
603 | } | |
c906108c SS |
604 | |
605 | ||
606 | /* | |
c5aa993b JM |
607 | ** _tuiScrollLeft_command(). |
608 | */ | |
c906108c | 609 | static void |
eca6576c | 610 | _tuiScrollLeft_command (char *arg, int fromTTY) |
c906108c SS |
611 | { |
612 | int numToScroll; | |
613 | TuiWinInfoPtr winToScroll; | |
614 | ||
615 | _parseScrollingArgs (arg, &winToScroll, &numToScroll); | |
e8b915dc SC |
616 | tui_scroll (LEFT_SCROLL, winToScroll, numToScroll); |
617 | } | |
c906108c SS |
618 | |
619 | ||
620 | /* | |
c5aa993b JM |
621 | ** _tuiScrollRight_command(). |
622 | */ | |
c906108c | 623 | static void |
eca6576c | 624 | _tuiScrollRight_command (char *arg, int fromTTY) |
c906108c SS |
625 | { |
626 | int numToScroll; | |
627 | TuiWinInfoPtr winToScroll; | |
628 | ||
629 | _parseScrollingArgs (arg, &winToScroll, &numToScroll); | |
e8b915dc SC |
630 | tui_scroll (RIGHT_SCROLL, winToScroll, numToScroll); |
631 | } | |
c906108c SS |
632 | |
633 | ||
634 | /* | |
c5aa993b JM |
635 | ** _tuiSetFocus(). |
636 | ** Set focus to the window named by 'arg' | |
637 | */ | |
c906108c | 638 | static void |
eca6576c | 639 | _tuiSetFocus (char *arg, int fromTTY) |
c906108c SS |
640 | { |
641 | if (arg != (char *) NULL) | |
642 | { | |
643 | char *bufPtr = (char *) tuiStrDup (arg); | |
644 | int i; | |
645 | TuiWinInfoPtr winInfo = (TuiWinInfoPtr) NULL; | |
646 | ||
647 | for (i = 0; (i < strlen (bufPtr)); i++) | |
648 | bufPtr[i] = toupper (arg[i]); | |
649 | ||
0963fc96 | 650 | if (subset_compare (bufPtr, "NEXT")) |
c906108c | 651 | winInfo = tuiNextWin (tuiWinWithFocus ()); |
0963fc96 | 652 | else if (subset_compare (bufPtr, "PREV")) |
c906108c SS |
653 | winInfo = tuiPrevWin (tuiWinWithFocus ()); |
654 | else | |
655 | winInfo = partialWinByName (bufPtr); | |
656 | ||
657 | if (winInfo == (TuiWinInfoPtr) NULL || !winInfo->generic.isVisible) | |
658 | warning ("Invalid window specified. \n\ | |
659 | The window name specified must be valid and visible.\n"); | |
660 | else | |
661 | { | |
662 | tuiSetWinFocusTo (winInfo); | |
663 | keypad (cmdWin->generic.handle, (winInfo != cmdWin)); | |
664 | } | |
665 | ||
75fd9bc1 | 666 | if (dataWin && dataWin->generic.isVisible) |
c906108c SS |
667 | tuiRefreshDataWin (); |
668 | tuiFree (bufPtr); | |
669 | printf_filtered ("Focus set to %s window.\n", | |
670 | winName ((TuiGenWinInfoPtr) tuiWinWithFocus ())); | |
671 | } | |
672 | else | |
673 | warning ("Incorrect Number of Arguments.\n%s", FOCUS_USAGE); | |
674 | ||
675 | return; | |
676 | } /* _tuiSetFocus */ | |
677 | ||
678 | ||
679 | /* | |
c5aa993b JM |
680 | ** _tui_vSetFocus() |
681 | */ | |
c906108c | 682 | static void |
eca6576c | 683 | _tui_vSetFocus (va_list args) |
c906108c SS |
684 | { |
685 | char *arg = va_arg (args, char *); | |
686 | int fromTTY = va_arg (args, int); | |
687 | ||
688 | _tuiSetFocus (arg, fromTTY); | |
689 | ||
690 | return; | |
691 | } /* tui_vSetFocus */ | |
692 | ||
693 | ||
694 | /* | |
c5aa993b JM |
695 | ** _tuiSetFocus_command() |
696 | */ | |
c906108c | 697 | static void |
eca6576c | 698 | _tuiSetFocus_command (char *arg, int fromTTY) |
c906108c | 699 | { |
e8b915dc SC |
700 | _tuiSetFocus (arg, fromTTY); |
701 | } | |
c906108c SS |
702 | |
703 | ||
704 | /* | |
c5aa993b JM |
705 | ** _tuiAllWindowsInfo(). |
706 | */ | |
c906108c | 707 | static void |
eca6576c | 708 | _tuiAllWindowsInfo (char *arg, int fromTTY) |
c906108c SS |
709 | { |
710 | TuiWinType type; | |
711 | TuiWinInfoPtr winWithFocus = tuiWinWithFocus (); | |
712 | ||
713 | for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++) | |
714 | if (winList[type]->generic.isVisible) | |
715 | { | |
716 | if (winWithFocus == winList[type]) | |
717 | printf_filtered (" %s\t(%d lines) <has focus>\n", | |
718 | winName (&winList[type]->generic), | |
719 | winList[type]->generic.height); | |
720 | else | |
721 | printf_filtered (" %s\t(%d lines)\n", | |
722 | winName (&winList[type]->generic), | |
723 | winList[type]->generic.height); | |
724 | } | |
725 | ||
726 | return; | |
727 | } /* _tuiAllWindowsInfo */ | |
728 | ||
729 | ||
730 | /* | |
c5aa993b JM |
731 | ** _tuiRefreshAll_command(). |
732 | */ | |
c906108c | 733 | static void |
eca6576c | 734 | _tuiRefreshAll_command (char *arg, int fromTTY) |
c906108c | 735 | { |
e8b915dc | 736 | tuiRefreshAll (); |
c906108c SS |
737 | } |
738 | ||
739 | ||
740 | /* | |
c5aa993b JM |
741 | ** _tuiSetWinTabWidth_command(). |
742 | ** Set the height of the specified window. | |
743 | */ | |
c906108c | 744 | static void |
eca6576c | 745 | _tuiSetTabWidth_command (char *arg, int fromTTY) |
c906108c SS |
746 | { |
747 | if (arg != (char *) NULL) | |
748 | { | |
749 | int ts; | |
750 | ||
751 | ts = atoi (arg); | |
752 | if (ts > 0) | |
753 | tuiSetDefaultTabLen (ts); | |
754 | else | |
755 | warning ("Tab widths greater than 0 must be specified.\n"); | |
756 | } | |
757 | ||
758 | return; | |
759 | } /* _tuiSetTabWidth_command */ | |
760 | ||
761 | ||
762 | /* | |
c5aa993b JM |
763 | ** _tuiSetWinHeight(). |
764 | ** Set the height of the specified window. | |
765 | */ | |
c906108c | 766 | static void |
eca6576c | 767 | _tuiSetWinHeight (char *arg, int fromTTY) |
c906108c SS |
768 | { |
769 | if (arg != (char *) NULL) | |
770 | { | |
771 | char *buf = tuiStrDup (arg); | |
772 | char *bufPtr = buf; | |
773 | char *wname = (char *) NULL; | |
774 | int newHeight, i; | |
775 | TuiWinInfoPtr winInfo; | |
776 | ||
777 | wname = bufPtr; | |
778 | bufPtr = strchr (bufPtr, ' '); | |
779 | if (bufPtr != (char *) NULL) | |
780 | { | |
781 | *bufPtr = (char) 0; | |
782 | ||
783 | /* | |
c5aa993b JM |
784 | ** Validate the window name |
785 | */ | |
c906108c SS |
786 | for (i = 0; i < strlen (wname); i++) |
787 | wname[i] = toupper (wname[i]); | |
788 | winInfo = partialWinByName (wname); | |
789 | ||
790 | if (winInfo == (TuiWinInfoPtr) NULL || !winInfo->generic.isVisible) | |
791 | warning ("Invalid window specified. \n\ | |
792 | The window name specified must be valid and visible.\n"); | |
793 | else | |
794 | { | |
795 | /* Process the size */ | |
796 | while (*(++bufPtr) == ' ') | |
797 | ; | |
798 | ||
799 | if (*bufPtr != (char) 0) | |
800 | { | |
801 | int negate = FALSE; | |
802 | int fixedSize = TRUE; | |
803 | int inputNo;; | |
804 | ||
805 | if (*bufPtr == '+' || *bufPtr == '-') | |
806 | { | |
807 | if (*bufPtr == '-') | |
808 | negate = TRUE; | |
809 | fixedSize = FALSE; | |
810 | bufPtr++; | |
811 | } | |
812 | inputNo = atoi (bufPtr); | |
813 | if (inputNo > 0) | |
814 | { | |
815 | if (negate) | |
816 | inputNo *= (-1); | |
817 | if (fixedSize) | |
818 | newHeight = inputNo; | |
819 | else | |
820 | newHeight = winInfo->generic.height + inputNo; | |
821 | /* | |
c5aa993b JM |
822 | ** Now change the window's height, and adjust all |
823 | ** other windows around it | |
824 | */ | |
c906108c SS |
825 | if (_tuiAdjustWinHeights (winInfo, |
826 | newHeight) == TUI_FAILURE) | |
827 | warning ("Invalid window height specified.\n%s", | |
828 | WIN_HEIGHT_USAGE); | |
829 | else | |
830 | init_page_info (); | |
831 | } | |
832 | else | |
833 | warning ("Invalid window height specified.\n%s", | |
834 | WIN_HEIGHT_USAGE); | |
835 | } | |
836 | } | |
837 | } | |
838 | else | |
839 | printf_filtered (WIN_HEIGHT_USAGE); | |
840 | ||
841 | if (buf != (char *) NULL) | |
842 | tuiFree (buf); | |
843 | } | |
844 | else | |
845 | printf_filtered (WIN_HEIGHT_USAGE); | |
846 | ||
847 | return; | |
848 | } /* _tuiSetWinHeight */ | |
849 | ||
850 | ||
851 | /* | |
c5aa993b JM |
852 | ** _tui_vSetWinHeight(). |
853 | ** Set the height of the specified window, with va_list. | |
854 | */ | |
c906108c | 855 | static void |
eca6576c | 856 | _tui_vSetWinHeight (va_list args) |
c906108c SS |
857 | { |
858 | char *arg = va_arg (args, char *); | |
859 | int fromTTY = va_arg (args, int); | |
860 | ||
861 | _tuiSetWinHeight (arg, fromTTY); | |
862 | ||
863 | return; | |
864 | } /* _tui_vSetWinHeight */ | |
865 | ||
866 | ||
867 | /* | |
c5aa993b JM |
868 | ** _tuiSetWinHeight_command(). |
869 | ** Set the height of the specified window, with va_list. | |
870 | */ | |
c906108c | 871 | static void |
eca6576c | 872 | _tuiSetWinHeight_command (char *arg, int fromTTY) |
c906108c | 873 | { |
e8b915dc SC |
874 | _tuiSetWinHeight (arg, fromTTY); |
875 | } | |
c906108c SS |
876 | |
877 | ||
878 | /* | |
c5aa993b JM |
879 | ** _tuiXDBsetWinHeight(). |
880 | ** XDB Compatibility command for setting the window height. This will | |
881 | ** increase or decrease the command window by the specified amount. | |
882 | */ | |
c906108c | 883 | static void |
eca6576c | 884 | _tuiXDBsetWinHeight (char *arg, int fromTTY) |
c906108c SS |
885 | { |
886 | if (arg != (char *) NULL) | |
887 | { | |
888 | int inputNo = atoi (arg); | |
889 | ||
890 | if (inputNo > 0) | |
891 | { /* Add 1 for the locator */ | |
892 | int newHeight = termHeight () - (inputNo + 1); | |
893 | ||
894 | if (!_newHeightOk (winList[CMD_WIN], newHeight) || | |
895 | _tuiAdjustWinHeights (winList[CMD_WIN], | |
896 | newHeight) == TUI_FAILURE) | |
897 | warning ("Invalid window height specified.\n%s", | |
898 | XDBWIN_HEIGHT_USAGE); | |
899 | } | |
900 | else | |
901 | warning ("Invalid window height specified.\n%s", | |
902 | XDBWIN_HEIGHT_USAGE); | |
903 | } | |
904 | else | |
905 | warning ("Invalid window height specified.\n%s", XDBWIN_HEIGHT_USAGE); | |
906 | ||
907 | return; | |
908 | } /* _tuiXDBsetWinHeight */ | |
909 | ||
910 | ||
911 | /* | |
c5aa993b JM |
912 | ** _tui_vXDBsetWinHeight(). |
913 | ** Set the height of the specified window, with va_list. | |
914 | */ | |
c906108c | 915 | static void |
eca6576c | 916 | _tui_vXDBsetWinHeight (va_list args) |
c906108c SS |
917 | { |
918 | char *arg = va_arg (args, char *); | |
919 | int fromTTY = va_arg (args, int); | |
920 | ||
921 | _tuiXDBsetWinHeight (arg, fromTTY); | |
922 | ||
923 | return; | |
924 | } /* _tui_vXDBsetWinHeight */ | |
925 | ||
926 | ||
927 | /* | |
c5aa993b JM |
928 | ** _tuiSetWinHeight_command(). |
929 | ** Set the height of the specified window, with va_list. | |
930 | */ | |
c906108c | 931 | static void |
eca6576c | 932 | _tuiXDBsetWinHeight_command (char *arg, int fromTTY) |
c906108c | 933 | { |
e8b915dc SC |
934 | _tuiXDBsetWinHeight (arg, fromTTY); |
935 | } | |
c906108c SS |
936 | |
937 | ||
938 | /* | |
c5aa993b JM |
939 | ** _tuiAdjustWinHeights(). |
940 | ** Function to adjust all window heights around the primary | |
941 | */ | |
c906108c | 942 | static TuiStatus |
eca6576c | 943 | _tuiAdjustWinHeights (TuiWinInfoPtr primaryWinInfo, int newHeight) |
c906108c SS |
944 | { |
945 | TuiStatus status = TUI_FAILURE; | |
946 | ||
947 | if (_newHeightOk (primaryWinInfo, newHeight)) | |
948 | { | |
949 | status = TUI_SUCCESS; | |
950 | if (newHeight != primaryWinInfo->generic.height) | |
951 | { | |
952 | int i, diff; | |
953 | TuiWinInfoPtr winInfo; | |
954 | TuiGenWinInfoPtr locator = locatorWinInfoPtr (); | |
955 | TuiLayoutType curLayout = currentLayout (); | |
956 | ||
957 | diff = (newHeight - primaryWinInfo->generic.height) * (-1); | |
958 | if (curLayout == SRC_COMMAND || curLayout == DISASSEM_COMMAND) | |
959 | { | |
960 | TuiWinInfoPtr srcWinInfo; | |
961 | ||
962 | _makeInvisibleAndSetNewHeight (primaryWinInfo, newHeight); | |
963 | if (primaryWinInfo->generic.type == CMD_WIN) | |
964 | { | |
965 | winInfo = (TuiWinInfoPtr) (sourceWindows ())->list[0]; | |
966 | srcWinInfo = winInfo; | |
967 | } | |
968 | else | |
969 | { | |
970 | winInfo = winList[CMD_WIN]; | |
971 | srcWinInfo = primaryWinInfo; | |
972 | } | |
973 | _makeInvisibleAndSetNewHeight (winInfo, | |
974 | winInfo->generic.height + diff); | |
975 | cmdWin->generic.origin.y = locator->origin.y + 1; | |
976 | _makeVisibleWithNewHeight (winInfo); | |
977 | _makeVisibleWithNewHeight (primaryWinInfo); | |
978 | if (srcWinInfo->generic.contentSize <= 0) | |
979 | tuiEraseSourceContent (srcWinInfo, EMPTY_SOURCE_PROMPT); | |
980 | } | |
981 | else | |
982 | { | |
983 | TuiWinInfoPtr firstWin, secondWin; | |
984 | ||
985 | if (curLayout == SRC_DISASSEM_COMMAND) | |
986 | { | |
987 | firstWin = srcWin; | |
988 | secondWin = disassemWin; | |
989 | } | |
990 | else | |
991 | { | |
992 | firstWin = dataWin; | |
993 | secondWin = (TuiWinInfoPtr) (sourceWindows ())->list[0]; | |
994 | } | |
995 | if (primaryWinInfo == cmdWin) | |
996 | { /* | |
c5aa993b JM |
997 | ** Split the change in height accross the 1st & 2nd windows |
998 | ** adjusting them as well. | |
999 | */ | |
c906108c SS |
1000 | int firstSplitDiff = diff / 2; /* subtract the locator */ |
1001 | int secondSplitDiff = firstSplitDiff; | |
1002 | ||
1003 | if (diff % 2) | |
1004 | { | |
1005 | if (firstWin->generic.height > | |
1006 | secondWin->generic.height) | |
1007 | if (diff < 0) | |
1008 | firstSplitDiff--; | |
1009 | else | |
1010 | firstSplitDiff++; | |
1011 | else | |
1012 | { | |
1013 | if (diff < 0) | |
1014 | secondSplitDiff--; | |
1015 | else | |
1016 | secondSplitDiff++; | |
1017 | } | |
1018 | } | |
1019 | /* make sure that the minimum hieghts are honored */ | |
1020 | while ((firstWin->generic.height + firstSplitDiff) < 3) | |
1021 | { | |
1022 | firstSplitDiff++; | |
1023 | secondSplitDiff--; | |
1024 | } | |
1025 | while ((secondWin->generic.height + secondSplitDiff) < 3) | |
1026 | { | |
1027 | secondSplitDiff++; | |
1028 | firstSplitDiff--; | |
1029 | } | |
1030 | _makeInvisibleAndSetNewHeight ( | |
1031 | firstWin, | |
1032 | firstWin->generic.height + firstSplitDiff); | |
1033 | secondWin->generic.origin.y = firstWin->generic.height - 1; | |
1034 | _makeInvisibleAndSetNewHeight ( | |
1035 | secondWin, secondWin->generic.height + secondSplitDiff); | |
1036 | cmdWin->generic.origin.y = locator->origin.y + 1; | |
1037 | _makeInvisibleAndSetNewHeight (cmdWin, newHeight); | |
1038 | } | |
1039 | else | |
1040 | { | |
1041 | if ((cmdWin->generic.height + diff) < 1) | |
1042 | { /* | |
c5aa993b JM |
1043 | ** If there is no way to increase the command window |
1044 | ** take real estate from the 1st or 2nd window. | |
1045 | */ | |
c906108c SS |
1046 | if ((cmdWin->generic.height + diff) < 1) |
1047 | { | |
1048 | int i; | |
1049 | for (i = cmdWin->generic.height + diff; | |
1050 | (i < 1); i++) | |
1051 | if (primaryWinInfo == firstWin) | |
1052 | secondWin->generic.height--; | |
1053 | else | |
1054 | firstWin->generic.height--; | |
1055 | } | |
1056 | } | |
1057 | if (primaryWinInfo == firstWin) | |
1058 | _makeInvisibleAndSetNewHeight (firstWin, newHeight); | |
1059 | else | |
1060 | _makeInvisibleAndSetNewHeight ( | |
1061 | firstWin, | |
1062 | firstWin->generic.height); | |
1063 | secondWin->generic.origin.y = firstWin->generic.height - 1; | |
1064 | if (primaryWinInfo == secondWin) | |
1065 | _makeInvisibleAndSetNewHeight (secondWin, newHeight); | |
1066 | else | |
1067 | _makeInvisibleAndSetNewHeight ( | |
1068 | secondWin, secondWin->generic.height); | |
1069 | cmdWin->generic.origin.y = locator->origin.y + 1; | |
1070 | if ((cmdWin->generic.height + diff) < 1) | |
1071 | _makeInvisibleAndSetNewHeight (cmdWin, 1); | |
1072 | else | |
1073 | _makeInvisibleAndSetNewHeight ( | |
1074 | cmdWin, cmdWin->generic.height + diff); | |
1075 | } | |
1076 | _makeVisibleWithNewHeight (cmdWin); | |
1077 | _makeVisibleWithNewHeight (secondWin); | |
1078 | _makeVisibleWithNewHeight (firstWin); | |
1079 | if (firstWin->generic.contentSize <= 0) | |
1080 | tuiEraseSourceContent (firstWin, EMPTY_SOURCE_PROMPT); | |
1081 | if (secondWin->generic.contentSize <= 0) | |
1082 | tuiEraseSourceContent (secondWin, EMPTY_SOURCE_PROMPT); | |
1083 | } | |
1084 | } | |
1085 | } | |
1086 | ||
1087 | return status; | |
1088 | } /* _tuiAdjustWinHeights */ | |
1089 | ||
1090 | ||
1091 | /* | |
c5aa993b JM |
1092 | ** _makeInvisibleAndSetNewHeight(). |
1093 | ** Function make the target window (and auxillary windows associated | |
1094 | ** with the targer) invisible, and set the new height and location. | |
1095 | */ | |
c906108c | 1096 | static void |
eca6576c | 1097 | _makeInvisibleAndSetNewHeight (TuiWinInfoPtr winInfo, int height) |
c906108c SS |
1098 | { |
1099 | int i; | |
1100 | struct symtab *s; | |
1101 | TuiGenWinInfoPtr genWinInfo; | |
1102 | ||
1103 | ||
1104 | m_beInvisible (&winInfo->generic); | |
1105 | winInfo->generic.height = height; | |
1106 | if (height > 1) | |
1107 | winInfo->generic.viewportHeight = height - 1; | |
1108 | else | |
1109 | winInfo->generic.viewportHeight = height; | |
1110 | if (winInfo != cmdWin) | |
1111 | winInfo->generic.viewportHeight--; | |
1112 | ||
1113 | /* Now deal with the auxillary windows associated with winInfo */ | |
1114 | switch (winInfo->generic.type) | |
1115 | { | |
1116 | case SRC_WIN: | |
1117 | case DISASSEM_WIN: | |
1118 | genWinInfo = winInfo->detail.sourceInfo.executionInfo; | |
1119 | m_beInvisible (genWinInfo); | |
1120 | genWinInfo->height = height; | |
1121 | genWinInfo->origin.y = winInfo->generic.origin.y; | |
1122 | if (height > 1) | |
1123 | genWinInfo->viewportHeight = height - 1; | |
1124 | else | |
1125 | genWinInfo->viewportHeight = height; | |
1126 | if (winInfo != cmdWin) | |
1127 | genWinInfo->viewportHeight--; | |
1128 | ||
1129 | if (m_hasLocator (winInfo)) | |
1130 | { | |
1131 | genWinInfo = locatorWinInfoPtr (); | |
1132 | m_beInvisible (genWinInfo); | |
1133 | genWinInfo->origin.y = winInfo->generic.origin.y + height; | |
1134 | } | |
1135 | break; | |
1136 | case DATA_WIN: | |
1137 | /* delete all data item windows */ | |
1138 | for (i = 0; i < winInfo->generic.contentSize; i++) | |
1139 | { | |
1140 | genWinInfo = (TuiGenWinInfoPtr) & ((TuiWinElementPtr) | |
1141 | winInfo->generic.content[i])->whichElement.dataWindow; | |
1142 | tuiDelwin (genWinInfo->handle); | |
1143 | genWinInfo->handle = (WINDOW *) NULL; | |
1144 | } | |
1145 | break; | |
1146 | default: | |
1147 | break; | |
1148 | } | |
1149 | ||
1150 | return; | |
1151 | } /* _makeInvisibleAndSetNewHeight */ | |
1152 | ||
1153 | ||
1154 | /* | |
c5aa993b JM |
1155 | ** _makeVisibleWithNewHeight(). |
1156 | ** Function to make the windows with new heights visible. | |
1157 | ** This means re-creating the windows' content since the window | |
1158 | ** had to be destroyed to be made invisible. | |
1159 | */ | |
c906108c | 1160 | static void |
eca6576c | 1161 | _makeVisibleWithNewHeight (TuiWinInfoPtr winInfo) |
c906108c SS |
1162 | { |
1163 | int i; | |
1164 | struct symtab *s; | |
1165 | ||
1166 | m_beVisible (&winInfo->generic); | |
1167 | checkAndDisplayHighlightIfNeeded (winInfo); | |
1168 | switch (winInfo->generic.type) | |
1169 | { | |
1170 | case SRC_WIN: | |
1171 | case DISASSEM_WIN: | |
1172 | freeWinContent (winInfo->detail.sourceInfo.executionInfo); | |
1173 | m_beVisible (winInfo->detail.sourceInfo.executionInfo); | |
1174 | if (winInfo->generic.content != (OpaquePtr) NULL) | |
1175 | { | |
1176 | TuiLineOrAddress lineOrAddr; | |
1177 | ||
1178 | if (winInfo->generic.type == SRC_WIN) | |
1179 | lineOrAddr.lineNo = | |
1180 | winInfo->detail.sourceInfo.startLineOrAddr.lineNo; | |
1181 | else | |
1182 | lineOrAddr.addr = | |
1183 | winInfo->detail.sourceInfo.startLineOrAddr.addr; | |
1184 | freeWinContent (&winInfo->generic); | |
1185 | tuiUpdateSourceWindow (winInfo, | |
1186 | current_source_symtab, | |
1187 | ((winInfo->generic.type == SRC_WIN) ? | |
1188 | (Opaque) lineOrAddr.lineNo : | |
1189 | lineOrAddr.addr), | |
1190 | TRUE); | |
1191 | } | |
1192 | else if (selected_frame != (struct frame_info *) NULL) | |
1193 | { | |
1194 | Opaque line = 0; | |
1195 | extern int current_source_line; | |
1196 | ||
1197 | s = find_pc_symtab (selected_frame->pc); | |
1198 | if (winInfo->generic.type == SRC_WIN) | |
1199 | line = (Opaque) current_source_line; | |
1200 | else | |
84b1e7c7 SC |
1201 | { |
1202 | CORE_ADDR pc; | |
1203 | ||
1204 | find_line_pc (s, current_source_line, &pc); | |
1205 | line = (Opaque) pc; | |
1206 | } | |
c906108c SS |
1207 | tuiUpdateSourceWindow (winInfo, s, line, TRUE); |
1208 | } | |
1209 | if (m_hasLocator (winInfo)) | |
1210 | { | |
1211 | m_beVisible (locatorWinInfoPtr ()); | |
1212 | tuiClearLocatorDisplay (); | |
1213 | tuiShowLocatorContent (); | |
1214 | } | |
1215 | break; | |
1216 | case DATA_WIN: | |
1217 | tuiDisplayAllData (); | |
1218 | break; | |
1219 | case CMD_WIN: | |
1220 | winInfo->detail.commandInfo.curLine = 0; | |
1221 | winInfo->detail.commandInfo.curch = 0; | |
1222 | wmove (winInfo->generic.handle, | |
1223 | winInfo->detail.commandInfo.curLine, | |
1224 | winInfo->detail.commandInfo.curch); | |
1225 | break; | |
1226 | default: | |
1227 | break; | |
1228 | } | |
1229 | ||
1230 | return; | |
1231 | } /* _makeVisibleWithNewHeight */ | |
1232 | ||
1233 | ||
1234 | static int | |
eca6576c | 1235 | _newHeightOk (TuiWinInfoPtr primaryWinInfo, int newHeight) |
c906108c SS |
1236 | { |
1237 | int ok = (newHeight < termHeight ()); | |
1238 | ||
1239 | if (ok) | |
1240 | { | |
1241 | int diff, curHeight; | |
1242 | TuiLayoutType curLayout = currentLayout (); | |
1243 | ||
1244 | diff = (newHeight - primaryWinInfo->generic.height) * (-1); | |
1245 | if (curLayout == SRC_COMMAND || curLayout == DISASSEM_COMMAND) | |
1246 | { | |
1247 | ok = ((primaryWinInfo->generic.type == CMD_WIN && | |
1248 | newHeight <= (termHeight () - 4) && | |
1249 | newHeight >= MIN_CMD_WIN_HEIGHT) || | |
1250 | (primaryWinInfo->generic.type != CMD_WIN && | |
1251 | newHeight <= (termHeight () - 2) && | |
1252 | newHeight >= MIN_WIN_HEIGHT)); | |
1253 | if (ok) | |
1254 | { /* check the total height */ | |
1255 | TuiWinInfoPtr winInfo; | |
1256 | ||
1257 | if (primaryWinInfo == cmdWin) | |
1258 | winInfo = (TuiWinInfoPtr) (sourceWindows ())->list[0]; | |
1259 | else | |
1260 | winInfo = cmdWin; | |
1261 | ok = ((newHeight + | |
1262 | (winInfo->generic.height + diff)) <= termHeight ()); | |
1263 | } | |
1264 | } | |
1265 | else | |
1266 | { | |
1267 | int curTotalHeight, totalHeight, minHeight; | |
1268 | TuiWinInfoPtr firstWin, secondWin; | |
1269 | ||
1270 | if (curLayout == SRC_DISASSEM_COMMAND) | |
1271 | { | |
1272 | firstWin = srcWin; | |
1273 | secondWin = disassemWin; | |
1274 | } | |
1275 | else | |
1276 | { | |
1277 | firstWin = dataWin; | |
1278 | secondWin = (TuiWinInfoPtr) (sourceWindows ())->list[0]; | |
1279 | } | |
1280 | /* | |
c5aa993b JM |
1281 | ** We could simply add all the heights to obtain the same result |
1282 | ** but below is more explicit since we subtract 1 for the | |
1283 | ** line that the first and second windows share, and add one | |
1284 | ** for the locator. | |
1285 | */ | |
c906108c SS |
1286 | curTotalHeight = |
1287 | (firstWin->generic.height + secondWin->generic.height - 1) | |
c5aa993b | 1288 | + cmdWin->generic.height + 1 /*locator */ ; |
c906108c SS |
1289 | if (primaryWinInfo == cmdWin) |
1290 | { | |
1291 | /* locator included since first & second win share a line */ | |
1292 | ok = ((firstWin->generic.height + | |
1293 | secondWin->generic.height + diff) >= | |
1294 | (MIN_WIN_HEIGHT * 2) && | |
1295 | newHeight >= MIN_CMD_WIN_HEIGHT); | |
1296 | if (ok) | |
1297 | { | |
1298 | totalHeight = newHeight + (firstWin->generic.height + | |
1299 | secondWin->generic.height + diff); | |
1300 | minHeight = MIN_CMD_WIN_HEIGHT; | |
1301 | } | |
1302 | } | |
1303 | else | |
1304 | { | |
1305 | minHeight = MIN_WIN_HEIGHT; | |
1306 | /* | |
c5aa993b JM |
1307 | ** First see if we can increase/decrease the command |
1308 | ** window. And make sure that the command window is | |
1309 | ** at least 1 line | |
1310 | */ | |
c906108c SS |
1311 | ok = ((cmdWin->generic.height + diff) > 0); |
1312 | if (!ok) | |
1313 | { /* | |
c5aa993b JM |
1314 | ** Looks like we have to increase/decrease one of |
1315 | ** the other windows | |
1316 | */ | |
c906108c SS |
1317 | if (primaryWinInfo == firstWin) |
1318 | ok = (secondWin->generic.height + diff) >= minHeight; | |
1319 | else | |
1320 | ok = (firstWin->generic.height + diff) >= minHeight; | |
1321 | } | |
1322 | if (ok) | |
1323 | { | |
1324 | if (primaryWinInfo == firstWin) | |
1325 | totalHeight = newHeight + | |
1326 | secondWin->generic.height + | |
1327 | cmdWin->generic.height + diff; | |
1328 | else | |
1329 | totalHeight = newHeight + | |
1330 | firstWin->generic.height + | |
1331 | cmdWin->generic.height + diff; | |
1332 | } | |
1333 | } | |
1334 | /* | |
c5aa993b JM |
1335 | ** Now make sure that the proposed total height doesn't exceed |
1336 | ** the old total height. | |
1337 | */ | |
c906108c SS |
1338 | if (ok) |
1339 | ok = (newHeight >= minHeight && totalHeight <= curTotalHeight); | |
1340 | } | |
1341 | } | |
1342 | ||
1343 | return ok; | |
1344 | } /* _newHeightOk */ | |
1345 | ||
1346 | ||
1347 | /* | |
c5aa993b JM |
1348 | ** _parseScrollingArgs(). |
1349 | */ | |
c906108c | 1350 | static void |
eca6576c | 1351 | _parseScrollingArgs (char *arg, TuiWinInfoPtr * winToScroll, int *numToScroll) |
c906108c SS |
1352 | { |
1353 | if (numToScroll) | |
1354 | *numToScroll = 0; | |
1355 | *winToScroll = tuiWinWithFocus (); | |
1356 | ||
1357 | /* | |
c5aa993b JM |
1358 | ** First set up the default window to scroll, in case there is no |
1359 | ** window name arg | |
1360 | */ | |
c906108c SS |
1361 | if (arg != (char *) NULL) |
1362 | { | |
1363 | char *buf, *bufPtr; | |
1364 | ||
1365 | /* process the number of lines to scroll */ | |
1366 | buf = bufPtr = tuiStrDup (arg); | |
1367 | if (isdigit (*bufPtr)) | |
1368 | { | |
1369 | char *numStr; | |
1370 | ||
1371 | numStr = bufPtr; | |
1372 | bufPtr = strchr (bufPtr, ' '); | |
1373 | if (bufPtr != (char *) NULL) | |
1374 | { | |
1375 | *bufPtr = (char) 0; | |
1376 | if (numToScroll) | |
1377 | *numToScroll = atoi (numStr); | |
1378 | bufPtr++; | |
1379 | } | |
1380 | else if (numToScroll) | |
1381 | *numToScroll = atoi (numStr); | |
1382 | } | |
1383 | ||
1384 | /* process the window name if one is specified */ | |
1385 | if (bufPtr != (char *) NULL) | |
1386 | { | |
1387 | char *wname; | |
1388 | int i; | |
1389 | ||
1390 | if (*bufPtr == ' ') | |
1391 | while (*(++bufPtr) == ' ') | |
1392 | ; | |
1393 | ||
1394 | if (*bufPtr != (char) 0) | |
1395 | wname = bufPtr; | |
1396 | ||
1397 | /* Validate the window name */ | |
1398 | for (i = 0; i < strlen (wname); i++) | |
1399 | wname[i] = toupper (wname[i]); | |
1400 | *winToScroll = partialWinByName (wname); | |
1401 | ||
1402 | if (*winToScroll == (TuiWinInfoPtr) NULL || | |
1403 | !(*winToScroll)->generic.isVisible) | |
1404 | warning ("Invalid window specified. \n\ | |
1405 | The window name specified must be valid and visible.\n"); | |
1406 | else if (*winToScroll == cmdWin) | |
1407 | *winToScroll = (TuiWinInfoPtr) (sourceWindows ())->list[0]; | |
1408 | } | |
1409 | tuiFree (buf); | |
1410 | } | |
1411 | ||
1412 | return; | |
1413 | } /* _parseScrollingArgs */ |