]> code.delx.au - gnu-emacs/blobdiff - src/w32console.c
(substitute-key-definition): Fix previous change.
[gnu-emacs] / src / w32console.c
index 31ec93635692fdf0a0cecbcb78fb12391a6fb671..24ae959f5ea62bcec369fb1cd76faa0f7eeaead3 100644 (file)
@@ -1,4 +1,4 @@
-/* Terminal hooks for Windows NT port of GNU Emacs.
+/* Terminal hooks for GNU Emacs on the Microsoft W32 API.
    Copyright (C) 1992 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
@@ -34,7 +34,7 @@ Boston, MA 02111-1307, USA.
 #include "disptab.h"
 #include "termhooks.h"
 
-#include "ntinevt.h"
+#include "w32inevt.h"
 
 /* from window.c */
 extern Lisp_Object Frecenter ();
@@ -58,7 +58,7 @@ static void reassert_line_highlight (int, int);
 static void insert_glyphs (GLYPH *start, int len);
 static void write_glyphs (GLYPH *string, int len);
 static void delete_glyphs (int n);
-void nt_ring_bell (void);
+void w32_sys_ring_bell (void);
 static void reset_terminal_modes (void);
 static void set_terminal_modes (void);
 static void set_terminal_window (int size);
@@ -80,6 +80,7 @@ COORD cursor_coords;
 HANDLE prev_screen, cur_screen;
 UCHAR  char_attr, char_attr_normal, char_attr_reverse;
 HANDLE  keyboard_handle;
+DWORD   prev_console_mode;
 
 
 /* Setting this as the ctrl handler prevents emacs from being killed when
@@ -192,7 +193,7 @@ ins_del_lines (int vpos, int n)
   
   ScrollConsoleScreenBuffer (cur_screen, &scroll, NULL, dest, &fill);
 
-  /* Here we have to deal with a win32 console flake: If the scroll
+  /* Here we have to deal with a w32 console flake: If the scroll
      region looks like abc and we scroll c to a and fill with d we get
      cbd... if we scroll block c one line at a time to a, we get cdd...
      Emacs expects cdd consistently... So we have to deal with that
@@ -417,7 +418,7 @@ delete_glyphs (int n)
 static unsigned int sound_type = 0xFFFFFFFF;
 
 void
-nt_ring_bell (void)
+w32_sys_ring_bell (void)
 {
   if (sound_type == 0xFFFFFFFF) 
       Beep (666, 100);
@@ -491,7 +492,7 @@ set_terminal_modes (void)
 
       SetConsoleActiveScreenBuffer (cur_screen);
 
-      /* make cursor big and visible (100 on Win95 makes it disappear)  */
+      /* make cursor big and visible (100 on Windows 95 makes it disappear)  */
       cci.dwSize = 99;
       cci.bVisible = TRUE;
       (void) SetConsoleCursorInfo (cur_screen, &cci);
@@ -521,21 +522,24 @@ set_terminal_window (int size)
 void
 unset_kbd (void)
 {
-  SetConsoleMode (keyboard_handle, ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT |
-                 ENABLE_ECHO_INPUT | ENABLE_MOUSE_INPUT);
+  SetConsoleMode (keyboard_handle, prev_console_mode);
 }
 
 void
 reset_kbd (void)
 {
   keyboard_handle = GetStdHandle (STD_INPUT_HANDLE);
+  GetConsoleMode (keyboard_handle, &prev_console_mode);
   SetConsoleMode (keyboard_handle, ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT);
+
+  /* Try to use interrupt input; if we can't, then start polling.  */
+  Fset_input_mode (Qt, Qnil, Qt, Qnil);
 }
 
 typedef int (*term_hook) ();
 
 void
-initialize_win_nt_display (void)
+initialize_w32_display (void)
 {
   CONSOLE_SCREEN_BUFFER_INFO   info;
   
@@ -550,15 +554,15 @@ initialize_win_nt_display (void)
   insert_glyphs_hook           = (term_hook) insert_glyphs;
   write_glyphs_hook            = (term_hook) write_glyphs;
   delete_glyphs_hook           = (term_hook) delete_glyphs;
-  ring_bell_hook               = (term_hook) nt_ring_bell;
+  ring_bell_hook               = (term_hook) w32_sys_ring_bell;
   reset_terminal_modes_hook    = (term_hook) reset_terminal_modes;
   set_terminal_modes_hook      = (term_hook) set_terminal_modes;
   set_terminal_window_hook     = (term_hook) set_terminal_window;
   update_begin_hook            = (term_hook) update_begin;
   update_end_hook              = (term_hook) update_end;
   
-  read_socket_hook = win32_read_socket;
-  mouse_position_hook = win32_mouse_position;
+  read_socket_hook = w32_console_read_socket;
+  mouse_position_hook = w32_mouse_position;
   
   prev_screen = GetStdHandle (STD_OUTPUT_HANDLE);
   
@@ -572,7 +576,7 @@ initialize_win_nt_display (void)
   char_attr_reverse = ((char_attr & 0xf) << 4) + ((char_attr & 0xf0) >> 4);
   
   FRAME_HEIGHT (selected_frame) = info.dwSize.Y;       /* lines per page */
-  FRAME_WIDTH (selected_frame) = info.dwSize.X;  /* characters per line */
+  SET_FRAME_WIDTH (selected_frame, info.dwSize.X); /* characters per line */
   
   move_cursor (0, 0);