OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.3/] [gdb/] [tui/] [tuiWin.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.