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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gdb/] [gdb-6.8/] [gdb/] [tui/] [tui-command.c] - Blame information for rev 25

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 25 jlechner
/* Specific command window processing.
2
 
3
   Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
4
   Free Software Foundation, 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 3 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, see <http://www.gnu.org/licenses/>.  */
22
 
23
#include "defs.h"
24
#include <ctype.h>
25
#include "tui/tui.h"
26
#include "tui/tui-data.h"
27
#include "tui/tui-win.h"
28
#include "tui/tui-io.h"
29
 
30
#include "gdb_curses.h"
31
#include "gdb_string.h"
32
 
33
 
34
/*****************************************
35
** STATIC LOCAL FUNCTIONS FORWARD DECLS    **
36
******************************************/
37
 
38
 
39
 
40
/*****************************************
41
** PUBLIC FUNCTIONS                        **
42
******************************************/
43
 
44
/* Dispatch the correct tui function based upon the control
45
   character.  */
46
unsigned int
47
tui_dispatch_ctrl_char (unsigned int ch)
48
{
49
  struct tui_win_info *win_info = tui_win_with_focus ();
50
 
51
  /* Handle the CTRL-L refresh for each window.  */
52
  if (ch == '\f')
53
    tui_refresh_all_win ();
54
 
55
  /* If the command window has the logical focus, or no-one does
56
     assume it is the command window; in this case, pass the character
57
     on through and do nothing here.  */
58
  if (win_info == NULL || win_info == TUI_CMD_WIN)
59
    return ch;
60
  else
61
    {
62
      unsigned int c = 0, ch_copy = ch;
63
      int i;
64
      char *term;
65
 
66
      /* If this is an xterm, page next/prev keys aren't returned by
67
         keypad as a single char, so we must handle them here.  Seems
68
         like a bug in the curses library?  */
69
      term = (char *) getenv ("TERM");
70
      if (term)
71
        {
72
          for (i = 0; term[i]; i++)
73
            term[i] = toupper (term[i]);
74
          if ((strcmp (term, "XTERM") == 0)
75
              && key_is_start_sequence (ch))
76
            {
77
              unsigned int page_ch = 0;
78
              unsigned int tmp_char;
79
              WINDOW *w = TUI_CMD_WIN->generic.handle;
80
 
81
              tmp_char = 0;
82
              while (!key_is_end_sequence (tmp_char))
83
                {
84
                  tmp_char = (int) wgetch (w);
85
                  if (tmp_char == ERR)
86
                    {
87
                      return ch;
88
                    }
89
                  if (!tmp_char)
90
                    break;
91
                  if (tmp_char == 53)
92
                    page_ch = KEY_PPAGE;
93
                  else if (tmp_char == 54)
94
                    page_ch = KEY_NPAGE;
95
                  else
96
                    {
97
                      return 0;
98
                    }
99
                }
100
              ch_copy = page_ch;
101
            }
102
        }
103
 
104
      switch (ch_copy)
105
        {
106
        case KEY_NPAGE:
107
          tui_scroll_forward (win_info, 0);
108
          break;
109
        case KEY_PPAGE:
110
          tui_scroll_backward (win_info, 0);
111
          break;
112
        case KEY_DOWN:
113
        case KEY_SF:
114
          tui_scroll_forward (win_info, 1);
115
          break;
116
        case KEY_UP:
117
        case KEY_SR:
118
          tui_scroll_backward (win_info, 1);
119
          break;
120
        case KEY_RIGHT:
121
          tui_scroll_left (win_info, 1);
122
          break;
123
        case KEY_LEFT:
124
          tui_scroll_right (win_info, 1);
125
          break;
126
        case '\f':
127
          break;
128
        default:
129
          c = ch_copy;
130
          break;
131
        }
132
      return c;
133
    }
134
}

powered by: WebSVN 2.1.0

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