diff options
| author | Geoff Voelker | 1997-09-03 00:46:41 +0000 |
|---|---|---|
| committer | Geoff Voelker | 1997-09-03 00:46:41 +0000 |
| commit | 3e671d90bac85ab5904610f97063383676af4443 (patch) | |
| tree | d3c427141dcb3ca822195a99865ab172b62cd0a0 /src | |
| parent | bb06745dc753854d491f1d3cfec6e9e6d1a18f29 (diff) | |
| download | emacs-3e671d90bac85ab5904610f97063383676af4443.tar.gz emacs-3e671d90bac85ab5904610f97063383676af4443.zip | |
(DebPrint, reset_kbd, unset_kbd, take_console): Delete functions.
(keyboard_init_hook): Delete variable.
(prev_console_cursor) [! USE_SEPARATE_SCREEN]: New variable.
(reset_terminal_modes) [! USE_SEPARATE_SCREEN]: Reset cursor info.
(initialize_w32_display) [USE_SEPARATE_SCREEN]: Create separate
screen buffer.
(ctrl_c_handler): Only ignore interrupts when interactive.
(set_terminal_modes): Set input mode.
(initialize_w32_display): Record original settings.
Don't reset cursor or clear frame.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32console.c | 108 |
1 files changed, 46 insertions, 62 deletions
diff --git a/src/w32console.c b/src/w32console.c index 97ff55907d1..b26790c630c 100644 --- a/src/w32console.c +++ b/src/w32console.c | |||
| @@ -64,24 +64,18 @@ static void set_terminal_modes (void); | |||
| 64 | static void set_terminal_window (int size); | 64 | static void set_terminal_window (int size); |
| 65 | static void update_begin (FRAME_PTR f); | 65 | static void update_begin (FRAME_PTR f); |
| 66 | static void update_end (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); | 67 | static int hl_mode (int new_highlight); |
| 70 | 68 | ||
| 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; | 69 | COORD cursor_coords; |
| 80 | HANDLE prev_screen, cur_screen; | 70 | HANDLE prev_screen, cur_screen; |
| 81 | UCHAR char_attr, char_attr_normal, char_attr_reverse; | 71 | UCHAR char_attr, char_attr_normal, char_attr_reverse; |
| 82 | HANDLE keyboard_handle; | 72 | HANDLE keyboard_handle; |
| 83 | DWORD prev_console_mode; | 73 | DWORD prev_console_mode; |
| 84 | 74 | ||
| 75 | #ifndef USE_SEPARATE_SCREEN | ||
| 76 | CONSOLE_CURSOR_INFO prev_console_cursor; | ||
| 77 | #endif | ||
| 78 | |||
| 85 | 79 | ||
| 86 | /* Setting this as the ctrl handler prevents emacs from being killed when | 80 | /* Setting this as the ctrl handler prevents emacs from being killed when |
| 87 | someone hits ^C in a 'suspended' session (child shell). | 81 | someone hits ^C in a 'suspended' session (child shell). |
| @@ -90,7 +84,9 @@ DWORD prev_console_mode; | |||
| 90 | BOOL | 84 | BOOL |
| 91 | ctrl_c_handler (unsigned long type) | 85 | ctrl_c_handler (unsigned long type) |
| 92 | { | 86 | { |
| 93 | return (type == CTRL_C_EVENT || type == CTRL_BREAK_EVENT); | 87 | /* Only ignore "interrupt" events when running interactively. */ |
| 88 | return (!noninteractive | ||
| 89 | && (type == CTRL_C_EVENT || type == CTRL_BREAK_EVENT)); | ||
| 94 | } | 90 | } |
| 95 | 91 | ||
| 96 | /* If we're updating a frame, use it as the current frame | 92 | /* If we're updating a frame, use it as the current frame |
| @@ -453,20 +449,16 @@ SOUND is nil to use the normal beep.") | |||
| 453 | 449 | ||
| 454 | return sound; | 450 | return sound; |
| 455 | } | 451 | } |
| 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 | 452 | ||
| 465 | void | 453 | void |
| 466 | reset_terminal_modes (void) | 454 | reset_terminal_modes (void) |
| 467 | { | 455 | { |
| 468 | unset_kbd (); | 456 | #ifdef USE_SEPARATE_SCREEN |
| 469 | SetConsoleActiveScreenBuffer (prev_screen); | 457 | SetConsoleActiveScreenBuffer (prev_screen); |
| 458 | #else | ||
| 459 | SetConsoleCursorInfo (prev_screen, &prev_console_cursor); | ||
| 460 | #endif | ||
| 461 | SetConsoleMode (keyboard_handle, prev_console_mode); | ||
| 470 | } | 462 | } |
| 471 | 463 | ||
| 472 | void | 464 | void |
| @@ -474,29 +466,18 @@ set_terminal_modes (void) | |||
| 474 | { | 466 | { |
| 475 | CONSOLE_CURSOR_INFO cci; | 467 | CONSOLE_CURSOR_INFO cci; |
| 476 | 468 | ||
| 477 | if (cur_screen == NULL) | 469 | /* make cursor big and visible (100 on Win95 makes it disappear) */ |
| 478 | { | 470 | cci.dwSize = 99; |
| 479 | reset_kbd (); | 471 | cci.bVisible = TRUE; |
| 480 | cur_screen = CreateConsoleScreenBuffer (GENERIC_READ | GENERIC_WRITE, | 472 | (void) SetConsoleCursorInfo (cur_screen, &cci); |
| 481 | 0, NULL, | ||
| 482 | CONSOLE_TEXTMODE_BUFFER, | ||
| 483 | NULL); | ||
| 484 | 473 | ||
| 485 | if (cur_screen == INVALID_HANDLE_VALUE) | 474 | SetConsoleActiveScreenBuffer (cur_screen); |
| 486 | { | ||
| 487 | printf ("CreateConsoleScreenBuffer failed in ResetTerm\n"); | ||
| 488 | printf ("LastError = 0x%lx\n", GetLastError ()); | ||
| 489 | fflush (stdout); | ||
| 490 | exit (0); | ||
| 491 | } | ||
| 492 | 475 | ||
| 493 | SetConsoleActiveScreenBuffer (cur_screen); | 476 | SetConsoleMode (keyboard_handle, ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT); |
| 494 | 477 | ||
| 495 | /* make cursor big and visible (100 on Windows 95 makes it disappear) */ | 478 | /* Initialize input mode: interrupt_input off, no flow control, allow |
| 496 | cci.dwSize = 99; | 479 | 8 bit character input, standard quit char. */ |
| 497 | cci.bVisible = TRUE; | 480 | Fset_input_mode (Qnil, Qnil, make_number (2), Qnil); |
| 498 | (void) SetConsoleCursorInfo (cur_screen, &cci); | ||
| 499 | } | ||
| 500 | } | 481 | } |
| 501 | 482 | ||
| 502 | /* hmmm... perhaps these let us bracket screen changes so that we can flush | 483 | /* hmmm... perhaps these let us bracket screen changes so that we can flush |
| @@ -519,23 +500,6 @@ set_terminal_window (int size) | |||
| 519 | { | 500 | { |
| 520 | } | 501 | } |
| 521 | 502 | ||
| 522 | void | ||
| 523 | unset_kbd (void) | ||
| 524 | { | ||
| 525 | SetConsoleMode (keyboard_handle, prev_console_mode); | ||
| 526 | } | ||
| 527 | |||
| 528 | void | ||
| 529 | reset_kbd (void) | ||
| 530 | { | ||
| 531 | keyboard_handle = GetStdHandle (STD_INPUT_HANDLE); | ||
| 532 | GetConsoleMode (keyboard_handle, &prev_console_mode); | ||
| 533 | SetConsoleMode (keyboard_handle, ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT); | ||
| 534 | |||
| 535 | /* Try to use interrupt input; if we can't, then start polling. */ | ||
| 536 | Fset_input_mode (Qt, Qnil, Qt, Qnil); | ||
| 537 | } | ||
| 538 | |||
| 539 | typedef int (*term_hook) (); | 503 | typedef int (*term_hook) (); |
| 540 | 504 | ||
| 541 | void | 505 | void |
| @@ -563,11 +527,31 @@ initialize_w32_display (void) | |||
| 563 | 527 | ||
| 564 | read_socket_hook = w32_console_read_socket; | 528 | read_socket_hook = w32_console_read_socket; |
| 565 | mouse_position_hook = w32_mouse_position; | 529 | mouse_position_hook = w32_mouse_position; |
| 566 | 530 | ||
| 531 | /* Remember original console settings. */ | ||
| 532 | keyboard_handle = GetStdHandle (STD_INPUT_HANDLE); | ||
| 533 | GetConsoleMode (keyboard_handle, &prev_console_mode); | ||
| 534 | |||
| 567 | prev_screen = GetStdHandle (STD_OUTPUT_HANDLE); | 535 | prev_screen = GetStdHandle (STD_OUTPUT_HANDLE); |
| 568 | 536 | ||
| 569 | set_terminal_modes (); | 537 | #ifdef USE_SEPARATE_SCREEN |
| 570 | 538 | cur_screen = CreateConsoleScreenBuffer (GENERIC_READ | GENERIC_WRITE, | |
| 539 | 0, NULL, | ||
| 540 | CONSOLE_TEXTMODE_BUFFER, | ||
| 541 | NULL); | ||
| 542 | |||
| 543 | if (cur_screen == INVALID_HANDLE_VALUE) | ||
| 544 | { | ||
| 545 | printf ("CreateConsoleScreenBuffer failed in ResetTerm\n"); | ||
| 546 | printf ("LastError = 0x%lx\n", GetLastError ()); | ||
| 547 | fflush (stdout); | ||
| 548 | exit (0); | ||
| 549 | } | ||
| 550 | #else | ||
| 551 | cur_screen = prev_screen; | ||
| 552 | GetConsoleCursorInfo (prev_screen, &prev_console_cursor); | ||
| 553 | #endif | ||
| 554 | |||
| 571 | GetConsoleScreenBufferInfo (cur_screen, &info); | 555 | GetConsoleScreenBufferInfo (cur_screen, &info); |
| 572 | 556 | ||
| 573 | meta_key = 1; | 557 | meta_key = 1; |
| @@ -578,9 +562,9 @@ initialize_w32_display (void) | |||
| 578 | FRAME_HEIGHT (selected_frame) = info.dwSize.Y; /* lines per page */ | 562 | FRAME_HEIGHT (selected_frame) = info.dwSize.Y; /* lines per page */ |
| 579 | SET_FRAME_WIDTH (selected_frame, info.dwSize.X); /* characters per line */ | 563 | SET_FRAME_WIDTH (selected_frame, info.dwSize.X); /* characters per line */ |
| 580 | 564 | ||
| 581 | move_cursor (0, 0); | 565 | // move_cursor (0, 0); |
| 582 | 566 | ||
| 583 | clear_frame (); | 567 | // clear_frame (); |
| 584 | } | 568 | } |
| 585 | 569 | ||
| 586 | DEFUN ("set-screen-color", Fset_screen_color, Sset_screen_color, 2, 2, 0, | 570 | DEFUN ("set-screen-color", Fset_screen_color, Sset_screen_color, 2, 2, 0, |