annotate src/w32console.c @ 11859:8d57babf4b36

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