]> code.delx.au - gnu-emacs/blobdiff - src/w32console.c
Fix comments.
[gnu-emacs] / src / w32console.c
index b0746e9f1ffda4e32e58530261e2638db4360197..490c1e10373a24f7440d5f094d49dfdd17520ac1 100644 (file)
@@ -35,11 +35,11 @@ Boston, MA 02111-1307, USA.
 #include "coding.h"
 #include "disptab.h"
 #include "termhooks.h"
-/* Disable features in dispextern.h that require a Window System.  */
+#include "dispextern.h"
+/* Disable features in frame.h that require a Window System.  */
 #undef HAVE_WINDOW_SYSTEM
 #include "frame.h"
 #include "w32inevt.h"
-#include "dispextern.h"
 
 /* from window.c */
 extern Lisp_Object Frecenter ();
@@ -58,8 +58,6 @@ static void clear_to_end (void);
 static void clear_frame (void);
 static void clear_end_of_line (int);
 static void ins_del_lines (int vpos, int n);
-static void change_line_highlight (int, int, int, int);
-static void reassert_line_highlight (int, int);
 static void insert_glyphs (struct glyph *start, int len);
 static void write_glyphs (struct glyph *string, int len);
 static void delete_glyphs (int n);
@@ -70,7 +68,6 @@ static void set_terminal_window (int size);
 static void update_begin (struct frame * f);
 static void update_end (struct frame * f);
 static WORD w32_face_attributes (struct frame *f, int face_id);
-static int hl_mode (int new_highlight);
 
 static COORD   cursor_coords;
 static HANDLE  prev_screen, cur_screen;
