Mercurial > emacs
annotate src/w32console.c @ 24513:2db3b19a94bb
(Info-directory-list): Revert change to re-writing
Info-default-directory-list, but put `alternative' first.
(Info-insert-dir): Modify selecting the top dir file as a
consequence.
author | Dave Love <fx@gnu.org> |
---|---|
date | Wed, 24 Mar 1999 14:25:58 +0000 |
parents | 1fa5f9f5c92e |
children | 3bb855a40bf6 |
rev | line source |
---|---|
16883
d1d4d81f9ece
Change all uses of win95, winnt, and win32
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
1 /* Terminal hooks for GNU Emacs on the Microsoft W32 API. |
9907 | 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" | |
18507
be4c110cda51
Include charset.h.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16883
diff
changeset
|
33 #include "charset.h" |
9907 | 34 #include "frame.h" |
35 #include "disptab.h" | |
36 #include "termhooks.h" | |
16593
4ed80eda6fac
Use new names for w32 files
Geoff Voelker <voelker@cs.washington.edu>
parents:
16588
diff
changeset
|
37 #include "w32inevt.h" |
9907 | 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); | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16262
diff
changeset
|
61 void w32_sys_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 int hl_mode (int new_highlight); | |
68 | |
69 COORD cursor_coords; | |
70 HANDLE prev_screen, cur_screen; | |
71 UCHAR char_attr, char_attr_normal, char_attr_reverse; | |
72 HANDLE keyboard_handle; | |
15203
5bda3e000c2c
(prev_console_mode): New variable.
Richard M. Stallman <rms@gnu.org>
parents:
14244
diff
changeset
|
73 DWORD prev_console_mode; |
9907 | 74 |
19706
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
75 #ifndef USE_SEPARATE_SCREEN |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
76 CONSOLE_CURSOR_INFO prev_console_cursor; |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
77 #endif |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
78 |
9907 | 79 |
80 /* 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
|
81 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
|
82 Also ignore Ctrl-Break signals. */ |
617f39b43557
(ctrl_c_handler): Ignore CTRL_BREAK_EVENT signals.
Richard M. Stallman <rms@gnu.org>
parents:
12183
diff
changeset
|
83 |
9907 | 84 BOOL |
85 ctrl_c_handler (unsigned long type) | |
86 { | |
19706
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
87 /* Only ignore "interrupt" events when running interactively. */ |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
88 return (!noninteractive |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
89 && (type == CTRL_C_EVENT || type == CTRL_BREAK_EVENT)); |
9907 | 90 } |
91 | |
92 /* If we're updating a frame, use it as the current frame | |
93 Otherwise, use the selected frame. */ | |
94 #define PICK_FRAME() (updating_frame ? updating_frame : selected_frame) | |
95 | |
96 /* Move the cursor to (row, col). */ | |
97 void | |
98 move_cursor (int row, int col) | |
99 { | |
100 cursor_coords.X = col; | |
101 cursor_coords.Y = row; | |
102 | |
11389 | 103 if (updating_frame == (FRAME_PTR) NULL) |
9907 | 104 { |
105 SetConsoleCursorPosition (cur_screen, cursor_coords); | |
106 } | |
107 } | |
108 | |
109 /* Clear from cursor to end of screen. */ | |
110 void | |
111 clear_to_end (void) | |
112 { | |
113 FRAME_PTR f = PICK_FRAME (); | |
114 | |
115 clear_end_of_line (FRAME_WIDTH (f) - 1); | |
116 ins_del_lines (cursor_coords.Y, FRAME_HEIGHT (f) - cursor_coords.Y - 1); | |
117 } | |
118 | |
119 /* Clear the frame. */ | |
120 void | |
121 clear_frame (void) | |
122 { | |
14244
493cff4d5960
(clear_frame): Use FillConsoleOutput* calls instead of
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
123 FRAME_PTR f = PICK_FRAME (); |
9907 | 124 COORD dest; |
14244
493cff4d5960
(clear_frame): Use FillConsoleOutput* calls instead of
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
125 int n, r; |
493cff4d5960
(clear_frame): Use FillConsoleOutput* calls instead of
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
126 |
9907 | 127 hl_mode (0); |
128 | |
14244
493cff4d5960
(clear_frame): Use FillConsoleOutput* calls instead of
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
129 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
|
130 dest.X = dest.Y = 0; |
493cff4d5960
(clear_frame): Use FillConsoleOutput* calls instead of
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
131 |
493cff4d5960
(clear_frame): Use FillConsoleOutput* calls instead of
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
132 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
|
133 FillConsoleOutputCharacter (cur_screen, ' ', n, dest, &r); |
493cff4d5960
(clear_frame): Use FillConsoleOutput* calls instead of
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
134 |
9907 | 135 move_cursor (0, 0); |
136 } | |
137 | |
138 | |
139 static GLYPH glyph_base[256]; | |
140 static BOOL ceol_initialized = FALSE; | |
141 | |
142 /* Clear from Cursor to end (what's "standout marker"?). */ | |
143 void | |
144 clear_end_of_line (int end) | |
145 { | |
146 if (!ceol_initialized) | |
147 { | |
148 int i; | |
149 for (i = 0; i < 256; i++) | |
150 { | |
151 glyph_base[i] = SPACEGLYPH; /* empty space */ | |
152 } | |
153 ceol_initialized = TRUE; | |
154 } | |
155 write_glyphs (glyph_base, end - cursor_coords.X); /* fencepost ? */ | |
156 } | |
157 | |
158 /* Insert n lines at vpos. if n is negative delete -n lines. */ | |
159 void | |
160 ins_del_lines (int vpos, int n) | |
161 { | |
162 int i, nb, save_highlight; | |
163 SMALL_RECT scroll; | |
164 COORD dest; | |
165 CHAR_INFO fill; | |
166 FRAME_PTR f = PICK_FRAME (); | |
167 | |
168 if (n < 0) | |
169 { | |
170 scroll.Top = vpos - n; | |
171 scroll.Bottom = FRAME_HEIGHT (f); | |
172 dest.Y = vpos; | |
173 } | |
174 else | |
175 { | |
176 scroll.Top = vpos; | |
177 scroll.Bottom = FRAME_HEIGHT (f) - n; | |
178 dest.Y = vpos + n; | |
179 } | |
180 scroll.Left = 0; | |
181 scroll.Right = FRAME_WIDTH (f); | |
182 | |
183 dest.X = 0; | |
184 | |
185 save_highlight = hl_mode (0); | |
186 | |
187 fill.Char.AsciiChar = 0x20; | |
188 fill.Attributes = char_attr; | |
189 | |
190 ScrollConsoleScreenBuffer (cur_screen, &scroll, NULL, dest, &fill); | |
191 | |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16262
diff
changeset
|
192 /* Here we have to deal with a w32 console flake: If the scroll |
9907 | 193 region looks like abc and we scroll c to a and fill with d we get |
194 cbd... if we scroll block c one line at a time to a, we get cdd... | |
195 Emacs expects cdd consistently... So we have to deal with that | |
196 here... (this also occurs scrolling the same way in the other | |
197 direction. */ | |
198 | |
199 if (n > 0) | |
200 { | |
201 if (scroll.Bottom < dest.Y) | |
202 { | |
203 for (i = scroll.Bottom; i < dest.Y; i++) | |
204 { | |
205 move_cursor (i, 0); | |
206 clear_end_of_line (FRAME_WIDTH (f)); | |
207 } | |
208 } | |
209 } | |
210 else | |
211 { | |
212 nb = dest.Y + (scroll.Bottom - scroll.Top) + 1; | |
213 | |
214 if (nb < scroll.Top) | |
215 { | |
216 for (i = nb; i < scroll.Top; i++) | |
217 { | |
218 move_cursor (i, 0); | |
219 clear_end_of_line (FRAME_WIDTH (f)); | |
220 } | |
221 } | |
222 } | |
223 | |
224 cursor_coords.X = 0; | |
225 cursor_coords.Y = vpos; | |
226 | |
227 hl_mode (save_highlight); | |
228 } | |
229 | |
230 /* Changes attribute to use when drawing characters to control. */ | |
231 static int | |
232 hl_mode (int new_highlight) | |
233 { | |
234 static int highlight = 0; | |
235 int old_highlight; | |
236 | |
237 old_highlight = highlight; | |
238 highlight = (new_highlight != 0); | |
239 if (highlight) | |
240 { | |
241 char_attr = char_attr_reverse; | |
242 } | |
243 else | |
244 { | |
245 char_attr = char_attr_normal; | |
246 } | |
247 return old_highlight; | |
248 } | |
249 | |
250 /* Call this when about to modify line at position VPOS and change whether it | |
251 is highlighted. */ | |
252 void | |
253 change_line_highlight (int new_highlight, int vpos, int first_unused_hpos) | |
254 { | |
255 hl_mode (new_highlight); | |
256 move_cursor (vpos, 0); | |
257 clear_end_of_line (first_unused_hpos); | |
258 } | |
259 | |
260 /* External interface to control of standout mode. Call this when about to | |
261 * modify line at position VPOS and not change whether it is highlighted. */ | |
262 void | |
263 reassert_line_highlight (int highlight, int vpos) | |
264 { | |
265 hl_mode (highlight); | |
266 vpos; /* pedantic compiler silencer */ | |
267 } | |
268 | |
269 #undef LEFT | |
270 #undef RIGHT | |
271 #define LEFT 1 | |
272 #define RIGHT 0 | |
273 | |
274 void | |
275 scroll_line (int dist, int direction) | |
276 { | |
277 /* The idea here is to implement a horizontal scroll in one line to | |
278 implement delete and half of insert. */ | |
279 SMALL_RECT scroll; | |
280 COORD dest; | |
281 CHAR_INFO fill; | |
282 FRAME_PTR f = PICK_FRAME (); | |
283 | |
284 scroll.Top = cursor_coords.Y; | |
285 scroll.Bottom = cursor_coords.Y; | |
286 | |
287 if (direction == LEFT) | |
288 { | |
289 scroll.Left = cursor_coords.X + dist; | |
290 scroll.Right = FRAME_WIDTH (f) - 1; | |
291 } | |
292 else | |
293 { | |
294 scroll.Left = cursor_coords.X; | |
295 scroll.Right = FRAME_WIDTH (f) - dist - 1; | |
296 } | |
297 | |
298 dest.X = cursor_coords.X; | |
299 dest.Y = cursor_coords.Y; | |
300 | |
301 fill.Char.AsciiChar = 0x20; | |
302 fill.Attributes = char_attr; | |
303 | |
304 ScrollConsoleScreenBuffer (cur_screen, &scroll, NULL, dest, &fill); | |
305 } | |
306 | |
307 | |
308 /* If start is zero insert blanks instead of a string at start ?. */ | |
309 void | |
310 insert_glyphs (register GLYPH *start, register int len) | |
311 { | |
312 scroll_line (len, RIGHT); | |
313 | |
314 /* Move len chars to the right starting at cursor_coords, fill with blanks */ | |
315 if (start) | |
316 { | |
317 /* Print the first len characters of start, cursor_coords.X adjusted | |
318 by write_glyphs. */ | |
319 | |
320 write_glyphs (start, len); | |
321 } | |
322 else | |
323 { | |
324 clear_end_of_line (cursor_coords.X + len); | |
325 } | |
326 } | |
327 | |
328 void | |
329 write_glyphs (register GLYPH *string, register int len) | |
330 { | |
331 register unsigned int glyph_len = GLYPH_TABLE_LENGTH; | |
332 Lisp_Object *glyph_table = GLYPH_TABLE_BASE; | |
333 FRAME_PTR f = PICK_FRAME (); | |
334 register char *ptr; | |
335 GLYPH glyph; | |
336 WORD *attrs; | |
337 char *chars; | |
338 int i; | |
339 | |
14244
493cff4d5960
(clear_frame): Use FillConsoleOutput* calls instead of
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
340 if (len <= 0) |
493cff4d5960
(clear_frame): Use FillConsoleOutput* calls instead of
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
341 return; |
493cff4d5960
(clear_frame): Use FillConsoleOutput* calls instead of
Geoff Voelker <voelker@cs.washington.edu>
parents:
14186
diff
changeset
|
342 |
9907 | 343 attrs = alloca (len * sizeof (*attrs)); |
344 chars = alloca (len * sizeof (*chars)); | |
345 if (attrs == NULL || chars == NULL) | |
346 { | |
347 printf ("alloca failed in write_glyphs\n"); | |
348 return; | |
349 } | |
350 | |
351 /* We have to deal with the glyph indirection...go over the glyph | |
352 buffer and extract the characters. */ | |
353 ptr = chars; | |
354 while (--len >= 0) | |
355 { | |
356 glyph = *string++; | |
357 | |
358 if (glyph > glyph_len) | |
359 { | |
360 *ptr++ = glyph & 0xFF; | |
361 continue; | |
362 } | |
363 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
|
364 #ifndef HAVE_NTGUI |
9907 | 365 if (GLYPH_FACE (fixfix, glyph) != 0) |
366 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
|
367 #endif /* !HAVE_NTGUI */ |
9907 | 368 if (GLYPH_SIMPLE_P (glyph_table, glyph_len, glyph)) |
369 { | |
370 *ptr++ = glyph & 0xFF; | |
371 continue; | |
372 } | |
373 for (i = 0; i < GLYPH_LENGTH (glyph_table, glyph); i++) | |
374 { | |
375 *ptr++ = (GLYPH_STRING (glyph_table, glyph))[i]; | |
376 } | |
377 } | |
378 | |
379 /* Number of characters we have in the buffer. */ | |
380 len = ptr-chars; | |
381 | |
382 /* 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
|
383 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
|
384 attrs[i] = char_attr; |
9907 | 385 |
386 /* Write the attributes. */ | |
387 if (!WriteConsoleOutputAttribute (cur_screen, attrs, len, cursor_coords, &i)) | |
388 { | |
11389 | 389 printf ("Failed writing console attributes: %d\n", GetLastError ()); |
9907 | 390 fflush (stdout); |
391 } | |
392 | |
393 /* Write the characters. */ | |
394 if (!WriteConsoleOutputCharacter (cur_screen, chars, len, cursor_coords, &i)) | |
395 { | |
11389 | 396 printf ("Failed writing console characters: %d\n", GetLastError ()); |
9907 | 397 fflush (stdout); |
398 } | |
399 | |
400 cursor_coords.X += len; | |
401 move_cursor (cursor_coords.Y, cursor_coords.X); | |
402 } | |
403 | |
404 void | |
405 delete_glyphs (int n) | |
406 { | |
407 /* delete chars means scroll chars from cursor_coords.X + n to | |
408 cursor_coords.X, anything beyond the edge of the screen should | |
409 come out empty... */ | |
410 | |
411 scroll_line (n, LEFT); | |
412 } | |
413 | |
11389 | 414 static unsigned int sound_type = 0xFFFFFFFF; |
23563
18c5f58b70b5
(Fset_message_beep): Recognize 'silent.
Geoff Voelker <voelker@cs.washington.edu>
parents:
22540
diff
changeset
|
415 #define MB_EMACS_SILENT (0xFFFFFFFF - 1) |
11389 | 416 |
9907 | 417 void |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16262
diff
changeset
|
418 w32_sys_ring_bell (void) |
9907 | 419 { |
11389 | 420 if (sound_type == 0xFFFFFFFF) |
23563
18c5f58b70b5
(Fset_message_beep): Recognize 'silent.
Geoff Voelker <voelker@cs.washington.edu>
parents:
22540
diff
changeset
|
421 { |
11389 | 422 Beep (666, 100); |
23563
18c5f58b70b5
(Fset_message_beep): Recognize 'silent.
Geoff Voelker <voelker@cs.washington.edu>
parents:
22540
diff
changeset
|
423 } |
18c5f58b70b5
(Fset_message_beep): Recognize 'silent.
Geoff Voelker <voelker@cs.washington.edu>
parents:
22540
diff
changeset
|
424 else if (sound_type == MB_EMACS_SILENT) |
18c5f58b70b5
(Fset_message_beep): Recognize 'silent.
Geoff Voelker <voelker@cs.washington.edu>
parents:
22540
diff
changeset
|
425 { |
18c5f58b70b5
(Fset_message_beep): Recognize 'silent.
Geoff Voelker <voelker@cs.washington.edu>
parents:
22540
diff
changeset
|
426 /* Do nothing. */ |
18c5f58b70b5
(Fset_message_beep): Recognize 'silent.
Geoff Voelker <voelker@cs.washington.edu>
parents:
22540
diff
changeset
|
427 } |
11389 | 428 else |
23563
18c5f58b70b5
(Fset_message_beep): Recognize 'silent.
Geoff Voelker <voelker@cs.washington.edu>
parents:
22540
diff
changeset
|
429 MessageBeep (sound_type); |
9907 | 430 } |
431 | |
11389 | 432 DEFUN ("set-message-beep", Fset_message_beep, Sset_message_beep, 1, 1, 0, |
433 "Set the sound generated when the bell is rung.\n\ | |
23563
18c5f58b70b5
(Fset_message_beep): Recognize 'silent.
Geoff Voelker <voelker@cs.washington.edu>
parents:
22540
diff
changeset
|
434 SOUND is 'asterisk, 'exclamation, 'hand, 'question, 'ok, or 'silent\n\ |
18c5f58b70b5
(Fset_message_beep): Recognize 'silent.
Geoff Voelker <voelker@cs.washington.edu>
parents:
22540
diff
changeset
|
435 to use the corresponding system sound for the bell. The 'silent sound\n\ |
18c5f58b70b5
(Fset_message_beep): Recognize 'silent.
Geoff Voelker <voelker@cs.washington.edu>
parents:
22540
diff
changeset
|
436 prevents Emacs from making any sound at all.\n\ |
11389 | 437 SOUND is nil to use the normal beep.") |
438 (sound) | |
439 Lisp_Object sound; | |
9907 | 440 { |
11389 | 441 CHECK_SYMBOL (sound, 0); |
442 | |
443 if (NILP (sound)) | |
444 sound_type = 0xFFFFFFFF; | |
445 else if (EQ (sound, intern ("asterisk"))) | |
446 sound_type = MB_ICONASTERISK; | |
447 else if (EQ (sound, intern ("exclamation"))) | |
448 sound_type = MB_ICONEXCLAMATION; | |
449 else if (EQ (sound, intern ("hand"))) | |
450 sound_type = MB_ICONHAND; | |
451 else if (EQ (sound, intern ("question"))) | |
452 sound_type = MB_ICONQUESTION; | |
453 else if (EQ (sound, intern ("ok"))) | |
454 sound_type = MB_OK; | |
23563
18c5f58b70b5
(Fset_message_beep): Recognize 'silent.
Geoff Voelker <voelker@cs.washington.edu>
parents:
22540
diff
changeset
|
455 else if (EQ (sound, intern ("silent"))) |
18c5f58b70b5
(Fset_message_beep): Recognize 'silent.
Geoff Voelker <voelker@cs.washington.edu>
parents:
22540
diff
changeset
|
456 sound_type = MB_EMACS_SILENT; |
11389 | 457 else |
458 sound_type = 0xFFFFFFFF; | |
459 | |
460 return sound; | |
9907 | 461 } |
462 | |
463 void | |
464 reset_terminal_modes (void) | |
465 { | |
19706
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
466 #ifdef USE_SEPARATE_SCREEN |
9907 | 467 SetConsoleActiveScreenBuffer (prev_screen); |
19706
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
468 #else |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
469 SetConsoleCursorInfo (prev_screen, &prev_console_cursor); |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
470 #endif |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
471 SetConsoleMode (keyboard_handle, prev_console_mode); |
9907 | 472 } |
473 | |
474 void | |
475 set_terminal_modes (void) | |
476 { | |
477 CONSOLE_CURSOR_INFO cci; | |
478 | |
19706
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
479 /* make cursor big and visible (100 on Win95 makes it disappear) */ |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
480 cci.dwSize = 99; |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
481 cci.bVisible = TRUE; |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
482 (void) SetConsoleCursorInfo (cur_screen, &cci); |
9907 | 483 |
19706
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
484 SetConsoleActiveScreenBuffer (cur_screen); |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
485 |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
486 SetConsoleMode (keyboard_handle, ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT); |
9907 | 487 |
19706
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
488 /* Initialize input mode: interrupt_input off, no flow control, allow |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
489 8 bit character input, standard quit char. */ |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
490 Fset_input_mode (Qnil, Qnil, make_number (2), Qnil); |
9907 | 491 } |
492 | |
493 /* hmmm... perhaps these let us bracket screen changes so that we can flush | |
494 clumps rather than one-character-at-a-time... | |
495 | |
496 we'll start with not moving the cursor while an update is in progress. */ | |
497 void | |
498 update_begin (FRAME_PTR f) | |
499 { | |
500 } | |
501 | |
502 void | |
503 update_end (FRAME_PTR f) | |
504 { | |
505 SetConsoleCursorPosition (cur_screen, cursor_coords); | |
506 } | |
507 | |
508 void | |
509 set_terminal_window (int size) | |
510 { | |
511 } | |
512 | |
513 typedef int (*term_hook) (); | |
514 | |
515 void | |
16883
d1d4d81f9ece
Change all uses of win95, winnt, and win32
Geoff Voelker <voelker@cs.washington.edu>
parents:
16593
diff
changeset
|
516 initialize_w32_display (void) |
9907 | 517 { |
518 CONSOLE_SCREEN_BUFFER_INFO info; | |
519 | |
21828
7e3f21132df4
(initialize_w32_displayed): Use new function prototypes.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19706
diff
changeset
|
520 cursor_to_hook = move_cursor; |
7e3f21132df4
(initialize_w32_displayed): Use new function prototypes.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19706
diff
changeset
|
521 raw_cursor_to_hook = move_cursor; |
7e3f21132df4
(initialize_w32_displayed): Use new function prototypes.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19706
diff
changeset
|
522 clear_to_end_hook = clear_to_end; |
7e3f21132df4
(initialize_w32_displayed): Use new function prototypes.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19706
diff
changeset
|
523 clear_frame_hook = clear_frame; |
7e3f21132df4
(initialize_w32_displayed): Use new function prototypes.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19706
diff
changeset
|
524 clear_end_of_line_hook = clear_end_of_line; |
7e3f21132df4
(initialize_w32_displayed): Use new function prototypes.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19706
diff
changeset
|
525 ins_del_lines_hook = ins_del_lines; |
7e3f21132df4
(initialize_w32_displayed): Use new function prototypes.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19706
diff
changeset
|
526 change_line_highlight_hook = change_line_highlight; |
7e3f21132df4
(initialize_w32_displayed): Use new function prototypes.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19706
diff
changeset
|
527 reassert_line_highlight_hook = reassert_line_highlight; |
7e3f21132df4
(initialize_w32_displayed): Use new function prototypes.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19706
diff
changeset
|
528 insert_glyphs_hook = insert_glyphs; |
7e3f21132df4
(initialize_w32_displayed): Use new function prototypes.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19706
diff
changeset
|
529 write_glyphs_hook = write_glyphs; |
7e3f21132df4
(initialize_w32_displayed): Use new function prototypes.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19706
diff
changeset
|
530 delete_glyphs_hook = delete_glyphs; |
7e3f21132df4
(initialize_w32_displayed): Use new function prototypes.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19706
diff
changeset
|
531 ring_bell_hook = w32_sys_ring_bell; |
7e3f21132df4
(initialize_w32_displayed): Use new function prototypes.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19706
diff
changeset
|
532 reset_terminal_modes_hook = reset_terminal_modes; |
7e3f21132df4
(initialize_w32_displayed): Use new function prototypes.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19706
diff
changeset
|
533 set_terminal_modes_hook = set_terminal_modes; |
7e3f21132df4
(initialize_w32_displayed): Use new function prototypes.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19706
diff
changeset
|
534 set_terminal_window_hook = set_terminal_window; |
7e3f21132df4
(initialize_w32_displayed): Use new function prototypes.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19706
diff
changeset
|
535 update_begin_hook = update_begin; |
7e3f21132df4
(initialize_w32_displayed): Use new function prototypes.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19706
diff
changeset
|
536 update_end_hook = update_end; |
9907 | 537 |
16588
481b7874a1e9
Change identifiers of the form win32* to w32*.
Geoff Voelker <voelker@cs.washington.edu>
parents:
16262
diff
changeset
|
538 read_socket_hook = w32_console_read_socket; |
21828
7e3f21132df4
(initialize_w32_displayed): Use new function prototypes.
Geoff Voelker <voelker@cs.washington.edu>
parents:
19706
diff
changeset
|
539 mouse_position_hook = w32_console_mouse_position; |
19706
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
540 |
22540
0e7c65caf1cb
(initialize_w32_display): Call init_crit to initialize
Andrew Innes <andrewi@gnu.org>
parents:
21828
diff
changeset
|
541 /* Initialize interrupt_handle. */ |
0e7c65caf1cb
(initialize_w32_display): Call init_crit to initialize
Andrew Innes <andrewi@gnu.org>
parents:
21828
diff
changeset
|
542 init_crit (); |
0e7c65caf1cb
(initialize_w32_display): Call init_crit to initialize
Andrew Innes <andrewi@gnu.org>
parents:
21828
diff
changeset
|
543 |
19706
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
544 /* Remember original console settings. */ |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
545 keyboard_handle = GetStdHandle (STD_INPUT_HANDLE); |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
546 GetConsoleMode (keyboard_handle, &prev_console_mode); |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
547 |
9907 | 548 prev_screen = GetStdHandle (STD_OUTPUT_HANDLE); |
549 | |
19706
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
550 #ifdef USE_SEPARATE_SCREEN |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
551 cur_screen = CreateConsoleScreenBuffer (GENERIC_READ | GENERIC_WRITE, |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
552 0, NULL, |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
553 CONSOLE_TEXTMODE_BUFFER, |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
554 NULL); |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
555 |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
556 if (cur_screen == INVALID_HANDLE_VALUE) |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
557 { |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
558 printf ("CreateConsoleScreenBuffer failed in ResetTerm\n"); |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
559 printf ("LastError = 0x%lx\n", GetLastError ()); |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
560 fflush (stdout); |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
561 exit (0); |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
562 } |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
563 #else |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
564 cur_screen = prev_screen; |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
565 GetConsoleCursorInfo (prev_screen, &prev_console_cursor); |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
566 #endif |
e21b63afe61f
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
Geoff Voelker <voelker@cs.washington.edu>
parents:
18507
diff
changeset
|
567 |
9907 | 568 GetConsoleScreenBufferInfo (cur_screen, &info); |
569 | |
570 meta_key = 1; | |
571 char_attr = info.wAttributes & 0xFF; | |
572 char_attr_normal = char_attr; | |
573 char_attr_reverse = ((char_attr & 0xf) << 4) + ((char_attr & 0xf0) >> 4); | |
23572
1fa5f9f5c92e
(initialize_w32_display): Use buffer coords
Geoff Voelker <voelker@cs.washington.edu>
parents:
23563
diff
changeset
|
574 |
1fa5f9f5c92e
(initialize_w32_display): Use buffer coords
Geoff Voelker <voelker@cs.washington.edu>
parents:
23563
diff
changeset
|
575 /* Lines per page. Use buffer coords instead of buffer size. */ |
1fa5f9f5c92e
(initialize_w32_display): Use buffer coords
Geoff Voelker <voelker@cs.washington.edu>
parents:
23563
diff
changeset
|
576 FRAME_HEIGHT (selected_frame) = 1 + info.srWindow.Bottom - |
1fa5f9f5c92e
(initialize_w32_display): Use buffer coords
Geoff Voelker <voelker@cs.washington.edu>
parents:
23563
diff
changeset
|
577 info.srWindow.Top; |
1fa5f9f5c92e
(initialize_w32_display): Use buffer coords
Geoff Voelker <voelker@cs.washington.edu>
parents:
23563
diff
changeset
|
578 /* Characters per line. Use buffer coords instead of buffer size. */ |
1fa5f9f5c92e
(initialize_w32_display): Use buffer coords
Geoff Voelker <voelker@cs.washington.edu>
parents:
23563
diff
changeset
|
579 SET_FRAME_WIDTH (selected_frame, 1 + info.srWindow.Right - |
1fa5f9f5c92e
(initialize_w32_display): Use buffer coords
Geoff Voelker <voelker@cs.washington.edu>
parents:
23563
diff
changeset
|
580 info.srWindow.Left); |
9907 | 581 } |
582 | |
583 DEFUN ("set-screen-color", Fset_screen_color, Sset_screen_color, 2, 2, 0, | |
584 "Set screen colors.") | |
585 (foreground, background) | |
586 Lisp_Object foreground; | |
587 Lisp_Object background; | |
588 { | |
589 char_attr_normal = XFASTINT (foreground) + (XFASTINT (background) << 4); | |
590 char_attr_reverse = XFASTINT (background) + (XFASTINT (foreground) << 4); | |
591 | |
592 Frecenter (Qnil); | |
593 return Qt; | |
594 } | |
595 | |
596 DEFUN ("set-cursor-size", Fset_cursor_size, Sset_cursor_size, 1, 1, 0, | |
597 "Set cursor size.") | |
598 (size) | |
599 Lisp_Object size; | |
600 { | |
601 CONSOLE_CURSOR_INFO cci; | |
602 cci.dwSize = XFASTINT (size); | |
603 cci.bVisible = TRUE; | |
604 (void) SetConsoleCursorInfo (cur_screen, &cci); | |
605 | |
606 return Qt; | |
607 } | |
608 | |
13424
efbbbfd268dd
(nt_ring_bell): Renamed from ring_bell, now global.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12336
diff
changeset
|
609 #ifndef HAVE_NTGUI |
9907 | 610 void |
611 pixel_to_glyph_coords (FRAME_PTR f, int pix_x, int pix_y, int *x, int *y, | |
612 void *bounds, int noclip) | |
613 { | |
614 *x = pix_x; | |
615 *y = pix_y; | |
616 } | |
617 | |
618 void | |
619 glyph_to_pixel_coords (FRAME_PTR f, int x, int y, int *pix_x, int *pix_y) | |
620 { | |
621 *pix_x = x; | |
622 *pix_y = y; | |
623 } | |
13424
efbbbfd268dd
(nt_ring_bell): Renamed from ring_bell, now global.
Geoff Voelker <voelker@cs.washington.edu>
parents:
12336
diff
changeset
|
624 #endif /* !HAVE_NTGUI */ |
9907 | 625 |
11389 | 626 void |
9907 | 627 syms_of_ntterm () |
628 { | |
629 defsubr (&Sset_screen_color); | |
630 defsubr (&Sset_cursor_size); | |
11389 | 631 defsubr (&Sset_message_beep); |
9907 | 632 } |