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