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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [tui/] [tuiCommand.c] - Blame information for rev 106

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

Line No. Rev Author Line
1 106 markom
/*
2
   ** tuiCommand.c
3
   **     This module contains functions specific to command window processing.
4
 */
5
 
6
 
7
#include "defs.h"
8
#include "tui.h"
9
#include "tuiData.h"
10
#include "tuiWin.h"
11
#include "tuiIO.h"
12
 
13
 
14
/*****************************************
15
** STATIC LOCAL FUNCTIONS FORWARD DECLS    **
16
******************************************/
17
 
18
 
19
 
20
/*****************************************
21
** PUBLIC FUNCTIONS                        **
22
******************************************/
23
 
24
/*
25
   ** tuiDispatchCtrlChar().
26
   **        Dispatch the correct tui function based upon the control character.
27
 */
28
unsigned int
29
#ifdef __STDC__
30
tuiDispatchCtrlChar (
31
                      unsigned int ch)
32
#else
33
tuiDispatchCtrlChar (ch)
34
     unsigned int ch;
35
#endif
36
{
37
  TuiWinInfoPtr winInfo = tuiWinWithFocus ();
38
 
39
  /*
40
     ** If the command window has the logical focus, or no-one does
41
     ** assume it is the command window; in this case, pass the
42
     ** character on through and do nothing here.
43
   */
44
  if (winInfo == (TuiWinInfoPtr) NULL || winInfo == cmdWin)
45
    return ch;
46
  else
47
    {
48
      unsigned int c = 0, chCopy = ch;
49
      register int i;
50
      char *term;
51
 
52
      /* If this is an xterm, page next/prev keys aren't returned
53
         ** by keypad as a single char, so we must handle them here.
54
         ** Seems like a bug in the curses library?
55
       */
56
      term = (char *) getenv ("TERM");
57
      for (i = 0; (term && term[i]); i++)
58
        term[i] = toupper (term[i]);
59
      if ((strcmp (term, "XTERM") == 0) && m_isStartSequence (ch))
60
        {
61
          unsigned int pageCh = 0, tmpChar;
62
 
63
          tmpChar = 0;
64
          while (!m_isEndSequence (tmpChar))
65
            {
66
              tmpChar = (int) wgetch (cmdWin->generic.handle);
67
              if (!tmpChar)
68
                break;
69
              if (tmpChar == 53)
70
                pageCh = KEY_PPAGE;
71
              else if (tmpChar == 54)
72
                pageCh = KEY_NPAGE;
73
            }
74
          chCopy = pageCh;
75
        }
76
 
77
      switch (chCopy)
78
        {
79
        case KEY_NPAGE:
80
          tuiScrollForward (winInfo, 0);
81
          break;
82
        case KEY_PPAGE:
83
          tuiScrollBackward (winInfo, 0);
84
          break;
85
        case KEY_DOWN:
86
        case KEY_SF:
87
          tuiScrollForward (winInfo, 1);
88
          break;
89
        case KEY_UP:
90
        case KEY_SR:
91
          tuiScrollBackward (winInfo, 1);
92
          break;
93
        case KEY_RIGHT:
94
          tuiScrollLeft (winInfo, 1);
95
          break;
96
        case KEY_LEFT:
97
          tuiScrollRight (winInfo, 1);
98
          break;
99
        case '\f':
100
          tuiRefreshAll ();
101
          break;
102
        default:
103
          c = chCopy;
104
          break;
105
        }
106
      return c;
107
    }
108
}                               /* tuiDispatchCtrlChar */
109
 
110
 
111
/*
112
   ** tuiIncrCommandCharCountBy()
113
   **     Increment the current character count in the command window,
114
   **     checking for overflow.  Returns the new value of the char count.
115
 */
116
int
117
#ifdef __STDC__
118
tuiIncrCommandCharCountBy (
119
                            int count)
120
#else
121
tuiIncrCommandCharCountBy (count)
122
     int count;
123
#endif
124
{
125
  if (tui_version)
126
    {
127
      if ((count + cmdWin->detail.commandInfo.curch) >= cmdWin->generic.width)
128
        cmdWin->detail.commandInfo.curch =
129
          (count + cmdWin->detail.commandInfo.curch) - cmdWin->generic.width;
130
      else
131
        cmdWin->detail.commandInfo.curch += count;
132
    }
133
 
134
  return cmdWin->detail.commandInfo.curch;
135
}                               /* tuiIncrCommandCharCountBy */
136
 
137
 
138
/*
139
   ** tuiDecrCommandCharCountBy()
140
   **     Decrement the current character count in the command window,
141
   **     checking for overflow.  Returns the new value of the char count.
142
 */
143
int
144
#ifdef __STDC__
145
tuiDecrCommandCharCountBy (
146
                            int count)
147
#else
148
tuiDecrCommandCharCountBy (count)
149
     int count;
150
#endif
151
{
152
  if (tui_version)
153
    {
154
      if ((cmdWin->detail.commandInfo.curch - count) < 0)
155
        cmdWin->detail.commandInfo.curch =
156
          cmdWin->generic.width + (cmdWin->detail.commandInfo.curch - count);
157
      else
158
        cmdWin->detail.commandInfo.curch -= count;
159
    }
160
 
161
  return cmdWin->detail.commandInfo.curch;
162
}                               /* tuiDecrCommandCharCountBy */
163
 
164
 
165
/*
166
   ** tuiSetCommandCharCountTo()
167
   **     Set the character count to count.
168
 */
169
int
170
#ifdef __STDC__
171
tuiSetCommandCharCountTo (
172
                           int count)
173
#else
174
tuiSetCommandCharCountTo (count)
175
     int count;
176
#endif
177
{
178
  if (tui_version)
179
    {
180
      if (count > cmdWin->generic.width - 1)
181
        {
182
          cmdWin->detail.commandInfo.curch = 0;
183
          tuiIncrCommandCharCountBy (count);
184
        }
185
      else
186
        cmdWin->detail.commandInfo.curch -= count;
187
    }
188
 
189
  return cmdWin->detail.commandInfo.curch;
190
}                               /* tuiSetCommandCharCountTo */
191
 
192
 
193
 
194
/*
195
   ** tuiClearCommandCharCount()
196
   **     Clear the character count to count.
197
 */
198
int
199
#ifdef __STDC__
200
tuiClearCommandCharCount (void)
201
#else
202
tuiClearCommandCharCount ()
203
#endif
204
{
205
  if (tui_version)
206
    cmdWin->detail.commandInfo.curch = 0;
207
 
208
  return cmdWin->detail.commandInfo.curch;
209
}                               /* tuiClearCommandCharCount */
210
 
211
 
212
 
213
/*****************************************
214
** STATIC LOCAL FUNCTIONS                 **
215
******************************************/

powered by: WebSVN 2.1.0

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