@@ -134,13 +131,12 @@ clear_frame (void)
 {
   struct frame *  f = PICK_FRAME ();
   COORD             dest;
-  int        n, r;
+  int        n;
+  DWORD      r;
   CONSOLE_SCREEN_BUFFER_INFO info;
 
   GetConsoleScreenBufferInfo (GetStdHandle (STD_OUTPUT_HANDLE), &info);
 
-  hl_mode (0);
-
   /* Remember that the screen buffer might be wider than the window.  */
   n = FRAME_HEIGHT (f) * info.dwSize.X;
   dest.X = dest.Y = 0;
@@ -175,7 +171,7 @@ clear_end_of_line (int end)
 void
 ins_del_lines (int vpos, int n)
 {
-  int       i, nb, save_highlight;
+  int       i, nb;
   SMALL_RECT scroll;
   COORD             dest;
   CHAR_INFO  fill;
@@ -198,8 +194,6 @@ ins_del_lines (int vpos, int n)
   
   dest.X = 0;
   
-  save_highlight = hl_mode (0);
-  
   fill.Char.AsciiChar = 0x20;
   fill.Attributes = char_attr_normal;
   
@@ -239,41 +233,6 @@ ins_del_lines (int vpos, int n)
   
   cursor_coords.X = 0;
   cursor_coords.Y = vpos;
-  
-  hl_mode (save_highlight);
-}
-
-/* Changes attribute to use when drawing characters to control.  */
-static int
-hl_mode (int new_highlight)
-{
-  static int highlight = 0;
-  int old_highlight;
-  
-  old_highlight = highlight;
-  highlight = (new_highlight != 0);
-
-  return old_highlight;
-}
-
-/* Call this when about to modify line at position VPOS and change whether it
-   is highlighted.  */
-void
-change_line_highlight (int new_highlight, int vpos, int y, 
-                       int first_unused_hpos)
-{
-  hl_mode (new_highlight);
-  move_cursor (vpos, 0);
-  clear_end_of_line (first_unused_hpos);
-}
-
-/* External interface to control of standout mode. Call this when about to
- * modify line at position VPOS and not change whether it is highlighted.  */
-void
-reassert_line_highlight (int highlight, int vpos)
-{
-  hl_mode (highlight);
-  vpos;                                /* pedantic compiler silencer */
 }
 
 #undef LEFT
@@ -338,9 +297,12 @@ insert_glyphs (register struct glyph *start, register int len)
 void
 write_glyphs (register struct glyph *string, register int len)
 {
-  int produced, consumed, i;
+  int produced, consumed;
+  DWORD r;
   struct frame * f = PICK_FRAME ();
   WORD char_attr;
+  unsigned char conversion_buffer[1024];
+  int conversion_buffer_size = sizeof conversion_buffer;
 
   if (len <= 0)
     return;
@@ -364,9 +326,9 @@ write_glyphs (register struct glyph *string, register int len)
 
       while (n > 0)
         {
-         /* We use a shared conversion buffer of the current size
-            (1024 bytes at least).  Usually it is sufficient, but if
-            not, we just repeat the loop.  */
+         /* We use a fixed size (1024 bytes) of conversion buffer.
+            Usually it is sufficient, but if not, we just repeat the
+            loop.  */
          produced = encode_terminal_code (string, conversion_buffer,
                                           n, conversion_buffer_size,
                                           &consumed);
@@ -374,7 +336,7 @@ write_glyphs (register struct glyph *string, register int len)
            {
               /* Set the attribute for these characters.  */
               if (!FillConsoleOutputAttribute (cur_screen, char_attr,
-                                               produced, cursor_coords, &i)) 
+                                               produced, cursor_coords, &r)) 
                 {
                   printf ("Failed writing console attributes: %d\n",
                           GetLastError ());
@@ -383,7 +345,7 @@ write_glyphs (register struct glyph *string, register int len)
 
               /* Write the characters.  */
               if (!WriteConsoleOutputCharacter (cur_screen, conversion_buffer,
-                                                produced, cursor_coords, &i))
+                                                produced, cursor_coords, &r))
                 {
                   printf ("Failed writing console characters: %d\n",
                           GetLastError ());
@@ -409,7 +371,7 @@ write_glyphs (register struct glyph *string, register int len)
         {
           if (!FillConsoleOutputAttribute (cur_screen, char_attr_normal,
                                            terminal_coding.produced,
-                                           cursor_coords, &i)) 
+                                           cursor_coords, &r)) 
             {
               printf ("Failed writing console attributes: %d\n",
                       GetLastError ());
@@ -418,7 +380,7 @@ write_glyphs (register struct glyph *string, register int len)
 
           /* Write the characters.  */
           if (!WriteConsoleOutputCharacter (cur_screen, conversion_buffer,
-                                            produced, cursor_coords, &i))
+                                            produced, cursor_coords, &r))
             {
               printf ("Failed writing console characters: %d\n",
                       GetLastError ());
@@ -458,15 +420,15 @@ w32_sys_ring_bell (void)
 }
 
 DEFUN ("set-message-beep", Fset_message_beep, Sset_message_beep, 1, 1, 0,
-       "Set the sound generated when the bell is rung.\n\
-SOUND is 'asterisk, 'exclamation, 'hand, 'question, 'ok, or 'silent\n\
-to use the corresponding system sound for the bell.  The 'silent sound\n\
-prevents Emacs from making any sound at all.\n\
-SOUND is nil to use the normal beep.")
+       doc: /* Set the sound generated when the bell is rung.
+SOUND is 'asterisk, 'exclamation, 'hand, 'question, 'ok, or 'silent
+to use the corresponding system sound for the bell.  The 'silent sound
+prevents Emacs from making any sound at all.
+SOUND is nil to use the normal beep.  */)
      (sound)
      Lisp_Object sound;
 {
-  CHECK_SYMBOL (sound, 0);
+  CHECK_SYMBOL (sound);
 
   if (NILP (sound)) 
       sound_type = 0xFFFFFFFF;
@@ -491,8 +453,6 @@ SOUND is nil to use the normal beep.")
 void
 reset_terminal_modes (void)
 {
-  hl_mode (0);
-
 #ifdef USE_SEPARATE_SCREEN
   SetConsoleActiveScreenBuffer (prev_screen);
 #else
@@ -506,8 +466,6 @@ set_terminal_modes (void)
 {
   CONSOLE_CURSOR_INFO cci;
 
-  hl_mode (0);
-
   /* make cursor big and visible (100 on Win95 makes it disappear)  */
   cci.dwSize = 99;
   cci.bVisible = TRUE;
@@ -529,13 +487,11 @@ set_terminal_modes (void)
 void
 update_begin (struct frame * f)
 {
-  hl_mode (0);
 }
 
 void
 update_end (struct frame * f)
 {
-  hl_mode (0);
   SetConsoleCursorPosition (cur_screen, cursor_coords);
 }
 
@@ -557,12 +513,8 @@ w32_face_attributes (f, face_id)
      int face_id;
 {
   WORD char_attr;
-  int highlight_on_p;
   struct face *face = FACE_FROM_ID (f, face_id);
 
-  highlight_on_p = hl_mode (0);
-  hl_mode (highlight_on_p);
-
   xassert (face != NULL);
 
   char_attr = char_attr_normal;
@@ -573,14 +525,16 @@ w32_face_attributes (f, face_id)
 
   if (face->background != FACE_TTY_DEFAULT_BG_COLOR
       && face->background != FACE_TTY_DEFAULT_COLOR)
-    char_attr = (char_attr & 0xff0f) + ((face->background % 16) * 16); 
+    char_attr = (char_attr & 0xff0f) + ((face->background % 16) << 4); 
 
 
-  /* Ensure readability (temporary measure until this all works) */
+  /* NTEMACS_TODO: Faces defined during startup get both foreground
+     and background of 0. Need a better way around this - for now detect
+     the problem and invert one of the faces to make the text readable. */
   if (((char_attr & 0x00f0) >> 4) == (char_attr & 0x000f))
     char_attr ^= 0x0007;
 
-  if (face->tty_reverse_p || highlight_on_p)
+  if (face->tty_reverse_p)
     char_attr = (char_attr & 0xff00) + ((char_attr & 0x000f) << 4)
       + ((char_attr & 0x00f0) >> 4);
 
@@ -626,8 +580,6 @@ initialize_w32_display (void)
   clear_frame_hook             = clear_frame;
   clear_end_of_line_hook       = clear_end_of_line;
   ins_del_lines_hook           = ins_del_lines;
-  change_line_highlight_hook   = change_line_highlight;
-  reassert_line_highlight_hook  = reassert_line_highlight;
   insert_glyphs_hook           = insert_glyphs;
   write_glyphs_hook            = write_glyphs;
   delete_glyphs_hook           = delete_glyphs;
@@ -707,7 +659,6 @@ initialize_w32_display (void)
   
   meta_key = 1;
   char_attr_normal = info.wAttributes;
-  hl_mode (0);
 
   if (w32_use_full_screen_buffer)
     {
@@ -731,7 +682,7 @@ initialize_w32_display (void)
 }
 
 DEFUN ("set-screen-color", Fset_screen_color, Sset_screen_color, 2, 2, 0,
-       "Set screen colors.")
+       doc: /* Set screen colors.  */)
     (foreground, background)
     Lisp_Object foreground;
     Lisp_Object background;
@@ -743,7 +694,7 @@ DEFUN ("set-screen-color", Fset_screen_color, Sset_screen_color, 2, 2, 0,
 }
 
 DEFUN ("set-cursor-size", Fset_cursor_size, Sset_cursor_size, 1, 1, 0,
-       "Set cursor size.")
+       doc: /* Set cursor size.  */)
     (size)
     Lisp_Object size;
 {
@@ -777,11 +728,11 @@ syms_of_ntterm ()
 {
   DEFVAR_BOOL ("w32-use-full-screen-buffer",
                &w32_use_full_screen_buffer,
-  "Non-nil means make terminal frames use the full screen buffer dimensions.\n\
-This is desirable when running Emacs over telnet, and is the default.\n\
-A value of nil means use the current console window dimensions; this\n\
-may be preferrable when working directly at the console with a large\n\
-scroll-back buffer.");
+              doc: /* Non-nil means make terminal frames use the full screen buffer dimensions.
+This is desirable when running Emacs over telnet, and is the default.
+A value of nil means use the current console window dimensions; this
+may be preferrable when working directly at the console with a large
+scroll-back buffer.  */);
   w32_use_full_screen_buffer = 1;
 
   defsubr (&Sset_screen_color);