ru.po: Heavily updated translation
[midnight-commander.git] / nt / slint.nt.c
blobf96b3a1f9bd6c74aae480832a149da690719df03
1 /* Slang interface to the Midnight Commander for Windows NT and OS/2
2 This emulates some features of ncurses on top of slang
3 S-lang is not fully consistent between its Unix and non-Unix versions.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
20 #include <config.h>
21 #include <stdio.h>
22 #include "tty.h"
23 #include "mad.h"
24 #include "color.h"
25 #include "util.h"
26 #include "mouse.h" /* Gpm_Event is required in key.h */
27 #include "key.h" /* define_sequence */
28 #include "main.h" /* extern: force_colors */
29 #include "win.h" /* do_exit_ca_mode */
31 #ifdef HAVE_SLANG
33 static void slang_sigterm ()
35 SLsmg_reset_smg ();
38 static int slinterrupt;
40 void enable_interrupt_key(void)
42 SLang_set_abort_signal(NULL);
43 slinterrupt = 1;
45 void disable_interrupt_key(void)
47 slinterrupt = 0;
49 int got_interrupt ()
51 int t;
52 int SLKeyboard_Quit=0; //FIXME!!
53 t = slinterrupt ? SLKeyboard_Quit : 0;
54 // SLKeyboard_Quit = 0;
55 return t;
58 /* Only done the first time */
59 void slang_init (void)
61 SLtt_get_terminfo ();
62 SLang_init_tty (XCTRL('c'), 1, 0);
63 slang_prog_mode ();
64 load_terminfo_keys ();
67 /* Done each time we come back from done mode */
68 void slang_prog_mode (void)
70 SLsmg_init_smg ();
71 SLsmg_touch_lines (0, LINES);
74 /* Called each time we want to shutdown slang screen manager */
75 void slang_shell_mode (void)
80 void slang_shutdown ()
82 slang_shell_mode ();
83 do_exit_ca_mode ();
84 SLang_reset_tty ();
86 /* reset the colors to those that were
87 * active when the program was started up
88 (not written)
92 /* keypad routines */
93 void slang_keypad (int set)
95 // enable keypad strings
96 // ?
99 static int no_slang_delay;
101 void set_slang_delay (int v)
103 no_slang_delay = v;
106 void hline (int ch, int len)
108 int last_x, last_y;
110 last_x = SLsmg_get_column ();
111 last_y = SLsmg_get_row ();
113 if (ch == 0)
114 ch = ACS_HLINE;
116 if (ch == ACS_HLINE){
117 SLsmg_draw_hline (len);
118 } else {
119 while (len--)
120 addch (ch);
122 move (last_y, last_x);
125 void vline (int character, int len)
127 if (!slow_terminal){
128 SLsmg_draw_vline (len);
129 } else {
130 int last_x, last_y, pos = 0;
132 last_x = SLsmg_get_column ();
133 last_y = SLsmg_get_row ();
135 while (len--){
136 move (last_y + pos++, last_x);
137 addch (' ');
139 move (last_x, last_y);
143 void init_pair (int index, char *foreground, char *background)
145 SLtt_set_color (index, "", foreground, background);
149 int has_colors ()
151 /* No terminals on NT, make default color */
152 if (!disable_colors)
153 SLtt_Use_Ansi_Colors = 1;
155 /* Setup emulated colors */
156 if (SLtt_Use_Ansi_Colors){
157 init_pair (A_REVERSE, "black", "white");
158 } else {
159 /* SLtt_set_mono (A_BOLD, NULL, SLTT_BOLD_MASK);
160 SLtt_set_mono (A_REVERSE, NULL, SLTT_REV_MASK);
161 SLtt_set_mono (A_BOLD|A_REVERSE, NULL, SLTT_BOLD_MASK | SLTT_REV_MASK);
162 */ }
163 return SLtt_Use_Ansi_Colors;
166 void attrset (int color)
168 if (!SLtt_Use_Ansi_Colors){
169 SLsmg_set_color (color);
170 return;
173 if (color & A_BOLD){
174 if (color == A_BOLD)
175 SLsmg_set_color (A_BOLD);
176 else
177 SLsmg_set_color ((color & (~A_BOLD)) + 8);
178 return;
181 if (color == A_REVERSE)
182 SLsmg_set_color (A_REVERSE);
183 else
184 SLsmg_set_color (color);
187 void load_terminfo_keys ()
191 int getch ()
193 if (no_slang_delay)
194 if (SLang_input_pending (0) == 0)
195 return -1;
197 return SLang_getkey ();
200 extern int slow_terminal;
202 #else
204 /* Non slang builds do not understand got_interrupt */
205 int got_interrupt ()
207 return 0;
209 #endif /* HAVE_SLANG */
211 void mc_refresh (void)
213 /* if (!we_are_background) (no background mode yet) */
214 refresh ();
217 void slang_set_raw_mode (void)
219 return;