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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [tui/] [tuiGeneralWin.c] - Blame information for rev 1771

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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