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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [tui/] [tuiGeneralWin.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 106 markom
/*
2
   ** TuiGeneralWin.c
3
   ** This module supports general window behavior
4
 */
5
 
6
#include <curses.h>
7
#include "defs.h"
8
#include "tui.h"
9
#include "tuiData.h"
10
#include "tuiGeneralWin.h"
11
 
12
 
13
/*
14
   ** local support functions
15
 */
16
static void _winResize PARAMS ((void));
17
 
18
 
19
/***********************
20
** PUBLIC FUNCTIONS
21
***********************/
22
/*
23
   ** tuiRefreshWin()
24
   **        Refresh the window
25
 */
26
void
27
#ifdef __STDC__
28
tuiRefreshWin (
29
                TuiGenWinInfoPtr winInfo)
30
#else
31
tuiRefreshWin (winInfo)
32
     TuiGenWinInfoPtr winInfo;
33
#endif
34
{
35
  if (winInfo->type == DATA_WIN && winInfo->contentSize > 0)
36
    {
37
      int i;
38
 
39
      for (i = 0; (i < winInfo->contentSize); i++)
40
        {
41
          TuiGenWinInfoPtr dataItemWinPtr;
42
 
43
          dataItemWinPtr = &((TuiWinContent)
44
                             winInfo->content)[i]->whichElement.dataWindow;
45
          if (m_genWinPtrNotNull (dataItemWinPtr) &&
46
              dataItemWinPtr->handle != (WINDOW *) NULL)
47
            wrefresh (dataItemWinPtr->handle);
48
        }
49
    }
50
  else if (winInfo->type == CMD_WIN)
51
    {
52
      /* Do nothing */
53
    }
54
  else
55
    {
56
      if (winInfo->handle != (WINDOW *) NULL)
57
        wrefresh (winInfo->handle);
58
    }
59
 
60
  return;
61
}                               /* tuiRefreshWin */
62
 
63
 
64
/*
65
   ** tuiDelwin()
66
   **        Function to delete the curses window, checking for null
67
 */
68
void
69
#ifdef __STDC__
70
tuiDelwin (
71
            WINDOW * window)
72
#else
73
tuiDelwin (window)
74
     WINDOW *window;
75
#endif
76
{
77
  if (window != (WINDOW *) NULL)
78
    delwin (window);
79
 
80
  return;
81
}                               /* tuiDelwin */
82
 
83
 
84
/*
85
   ** boxWin().
86
 */
87
void
88
#ifdef __STDC__
89
boxWin (
90
         TuiGenWinInfoPtr winInfo,
91
         int highlightFlag)
92
#else
93
boxWin (winInfo, highlightFlag)
94
     TuiGenWinInfoPtr winInfo;
95
     int highlightFlag;
96
#endif
97
{
98
  if (m_genWinPtrNotNull (winInfo) && winInfo->handle != (WINDOW *) NULL)
99
    {
100
      if (highlightFlag == HILITE)
101
        box (winInfo->handle, '|', '-');
102
      else
103
        {
104
/*            wattron(winInfo->handle, A_DIM); */
105
          box (winInfo->handle, ':', '.');
106
/*            wattroff(winInfo->handle, A_DIM); */
107
        }
108
    }
109
 
110
  return;
111
}                               /* boxWin */
112
 
113
 
114
/*
115
   ** unhighlightWin().
116
 */
117
void
118
#ifdef __STDC__
119
unhighlightWin (
120
                 TuiWinInfoPtr winInfo)
121
#else
122
unhighlightWin (winInfo)
123
     TuiWinInfoPtr winInfo;
124
#endif
125
{
126
  if (m_winPtrNotNull (winInfo) && winInfo->generic.handle != (WINDOW *) NULL)
127
    {
128
      boxWin ((TuiGenWinInfoPtr) winInfo, NO_HILITE);
129
      wrefresh (winInfo->generic.handle);
130
      m_setWinHighlightOff (winInfo);
131
    }
132
}                               /* unhighlightWin */
133
 
134
 
135
/*
136
   ** highlightWin().
137
 */
138
void
139
#ifdef __STDC__
140
highlightWin (
141
               TuiWinInfoPtr winInfo)
142
#else
143
highlightWin (winInfo)
144
     TuiWinInfoPtr winInfo;
145
#endif
146
{
147
  if (m_winPtrNotNull (winInfo) &&
148
      winInfo->canHighlight && winInfo->generic.handle != (WINDOW *) NULL)
149
    {
150
      boxWin ((TuiGenWinInfoPtr) winInfo, HILITE);
151
      wrefresh (winInfo->generic.handle);
152
      m_setWinHighlightOn (winInfo);
153
    }
154
}                               /* highlightWin */
155
 
156
 
157
/*
158
   ** checkAndDisplayHighlightIfNecessay
159
 */
160
void
161
#ifdef __STDC__
162
checkAndDisplayHighlightIfNeeded (
163
                                   TuiWinInfoPtr winInfo)
164
#else
165
checkAndDisplayHighlightIfNeeded (winInfo)
166
     TuiWinInfoPtr winInfo;
167
#endif
168
{
169
  if (m_winPtrNotNull (winInfo) && winInfo->generic.type != CMD_WIN)
170
    {
171
      if (winInfo->isHighlighted)
172
        highlightWin (winInfo);
173
      else
174
        unhighlightWin (winInfo);
175
 
176
    }
177
  return;
178
}                               /* checkAndDisplayHighlightIfNeeded */
179
 
180
 
181
/*
182
   ** makeWindow().
183
 */
184
void
185
#ifdef __STDC__
186
makeWindow (
187
             TuiGenWinInfoPtr winInfo,
188
             int boxIt)
189
#else
190
makeWindow (winInfo, boxIt)
191
     TuiGenWinInfoPtr winInfo;
192
     int boxIt;
193
#endif
194
{
195
  WINDOW *handle;
196
 
197
  handle = newwin (winInfo->height,
198
                   winInfo->width,
199
                   winInfo->origin.y,
200
                   winInfo->origin.x);
201
  winInfo->handle = handle;
202
  if (handle != (WINDOW *) NULL)
203
    {
204
      if (boxIt == BOX_WINDOW)
205
        boxWin (winInfo, NO_HILITE);
206
      winInfo->isVisible = TRUE;
207
      scrollok (handle, TRUE);
208
      tuiRefreshWin (winInfo);
209
 
210
#ifndef FOR_TEST
211
      if (                      /*!m_WinIsAuxillary(winInfo->type) && */
212
           (winInfo->type != CMD_WIN) &&
213
           (winInfo->content == (OpaquePtr) NULL))
214
        {
215
          mvwaddstr (handle, 1, 1, winName (winInfo));
216
          tuiRefreshWin (winInfo);
217
        }
218
#endif /*FOR_TEST */
219
    }
220
 
221
  return;
222
}                               /* makeWindow */
223
 
224
 
225
/*
226
   ** tuiClearWin().
227
   **        Clear the window of all contents without calling wclear.
228
 */
229
void
230
#ifdef __STDC__
231
tuiClearWin (
232
              TuiGenWinInfoPtr winInfo)
233
#else
234
tuiClearWin (winInfo)
235
     TuiGenWinInfoPtr winInfo;
236
#endif
237
{
238
  if (m_genWinPtrNotNull (winInfo) && winInfo->handle != (WINDOW *) NULL)
239
    {
240
      int curRow, curCol;
241
 
242
      for (curRow = 0; (curRow < winInfo->height); curRow++)
243
        for (curCol = 0; (curCol < winInfo->width); curCol++)
244
          mvwaddch (winInfo->handle, curRow, curCol, ' ');
245
 
246
      tuiRefreshWin (winInfo);
247
    }
248
 
249
  return;
250
}                               /* tuiClearWin */
251
 
252
 
253
/*
254
   ** makeVisible().
255
   **        We can't really make windows visible, or invisible.  So we
256
   **        have to delete the entire window when making it visible,
257
   **        and create it again when making it visible.
258
 */
259
void
260
#ifdef __STDC__
261
makeVisible (
262
              TuiGenWinInfoPtr winInfo,
263
              int visible)
264
#else
265
makeVisible (winInfo, visible)
266
     TuiGenWinInfoPtr winInfo;
267
     int visible;
268
#endif
269
{
270
  /* Don't tear down/recreate command window */
271
  if (winInfo->type == CMD_WIN)
272
    return;
273
 
274
  if (visible)
275
    {
276
      if (!winInfo->isVisible)
277
        {
278
          makeWindow (
279
                       winInfo,
280
           (winInfo->type != CMD_WIN && !m_winIsAuxillary (winInfo->type)));
281
          winInfo->isVisible = TRUE;
282
        }
283
      tuiRefreshWin (winInfo);
284
    }
285
  else if (!visible &&
286
           winInfo->isVisible && winInfo->handle != (WINDOW *) NULL)
287
    {
288
      winInfo->isVisible = FALSE;
289
      tuiClearWin (winInfo);
290
      tuiDelwin (winInfo->handle);
291
      winInfo->handle = (WINDOW *) NULL;
292
    }
293
 
294
  return;
295
}                               /* makeVisible */
296
 
297
 
298
/*
299
   ** makeAllVisible().
300
   **        Makes all windows invisible (except the command and locator windows)
301
 */
302
void
303
#ifdef __STDC__
304
makeAllVisible (
305
                 int visible)
306
#else
307
makeAllVisible (visible)
308
     int visible;
309
#endif
310
{
311
  int i;
312
 
313
  for (i = 0; i < MAX_MAJOR_WINDOWS; i++)
314
    {
315
      if (m_winPtrNotNull (winList[i]) &&
316
          ((winList[i])->generic.type) != CMD_WIN)
317
        {
318
          if (m_winIsSourceType ((winList[i])->generic.type))
319
            makeVisible ((winList[i])->detail.sourceInfo.executionInfo,
320
                         visible);
321
          makeVisible ((TuiGenWinInfoPtr) winList[i], visible);
322
        }
323
    }
324
 
325
  return;
326
}                               /* makeAllVisible */
327
 
328
 
329
/*
330
   ** scrollWinForward
331
 */
332
void
333
#ifdef __STDC__
334
scrollWinForward (
335
                   TuiGenWinInfoPtr winInfo,
336
                   int numLines)
337
#else
338
scrollWinForward (winInfo, numLines)
339
     TuiGenWinInfoPtr winInfo;
340
     int numLines;
341
#endif
342
{
343
  if (winInfo->content != (OpaquePtr) NULL &&
344
      winInfo->lastVisibleLine < winInfo->contentSize - 1)
345
    {
346
      int i, firstLine, newLastLine;
347
 
348
      firstLine = winInfo->lastVisibleLine - winInfo->viewportHeight + 1;
349
      if (winInfo->lastVisibleLine + numLines > winInfo->contentSize)
350
        newLastLine = winInfo->contentSize - 1;
351
      else
352
        newLastLine = winInfo->lastVisibleLine + numLines - 1;
353
 
354
      for (i = (newLastLine - winInfo->viewportHeight);
355
           (i <= newLastLine); i++)
356
        {
357
          TuiWinElementPtr line;
358
          int lineHeight;
359
 
360
          line = (TuiWinElementPtr) winInfo->content[i];
361
          if (line->highlight)
362
            wstandout (winInfo->handle);
363
          mvwaddstr (winInfo->handle,
364
                     i - (newLastLine - winInfo->viewportHeight),
365
                     1,
366
                     displayableWinContentOf (winInfo, line));
367
          if (line->highlight)
368
            wstandend (winInfo->handle);
369
          lineHeight = winElementHeight (winInfo, line);
370
          newLastLine += (lineHeight - 1);
371
        }
372
      winInfo->lastVisibleLine = newLastLine;
373
    }
374
 
375
  return;
376
}                               /* scrollWinForward */
377
 
378
 
379
/*
380
   ** scrollWinBackward
381
 */
382
void
383
#ifdef __STDC__
384
scrollWinBackward (
385
                    TuiGenWinInfoPtr winInfo,
386
                    int numLines)
387
#else
388
scrollWinBackward (winInfo, numLines)
389
     TuiGenWinInfoPtr winInfo;
390
     int numLines;
391
#endif
392
{
393
  if (winInfo->content != (OpaquePtr) NULL &&
394
      (winInfo->lastVisibleLine - winInfo->viewportHeight) > 0)
395
    {
396
      int i, newLastLine, firstLine;
397
 
398
      firstLine = winInfo->lastVisibleLine - winInfo->viewportHeight + 1;
399
      if ((firstLine - numLines) < 0)
400
        newLastLine = winInfo->viewportHeight - 1;
401
      else
402
        newLastLine = winInfo->lastVisibleLine - numLines + 1;
403
 
404
      for (i = newLastLine - winInfo->viewportHeight; (i <= newLastLine); i++)
405
        {
406
          TuiWinElementPtr line;
407
          int lineHeight;
408
 
409
          line = (TuiWinElementPtr) winInfo->content[i];
410
          if (line->highlight)
411
            wstandout (winInfo->handle);
412
          mvwaddstr (winInfo->handle,
413
                     i - (newLastLine - winInfo->viewportHeight),
414
                     1,
415
                     displayableWinContentOf (winInfo, line));
416
          if (line->highlight)
417
            wstandend (winInfo->handle);
418
          lineHeight = winElementHeight (winInfo, line);
419
          newLastLine += (lineHeight - 1);
420
        }
421
      winInfo->lastVisibleLine = newLastLine;
422
    }
423
 
424
  return;
425
}                               /* scrollWinBackward */
426
 
427
 
428
/*
429
   ** refreshAll().
430
   **        Function to refresh all the windows currently displayed
431
 */
432
void
433
#ifdef __STDC__
434
refreshAll (
435
             TuiWinInfoPtr * list)
436
#else
437
refreshAll (list)
438
     TuiWinInfoPtr *list;
439
#endif
440
{
441
  TuiWinType type;
442
  TuiGenWinInfoPtr locator = locatorWinInfoPtr ();
443
 
444
  for (type = SRC_WIN; (type < MAX_MAJOR_WINDOWS); type++)
445
    {
446
      if (list[type]->generic.isVisible)
447
        {
448
          if (type == SRC_WIN || type == DISASSEM_WIN)
449
            {
450
              touchwin (list[type]->detail.sourceInfo.executionInfo->handle);
451
              tuiRefreshWin (list[type]->detail.sourceInfo.executionInfo);
452
            }
453
          touchwin (list[type]->generic.handle);
454
          tuiRefreshWin (&list[type]->generic);
455
        }
456
    }
457
  if (locator->isVisible)
458
    {
459
      touchwin (locator->handle);
460
      tuiRefreshWin (locator);
461
    }
462
 
463
  return;
464
}                               /* refreshAll */
465
 
466
 
467
/*********************************
468
** Local Static Functions
469
*********************************/

powered by: WebSVN 2.1.0

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