Just a little correction at the it.po file.
[midnight-commander.git] / src / win.c
blobe533c96d06bcb959921a20be5703d8254416a2f1
1 /* Curses utilities
2 Copyright (C) 1995 Miguel de Icaza, Janne Kukonlehto
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
18 #include <config.h>
19 #include <stdio.h>
20 #include <string.h>
21 #ifdef HAVE_TERMIOS_H
22 # include <termios.h>
23 #endif
25 #include "global.h"
26 #include "tty.h"
27 #include "color.h"
28 #include "mouse.h"
29 #include "dlg.h"
30 #include "widget.h"
31 #include "win.h"
32 #include "key.h" /* XCTRL and ALT macros */
33 #include "layout.h"
35 /* Return values: 0 = not a movement key, 1 = was a movement key */
36 int check_movement_keys (int c, int additional, int page_size, void *data,
37 movefn backfn, movefn forfn, movefn topfn,
38 movefn bottomfn)
40 switch (c){
41 case KEY_UP:
42 case XCTRL ('p'):
43 (*backfn)(data, 1);
44 return 1;
46 case KEY_DOWN:
47 case XCTRL ('n'):
48 (*forfn)(data, 1);
49 return 1;
51 case KEY_PPAGE:
52 case ALT('v'):
53 (*backfn)(data, page_size-1);
54 return 1;
56 case KEY_NPAGE:
57 case XCTRL('v'):
58 (*forfn)(data, page_size-1);
59 return 1;
61 case KEY_HOME:
62 case KEY_A1:
63 (*topfn)(data, 0);
64 return 1;
65 case KEY_END:
66 case KEY_C1:
67 (*bottomfn)(data, 0);
68 return 1;
70 if (additional)
71 switch (c){
72 case 'b':
73 case KEY_BACKSPACE:
74 (*backfn)(data, page_size-1);
75 return 1;
76 case ' ':
77 (*forfn)(data, page_size-1);
78 return 1;
79 case 'u':
80 (*backfn)(data, page_size / 2);
81 return 1;
82 case 'd':
83 (*forfn)(data, page_size / 2);
84 return 1;
85 case 'g':
86 (*topfn)(data, 0);
87 return 1;
88 case 'G':
89 (*bottomfn)(data, 0);
90 return 1;
92 return 0;
95 /* Classification routines */
96 int is_abort_char (int c)
98 return (c == XCTRL('c') || c == XCTRL('g') || c == ESC_CHAR ||
99 c == KEY_F(10));
102 void mc_raw_mode (void)
104 raw ();
107 void mc_noraw_mode (void)
109 noraw ();
112 /* This table is a mapping between names and the constants we use
113 * We use this to allow users to define alternate definitions for
114 * certain keys that may be missing from the terminal database
116 key_code_name_t key_name_conv_tab [] = {
117 /* KEY_F(0) is not here, since we are mapping it to f10, so there is no reason
118 to define f0 as well. Also, it makes Learn keys a bunch of problems :( */
119 { KEY_F(1), "f1", N_("Function key 1") },
120 { KEY_F(2), "f2", N_("Function key 2") },
121 { KEY_F(3), "f3", N_("Function key 3") },
122 { KEY_F(4), "f4", N_("Function key 4") },
123 { KEY_F(5), "f5", N_("Function key 5") },
124 { KEY_F(6), "f6", N_("Function key 6") },
125 { KEY_F(7), "f7", N_("Function key 7") },
126 { KEY_F(8), "f8", N_("Function key 8") },
127 { KEY_F(9), "f9", N_("Function key 9") },
128 { KEY_F(10), "f10", N_("Function key 10") },
129 { KEY_F(11), "f11", N_("Function key 11") },
130 { KEY_F(12), "f12", N_("Function key 12") },
131 { KEY_F(13), "f13", N_("Function key 13") },
132 { KEY_F(14), "f14", N_("Function key 14") },
133 { KEY_F(15), "f15", N_("Function key 15") },
134 { KEY_F(16), "f16", N_("Function key 16") },
135 { KEY_F(17), "f17", N_("Function key 17") },
136 { KEY_F(18), "f18", N_("Function key 18") },
137 { KEY_F(19), "f19", N_("Function key 19") },
138 { KEY_F(20), "f20", N_("Function key 20") },
139 { KEY_BACKSPACE, "bs", N_("Backspace key") },
140 { KEY_END, "end", N_("End key") },
141 { KEY_UP, "up", N_("Up arrow key") },
142 { KEY_DOWN, "down", N_("Down arrow key") },
143 { KEY_LEFT, "left", N_("Left arrow key") },
144 { KEY_RIGHT, "right", N_("Right arrow key") },
145 { KEY_HOME, "home", N_("Home key") },
146 { KEY_NPAGE, "pgdn", N_("Page Down key") },
147 { KEY_PPAGE, "pgup", N_("Page Up key") },
148 { KEY_IC, "insert", N_("Insert key") },
149 { KEY_DC, "delete", N_("Delete key") },
150 { ALT('\t'), "complete", N_("Completion/M-tab") },
151 { KEY_KP_ADD, "kpplus", N_("+ on keypad") },
152 { KEY_KP_SUBTRACT,"kpminus", N_("- on keypad") },
153 { KEY_KP_MULTIPLY,"kpasterix", N_("* on keypad") },
154 /* From here on, these won't be shown in Learn keys (no space) */
155 { KEY_LEFT, "kpleft", N_("Left arrow keypad") },
156 { KEY_RIGHT, "kpright", N_("Right arrow keypad") },
157 { KEY_UP, "kpup", N_("Up arrow keypad") },
158 { KEY_DOWN, "kpdown", N_("Down arrow keypad") },
159 { KEY_HOME, "kphome", N_("Home on keypad") },
160 { KEY_END, "kpend", N_("End on keypad") },
161 { KEY_NPAGE, "kpnpage", N_("Page Down keypad") },
162 { KEY_PPAGE, "kpppage", N_("Page Up keypad") },
163 { KEY_IC, "kpinsert", N_("Insert on keypad") },
164 { KEY_DC, "kpdelete", N_("Delete on keypad") },
165 { (int) '\n', "kpenter", N_("Enter on keypad") },
166 { (int) '/', "kpslash", N_("Slash on keypad") },
167 { (int) '#', "kpnumlock", N_("NumLock on keypad") },
168 { 0, 0, 0 }
171 /* Return the code associated with the symbolic name keyname */
172 int lookup_key (char *keyname)
174 int i;
176 for (i = 0; key_name_conv_tab [i].code; i++){
177 if ( g_strcasecmp (key_name_conv_tab [i].name, keyname))
178 continue;
179 return key_name_conv_tab [i].code;
181 return 0;