Mercurial > emacs
annotate src/w32console.c @ 15426:28464b50adfb
(LIBS_SYSTEM): Two new definitions (and #undef first).
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Thu, 13 Jun 1996 16:41:20 +0000 |
parents | 5bda3e000c2c |
children | 769461738e5d |
rev | line source |
---|---|
9907 | 1 /* Terminal hooks for Windows NT port of GNU Emacs. |
2 Copyright (C) 1992 Free Software Foundation, Inc. | |
3 | |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13424
diff
changeset
|
4 This file is part of GNU Emacs. |
9907 | 5 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13424
diff
changeset
|
6 GNU Emacs is free software; you can redistribute it and/or modify |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13424
diff
changeset
|
7 it under the terms of the GNU General Public License as published by |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13424
diff
changeset
|
8 the Free Software Foundation; either version 2, or (at your option) |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13424
diff
changeset
|
9 any later version. |
9907 | 10 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13424
diff
changeset
|
11 GNU Emacs is distributed in the hope that it will be useful, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13424
diff
changeset
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13424
diff
changeset
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13424
diff
changeset
|
14 GNU General Public License for more details. |
9907 | 15 |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13424
diff
changeset
|
16 You should have received a copy of the GNU General Public License |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13424
diff
changeset
|
17 along with GNU Emacs; see the file COPYING. If not, write to |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13424
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
13424
diff
changeset
|
19 Boston, MA 02111-1307, USA. |
9907 | 20 |
21 Tim Fleehart (apollo@online.com) 1-17-92 | |
22 Geoff Voelker (voelker@cs.washington.edu) 9-12-93 | |
23 */ | |
24 | |
25 | |
12183
47685fb0fbd1
Include config.h before stdio.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
11942
diff
changeset
|
26 #include <config.h> |
47685fb0fbd1
Include config.h before stdio.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
11942
diff
changeset
|
27 |
9907 | 28 #include <stdlib.h> |
29 #include <stdio.h> | |
30 #include <windows.h> | |
31 | |
32 #include "lisp.h" | |
33 #include "frame.h" | |
34 #include "disptab.h" | |
35 #include "termhooks.h" | |
36 | |
37 #include "ntinevt.h" | |
38 | |
11389 | 39 /* from window.c */ |
9907 | 40 extern Lisp_Object Frecenter (); |
41 | |
42 /* from keyboard.c */ | |
43 extern int detect_input_pending (); | |
44 | |
45 /* from sysdep.c */ | |
46 extern int read_input_pending (); | |
47 | |
48 extern FRAME_PTR updating_frame; | |
49 extern int meta_key; | |
50 | |
51 static void move_cursor (int row, int col); | |
52 static void clear_to_end (void); | |
53 static void clear_frame (void); | |
54 static void clear_end_of_line (int); | |
55 static void ins_del_lines (int vpos, int n); | |
56 static void change_line_highlight (int, int, int); | |
57 static void reassert_line_highlight (int, int); | |
58 static void insert_glyphs (GLYPH *start, int len); | |
59 static void write_glyphs (GLYPH *string, int len); | |
60 static void delete_glyphs (int n); | |
13424
efbbbfd268dd
(nt_ring_bell): Renamed from ring_bell, now global.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12336
diff
changeset
|
61 void nt_ring_bell (void); |
9907 | 62 static void reset_terminal_modes (void); |
63 static void set_terminal_modes (void); | |
64 static void set_terminal_window (int size); | |
65 static void update_begin (FRAME_PTR f); | |
66 static void update_end (FRAME_PTR f); | |
67 static void reset_kbd (void); | |
68 static void unset_kbd (void); | |
69 static int hl_mode (int new_highlight); | |
70 | |
71 void | |
72 DebPrint () | |
73 { | |
74 } | |
75 | |
76 /* Init hook called in init_keyboard. */ | |
77 void (*keyboard_init_hook)(void) = reset_kbd; | |
78 | |
79 COORD cursor_coords; | |
80 HANDLE prev_screen, cur_screen; | |
81 UCHAR char_attr, char_attr_normal, char_attr_reverse; | |
82 HANDLE keyboard_handle; | |
15203
5bda3e000c2c
(prev_console_mode): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14244
diff
changeset
|
83 DWORD prev_console_mode; |
9907 | 84 |
85 | |
86 /* Setting this as the ctrl handler prevents emacs from being killed when | |
12336
617f39b43557
(ctrl_c_handler): Ignore CTRL_BREAK_EVENT signals.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
87 someone hits ^C in a 'suspended' session (child shell). |
617f39b43557
(ctrl_c_handler): Ignore CTRL_BREAK_EVENT signals.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
88 Also ignore Ctrl-Break signals. */ |
617f39b43557
(ctrl_c_handler): Ignore CTRL_BREAK_EVENT signals.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
89 |
9907 | 90 BOOL |
91 ctrl_c_handler (unsigned long type) | |
92 { | |
12336
617f39b43557
(ctrl_c_handler): Ignore CTRL_BREAK_EVENT signals.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
93 return (type == CTRL_C_EVENT || type == CTRL_BREAK_EVENT); |
9907 | 94 } |
95 | |
96 /* If we're updating a frame, use it as the current frame | |
97 Otherwise, use the selected frame. */ | |
98 #define PICK_FRAME() (updating_frame ? updating_frame : selected_frame) | |
99 | |
100 /* Move the cursor to (row, col). */ | |
101 void | |
102 move_cursor (int row, int col) | |
103 { | |
104 cursor_coords.X = col; | |
105 cursor_coords.Y = row; | |
106 | |
11389 | 107 if (updating_frame == (FRAME_PTR) NULL) |
9907 | 108 { |
109 SetConsoleCursorPosition (cur_screen, cursor_coords); | |
110 } | |
111 } | |
112 | |
113 /* Clear from cursor to end of screen. */ | |
114 void | |
115 clear_to_end (void) | |
116 { | |
117 FRAME_PTR f = PICK_FRAME (); | |
118 | |
119 clear_end_of_line (FRAME_WIDTH (f) - 1); | |
120 ins_del_lines (cursor_coords.Y, FRAME_HEIGHT (f) - cursor_coords.Y - 1); | |
121 } | |
122 | |
123 /* Clear the frame. */ | |
124 void | |
125 clear_frame (void) | |
126 { | |
14244
493cff4d5960
(clear_frame): Use FillConsoleOutput* calls instead of
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
127 FRAME_PTR f = PICK_FRAME (); |
9907 | 128 COORD dest; |
14244
493cff4d5960
(clear_frame): Use FillConsoleOutput* calls instead of
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
129 int n, r; |
493cff4d5960
(clear_frame): Use FillConsoleOutput* calls instead of
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
130 |
9907 | 131 hl_mode (0); |
132 | |
14244
493cff4d5960
(clear_frame): Use FillConsoleOutput* calls instead of
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
133 n = FRAME_HEIGHT (f) * FRAME_WIDTH (f); |
493cff4d5960
(clear_frame): Use FillConsoleOutput* calls instead of
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
134 dest.X = dest.Y = 0; |
493cff4d5960
(clear_frame): Use FillConsoleOutput* calls instead of
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
135 |
493cff4d5960
(clear_frame): Use FillConsoleOutput* calls instead of
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
136 FillConsoleOutputAttribute (cur_screen, char_attr, n, dest, &r); |
493cff4d5960
(clear_frame): Use FillConsoleOutput* calls instead of
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
137 FillConsoleOutputCharacter (cur_screen, ' ', n, dest, &r); |
493cff4d5960
(clear_frame): Use FillConsoleOutput* calls instead of
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
138 |
9907 | 139 move_cursor (0, 0); |
140 } | |
141 | |
142 | |
143 static GLYPH glyph_base[256]; | |
144 static BOOL ceol_initialized = FALSE; | |
145 | |
146 /* Clear from Cursor to end (what's "standout marker"?). */ | |
147 void | |
148 clear_end_of_line (int end) | |
149 { | |
150 if (!ceol_initialized) | |
151 { | |
152 int i; | |
153 for (i = 0; i < 256; i++) | |
154 { | |
155 glyph_base[i] = SPACEGLYPH; /* empty space */ | |
156 } | |
157 ceol_initialized = TRUE; | |
158 } | |
159 write_glyphs (glyph_base, end - cursor_coords.X); /* fencepost ? */ | |
160 } | |
161 | |
162 /* Insert n lines at vpos. if n is negative delete -n lines. */ | |
163 void | |
164 ins_del_lines (int vpos, int n) | |
165 { | |
166 int i, nb, save_highlight; | |
167 SMALL_RECT scroll; | |
168 COORD dest; | |
169 CHAR_INFO fill; | |
170 FRAME_PTR f = PICK_FRAME (); | |
171 | |
172 if (n < 0) | |
173 { | |
174 scroll.Top = vpos - n; | |
175 scroll.Bottom = FRAME_HEIGHT (f); | |
176 dest.Y = vpos; | |
177 } | |
178 else | |
179 { | |
180 scroll.Top = vpos; | |
181 scroll.Bottom = FRAME_HEIGHT (f) - n; | |
182 dest.Y = vpos + n; | |
183 } | |
184 scroll.Left = 0; | |
185 scroll.Right = FRAME_WIDTH (f); | |
186 | |
187 dest.X = 0; | |
188 | |
189 save_highlight = hl_mode (0); | |
190 | |
191 fill.Char.AsciiChar = 0x20; | |
192 fill.Attributes = char_attr; | |
193 | |
194 ScrollConsoleScreenBuffer (cur_screen, &scroll, NULL, dest, &fill); | |
195 | |
196 /* Here we have to deal with a win32 console flake: If the scroll | |
197 region looks like abc and we scroll c to a and fill with d we get | |
198 cbd... if we scroll block c one line at a time to a, we get cdd... | |
199 Emacs expects cdd consistently... So we have to deal with that | |
200 here... (this also occurs scrolling the same way in the other | |
201 direction. */ | |
202 | |
203 if (n > 0) | |
204 { | |
205 if (scroll.Bottom < dest.Y) | |
206 { | |
207 for (i = scroll.Bottom; i < dest.Y; i++) | |
208 { | |
209 move_cursor (i, 0); | |
210 clear_end_of_line (FRAME_WIDTH (f)); | |
211 } | |
212 } | |
213 } | |
214 else | |
215 { | |
216 nb = dest.Y + (scroll.Bottom - scroll.Top) + 1; | |
217 | |
218 if (nb < scroll.Top) | |
219 { | |
220 for (i = nb; i < scroll.Top; i++) | |
221 { | |
222 move_cursor (i, 0); | |
223 clear_end_of_line (FRAME_WIDTH (f)); | |
224 } | |
225 } | |
226 } | |
227 | |
228 cursor_coords.X = 0; | |
229 cursor_coords.Y = vpos; | |
230 | |
231 hl_mode (save_highlight); | |
232 } | |
233 | |
234 /* Changes attribute to use when drawing characters to control. */ | |
235 static int | |
236 hl_mode (int new_highlight) | |
237 { | |
238 static int highlight = 0; | |
239 int old_highlight; | |
240 | |
241 old_highlight = highlight; | |
242 highlight = (new_highlight != 0); | |
243 if (highlight) | |
244 { | |
245 char_attr = char_attr_reverse; | |
246 } | |
247 else | |
248 { | |
249 char_attr = char_attr_normal; | |
250 } | |
251 return old_highlight; | |
252 } | |
253 | |
254 /* Call this when about to modify line at position VPOS and change whether it | |
255 is highlighted. */ | |
256 void | |
257 change_line_highlight (int new_highlight, int vpos, int first_unused_hpos) | |
258 { | |
259 hl_mode (new_highlight); | |
260 move_cursor (vpos, 0); | |
261 clear_end_of_line (first_unused_hpos); | |
262 } | |
263 | |
264 /* External interface to control of standout mode. Call this when about to | |
265 * modify line at position VPOS and not change whether it is highlighted. */ | |
266 void | |
267 reassert_line_highlight (int highlight, int vpos) | |
268 { | |
269 hl_mode (highlight); | |
270 vpos; /* pedantic compiler silencer */ | |
271 } | |
272 | |
273 #undef LEFT | |
274 #undef RIGHT | |
275 #define LEFT 1 | |
276 #define RIGHT 0 | |
277 | |
278 void | |
279 scroll_line (int dist, int direction) | |
280 { | |
281 /* The idea here is to implement a horizontal scroll in one line to | |
282 implement delete and half of insert. */ | |
283 SMALL_RECT scroll; | |
284 COORD dest; | |
285 CHAR_INFO fill; | |
286 FRAME_PTR f = PICK_FRAME (); | |
287 | |
288 scroll.Top = cursor_coords.Y; | |
289 scroll.Bottom = cursor_coords.Y; | |
290 | |
291 if (direction == LEFT) | |
292 { | |
293 scroll.Left = cursor_coords.X + dist; | |
294 scroll.Right = FRAME_WIDTH (f) - 1; | |
295 } | |
296 else | |
297 { | |
298 scroll.Left = cursor_coords.X; | |
299 scroll.Right = FRAME_WIDTH (f) - dist - 1; | |
300 } | |
301 | |
302 dest.X = cursor_coords.X; | |
303 dest.Y = cursor_coords.Y; | |
304 | |
305 fill.Char.AsciiChar = 0x20; | |
306 fill.Attributes = char_attr; | |
307 | |
308 ScrollConsoleScreenBuffer (cur_screen, &scroll, NULL, dest, &fill); | |
309 } | |
310 | |
311 | |
312 /* If start is zero insert blanks instead of a string at start ?. */ | |
313 void | |
314 insert_glyphs (register GLYPH *start, register int len) | |
315 { | |
316 scroll_line (len, RIGHT); | |
317 | |
318 /* Move len chars to the right starting at cursor_coords, fill with blanks */ | |
319 if (start) | |
320 { | |
321 /* Print the first len characters of start, cursor_coords.X adjusted | |
322 by write_glyphs. */ | |
323 | |
324 write_glyphs (start, len); | |
325 } | |
326 else | |
327 { | |
328 clear_end_of_line (cursor_coords.X + len); | |
329 } | |
330 } | |
331 | |
332 void | |
333 write_glyphs (register GLYPH *string, register int len) | |
334 { | |
335 register unsigned int glyph_len = GLYPH_TABLE_LENGTH; | |
336 Lisp_Object *glyph_table = GLYPH_TABLE_BASE; | |
337 FRAME_PTR f = PICK_FRAME (); | |
338 register char *ptr; | |
339 GLYPH glyph; | |
340 WORD *attrs; | |
341 char *chars; | |
342 int i; | |
343 | |
14244
493cff4d5960
(clear_frame): Use FillConsoleOutput* calls instead of
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
344 if (len <= 0) |
493cff4d5960
(clear_frame): Use FillConsoleOutput* calls instead of
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
345 return; |
493cff4d5960
(clear_frame): Use FillConsoleOutput* calls instead of
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
346 |
9907 | 347 attrs = alloca (len * sizeof (*attrs)); |
348 chars = alloca (len * sizeof (*chars)); | |
349 if (attrs == NULL || chars == NULL) | |
350 { | |
351 printf ("alloca failed in write_glyphs\n"); | |
352 return; | |
353 } | |
354 | |
355 /* We have to deal with the glyph indirection...go over the glyph | |
356 buffer and extract the characters. */ | |
357 ptr = chars; | |
358 while (--len >= 0) | |
359 { | |
360 glyph = *string++; | |
361 | |
362 if (glyph > glyph_len) | |
363 { | |
364 *ptr++ = glyph & 0xFF; | |
365 continue; | |
366 } | |
367 GLYPH_FOLLOW_ALIASES (glyph_table, glyph_len, glyph); | |
13424
efbbbfd268dd
(nt_ring_bell): Renamed from ring_bell, now global.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12336
diff
changeset
|
368 #ifndef HAVE_NTGUI |
9907 | 369 if (GLYPH_FACE (fixfix, glyph) != 0) |
370 printf ("Glyph face is %d\n", GLYPH_FACE (fixfix, glyph)); | |
13424
efbbbfd268dd
(nt_ring_bell): Renamed from ring_bell, now global.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12336
diff
changeset
|
371 #endif /* !HAVE_NTGUI */ |
9907 | 372 if (GLYPH_SIMPLE_P (glyph_table, glyph_len, glyph)) |
373 { | |
374 *ptr++ = glyph & 0xFF; | |
375 continue; | |
376 } | |
377 for (i = 0; i < GLYPH_LENGTH (glyph_table, glyph); i++) | |
378 { | |
379 *ptr++ = (GLYPH_STRING (glyph_table, glyph))[i]; | |
380 } | |
381 } | |
382 | |
383 /* Number of characters we have in the buffer. */ | |
384 len = ptr-chars; | |
385 | |
386 /* Fill in the attributes for these characters. */ | |
11942
04cc0b15ef74
(set_terminal_modes): Set cursor size appropriate for Win95.
Geoff Voelker <voelker@cs.washington.edu>
parents:
11389
diff
changeset
|
387 for (i = 0; i < len; i++) |
04cc0b15ef74
(set_terminal_modes): Set cursor size appropriate for Win95.
Geoff Voelker <voelker@cs.washington.edu>
parents:
11389
diff
changeset
|
388 attrs[i] = char_attr; |
9907 | 389 |
390 /* Write the attributes. */ | |
391 if (!WriteConsoleOutputAttribute (cur_screen, attrs, len, cursor_coords, &i)) | |
392 { | |
11389 | 393 printf ("Failed writing console attributes: %d\n", GetLastError ()); |
9907 | 394 fflush (stdout); |
395 } | |
396 | |
397 /* Write the characters. */ | |
398 if (!WriteConsoleOutputCharacter (cur_screen, chars, len, cursor_coords, &i)) | |
399 { | |
11389 | 400 printf ("Failed writing console characters: %d\n", GetLastError ()); |
9907 | 401 fflush (stdout); |
402 } | |
403 | |
404 cursor_coords.X += len; | |
405 move_cursor (cursor_coords.Y, cursor_coords.X); | |
406 } | |
407 | |
408 void | |
409 delete_glyphs (int n) | |
410 { | |
411 /* delete chars means scroll chars from cursor_coords.X + n to | |
412 cursor_coords.X, anything beyond the edge of the screen should | |
413 come out empty... */ | |
414 | |
415 scroll_line (n, LEFT); | |
416 } | |
417 | |
11389 | 418 static unsigned int sound_type = 0xFFFFFFFF; |
419 | |
9907 | 420 void |
13424
efbbbfd268dd
(nt_ring_bell): Renamed from ring_bell, now global.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12336
diff
changeset
|
421 nt_ring_bell (void) |
9907 | 422 { |
11389 | 423 if (sound_type == 0xFFFFFFFF) |
424 Beep (666, 100); | |
425 else | |
426 MessageBeep (sound_type); | |
9907 | 427 } |
428 | |
11389 | 429 DEFUN ("set-message-beep", Fset_message_beep, Sset_message_beep, 1, 1, 0, |
430 "Set the sound generated when the bell is rung.\n\ | |
431 SOUND is 'asterisk, 'exclamation, 'hand, 'question, or 'ok\n\ | |
432 to use the corresponding system sound for the bell.\n\ | |
433 SOUND is nil to use the normal beep.") | |
434 (sound) | |
435 Lisp_Object sound; | |
9907 | 436 { |
11389 | 437 CHECK_SYMBOL (sound, 0); |
438 | |
439 if (NILP (sound)) | |
440 sound_type = 0xFFFFFFFF; | |
441 else if (EQ (sound, intern ("asterisk"))) | |
442 sound_type = MB_ICONASTERISK; | |
443 else if (EQ (sound, intern ("exclamation"))) | |
444 sound_type = MB_ICONEXCLAMATION; | |
445 else if (EQ (sound, intern ("hand"))) | |
446 sound_type = MB_ICONHAND; | |
447 else if (EQ (sound, intern ("question"))) | |
448 sound_type = MB_ICONQUESTION; | |
449 else if (EQ (sound, intern ("ok"))) | |
450 sound_type = MB_OK; | |
451 else | |
452 sound_type = 0xFFFFFFFF; | |
453 | |
454 return sound; | |
9907 | 455 } |
456 | |
457 /* Put our console back up, for ending a suspended session. */ | |
458 void | |
459 take_console (void) | |
460 { | |
461 reset_kbd (); | |
462 SetConsoleActiveScreenBuffer (cur_screen); | |
463 } | |
464 | |
465 void | |
466 reset_terminal_modes (void) | |
467 { | |
468 unset_kbd (); | |
469 SetConsoleActiveScreenBuffer (prev_screen); | |
470 } | |
471 | |
472 void | |
473 set_terminal_modes (void) | |
474 { | |
475 CONSOLE_CURSOR_INFO cci; | |
476 | |
477 if (cur_screen == NULL) | |
478 { | |
479 reset_kbd (); | |
480 cur_screen = CreateConsoleScreenBuffer (GENERIC_READ | GENERIC_WRITE, | |
481 0, NULL, | |
482 CONSOLE_TEXTMODE_BUFFER, | |
483 NULL); | |
484 | |
485 if (cur_screen == INVALID_HANDLE_VALUE) | |
486 { | |
487 printf ("CreateConsoleScreenBuffer failed in ResetTerm\n"); | |
488 printf ("LastError = 0x%lx\n", GetLastError ()); | |
489 fflush (stdout); | |
490 exit (0); | |
491 } | |
492 | |
493 SetConsoleActiveScreenBuffer (cur_screen); | |
494 | |
11942
04cc0b15ef74
(set_terminal_modes): Set cursor size appropriate for Win95.
Geoff Voelker <voelker@cs.washington.edu>
parents:
11389
diff
changeset
|
495 /* make cursor big and visible (100 on Win95 makes it disappear) */ |
04cc0b15ef74
(set_terminal_modes): Set cursor size appropriate for Win95.
Geoff Voelker <voelker@cs.washington.edu>
parents:
11389
diff
changeset
|
496 cci.dwSize = 99; |
9907 | 497 cci.bVisible = TRUE; |
498 (void) SetConsoleCursorInfo (cur_screen, &cci); | |
499 } | |
500 } | |
501 | |
502 /* hmmm... perhaps these let us bracket screen changes so that we can flush | |
503 clumps rather than one-character-at-a-time... | |
504 | |
505 we'll start with not moving the cursor while an update is in progress. */ | |
506 void | |
507 update_begin (FRAME_PTR f) | |
508 { | |
509 } | |
510 | |
511 void | |
512 update_end (FRAME_PTR f) | |
513 { | |
514 SetConsoleCursorPosition (cur_screen, cursor_coords); | |
515 } | |
516 | |
517 void | |
518 set_terminal_window (int size) | |
519 { | |
520 } | |
521 | |
522 void | |
523 unset_kbd (void) | |
524 { | |
15203
5bda3e000c2c
(prev_console_mode): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14244
diff
changeset
|
525 SetConsoleMode (keyboard_handle, prev_console_mode); |
9907 | 526 } |
527 | |
528 void | |
529 reset_kbd (void) | |
530 { | |
531 keyboard_handle = GetStdHandle (STD_INPUT_HANDLE); | |
15203
5bda3e000c2c
(prev_console_mode): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14244
diff
changeset
|
532 GetConsoleMode (keyboard_handle, &prev_console_mode); |
9907 | 533 SetConsoleMode (keyboard_handle, ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT); |
15203
5bda3e000c2c
(prev_console_mode): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14244
diff
changeset
|
534 |
5bda3e000c2c
(prev_console_mode): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14244
diff
changeset
|
535 /* Try to use interrupt input; if we can't, then start polling. */ |
5bda3e000c2c
(prev_console_mode): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14244
diff
changeset
|
536 Fset_input_mode (Qt, Qnil, Qt, Qnil); |
9907 | 537 } |
538 | |
539 typedef int (*term_hook) (); | |
540 | |
541 void | |
542 initialize_win_nt_display (void) | |
543 { | |
544 CONSOLE_SCREEN_BUFFER_INFO info; | |
545 | |
546 cursor_to_hook = (term_hook) move_cursor; | |
547 raw_cursor_to_hook = (term_hook) move_cursor; | |
548 clear_to_end_hook = (term_hook) clear_to_end; | |
549 clear_frame_hook = (term_hook) clear_frame; | |
550 clear_end_of_line_hook = (term_hook) clear_end_of_line; | |
551 ins_del_lines_hook = (term_hook) ins_del_lines; | |
552 change_line_highlight_hook = (term_hook) change_line_highlight; | |
553 reassert_line_highlight_hook = (term_hook) reassert_line_highlight; | |
554 insert_glyphs_hook = (term_hook) insert_glyphs; | |
555 write_glyphs_hook = (term_hook) write_glyphs; | |
556 delete_glyphs_hook = (term_hook) delete_glyphs; | |
13424
efbbbfd268dd
(nt_ring_bell): Renamed from ring_bell, now global.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12336
diff
changeset
|
557 ring_bell_hook = (term_hook) nt_ring_bell; |
9907 | 558 reset_terminal_modes_hook = (term_hook) reset_terminal_modes; |
559 set_terminal_modes_hook = (term_hook) set_terminal_modes; | |
560 set_terminal_window_hook = (term_hook) set_terminal_window; | |
561 update_begin_hook = (term_hook) update_begin; | |
562 update_end_hook = (term_hook) update_end; | |
563 | |
564 read_socket_hook = win32_read_socket; | |
565 mouse_position_hook = win32_mouse_position; | |
566 | |
567 prev_screen = GetStdHandle (STD_OUTPUT_HANDLE); | |
568 | |
569 set_terminal_modes (); | |
570 | |
571 GetConsoleScreenBufferInfo (cur_screen, &info); | |
572 | |
573 meta_key = 1; | |
574 char_attr = info.wAttributes & 0xFF; | |
575 char_attr_normal = char_attr; | |
576 char_attr_reverse = ((char_attr & 0xf) << 4) + ((char_attr & 0xf0) >> 4); | |
577 | |
578 FRAME_HEIGHT (selected_frame) = info.dwSize.Y; /* lines per page */ | |
579 FRAME_WIDTH (selected_frame) = info.dwSize.X; /* characters per line */ | |
580 | |
581 move_cursor (0, 0); | |
582 | |
583 clear_frame (); | |
584 } | |
585 | |
586 DEFUN ("set-screen-color", Fset_screen_color, Sset_screen_color, 2, 2, 0, | |
587 "Set screen colors.") | |
588 (foreground, background) | |
589 Lisp_Object foreground; | |
590 Lisp_Object background; | |
591 { | |
592 char_attr_normal = XFASTINT (foreground) + (XFASTINT (background) << 4); | |
593 char_attr_reverse = XFASTINT (background) + (XFASTINT (foreground) << 4); | |
594 | |
595 Frecenter (Qnil); | |
596 return Qt; | |
597 } | |
598 | |
599 DEFUN ("set-cursor-size", Fset_cursor_size, Sset_cursor_size, 1, 1, 0, | |
600 "Set cursor size.") | |
601 (size) | |
602 Lisp_Object size; | |
603 { | |
604 CONSOLE_CURSOR_INFO cci; | |
605 cci.dwSize = XFASTINT (size); | |
606 cci.bVisible = TRUE; | |
607 (void) SetConsoleCursorInfo (cur_screen, &cci); | |
608 | |
609 return Qt; | |
610 } | |
611 | |
13424
efbbbfd268dd
(nt_ring_bell): Renamed from ring_bell, now global.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12336
diff
changeset
|
612 #ifndef HAVE_NTGUI |
9907 | 613 void |
614 pixel_to_glyph_coords (FRAME_PTR f, int pix_x, int pix_y, int *x, int *y, | |
615 void *bounds, int noclip) | |
616 { | |
617 *x = pix_x; | |
618 *y = pix_y; | |
619 } | |
620 | |
621 void | |
622 glyph_to_pixel_coords (FRAME_PTR f, int x, int y, int *pix_x, int *pix_y) | |
623 { | |
624 *pix_x = x; | |
625 *pix_y = y; | |
626 } | |
13424
efbbbfd268dd
(nt_ring_bell): Renamed from ring_bell, now global.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12336
diff
changeset
|
627 #endif /* !HAVE_NTGUI */ |
9907 | 628 |
11389 | 629 void |
9907 | 630 syms_of_ntterm () |
631 { | |
632 defsubr (&Sset_screen_color); | |
633 defsubr (&Sset_cursor_size); | |
11389 | 634 defsubr (&Sset_message_beep); |
9907 | 635 } |