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