Mercurial > emacs
comparison src/term.c @ 83004:7900111db01c
Converted display hooks to be display-local. Plus many bugfixes.
lib-src/emacsclient.c (window_change_signal): Renamed to pass_signal_to_emacs.
(init_signal): Pass SIGINT and SIGQUIT to the emacs process.
lisp/faces.el (face-valid-attribute-values): Use the window-system
function, not the variable.
(read-face-attribute, face-spec-set-match-display, frame-set-background-mode)
(face-set-after-frame-default): Ditto.
lisp/frame.el (make-frame-on-tty): Added interactive declaration
(suggested by Robert J. Chassell). Use tty-create-frame-with-faces,
not make-terminal-frame.
src/termhooks.h (struct display_method): Renamed to display for brevity.
(struct display): Added all display hook variables as members of this structure.
Added next_display, reference_count, type and display_info components.
(FRAME_MUST_WRITE_SPACES, FRAME_FAST_CLEAR_END_OF_LINE, FRAME_LINE_INS_DEL_OK)
(FRAME_CHAR_INS_DEL_OK, FRAME_SCROLL_REGION_OK, FRAME_SCROLL_REGION_COST)
(FRAME_MEMORY_BELOW_FRAME, FRAME_RIF): Updated for struct display.
(FRAME_DISPLAY): New macro.
(create_display, delete_display): New prototypes.
src/frame.h (struct frame): Added `display' member, removed display_method.
(FRAME_LIVE_P): Look at f->display, not f->output_data.
src/termchar.h (struct tty_display_info): Removed display_method component.
(FRAME_TTY): Use the display structure, not output_data.
src/term.c (display_list): New variable.
(cursor_to_hook, raw_cursor_to_hook, clear_to_end_hook, clear_frame_hook)
(clear_end_of_line_hook, ins_del_lines_hook, delete_glyphs_hook)
(ring_bell_hook, reset_terminal_modes_hook, set_terminal_modes_hook)
(update_begin_hook, update_end_hook, set_terminal_window_hook)
(insert_glyphs_hook, write_glyphs_hook, delete_glyphs_hoo, read_socket_hook)
(frame_up_to_date_hook, mouse_position_hook, frame_rehighlight_hook)
(frame_raise_lower_hook, set_vertical_scroll_bar_hook, condemn_scroll_bars_hook)
(redeem_scroll_bar_hook, judge_scroll_bars_hook): Moved to struct display.
(tty_display_method_template): Removed.
(syms_of_term): Don't initialize tty_display_method_template.
(ring_bell, set_terminal_modes, reset_terminal_modes, update_begin)
(update_end, set_terminal_window, cursor_to, raw_cursor_to, clear_to_end)
(clear_frame, clear_end_of_line, write_glyphs, insert_glyphs)
(delete_glyphs, ins_del_lines): Access display hooks through the frame pointer.
(Ftty_display_color_p): Use the frame given as a parameter, or else return nil.
(Ftty_display_color_cells): Ditto.
(get_named_tty): Renamed to get_named_tty_display, changed return type to struct display.
(term_dummy_init): Renamed to initial_term_init. Create and return an initial display.
(term_init): Initialize a new struct display and return a pointer to
it instead of tty_display_info. Removed frame initialization kludge.
(Fdelete_tty): Updated for struct display.
(delete_tty): The parameter type is now struct display, not tty_display_info.
Delete the display, too.
(create_tty_output): New function for creating tty_output structures.
(delete_tty_output): New function for deleting tty_output structures.
(create_display): New function for creating and registering display structures.
(delete_display): New function for deleting and unregistering display structures.
src/dispextern.h: Updated prototypes.
src/dispnew.c: Include frame.h before termhooks.h.
(init_display): Updated term_init call to new signature.
src/emacs.c: Include frame.h (for termhooks.h).
src/keymap.c: Ditto.
src/lread.c: Ditto.
src/xsmfns.c: Ditto.
src/process.c: Include frame.h before termhooks.h.
src/frame.c (Fwindow_system): New function.
(syms_of_frame): Initialize it.
(make_terminal_frame): Open the terminal device before creating the new frame.
Disable scrollbars here, term_init cannot do that anymore.
(Fdelete_frame): Use the new delete_frame_hook, don't do display-specific
frame deletion here. Ditto for delete_display_hook.
(Fmouse_position, Fmouse_pixel_position, Fraise_frame, Flower_frame)
(Fredirect_frame_focus): Access display hooks through the frame pointer.
src/keyboard.c: Include frame.h before termhooks.h.
(start_polling, input_polling_used, stop_polling, gobble_input): Ignore read_socket_hook.
(kbd_buffer_get_event, Fset_input_mode): Access display hooks through the frame pointer.
(read_avail_input): Loop through all display devices for and call all read_socket_hook functions. Check ttys even if read_socket_hook returned an error.
src/sysdep.c (discard_tty_input): Ignore read_socket_hook.
(stuff_char): Don't do anything if the current frame is not on a termcap display.
(request_sigio, unrequest_sigio): Ignore read_socket_hook.
(init_sys_modes): Always call narrow_foreground_group. Set up terminal modes and sigio even under X.
src/xdisp.c (message2_nolog, message3_nolog, redisplay_internal)
(set_vertical_scroll_bar, redisplay_window): Access display hooks through the frame pointer.
(echo_area_display): Don't be afraid of termcap frames during an X+tty combo session.
src/xfaces.c: Include termhooks.h.
(Ftty_supports_face_attributes_p): Use the given frame, not selected_frame.
src/xfns.c (x_set_scroll_bar_foreground, x_set_scroll_bar_background): Access display hooks through the frame pointer.
(Fx_create_frame, x_create_tip_frame): Initialize the frame's display structure.
src/xmenu.c: Include termhooks.h after frame.h.
src/xselect.c (x_own_selection, some_frame_on_display, x_get_foreign_selection)
(Fx_disown_selection_internal, Fx_get_cut_buffer_internal)
(Fx_store_cut_buffer_internal, Fx_rotate_cut_buffers_internal): Don't do anything
if the selected frame is not an X frame.
src/xterm.c (x_display_method): Removed.
(x_create_frame_display, x_delete_frame_display): New functions for handling struct display objects.
(x_term_init): Set up a new struct display object, too.
(x_delete_display): Delete the struct display corresponding to the X display.
(x_initialize): Moved hook initialization to x_create_frame_display.
src/xterm.h (x_display_method): Removed.
(struct x_display_info): Added frame_display component.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-44
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Mon, 05 Jan 2004 05:54:35 +0000 |
parents | 039bd6989d29 |
children | 040dd41ed7d0 |
comparison
equal
deleted
inserted
replaced
83003:19208c3cbcc9 | 83004:7900111db01c |
---|---|
27 #include <string.h> | 27 #include <string.h> |
28 | 28 |
29 #include <sys/file.h> | 29 #include <sys/file.h> |
30 | 30 |
31 #include "lisp.h" | 31 #include "lisp.h" |
32 #include "systty.h" /* For emacs_tty in termchar.h */ | |
33 #include "termchar.h" | 32 #include "termchar.h" |
34 #include "termopts.h" | 33 #include "termopts.h" |
35 #include "charset.h" | 34 #include "charset.h" |
36 #include "coding.h" | 35 #include "coding.h" |
37 #include "keyboard.h" | 36 #include "keyboard.h" |
70 static void turn_on_face P_ ((struct frame *, int face_id)); | 69 static void turn_on_face P_ ((struct frame *, int face_id)); |
71 static void turn_off_face P_ ((struct frame *, int face_id)); | 70 static void turn_off_face P_ ((struct frame *, int face_id)); |
72 static void tty_show_cursor P_ ((struct tty_display_info *)); | 71 static void tty_show_cursor P_ ((struct tty_display_info *)); |
73 static void tty_hide_cursor P_ ((struct tty_display_info *)); | 72 static void tty_hide_cursor P_ ((struct tty_display_info *)); |
74 | 73 |
75 void delete_tty P_ ((struct tty_display_info *)); | 74 void delete_tty P_ ((struct display *)); |
76 static void delete_tty_1 P_ ((struct tty_display_info *)); | 75 void create_tty_output P_ ((struct frame *)); |
77 | 76 void delete_tty_output P_ ((struct frame *)); |
78 | 77 |
79 #define OUTPUT(tty, a) \ | 78 #define OUTPUT(tty, a) \ |
80 emacs_tputs ((tty), a, \ | 79 emacs_tputs ((tty), a, \ |
81 (int) (FRAME_LINES (XFRAME (selected_frame)) \ | 80 (int) (FRAME_LINES (XFRAME (selected_frame)) \ |
82 - curY (tty)), \ | 81 - curY (tty)), \ |
101 Lisp_Object Vring_bell_function; | 100 Lisp_Object Vring_bell_function; |
102 | 101 |
103 /* Functions to call after a tty was deleted. */ | 102 /* Functions to call after a tty was deleted. */ |
104 Lisp_Object Vdelete_tty_after_functions; | 103 Lisp_Object Vdelete_tty_after_functions; |
105 | 104 |
106 /* Terminal characteristics that higher levels want to look at. */ | 105 /* Chain of all displays currently in use. */ |
107 | 106 struct display *display_list; |
107 | |
108 /* Chain of all tty device parameters. */ | |
108 struct tty_display_info *tty_list; | 109 struct tty_display_info *tty_list; |
109 | 110 |
110 /* Nonzero means no need to redraw the entire frame on resuming a | 111 /* Nonzero means no need to redraw the entire frame on resuming a |
111 suspended Emacs. This is useful on terminals with multiple | 112 suspended Emacs. This is useful on terminals with multiple |
112 pages, where one page is used for Emacs and another for all | 113 pages, where one page is used for Emacs and another for all |
113 else. */ | 114 else. */ |
114 int no_redraw_on_reenter; | 115 int no_redraw_on_reenter; |
115 | 116 |
116 Lisp_Object Qframe_tty_name, Qframe_tty_type; | 117 Lisp_Object Qframe_tty_name, Qframe_tty_type; |
117 | 118 |
118 /* Hook functions that you can set to snap out the functions in this file. | |
119 These are all extern'd in termhooks.h */ | |
120 | |
121 void (*cursor_to_hook) P_ ((int, int)); | |
122 void (*raw_cursor_to_hook) P_ ((int, int)); | |
123 void (*clear_to_end_hook) P_ ((void)); | |
124 void (*clear_frame_hook) P_ ((void)); | |
125 void (*clear_end_of_line_hook) P_ ((int)); | |
126 | |
127 void (*ins_del_lines_hook) P_ ((int, int)); | |
128 | |
129 void (*delete_glyphs_hook) P_ ((int)); | |
130 | |
131 void (*ring_bell_hook) P_ ((void)); | |
132 | |
133 void (*reset_terminal_modes_hook) P_ ((void)); | |
134 void (*set_terminal_modes_hook) P_ ((void)); | |
135 void (*update_begin_hook) P_ ((struct frame *)); | |
136 void (*update_end_hook) P_ ((struct frame *)); | |
137 void (*set_terminal_window_hook) P_ ((int)); | |
138 void (*insert_glyphs_hook) P_ ((struct glyph *, int)); | |
139 void (*write_glyphs_hook) P_ ((struct glyph *, int)); | |
140 void (*delete_glyphs_hook) P_ ((int)); | |
141 | |
142 int (*read_socket_hook) P_ ((struct input_event *, int, int)); | |
143 | |
144 void (*frame_up_to_date_hook) P_ ((struct frame *)); | |
145 | |
146 /* Return the current position of the mouse. | |
147 | |
148 Set *f to the frame the mouse is in, or zero if the mouse is in no | |
149 Emacs frame. If it is set to zero, all the other arguments are | |
150 garbage. | |
151 | |
152 If the motion started in a scroll bar, set *bar_window to the | |
153 scroll bar's window, *part to the part the mouse is currently over, | |
154 *x to the position of the mouse along the scroll bar, and *y to the | |
155 overall length of the scroll bar. | |
156 | |
157 Otherwise, set *bar_window to Qnil, and *x and *y to the column and | |
158 row of the character cell the mouse is over. | |
159 | |
160 Set *time to the time the mouse was at the returned position. | |
161 | |
162 This should clear mouse_moved until the next motion | |
163 event arrives. */ | |
164 | |
165 void (*mouse_position_hook) P_ ((FRAME_PTR *f, int insist, | |
166 Lisp_Object *bar_window, | |
167 enum scroll_bar_part *part, | |
168 Lisp_Object *x, | |
169 Lisp_Object *y, | |
170 unsigned long *time)); | |
171 | |
172 /* When reading from a minibuffer in a different frame, Emacs wants | |
173 to shift the highlight from the selected frame to the mini-buffer's | |
174 frame; under X, this means it lies about where the focus is. | |
175 This hook tells the window system code to re-decide where to put | |
176 the highlight. */ | |
177 | |
178 void (*frame_rehighlight_hook) P_ ((FRAME_PTR f)); | |
179 | |
180 /* If we're displaying frames using a window system that can stack | |
181 frames on top of each other, this hook allows you to bring a frame | |
182 to the front, or bury it behind all the other windows. If this | |
183 hook is zero, that means the device we're displaying on doesn't | |
184 support overlapping frames, so there's no need to raise or lower | |
185 anything. | |
186 | |
187 If RAISE is non-zero, F is brought to the front, before all other | |
188 windows. If RAISE is zero, F is sent to the back, behind all other | |
189 windows. */ | |
190 | |
191 void (*frame_raise_lower_hook) P_ ((FRAME_PTR f, int raise)); | |
192 | |
193 /* Set the vertical scroll bar for WINDOW to have its upper left corner | |
194 at (TOP, LEFT), and be LENGTH rows high. Set its handle to | |
195 indicate that we are displaying PORTION characters out of a total | |
196 of WHOLE characters, starting at POSITION. If WINDOW doesn't yet | |
197 have a scroll bar, create one for it. */ | |
198 | |
199 void (*set_vertical_scroll_bar_hook) | |
200 P_ ((struct window *window, | |
201 int portion, int whole, int position)); | |
202 | |
203 | |
204 /* The following three hooks are used when we're doing a thorough | |
205 redisplay of the frame. We don't explicitly know which scroll bars | |
206 are going to be deleted, because keeping track of when windows go | |
207 away is a real pain - can you say set-window-configuration? | |
208 Instead, we just assert at the beginning of redisplay that *all* | |
209 scroll bars are to be removed, and then save scroll bars from the | |
210 fiery pit when we actually redisplay their window. */ | |
211 | |
212 /* Arrange for all scroll bars on FRAME to be removed at the next call | |
213 to `*judge_scroll_bars_hook'. A scroll bar may be spared if | |
214 `*redeem_scroll_bar_hook' is applied to its window before the judgment. | |
215 | |
216 This should be applied to each frame each time its window tree is | |
217 redisplayed, even if it is not displaying scroll bars at the moment; | |
218 if the HAS_SCROLL_BARS flag has just been turned off, only calling | |
219 this and the judge_scroll_bars_hook will get rid of them. | |
220 | |
221 If non-zero, this hook should be safe to apply to any frame, | |
222 whether or not it can support scroll bars, and whether or not it is | |
223 currently displaying them. */ | |
224 | |
225 void (*condemn_scroll_bars_hook) P_ ((FRAME_PTR frame)); | |
226 | |
227 /* Unmark WINDOW's scroll bar for deletion in this judgement cycle. | |
228 Note that it's okay to redeem a scroll bar that is not condemned. */ | |
229 | |
230 void (*redeem_scroll_bar_hook) P_ ((struct window *window)); | |
231 | |
232 /* Remove all scroll bars on FRAME that haven't been saved since the | |
233 last call to `*condemn_scroll_bars_hook'. | |
234 | |
235 This should be applied to each frame after each time its window | |
236 tree is redisplayed, even if it is not displaying scroll bars at the | |
237 moment; if the HAS_SCROLL_BARS flag has just been turned off, only | |
238 calling this and condemn_scroll_bars_hook will get rid of them. | |
239 | |
240 If non-zero, this hook should be safe to apply to any frame, | |
241 whether or not it can support scroll bars, and whether or not it is | |
242 currently displaying them. */ | |
243 | |
244 void (*judge_scroll_bars_hook) P_ ((FRAME_PTR FRAME)); | |
245 | 119 |
246 | 120 |
247 /* Meaning of bits in no_color_video. Each bit set means that the | 121 /* Meaning of bits in no_color_video. Each bit set means that the |
248 corresponding attribute cannot be combined with colors. */ | 122 corresponding attribute cannot be combined with colors. */ |
249 | 123 |
268 | 142 |
269 /* The largest frame height in any call to calculate_costs. */ | 143 /* The largest frame height in any call to calculate_costs. */ |
270 | 144 |
271 int max_frame_lines; | 145 int max_frame_lines; |
272 | 146 |
273 /* A template for tty display methods, with common values | |
274 preinitialized. */ | |
275 static struct display_method tty_display_method_template; | |
276 | |
277 /* Frame currently being redisplayed; 0 if not currently redisplaying. | 147 /* Frame currently being redisplayed; 0 if not currently redisplaying. |
278 (Direct output does not count). */ | 148 (Direct output does not count). */ |
279 | 149 |
280 FRAME_PTR updating_frame; | 150 FRAME_PTR updating_frame; |
281 | 151 |
321 | 191 |
322 call0 (function); | 192 call0 (function); |
323 | 193 |
324 Vring_bell_function = function; | 194 Vring_bell_function = function; |
325 } | 195 } |
326 else if (!FRAME_TERMCAP_P (f)) | 196 else if (FRAME_DISPLAY (f)->ring_bell_hook) |
327 (*ring_bell_hook) (); | 197 (*FRAME_DISPLAY (f)->ring_bell_hook) (); |
328 else { | 198 else { |
329 struct tty_display_info *tty = FRAME_TTY (f); | 199 struct tty_display_info *tty = FRAME_TTY (f); |
330 OUTPUT (tty, tty->TS_visible_bell && visible_bell ? tty->TS_visible_bell : tty->TS_bell); | 200 OUTPUT (tty, tty->TS_visible_bell && visible_bell ? tty->TS_visible_bell : tty->TS_bell); |
331 } | 201 } |
332 } | 202 } |
341 | 211 |
342 void | 212 void |
343 set_terminal_modes () | 213 set_terminal_modes () |
344 { | 214 { |
345 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | 215 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); |
346 if (FRAME_TERMCAP_P (f)) | 216 if (FRAME_DISPLAY (f)->set_terminal_modes_hook) |
217 (*FRAME_DISPLAY (f)->set_terminal_modes_hook) (); | |
218 else | |
347 tty_set_terminal_modes (FRAME_TTY (f)); | 219 tty_set_terminal_modes (FRAME_TTY (f)); |
348 else | |
349 (*set_terminal_modes_hook) (); | |
350 } | 220 } |
351 | 221 |
352 void tty_reset_terminal_modes (struct tty_display_info *tty) | 222 void tty_reset_terminal_modes (struct tty_display_info *tty) |
353 { | 223 { |
354 turn_off_highlight (tty); | 224 turn_off_highlight (tty); |
364 | 234 |
365 void | 235 void |
366 reset_terminal_modes () | 236 reset_terminal_modes () |
367 { | 237 { |
368 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | 238 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); |
369 if (FRAME_TERMCAP_P (f)) | 239 if (FRAME_DISPLAY (f)->reset_terminal_modes_hook) |
240 (*FRAME_DISPLAY (f)->reset_terminal_modes_hook) (); | |
241 else | |
370 tty_reset_terminal_modes (FRAME_TTY (f)); | 242 tty_reset_terminal_modes (FRAME_TTY (f)); |
371 else if (reset_terminal_modes_hook) | |
372 (*reset_terminal_modes_hook) (); | |
373 } | 243 } |
374 | 244 |
375 void | 245 void |
376 update_begin (f) | 246 update_begin (f) |
377 struct frame *f; | 247 struct frame *f; |
378 { | 248 { |
379 updating_frame = f; | 249 updating_frame = f; |
380 if (!FRAME_TERMCAP_P (f)) | 250 if (FRAME_DISPLAY (f)->update_begin_hook) |
381 update_begin_hook (f); | 251 (*FRAME_DISPLAY (f)->update_begin_hook) (f); |
382 } | 252 } |
383 | 253 |
384 void | 254 void |
385 update_end (f) | 255 update_end (f) |
386 struct frame *f; | 256 struct frame *f; |
387 { | 257 { |
388 if (FRAME_TERMCAP_P (f)) | 258 if (FRAME_DISPLAY (f)->update_end_hook) |
259 (*FRAME_DISPLAY (f)->update_end_hook) (f); | |
260 else if (FRAME_TERMCAP_P (f)) | |
389 { | 261 { |
390 struct tty_display_info *tty = FRAME_TTY (f); | 262 struct tty_display_info *tty = FRAME_TTY (f); |
391 if (!XWINDOW (selected_window)->cursor_off_p) | 263 if (!XWINDOW (selected_window)->cursor_off_p) |
392 tty_show_cursor (tty); | 264 tty_show_cursor (tty); |
393 turn_off_insert (tty); | 265 turn_off_insert (tty); |
394 background_highlight (tty); | 266 background_highlight (tty); |
395 } | 267 } |
396 else | |
397 update_end_hook (f); | |
398 | 268 |
399 updating_frame = NULL; | 269 updating_frame = NULL; |
400 } | 270 } |
401 | 271 |
402 void | 272 void |
403 set_terminal_window (size) | 273 set_terminal_window (size) |
404 int size; | 274 int size; |
405 { | 275 { |
406 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | 276 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); |
407 if (FRAME_TERMCAP_P (f)) | 277 if (FRAME_DISPLAY (f)->set_terminal_window_hook) |
278 (*FRAME_DISPLAY (f)->set_terminal_window_hook) (size); | |
279 else if (FRAME_TERMCAP_P (f)) | |
408 { | 280 { |
409 struct tty_display_info *tty = FRAME_TTY (f); | 281 struct tty_display_info *tty = FRAME_TTY (f); |
410 tty->specified_window = size ? size : FRAME_LINES (f); | 282 tty->specified_window = size ? size : FRAME_LINES (f); |
411 if (FRAME_SCROLL_REGION_OK (f)) | 283 if (FRAME_SCROLL_REGION_OK (f)) |
412 set_scroll_region (0, tty->specified_window); | 284 set_scroll_region (0, tty->specified_window); |
413 } | 285 } |
414 else | |
415 set_terminal_window_hook (size); | |
416 } | 286 } |
417 | 287 |
418 void | 288 void |
419 set_scroll_region (start, stop) | 289 set_scroll_region (start, stop) |
420 int start, stop; | 290 int start, stop; |
543 int vpos, hpos; | 413 int vpos, hpos; |
544 { | 414 { |
545 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | 415 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); |
546 struct tty_display_info *tty; | 416 struct tty_display_info *tty; |
547 | 417 |
548 if (! FRAME_TERMCAP_P (f) && cursor_to_hook) | 418 if (FRAME_DISPLAY (f)->cursor_to_hook) |
549 { | 419 { |
550 (*cursor_to_hook) (vpos, hpos); | 420 (*FRAME_DISPLAY (f)->cursor_to_hook) (vpos, hpos); |
551 return; | 421 return; |
552 } | 422 } |
553 | 423 |
554 tty = FRAME_TTY (f); | 424 tty = FRAME_TTY (f); |
555 | 425 |
574 raw_cursor_to (row, col) | 444 raw_cursor_to (row, col) |
575 int row, col; | 445 int row, col; |
576 { | 446 { |
577 struct frame *f = updating_frame ? updating_frame : XFRAME (selected_frame); | 447 struct frame *f = updating_frame ? updating_frame : XFRAME (selected_frame); |
578 struct tty_display_info *tty; | 448 struct tty_display_info *tty; |
579 if (! FRAME_TERMCAP_P (f)) | 449 if (FRAME_DISPLAY (f)->raw_cursor_to_hook) |
580 { | 450 { |
581 (*raw_cursor_to_hook) (row, col); | 451 (*FRAME_DISPLAY (f)->raw_cursor_to_hook) (row, col); |
582 return; | 452 return; |
583 } | 453 } |
584 tty = FRAME_TTY (f); | 454 tty = FRAME_TTY (f); |
585 if (curY (tty) == row | 455 if (curY (tty) == row |
586 && curX (tty) == col) | 456 && curX (tty) == col) |
601 register int i; | 471 register int i; |
602 | 472 |
603 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | 473 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); |
604 struct tty_display_info *tty; | 474 struct tty_display_info *tty; |
605 | 475 |
606 if (clear_to_end_hook && ! FRAME_TERMCAP_P (f)) | 476 if (FRAME_DISPLAY (f)->clear_to_end_hook) |
607 { | 477 { |
608 (*clear_to_end_hook) (); | 478 (*FRAME_DISPLAY (f)->clear_to_end_hook) (); |
609 return; | 479 return; |
610 } | 480 } |
611 tty = FRAME_TTY (f); | 481 tty = FRAME_TTY (f); |
612 if (tty->TS_clr_to_bottom) | 482 if (tty->TS_clr_to_bottom) |
613 { | 483 { |
630 clear_frame () | 500 clear_frame () |
631 { | 501 { |
632 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | 502 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); |
633 struct tty_display_info *tty; | 503 struct tty_display_info *tty; |
634 | 504 |
635 if (clear_frame_hook && ! FRAME_TERMCAP_P (f)) | 505 if (FRAME_DISPLAY (f)->clear_frame_hook) |
636 { | 506 { |
637 (*clear_frame_hook) (); | 507 (*FRAME_DISPLAY (f)->clear_frame_hook) (); |
638 return; | 508 return; |
639 } | 509 } |
640 tty = FRAME_TTY (f); | 510 tty = FRAME_TTY (f); |
641 if (tty->TS_clr_frame) | 511 if (tty->TS_clr_frame) |
642 { | 512 { |
661 int first_unused_hpos; | 531 int first_unused_hpos; |
662 { | 532 { |
663 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | 533 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); |
664 struct tty_display_info *tty; | 534 struct tty_display_info *tty; |
665 | 535 |
666 if (clear_end_of_line_hook && ! FRAME_TERMCAP_P (f)) | 536 if (FRAME_DISPLAY (f)->clear_end_of_line_hook) |
667 { | 537 { |
668 (*clear_end_of_line_hook) (first_unused_hpos); | 538 (*FRAME_DISPLAY (f)->clear_end_of_line_hook) (first_unused_hpos); |
669 return; | 539 return; |
670 } | 540 } |
671 | 541 |
672 tty_clear_end_of_line (FRAME_TTY (f), first_unused_hpos); | 542 tty_clear_end_of_line (FRAME_TTY (f), first_unused_hpos); |
673 } | 543 } |
826 struct frame *f = updating_frame ? updating_frame : XFRAME (selected_frame); | 696 struct frame *f = updating_frame ? updating_frame : XFRAME (selected_frame); |
827 struct tty_display_info *tty; | 697 struct tty_display_info *tty; |
828 unsigned char conversion_buffer[1024]; | 698 unsigned char conversion_buffer[1024]; |
829 int conversion_buffer_size = sizeof conversion_buffer; | 699 int conversion_buffer_size = sizeof conversion_buffer; |
830 | 700 |
831 if (write_glyphs_hook && ! FRAME_TERMCAP_P (f)) | 701 if (FRAME_DISPLAY (f)->write_glyphs_hook) |
832 { | 702 { |
833 (*write_glyphs_hook) (string, len); | 703 (*FRAME_DISPLAY (f)->write_glyphs_hook) (string, len); |
834 return; | 704 return; |
835 } | 705 } |
836 | 706 |
837 tty = FRAME_TTY (f); | 707 tty = FRAME_TTY (f); |
838 | 708 |
933 if (len <= 0) | 803 if (len <= 0) |
934 return; | 804 return; |
935 | 805 |
936 f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | 806 f = (updating_frame ? updating_frame : XFRAME (selected_frame)); |
937 | 807 |
938 if (insert_glyphs_hook && ! FRAME_TERMCAP_P (f)) | 808 if (FRAME_DISPLAY (f)->insert_glyphs_hook) |
939 { | 809 { |
940 (*insert_glyphs_hook) (start, len); | 810 (*FRAME_DISPLAY (f)->insert_glyphs_hook) (start, len); |
941 return; | 811 return; |
942 } | 812 } |
943 | 813 |
944 tty = FRAME_TTY (f); | 814 tty = FRAME_TTY (f); |
945 | 815 |
1022 char *buf; | 892 char *buf; |
1023 register int i; | 893 register int i; |
1024 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | 894 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); |
1025 struct tty_display_info *tty = FRAME_TTY (f); | 895 struct tty_display_info *tty = FRAME_TTY (f); |
1026 | 896 |
1027 if (delete_glyphs_hook && ! FRAME_TERMCAP_P (f)) | 897 if (FRAME_DISPLAY (f)->delete_glyphs_hook) |
1028 { | 898 { |
1029 (*delete_glyphs_hook) (n); | 899 (*FRAME_DISPLAY (f)->delete_glyphs_hook) (n); |
1030 return; | 900 return; |
1031 } | 901 } |
1032 | 902 |
1033 | 903 |
1034 if (tty->delete_in_insert_mode) | 904 if (tty->delete_in_insert_mode) |
1059 void | 929 void |
1060 ins_del_lines (vpos, n) | 930 ins_del_lines (vpos, n) |
1061 int vpos, n; | 931 int vpos, n; |
1062 { | 932 { |
1063 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | 933 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); |
1064 if (ins_del_lines_hook && ! FRAME_TERMCAP_P (f)) | 934 if (FRAME_DISPLAY (f)->ins_del_lines_hook) |
1065 { | 935 { |
1066 (*ins_del_lines_hook) (vpos, n); | 936 (*FRAME_DISPLAY (f)->ins_del_lines_hook) (vpos, n); |
1067 return; | 937 return; |
1068 } | 938 } |
1069 else | 939 else |
1070 { | 940 { |
1071 struct tty_display_info *tty = FRAME_TTY (f); | 941 struct tty_display_info *tty = FRAME_TTY (f); |
1946 0, 1, 0, | 1816 0, 1, 0, |
1947 doc: /* Return non-nil if TTY can display colors on DISPLAY. */) | 1817 doc: /* Return non-nil if TTY can display colors on DISPLAY. */) |
1948 (display) | 1818 (display) |
1949 Lisp_Object display; | 1819 Lisp_Object display; |
1950 { | 1820 { |
1951 struct tty_display_info *tty = FRAME_TTY (SELECTED_FRAME ()); | 1821 struct tty_display_info *tty; |
1822 | |
1823 if (! FRAMEP (display)) | |
1824 return Qnil; | |
1825 | |
1826 tty = FRAME_TTY (XFRAME (display)); | |
1952 return tty->TN_max_colors > 0 ? Qt : Qnil; | 1827 return tty->TN_max_colors > 0 ? Qt : Qnil; |
1953 } | 1828 } |
1954 | 1829 |
1955 /* Return the number of supported colors. */ | 1830 /* Return the number of supported colors. */ |
1956 DEFUN ("tty-display-color-cells", Ftty_display_color_cells, | 1831 DEFUN ("tty-display-color-cells", Ftty_display_color_cells, |
1957 Stty_display_color_cells, 0, 1, 0, | 1832 Stty_display_color_cells, 0, 1, 0, |
1958 doc: /* Return the number of colors supported by TTY on DISPLAY. */) | 1833 doc: /* Return the number of colors supported by TTY on DISPLAY. */) |
1959 (display) | 1834 (display) |
1960 Lisp_Object display; | 1835 Lisp_Object display; |
1961 { | 1836 { |
1962 struct tty_display_info *tty = FRAME_TTY (SELECTED_FRAME ()); | 1837 struct tty_display_info *tty; |
1838 | |
1839 if (! FRAMEP (display)) | |
1840 return Qnil; | |
1841 | |
1842 tty = FRAME_TTY (XFRAME (display)); | |
1963 return make_number (tty->TN_max_colors); | 1843 return make_number (tty->TN_max_colors); |
1964 } | 1844 } |
1965 | 1845 |
1966 #ifndef WINDOWSNT | 1846 #ifndef WINDOWSNT |
1967 | 1847 |
2100 | 1980 |
2101 #endif /* !WINDOWSNT */ | 1981 #endif /* !WINDOWSNT */ |
2102 | 1982 |
2103 | 1983 |
2104 | 1984 |
2105 struct tty_display_info * | 1985 static struct display * |
2106 get_named_tty (name) | 1986 get_named_tty_display (name) |
2107 char *name; | 1987 char *name; |
2108 { | 1988 { |
2109 struct tty_display_info *tty = tty_list; | 1989 struct display *d; |
2110 | 1990 |
2111 while (tty) { | 1991 for (d = display_list; d; d = d->next_display) { |
2112 if ((tty->name == 0 && name == 0) | 1992 if (d->type == output_termcap |
2113 || (name && tty->name && !strcmp (tty->name, name))) | 1993 && ((d->display_info.tty->name == 0 && name == 0) |
2114 return tty; | 1994 || (name && d->display_info.tty->name |
2115 tty = tty->next; | 1995 && !strcmp (d->display_info.tty->name, name)))) |
1996 return d; | |
2116 }; | 1997 }; |
2117 | 1998 |
2118 return 0; | 1999 return 0; |
2119 } | 2000 } |
2120 | 2001 |
2175 | 2056 |
2176 /*********************************************************************** | 2057 /*********************************************************************** |
2177 Initialization | 2058 Initialization |
2178 ***********************************************************************/ | 2059 ***********************************************************************/ |
2179 | 2060 |
2180 struct tty_display_info * | 2061 struct display * |
2181 term_dummy_init (void) | 2062 initial_term_init (void) |
2182 { | 2063 { |
2183 if (initialized || tty_list) | 2064 if (initialized || display_list || tty_list) |
2184 error ("tty already initialized"); | 2065 abort (); |
2066 | |
2067 display_list = create_display (); | |
2185 | 2068 |
2186 tty_list = xmalloc (sizeof (struct tty_display_info)); | 2069 tty_list = xmalloc (sizeof (struct tty_display_info)); |
2187 bzero (tty_list, sizeof (struct tty_display_info)); | 2070 bzero (tty_list, sizeof (struct tty_display_info)); |
2188 tty_list->name = 0; | 2071 tty_list->name = 0; |
2189 tty_list->input = stdin; | 2072 tty_list->input = stdin; |
2190 tty_list->output = stdout; | 2073 tty_list->output = stdout; |
2191 tty_list->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); | 2074 tty_list->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); |
2192 tty_list->display_method = (struct display_method *) xmalloc (sizeof (struct display_method)); | 2075 #ifdef MULTI_KBOARD |
2193 tty_list->kboard = initial_kboard; | 2076 tty_list->kboard = initial_kboard; |
2194 return tty_list; | 2077 #endif |
2195 } | 2078 |
2196 | 2079 display_list->type = output_termcap; |
2197 | 2080 display_list->display_info.tty = tty_list; |
2198 struct tty_display_info * | 2081 |
2199 term_init (Lisp_Object frame, char *name, char *terminal_type) | 2082 return display_list; |
2083 } | |
2084 | |
2085 | |
2086 struct display * | |
2087 term_init (char *name, char *terminal_type) | |
2200 { | 2088 { |
2201 char *area; | 2089 char *area; |
2202 char **address = &area; | 2090 char **address = &area; |
2203 char *buffer = NULL; | 2091 char *buffer = NULL; |
2204 int buffer_size = 4096; | 2092 int buffer_size = 4096; |
2205 register char *p; | 2093 register char *p; |
2206 int status; | 2094 int status; |
2207 struct frame *f = XFRAME (frame); | |
2208 struct tty_display_info *tty; | 2095 struct tty_display_info *tty; |
2209 | 2096 struct display *display; |
2210 tty = get_named_tty (name); | 2097 |
2211 if (tty) | 2098 display = get_named_tty_display (name); |
2212 { | 2099 if (display) |
2100 { | |
2101 tty = display->display_info.tty; | |
2102 | |
2213 /* Return the previously initialized terminal, except if it is | 2103 /* Return the previously initialized terminal, except if it is |
2214 the dummy terminal created for the initial frame. */ | 2104 the dummy terminal created for the initial frame. */ |
2215 if (tty->type) | 2105 if (tty->type) |
2216 return tty; | 2106 return display; |
2217 | 2107 |
2218 /* Free up temporary structures. */ | 2108 /* Free up temporary structures. */ |
2219 if (tty->Wcm) | 2109 if (tty->Wcm) |
2220 xfree (tty->Wcm); | 2110 xfree (tty->Wcm); |
2221 if (tty->display_method) | |
2222 xfree (tty->display_method); | |
2223 if (tty->kboard != initial_kboard) | 2111 if (tty->kboard != initial_kboard) |
2224 abort (); | 2112 abort (); |
2225 tty->kboard = 0; | 2113 tty->kboard = 0; |
2226 } | 2114 } |
2227 else | 2115 else |
2228 { | 2116 { |
2117 display = create_display (); | |
2229 tty = (struct tty_display_info *) xmalloc (sizeof (struct tty_display_info)); | 2118 tty = (struct tty_display_info *) xmalloc (sizeof (struct tty_display_info)); |
2230 bzero (tty, sizeof (struct tty_display_info)); | 2119 bzero (tty, sizeof (struct tty_display_info)); |
2231 tty->next = tty_list; | 2120 tty->next = tty_list; |
2232 tty_list = tty; | 2121 tty_list = tty; |
2122 | |
2123 display->type = output_termcap; | |
2124 display->display_info.tty = tty; | |
2233 } | 2125 } |
2234 | 2126 |
2235 tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); | 2127 tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); |
2236 Wcm_clear (tty); | 2128 Wcm_clear (tty); |
2237 | 2129 |
2238 /* Each termcap frame has its own display method. */ | 2130 display->rif = 0; /* ttys don't support window-based redisplay. */ |
2239 tty->display_method = (struct display_method *) xmalloc (sizeof (struct display_method)); | 2131 display->delete_frame_hook = &delete_tty_output; |
2240 bzero (tty->display_method, sizeof (struct display_method)); | 2132 display->delete_display_hook = &delete_tty; |
2241 | 2133 |
2242 /* Initialize the common members in the new display method with our | |
2243 predefined template. */ | |
2244 *tty->display_method = tty_display_method_template; | |
2245 f->display_method = tty->display_method; | |
2246 | |
2247 /* Make sure the frame is live; if an error happens, it must be | |
2248 deleted. */ | |
2249 f->output_method = output_termcap; | |
2250 if (! f->output_data.tty) | |
2251 abort (); | |
2252 f->output_data.tty->display_info = tty; | |
2253 if (name) | 2134 if (name) |
2254 { | 2135 { |
2255 int fd; | 2136 int fd; |
2256 FILE *file; | 2137 FILE *file; |
2257 fd = emacs_open (name, O_RDWR, 0); | 2138 fd = emacs_open (name, O_RDWR, 0); |
2258 if (fd < 0) | 2139 if (fd < 0) |
2259 { | 2140 { |
2260 delete_tty (tty); | 2141 delete_tty (display); |
2261 error ("Could not open file: %s", name); | 2142 error ("Could not open file: %s", name); |
2262 } | 2143 } |
2263 file = fdopen (fd, "w+"); | 2144 file = fdopen (fd, "w+"); |
2264 tty->name = xstrdup (name); | 2145 tty->name = xstrdup (name); |
2265 tty->input = file; | 2146 tty->input = file; |
2281 | 2162 |
2282 Wcm_clear (tty); | 2163 Wcm_clear (tty); |
2283 | 2164 |
2284 area = (char *) xmalloc (2044); | 2165 area = (char *) xmalloc (2044); |
2285 | 2166 |
2286 FrameRows (tty) = FRAME_LINES (f); | 2167 FrameRows (tty) = FRAME_LINES (f); /* XXX */ |
2287 FrameCols (tty) = FRAME_COLS (f); | 2168 FrameCols (tty) = FRAME_COLS (f); /* XXX */ |
2288 tty->specified_window = FRAME_LINES (f); | 2169 tty->specified_window = FRAME_LINES (f); /* XXX */ |
2289 | 2170 |
2290 tty->display_method->delete_in_insert_mode = 1; | 2171 tty->display->delete_in_insert_mode = 1; |
2291 | 2172 |
2292 UseTabs (tty) = 0; | 2173 UseTabs (tty) = 0; |
2293 FRAME_SCROLL_REGION_OK (f) = 0; | 2174 display->scroll_region_ok = 0; |
2294 | 2175 |
2295 /* Seems to insert lines when it's not supposed to, messing | 2176 /* Seems to insert lines when it's not supposed to, messing |
2296 up the display. In doing a trace, it didn't seem to be | 2177 up the display. In doing a trace, it didn't seem to be |
2297 called much, so I don't think we're losing anything by | 2178 called much, so I don't think we're losing anything by |
2298 turning it off. */ | 2179 turning it off. */ |
2299 FRAME_LINE_INS_DEL_OK (f) = 0; | 2180 display->line_ins_del_ok = 0; |
2300 FRAME_CHAR_INS_DEL_OK (f) = 1; | 2181 display->char_ins_del_ok = 1; |
2301 | 2182 |
2302 baud_rate = 19200; | 2183 baud_rate = 19200; |
2303 | 2184 |
2304 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; | 2185 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; /* XXX */ |
2305 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; | 2186 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; /* XXX */ |
2306 TN_max_colors = 16; /* Required to be non-zero for tty-display-color-p */ | 2187 TN_max_colors = 16; /* Required to be non-zero for tty-display-color-p */ |
2307 | 2188 |
2308 return tty; | 2189 return display; |
2309 #else /* not WINDOWSNT */ | 2190 #else /* not WINDOWSNT */ |
2310 | 2191 |
2311 Wcm_clear (tty); | 2192 Wcm_clear (tty); |
2312 | 2193 |
2313 buffer = (char *) xmalloc (buffer_size); | 2194 buffer = (char *) xmalloc (buffer_size); |
2316 { | 2197 { |
2317 #ifdef TERMINFO | 2198 #ifdef TERMINFO |
2318 if (name) | 2199 if (name) |
2319 { | 2200 { |
2320 xfree (buffer); | 2201 xfree (buffer); |
2321 delete_tty (tty); | 2202 delete_tty (display); |
2322 error ("Cannot open terminfo database file"); | 2203 error ("Cannot open terminfo database file"); |
2323 } | 2204 } |
2324 else | 2205 else |
2325 fatal ("Cannot open terminfo database file"); | 2206 fatal ("Cannot open terminfo database file"); |
2326 #else | 2207 #else |
2327 if (name) | 2208 if (name) |
2328 { | 2209 { |
2329 xfree (buffer); | 2210 xfree (buffer); |
2330 delete_tty (tty); | 2211 delete_tty (display); |
2331 error ("Cannot open termcap database file"); | 2212 error ("Cannot open termcap database file"); |
2332 } | 2213 } |
2333 else | 2214 else |
2334 fatal ("Cannot open termcap database file"); | 2215 fatal ("Cannot open termcap database file"); |
2335 #endif | 2216 #endif |
2338 { | 2219 { |
2339 #ifdef TERMINFO | 2220 #ifdef TERMINFO |
2340 if (name) | 2221 if (name) |
2341 { | 2222 { |
2342 xfree (buffer); | 2223 xfree (buffer); |
2343 delete_tty (tty); | 2224 delete_tty (display); |
2344 error ("Terminal type %s is not defined", terminal_type); | 2225 error ("Terminal type %s is not defined", terminal_type); |
2345 } | 2226 } |
2346 else | 2227 else |
2347 fatal ("Terminal type %s is not defined.\n\ | 2228 fatal ("Terminal type %s is not defined.\n\ |
2348 If that is not the actual type of terminal you have,\n\ | 2229 If that is not the actual type of terminal you have,\n\ |
2352 terminal_type); | 2233 terminal_type); |
2353 #else | 2234 #else |
2354 if (name) | 2235 if (name) |
2355 { | 2236 { |
2356 xfree (buffer); | 2237 xfree (buffer); |
2357 delete_tty (tty); | 2238 delete_tty (display); |
2358 error ("Terminal type %s is not defined", terminal_type); | 2239 error ("Terminal type %s is not defined", terminal_type); |
2359 } | 2240 } |
2360 else | 2241 else |
2361 fatal ("Terminal type %s is not defined.\n\ | 2242 fatal ("Terminal type %s is not defined.\n\ |
2362 If that is not the actual type of terminal you have,\n\ | 2243 If that is not the actual type of terminal you have,\n\ |
2476 | 2357 |
2477 MagicWrap (tty) = tgetflag ("xn"); | 2358 MagicWrap (tty) = tgetflag ("xn"); |
2478 /* Since we make MagicWrap terminals look like AutoWrap, we need to have | 2359 /* Since we make MagicWrap terminals look like AutoWrap, we need to have |
2479 the former flag imply the latter. */ | 2360 the former flag imply the latter. */ |
2480 AutoWrap (tty) = MagicWrap (tty) || tgetflag ("am"); | 2361 AutoWrap (tty) = MagicWrap (tty) || tgetflag ("am"); |
2481 FRAME_MEMORY_BELOW_FRAME (f) = tgetflag ("db"); | 2362 display->memory_below_frame = tgetflag ("db"); |
2482 tty->TF_hazeltine = tgetflag ("hz"); | 2363 tty->TF_hazeltine = tgetflag ("hz"); |
2483 FRAME_MUST_WRITE_SPACES (f) = tgetflag ("in"); | 2364 display->must_write_spaces = tgetflag ("in"); |
2484 tty->meta_key = tgetflag ("km") || tgetflag ("MT"); | 2365 tty->meta_key = tgetflag ("km") || tgetflag ("MT"); |
2485 tty->TF_insmode_motion = tgetflag ("mi"); | 2366 tty->TF_insmode_motion = tgetflag ("mi"); |
2486 tty->TF_standout_motion = tgetflag ("ms"); | 2367 tty->TF_standout_motion = tgetflag ("ms"); |
2487 tty->TF_underscore = tgetflag ("ul"); | 2368 tty->TF_underscore = tgetflag ("ul"); |
2488 tty->TF_teleray = tgetflag ("xt"); | 2369 tty->TF_teleray = tgetflag ("xt"); |
2504 | 2385 |
2505 if (FrameRows (tty) < 3 || FrameCols (tty) < 3) | 2386 if (FrameRows (tty) < 3 || FrameCols (tty) < 3) |
2506 { | 2387 { |
2507 if (initialized) | 2388 if (initialized) |
2508 { | 2389 { |
2509 delete_tty (tty); | 2390 delete_tty (display); |
2510 error ("Screen size %dx%d is too small", | 2391 error ("Screen size %dx%d is too small", |
2511 FrameCols (tty), FrameRows (tty)); | 2392 FrameCols (tty), FrameRows (tty)); |
2512 } | 2393 } |
2513 else | 2394 else |
2514 { | 2395 { |
2516 FrameCols (tty), FrameRows (tty)); | 2397 FrameCols (tty), FrameRows (tty)); |
2517 } | 2398 } |
2518 } | 2399 } |
2519 | 2400 |
2520 #if 0 /* This is not used anywhere. */ | 2401 #if 0 /* This is not used anywhere. */ |
2521 tty->display_method->min_padding_speed = tgetnum ("pb"); | 2402 tty->display->min_padding_speed = tgetnum ("pb"); |
2522 #endif | 2403 #endif |
2523 | 2404 |
2524 TabWidth (tty) = tgetnum ("tw"); | 2405 TabWidth (tty) = tgetnum ("tw"); |
2525 | 2406 |
2526 #ifdef VMS | 2407 #ifdef VMS |
2594 | 2475 |
2595 /* Special handling for certain terminal types known to need it */ | 2476 /* Special handling for certain terminal types known to need it */ |
2596 | 2477 |
2597 if (!strcmp (terminal_type, "supdup")) | 2478 if (!strcmp (terminal_type, "supdup")) |
2598 { | 2479 { |
2599 FRAME_MEMORY_BELOW_FRAME (f) = 1; | 2480 display->memory_below_frame = 1; |
2600 tty->Wcm->cm_losewrap = 1; | 2481 tty->Wcm->cm_losewrap = 1; |
2601 } | 2482 } |
2602 if (!strncmp (terminal_type, "c10", 3) | 2483 if (!strncmp (terminal_type, "c10", 3) |
2603 || !strcmp (terminal_type, "perq")) | 2484 || !strcmp (terminal_type, "perq")) |
2604 { | 2485 { |
2621 p++; | 2502 p++; |
2622 if (*p) | 2503 if (*p) |
2623 tty->TS_set_window = "\033v%C %C %C %C "; | 2504 tty->TS_set_window = "\033v%C %C %C %C "; |
2624 } | 2505 } |
2625 /* Termcap entry often fails to have :in: flag */ | 2506 /* Termcap entry often fails to have :in: flag */ |
2626 FRAME_MUST_WRITE_SPACES (f) = 1; | 2507 display->must_write_spaces = 1; |
2627 /* :ti string typically fails to have \E^G! in it */ | 2508 /* :ti string typically fails to have \E^G! in it */ |
2628 /* This limits scope of insert-char to one line. */ | 2509 /* This limits scope of insert-char to one line. */ |
2629 strcpy (area, tty->TS_termcap_modes); | 2510 strcpy (area, tty->TS_termcap_modes); |
2630 strcat (area, "\033\007!"); | 2511 strcat (area, "\033\007!"); |
2631 tty->TS_termcap_modes = area; | 2512 tty->TS_termcap_modes = area; |
2644 tty->specified_window = FrameRows (tty); | 2525 tty->specified_window = FrameRows (tty); |
2645 | 2526 |
2646 if (Wcm_init (tty) == -1) /* can't do cursor motion */ | 2527 if (Wcm_init (tty) == -1) /* can't do cursor motion */ |
2647 if (name) | 2528 if (name) |
2648 { | 2529 { |
2649 delete_tty (tty); | 2530 delete_tty (display); |
2650 error ("Terminal type \"%s\" is not powerful enough to run Emacs", | 2531 error ("Terminal type \"%s\" is not powerful enough to run Emacs", |
2651 terminal_type); | 2532 terminal_type); |
2652 } | 2533 } |
2653 else { | 2534 else { |
2654 #ifdef VMS | 2535 #ifdef VMS |
2681 | 2562 |
2682 if (FrameRows (tty) <= 0 || FrameCols (tty) <= 0) | 2563 if (FrameRows (tty) <= 0 || FrameCols (tty) <= 0) |
2683 { | 2564 { |
2684 if (name) | 2565 if (name) |
2685 { | 2566 { |
2686 delete_tty (tty); | 2567 delete_tty (display); |
2687 error ("The frame size has not been specified"); | 2568 error ("The frame size has not been specified"); |
2688 } | 2569 } |
2689 else | 2570 else |
2690 fatal ("The frame size has not been specified"); | 2571 fatal ("The frame size has not been specified"); |
2691 } | 2572 } |
2698 && tty->TS_end_standout_mode | 2579 && tty->TS_end_standout_mode |
2699 && !strcmp (tty->TS_standout_mode, tty->TS_end_standout_mode)); | 2580 && !strcmp (tty->TS_standout_mode, tty->TS_end_standout_mode)); |
2700 | 2581 |
2701 UseTabs (tty) = tabs_safe_p (fileno (TTY_INPUT (tty))) && TabWidth (tty) == 8; | 2582 UseTabs (tty) = tabs_safe_p (fileno (TTY_INPUT (tty))) && TabWidth (tty) == 8; |
2702 | 2583 |
2703 FRAME_SCROLL_REGION_OK (f) | 2584 display->scroll_region_ok |
2704 = (tty->Wcm->cm_abs | 2585 = (tty->Wcm->cm_abs |
2705 && (tty->TS_set_window || tty->TS_set_scroll_region || tty->TS_set_scroll_region_1)); | 2586 && (tty->TS_set_window || tty->TS_set_scroll_region || tty->TS_set_scroll_region_1)); |
2706 | 2587 |
2707 FRAME_LINE_INS_DEL_OK (f) | 2588 display->line_ins_del_ok |
2708 = (((tty->TS_ins_line || tty->TS_ins_multi_lines) | 2589 = (((tty->TS_ins_line || tty->TS_ins_multi_lines) |
2709 && (tty->TS_del_line || tty->TS_del_multi_lines)) | 2590 && (tty->TS_del_line || tty->TS_del_multi_lines)) |
2710 || (FRAME_SCROLL_REGION_OK (f) | 2591 || (display->scroll_region_ok |
2711 && tty->TS_fwd_scroll && tty->TS_rev_scroll)); | 2592 && tty->TS_fwd_scroll && tty->TS_rev_scroll)); |
2712 | 2593 |
2713 FRAME_CHAR_INS_DEL_OK (f) | 2594 display->char_ins_del_ok |
2714 = ((tty->TS_ins_char || tty->TS_insert_mode | 2595 = ((tty->TS_ins_char || tty->TS_insert_mode |
2715 || tty->TS_pad_inserted_char || tty->TS_ins_multi_chars) | 2596 || tty->TS_pad_inserted_char || tty->TS_ins_multi_chars) |
2716 && (tty->TS_del_char || tty->TS_del_multi_chars)); | 2597 && (tty->TS_del_char || tty->TS_del_multi_chars)); |
2717 | 2598 |
2718 FRAME_FAST_CLEAR_END_OF_LINE (f) = tty->TS_clr_line != 0; | 2599 display->fast_clear_end_of_line = tty->TS_clr_line != 0; |
2719 | 2600 |
2720 init_baud_rate (fileno (TTY_INPUT (tty))); | 2601 init_baud_rate (fileno (TTY_INPUT (tty))); |
2721 if (read_socket_hook) /* Baudrate is somewhat | 2602 |
2722 meaningless in this case */ | 2603 /* XXX This condition sounds bogus. */ |
2604 if (display->read_socket_hook) /* Baudrate is somewhat | |
2605 meaningless in this case */ | |
2723 baud_rate = 9600; | 2606 baud_rate = 9600; |
2724 | |
2725 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; | |
2726 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; | |
2727 | 2607 |
2728 #ifdef AIXHFT | 2608 #ifdef AIXHFT |
2729 /* The HFT system on AIX doesn't optimize for scrolling, so it's | 2609 /* The HFT system on AIX doesn't optimize for scrolling, so it's |
2730 really ugly at times. */ | 2610 really ugly at times. */ |
2731 FRAME_LINE_INS_DEL_OK (f) = 0; | 2611 display->line_ins_del_ok = 0; |
2732 FRAME_CHAR_INS_DEL_OK (f) = 0; | 2612 display->char_ins_del_ok = 0; |
2733 #endif | 2613 #endif |
2734 | 2614 |
2735 #ifdef MULTI_KBOARD | 2615 #ifdef MULTI_KBOARD |
2736 tty->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); | 2616 tty->kboard = (KBOARD *) xmalloc (sizeof (KBOARD)); |
2737 init_kboard (tty->kboard); | 2617 init_kboard (tty->kboard); |
2746 #endif | 2626 #endif |
2747 | 2627 |
2748 /* Don't do this. I think termcap may still need the buffer. */ | 2628 /* Don't do this. I think termcap may still need the buffer. */ |
2749 /* xfree (buffer); */ | 2629 /* xfree (buffer); */ |
2750 | 2630 |
2751 /* Set the top frame to the first frame on this display. */ | |
2752 tty->top_frame = frame; | |
2753 | |
2754 /* Init system terminal modes (RAW or CBREAK, etc.). */ | 2631 /* Init system terminal modes (RAW or CBREAK, etc.). */ |
2755 init_sys_modes (tty); | 2632 init_sys_modes (tty); |
2756 | 2633 |
2757 return tty; | 2634 return display; |
2758 #endif /* not WINDOWSNT */ | 2635 #endif /* not WINDOWSNT */ |
2759 } | 2636 } |
2760 | 2637 |
2761 /* VARARGS 1 */ | 2638 /* VARARGS 1 */ |
2762 void | 2639 void |
2779 This function runs `delete-tty-after-functions' after closing the | 2656 This function runs `delete-tty-after-functions' after closing the |
2780 tty. The functions are run with one arg, the frame to be deleted. */) | 2657 tty. The functions are run with one arg, the frame to be deleted. */) |
2781 (tty) | 2658 (tty) |
2782 Lisp_Object tty; | 2659 Lisp_Object tty; |
2783 { | 2660 { |
2784 struct tty_display_info *t; | 2661 struct display *d; |
2785 char *name = 0; | 2662 char *name = 0; |
2786 | 2663 |
2787 CHECK_STRING (tty); | 2664 CHECK_STRING (tty); |
2788 | 2665 |
2789 if (SBYTES (tty) > 0) | 2666 if (SBYTES (tty) > 0) |
2791 name = (char *) alloca (SBYTES (tty) + 1); | 2668 name = (char *) alloca (SBYTES (tty) + 1); |
2792 strncpy (name, SDATA (tty), SBYTES (tty)); | 2669 strncpy (name, SDATA (tty), SBYTES (tty)); |
2793 name[SBYTES (tty)] = 0; | 2670 name[SBYTES (tty)] = 0; |
2794 } | 2671 } |
2795 | 2672 |
2796 t = get_named_tty (name); | 2673 d = get_named_tty_display (name); |
2797 | 2674 |
2798 if (! t) | 2675 if (! d) |
2799 error ("No such tty device: %s", name); | 2676 error ("No such terminal device: %s", name); |
2800 | 2677 |
2801 delete_tty (t); | 2678 delete_tty (d); |
2802 } | 2679 } |
2803 | 2680 |
2804 static int deleting_tty = 0; | 2681 static int deleting_tty = 0; |
2805 | 2682 |
2806 void | 2683 void |
2807 delete_tty (struct tty_display_info *tty) | 2684 delete_tty (struct display *display) |
2808 { | 2685 { |
2686 struct tty_display_info *tty; | |
2809 Lisp_Object tail, frame; | 2687 Lisp_Object tail, frame; |
2810 char *tty_name; | 2688 char *tty_name; |
2811 | 2689 |
2812 if (deleting_tty) | 2690 if (deleting_tty) |
2813 /* We get a recursive call when we delete the last frame on this | 2691 /* We get a recursive call when we delete the last frame on this |
2814 tty. */ | 2692 display. */ |
2815 return; | 2693 return; |
2816 | 2694 |
2817 deleting_tty = 1; | 2695 deleting_tty = 1; |
2818 | 2696 |
2697 if (display->type != output_termcap) | |
2698 abort (); | |
2699 | |
2700 tty = display->display_info.tty; | |
2701 | |
2819 if (tty == tty_list) | 2702 if (tty == tty_list) |
2820 tty_list = tty->next; | 2703 tty_list = tty->next; |
2821 else | 2704 else |
2822 { | 2705 { |
2823 struct tty_display_info *p; | 2706 struct tty_display_info *p; |
2840 Fdelete_frame (frame, Qt); | 2723 Fdelete_frame (frame, Qt); |
2841 f->output_data.tty = 0; | 2724 f->output_data.tty = 0; |
2842 } | 2725 } |
2843 } | 2726 } |
2844 | 2727 |
2728 delete_display (display); | |
2729 | |
2845 reset_sys_modes (tty); | 2730 reset_sys_modes (tty); |
2846 | 2731 |
2847 tty_name = tty->name; | 2732 tty_name = tty->name; |
2848 if (tty->type) | 2733 if (tty->type) |
2849 xfree (tty->type); | 2734 xfree (tty->type); |
2862 if (tty->old_tty) | 2747 if (tty->old_tty) |
2863 xfree (tty->old_tty); | 2748 xfree (tty->old_tty); |
2864 | 2749 |
2865 if (tty->Wcm) | 2750 if (tty->Wcm) |
2866 xfree (tty->Wcm); | 2751 xfree (tty->Wcm); |
2867 | |
2868 if (tty->display_method) | |
2869 xfree (tty->display_method); | |
2870 | 2752 |
2871 #ifdef MULTI_KBOARD | 2753 #ifdef MULTI_KBOARD |
2872 if (tty->kboard && --tty->kboard->reference_count > 0) | 2754 if (tty->kboard && --tty->kboard->reference_count > 0) |
2873 abort (); | 2755 abort (); |
2874 if (tty->kboard) | 2756 if (tty->kboard) |
2893 args[1] = Qnil; | 2775 args[1] = Qnil; |
2894 Frun_hook_with_args (2, args); | 2776 Frun_hook_with_args (2, args); |
2895 } | 2777 } |
2896 } | 2778 } |
2897 | 2779 |
2780 | |
2781 | |
2782 /* Initialize the tty-dependent part of frame F. The frame must | |
2783 already have its display initialized. */ | |
2784 void | |
2785 create_tty_output (struct frame *f) | |
2786 { | |
2787 if (! FRAME_TERMCAP_P (f)) | |
2788 abort (); | |
2789 | |
2790 struct tty_output *t = xmalloc (sizeof (struct tty_output)); | |
2791 bzero (t, sizeof (struct tty_output)); | |
2792 | |
2793 t->display_info = FRAME_DISPLAY (f)->display_info.tty; | |
2794 | |
2795 f->output_data.tty = t; | |
2796 } | |
2797 | |
2798 /* Delete the tty-dependent part of frame F. */ | |
2799 void | |
2800 delete_tty_output (struct frame *f) | |
2801 { | |
2802 if (! FRAME_TERMCAP_P (f)) | |
2803 abort (); | |
2804 | |
2805 xfree (f->output_data.tty); | |
2806 } | |
2807 | |
2898 | 2808 |
2899 | 2809 |
2900 | 2810 |
2901 /* Mark the pointers in the tty_display_info objects. | 2811 /* Mark the pointers in the tty_display_info objects. |
2902 Called by the Fgarbage_collector. */ | 2812 Called by the Fgarbage_collector. */ |
2908 for (tty = tty_list; tty; tty = tty->next) | 2818 for (tty = tty_list; tty; tty = tty->next) |
2909 { | 2819 { |
2910 if (tty->top_frame) | 2820 if (tty->top_frame) |
2911 mark_object (tty->top_frame); | 2821 mark_object (tty->top_frame); |
2912 } | 2822 } |
2823 } | |
2824 | |
2825 | |
2826 | |
2827 /* Create a new display object and add it to the display list. */ | |
2828 struct display * | |
2829 create_display (void) | |
2830 { | |
2831 struct display *dev = (struct display *) xmalloc (sizeof (struct display)); | |
2832 | |
2833 bzero (dev, sizeof (struct display)); | |
2834 dev->next_display = display_list; | |
2835 display_list = dev; | |
2836 | |
2837 return dev; | |
2838 } | |
2839 | |
2840 /* Remove a display from the display list and free its memory. */ | |
2841 void | |
2842 delete_display (struct display *dev) | |
2843 { | |
2844 struct display **dp; | |
2845 for (dp = &display_list; *dp != dev; dp = &(*dp)->next_display) | |
2846 if (! *dp) | |
2847 abort (); | |
2848 *dp = dev->next_display; | |
2849 | |
2850 bzero (dev, sizeof (struct display)); | |
2851 xfree (dev); | |
2913 } | 2852 } |
2914 | 2853 |
2915 | 2854 |
2916 | 2855 |
2917 void | 2856 void |
2949 defsubr (&Sframe_tty_type); | 2888 defsubr (&Sframe_tty_type); |
2950 defsubr (&Sdelete_tty); | 2889 defsubr (&Sdelete_tty); |
2951 | 2890 |
2952 Fprovide (intern ("multi-tty"), Qnil); | 2891 Fprovide (intern ("multi-tty"), Qnil); |
2953 | 2892 |
2954 /* Initialize the display method template. */ | |
2955 | |
2956 /* Termcap-based displays don't support window-based redisplay. */ | |
2957 tty_display_method_template.rif = 0; | |
2958 | |
2959 } | 2893 } |
2960 | 2894 |
2961 | 2895 |
2962 | 2896 |
2963 /* arch-tag: 498e7449-6f2e-45e2-91dd-b7d4ca488193 | 2897 /* arch-tag: 498e7449-6f2e-45e2-91dd-b7d4ca488193 |