]> code.delx.au - gnu-emacs/blobdiff - src/w32console.c
merge trunk
[gnu-emacs] / src / w32console.c
index c2fe6e7db5c7944f0d73bcc65c7fe95d1e7d5b1a..e8b0f621b4f8f7447d41f2c825f5239811e59945 100644 (file)
@@ -1,6 +1,5 @@
 /* Terminal hooks for GNU Emacs on the Microsoft W32 API.
-   Copyright (C) 1992, 1999, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-                 2008, 2009, 2010  Free Software Foundation, Inc.
+   Copyright (C) 1992, 1999, 2001-2012  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -25,10 +24,8 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 
-#include <stdlib.h>
 #include <stdio.h>
 #include <windows.h>
-#include <string.h>
 #include <setjmp.h>
 
 #include "lisp.h"
@@ -44,12 +41,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 /* from window.c */
 extern Lisp_Object Frecenter (Lisp_Object);
 
-/* from keyboard.c */
-extern int detect_input_pending (void);
-
-/* from sysdep.c */
-extern int read_input_pending (void);
-
 static void w32con_move_cursor (struct frame *f, int row, int col);
 static void w32con_clear_to_end (struct frame *f);
 static void w32con_clear_frame (struct frame *f);
@@ -74,13 +65,6 @@ static DWORD prev_console_mode;
 static CONSOLE_CURSOR_INFO prev_console_cursor;
 #endif
 
-extern Lisp_Object Vtty_defined_color_alist;
-
-/* Determine whether to make frame dimensions match the screen buffer,
-   or the current window size.  The former is desirable when running
-   over telnet, while the latter is more useful when working directly at
-   the console with a large scroll-back buffer.  */
-int w32_use_full_screen_buffer;
 HANDLE  keyboard_handle;
 
 
@@ -287,9 +271,6 @@ w32con_insert_glyphs (struct frame *f, register struct glyph *start,
     }
 }
 
-extern unsigned char *encode_terminal_code (struct glyph *, int,
-                                            struct coding_system *);
-
 static void
 w32con_write_glyphs (struct frame *f, register struct glyph *string,
                      register int len)
@@ -393,8 +374,7 @@ 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;
+  (Lisp_Object sound)
 {
   CHECK_SYMBOL (sound);
 
@@ -493,7 +473,7 @@ w32con_set_terminal_window (struct frame *f, int size)
  ***********************************************************************/
 
 void
-sys_tputs (char *str, int nlines, int (*outfun)(int))
+sys_tputs (char *str, int nlines, int (*outfun) (int))
 {
 }
 
@@ -586,28 +566,6 @@ w32_face_attributes (struct frame *f, int face_id)
   return char_attr;
 }
 
-
-
-/* Given a color index, return its standard name.  */
-Lisp_Object
-vga_stdcolor_name (int idx)
-{
-  /* Standard VGA colors, in the order of their standard numbering
-     in the default VGA palette.  */
-  static char *vga_colors[16] = {
-    "black", "blue", "green", "cyan", "red", "magenta", "brown",
-    "lightgray", "darkgray", "lightblue", "lightgreen", "lightcyan",
-    "lightred", "lightmagenta", "yellow", "white"
-  };
-
-  extern Lisp_Object Qunspecified;
-
-  if (idx >= 0 && idx < sizeof (vga_colors) / sizeof (vga_colors[0]))
-    return build_string (vga_colors[idx]);
-  else
-    return Qunspecified;       /* meaning the default */
-}
-
 void
 initialize_w32_display (struct terminal *term)
 {
@@ -671,8 +629,8 @@ initialize_w32_display (struct terminal *term)
 
   /* Respect setting of LINES and COLUMNS environment variables.  */
   {
-    char * lines = getenv("LINES");
-    char * columns = getenv("COLUMNS");
+    char * lines = getenv ("LINES");
+    char * columns = getenv ("COLUMNS");
 
     if (lines != NULL && columns != NULL)
       {
@@ -747,10 +705,10 @@ initialize_w32_display (struct terminal *term)
 
 
 DEFUN ("set-screen-color", Fset_screen_color, Sset_screen_color, 2, 2, 0,
-       doc: /* Set screen colors.  */)
-    (foreground, background)
-    Lisp_Object foreground;
-    Lisp_Object background;
+       doc: /* Set screen foreground and background colors.
+
+Arguments should be indices between 0 and 15, see w32console.el.  */)
+  (Lisp_Object foreground, Lisp_Object background)
 {
   char_attr_normal = XFASTINT (foreground) + (XFASTINT (background) << 4);
 
@@ -758,10 +716,21 @@ DEFUN ("set-screen-color", Fset_screen_color, Sset_screen_color, 2, 2, 0,
   return Qt;
 }
 
+DEFUN ("get-screen-color", Fget_screen_color, Sget_screen_color, 0, 0, 0,
+       doc: /* Get color indices of the current screen foreground and background.
+
+The colors are returned as a list of 2 indices (FOREGROUND BACKGROUND).
+See w32console.el and `tty-defined-color-alist' for mapping of indices
+to colors.  */)
+  (void)
+{
+  return Fcons (make_number (char_attr_normal & 0x000f),
+               Fcons (make_number ((char_attr_normal >> 4) & 0x000f), Qnil));
+}
+
 DEFUN ("set-cursor-size", Fset_cursor_size, Sset_cursor_size, 1, 1, 0,
        doc: /* Set cursor size.  */)
-    (size)
-    Lisp_Object size;
+  (Lisp_Object size)
 {
   CONSOLE_CURSOR_INFO cci;
   cci.dwSize = XFASTINT (size);
@@ -775,18 +744,16 @@ void
 syms_of_ntterm (void)
 {
   DEFVAR_BOOL ("w32-use-full-screen-buffer",
-               &w32_use_full_screen_buffer,
+               w32_use_full_screen_buffer,
               doc: /* Non-nil means make terminal frames use the full screen buffer dimensions.
 This is desirable when running Emacs over telnet.
 A value of nil means use the current console window dimensions; this
-may be preferrable when working directly at the console with a large
+may be preferable when working directly at the console with a large
 scroll-back buffer.  */);
   w32_use_full_screen_buffer = 0;
 
   defsubr (&Sset_screen_color);
+  defsubr (&Sget_screen_color);
   defsubr (&Sset_cursor_size);
   defsubr (&Sset_message_beep);
 }
-
-/* arch-tag: a390a07f-f661-42bc-aeb4-e6d8bf860337
-   (do not change this comment) */