Mercurial > emacs
comparison src/term.c @ 82990:2ecd1f669db9
Fixed X support, preliminary support for X-tty combo sessions.
lib-src/emacsclient.c (copy_from_to, pty_conversation): Re-added SIGIO
hack. (Sigh.)
lisp/frame.el (make-frame-on-tty): Use make-terminal-frame, not
make-frame.
src/dispnew.c (line_hash_code, line_draw_cost): Updated to use
the new display_method parameters.
(Fredraw_frame): fflush the tty only if f is a termcap frame.
(direct_output_for_insert): Updated to use the new display_method
parameters. fflush the tty only if f is a termcap frame.
(direct_output_forward_char, update_frame_1, scrolling): Ditto.
(update_frame_line, Fding, bitch_at_user): Ditto.
(Fsend_string_to_terminal): Fail if current frame is not on a tty.
(init_display): Frame size change is safe here.
src/frame.c (Vterminal_frame): Restored previously deleted variable.
(syms_of_frame): Initialize it.
(make_terminal_frame): Copy the frame's display_method from tty_display_info.
(Fmake_terminal_frame): Enable simultaneous X and tty frames (buggy).
(Fredirect_frame_focus): Don't call frame_rehighlight_hook if frame
is on a termcap device.
src/frame.h (struct frame): Renamed display to display_method.
(Vterminal_frame): Re-added declaration.
src/keyboard.c (flow_control): Moved to struct tty_display_info.
(read_avail_input): Check ttys even if there is a read_socket_hook.
(Fset_input_mode): Call reset_sys_modes/init_sys_modes and set
flow_control or meta_key only when the frame is a termcap frame.
(Fcurrent_input_mode): Handle flow_control and meta_key right on
non-termcap frames.
src/scroll.c (calculate_scrolling, calculate_direct_scrolling): Update
to use the new display_method parameters.
(scrolling_1, scroll_cost): Ditto.
src/sysdep.c (init_sys_modes, reset_sys_modes): Always set the
terminal parameters if tty_out->input is not stdin. Updated to the
new location of flow_control.
(hft_init): Moved HFT init code to term_init, as it needs the frame.
src/term.c (tty_display_method_template): New variable.
(update_begin): Added rif hack.
(set_terminal_window, ins_del_lines, term_init): Updated to use the
new display_method parameters.
(insert_glyphs, ins_del_lines): Only call insert_glyphs_hook if the
current frame is not on a tty.
(calculate_costs): Don't calculate costs if not on a tty.
(term_dummy_init): Fixed tty->output initialization. Preallocate Wcm
and display_method.
(term_init): Allocate & initialize display_method. Blindly fixed
WINDOWSNT-specific parts. Added HFT-specific initialization
exception from hft_init.
(delete_tty): Only delete termcap frames. Free() the display_method.
src/termchar.h (struct tty_display_info): Moved high-level terminal
characteristics to struct display_method. Added flow_control and
display_method members.
src/termhooks.h (struct display_method): New struct (renamed from
struct device). Added accessor macros.
src/window.c (init_window_once): Initialize Vterminal_frame.
src/xdisp.c (init_iterator, expose_frame): Added rif hack.
(try_window_id): Updated to use the new display_method parameters.
src/xfaces.c (realize_basic_faces): Don't call
x_update_menu_appearance if the frame is a tty frame.
src/xfns.c (Fx_create_frame): Added rif hack. Initialize
display_method.
(x_create_tip_frame): Initialize display_method.
src/xterm.c (x_display_method): New variable.
(x_flush, x_frame_of_widget, XTmouse_position): Ignore non-X frames.
(x_window_to_scroll_bar, x_window_to_menu_bar): Ditto.
(xim_destroy_callback, xim_instantiate_callback): Ditto.
(frame_highlight, frame_unhighlight): Added rif hack.
(x_initialize): Don't initialize rif. Do initialize x_display_method.
src/xterm.h (x_display_method): New declaration.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-30
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Fri, 02 Jan 2004 01:15:26 +0000 |
parents | f3845715a5f6 |
children | 2b26656ff804 |
comparison
equal
deleted
inserted
replaced
82989:f3845715a5f6 | 82990:2ecd1f669db9 |
---|---|
265 | 265 |
266 /* The largest frame height in any call to calculate_costs. */ | 266 /* The largest frame height in any call to calculate_costs. */ |
267 | 267 |
268 int max_frame_lines; | 268 int max_frame_lines; |
269 | 269 |
270 /* A template for tty display methods, with common values | |
271 preinitialized. */ | |
272 static struct display_method tty_display_method_template; | |
273 | |
270 /* Frame currently being redisplayed; 0 if not currently redisplaying. | 274 /* Frame currently being redisplayed; 0 if not currently redisplaying. |
271 (Direct output does not count). */ | 275 (Direct output does not count). */ |
272 | 276 |
273 FRAME_PTR updating_frame; | 277 FRAME_PTR updating_frame; |
274 | 278 |
368 void | 372 void |
369 update_begin (f) | 373 update_begin (f) |
370 struct frame *f; | 374 struct frame *f; |
371 { | 375 { |
372 updating_frame = f; | 376 updating_frame = f; |
377 /* XXX rif hack */ | |
378 rif = f->display_method->rif; | |
373 if (!FRAME_TERMCAP_P (f)) | 379 if (!FRAME_TERMCAP_P (f)) |
374 update_begin_hook (f); | 380 update_begin_hook (f); |
375 } | 381 } |
376 | 382 |
377 void | 383 void |
399 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | 405 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); |
400 if (FRAME_TERMCAP_P (f)) | 406 if (FRAME_TERMCAP_P (f)) |
401 { | 407 { |
402 struct tty_display_info *tty = FRAME_TTY (f); | 408 struct tty_display_info *tty = FRAME_TTY (f); |
403 tty->specified_window = size ? size : FRAME_LINES (f); | 409 tty->specified_window = size ? size : FRAME_LINES (f); |
404 if (TTY_SCROLL_REGION_OK (tty)) | 410 if (FRAME_SCROLL_REGION_OK (f)) |
405 set_scroll_region (0, tty->specified_window); | 411 set_scroll_region (0, tty->specified_window); |
406 } | 412 } |
407 else | 413 else |
408 set_terminal_window_hook (size); | 414 set_terminal_window_hook (size); |
409 } | 415 } |
535 cursor_to (vpos, hpos) | 541 cursor_to (vpos, hpos) |
536 int vpos, hpos; | 542 int vpos, hpos; |
537 { | 543 { |
538 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | 544 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); |
539 struct tty_display_info *tty; | 545 struct tty_display_info *tty; |
540 | 546 |
541 if (! FRAME_TERMCAP_P (f) && cursor_to_hook) | 547 if (! FRAME_TERMCAP_P (f) && cursor_to_hook) |
542 { | 548 { |
543 (*cursor_to_hook) (vpos, hpos); | 549 (*cursor_to_hook) (vpos, hpos); |
544 return; | 550 return; |
545 } | 551 } |
593 { | 599 { |
594 register int i; | 600 register int i; |
595 | 601 |
596 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | 602 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); |
597 struct tty_display_info *tty; | 603 struct tty_display_info *tty; |
598 | 604 |
599 if (clear_to_end_hook && ! FRAME_TERMCAP_P (f)) | 605 if (clear_to_end_hook && ! FRAME_TERMCAP_P (f)) |
600 { | 606 { |
601 (*clear_to_end_hook) (); | 607 (*clear_to_end_hook) (); |
602 return; | 608 return; |
603 } | 609 } |
622 void | 628 void |
623 clear_frame () | 629 clear_frame () |
624 { | 630 { |
625 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | 631 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); |
626 struct tty_display_info *tty; | 632 struct tty_display_info *tty; |
627 | 633 |
628 if (clear_frame_hook && ! FRAME_TERMCAP_P (f)) | 634 if (clear_frame_hook && ! FRAME_TERMCAP_P (f)) |
629 { | 635 { |
630 (*clear_frame_hook) (); | 636 (*clear_frame_hook) (); |
631 return; | 637 return; |
632 } | 638 } |
653 clear_end_of_line (first_unused_hpos) | 659 clear_end_of_line (first_unused_hpos) |
654 int first_unused_hpos; | 660 int first_unused_hpos; |
655 { | 661 { |
656 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | 662 struct frame *f = (updating_frame ? updating_frame : XFRAME (selected_frame)); |
657 struct tty_display_info *tty; | 663 struct tty_display_info *tty; |
658 | 664 |
659 if (clear_end_of_line_hook | 665 if (clear_end_of_line_hook && ! FRAME_TERMCAP_P (f)) |
660 && ! FRAME_TERMCAP_P (f)) | |
661 { | 666 { |
662 (*clear_end_of_line_hook) (first_unused_hpos); | 667 (*clear_end_of_line_hook) (first_unused_hpos); |
663 return; | 668 return; |
664 } | 669 } |
665 | 670 |
820 struct frame *f = updating_frame ? updating_frame : XFRAME (selected_frame); | 825 struct frame *f = updating_frame ? updating_frame : XFRAME (selected_frame); |
821 struct tty_display_info *tty; | 826 struct tty_display_info *tty; |
822 unsigned char conversion_buffer[1024]; | 827 unsigned char conversion_buffer[1024]; |
823 int conversion_buffer_size = sizeof conversion_buffer; | 828 int conversion_buffer_size = sizeof conversion_buffer; |
824 | 829 |
825 if (write_glyphs_hook | 830 if (write_glyphs_hook && ! FRAME_TERMCAP_P (f)) |
826 && ! FRAME_TERMCAP_P (f)) | |
827 { | 831 { |
828 (*write_glyphs_hook) (string, len); | 832 (*write_glyphs_hook) (string, len); |
829 return; | 833 return; |
830 } | 834 } |
831 | 835 |
922 { | 926 { |
923 char *buf; | 927 char *buf; |
924 struct glyph *glyph = NULL; | 928 struct glyph *glyph = NULL; |
925 struct frame *f; | 929 struct frame *f; |
926 struct tty_display_info *tty; | 930 struct tty_display_info *tty; |
927 | 931 |
928 if (len <= 0) | 932 if (len <= 0) |
929 return; | 933 return; |
930 | 934 |
931 if (insert_glyphs_hook) | 935 f = (updating_frame ? updating_frame : XFRAME (selected_frame)); |
936 | |
937 if (insert_glyphs_hook && ! FRAME_TERMCAP_P (f)) | |
932 { | 938 { |
933 (*insert_glyphs_hook) (start, len); | 939 (*insert_glyphs_hook) (start, len); |
934 return; | 940 return; |
935 } | 941 } |
936 | 942 |
937 f = (updating_frame ? updating_frame : XFRAME (selected_frame)); | |
938 tty = FRAME_TTY (f); | 943 tty = FRAME_TTY (f); |
939 | 944 |
940 if (tty->TS_ins_multi_chars) | 945 if (tty->TS_ins_multi_chars) |
941 { | 946 { |
942 buf = tparam (tty->TS_ins_multi_chars, 0, 0, len); | 947 buf = tparam (tty->TS_ins_multi_chars, 0, 0, len); |
1032 else | 1037 else |
1033 { | 1038 { |
1034 turn_off_insert (tty); | 1039 turn_off_insert (tty); |
1035 OUTPUT_IF (tty, tty->TS_delete_mode); | 1040 OUTPUT_IF (tty, tty->TS_delete_mode); |
1036 } | 1041 } |
1037 | 1042 |
1038 if (tty->TS_del_multi_chars) | 1043 if (tty->TS_del_multi_chars) |
1039 { | 1044 { |
1040 buf = tparam (tty->TS_del_multi_chars, 0, 0, n); | 1045 buf = tparam (tty->TS_del_multi_chars, 0, 0, n); |
1041 OUTPUT1 (tty, buf); | 1046 OUTPUT1 (tty, buf); |
1042 xfree (buf); | 1047 xfree (buf); |
1064 { | 1069 { |
1065 struct tty_display_info *tty = FRAME_TTY (f); | 1070 struct tty_display_info *tty = FRAME_TTY (f); |
1066 char *multi = n > 0 ? tty->TS_ins_multi_lines : tty->TS_del_multi_lines; | 1071 char *multi = n > 0 ? tty->TS_ins_multi_lines : tty->TS_del_multi_lines; |
1067 char *single = n > 0 ? tty->TS_ins_line : tty->TS_del_line; | 1072 char *single = n > 0 ? tty->TS_ins_line : tty->TS_del_line; |
1068 char *scroll = n > 0 ? tty->TS_rev_scroll : tty->TS_fwd_scroll; | 1073 char *scroll = n > 0 ? tty->TS_rev_scroll : tty->TS_fwd_scroll; |
1069 | 1074 |
1070 register int i = n > 0 ? n : -n; | 1075 register int i = n > 0 ? n : -n; |
1071 register char *buf; | 1076 register char *buf; |
1072 | 1077 |
1073 /* If the lines below the insertion are being pushed | 1078 /* If the lines below the insertion are being pushed |
1074 into the end of the window, this is the same as clearing; | 1079 into the end of the window, this is the same as clearing; |
1075 and we know the lines are already clear, since the matching | 1080 and we know the lines are already clear, since the matching |
1076 deletion has already been done. So can ignore this. */ | 1081 deletion has already been done. So can ignore this. */ |
1077 /* If the lines below the deletion are blank lines coming | 1082 /* If the lines below the deletion are blank lines coming |
1078 out of the end of the window, don't bother, | 1083 out of the end of the window, don't bother, |
1079 as there will be a matching inslines later that will flush them. */ | 1084 as there will be a matching inslines later that will flush them. */ |
1080 if (TTY_SCROLL_REGION_OK (tty) | 1085 if (FRAME_SCROLL_REGION_OK (f) |
1081 && vpos + i >= tty->specified_window) | 1086 && vpos + i >= tty->specified_window) |
1082 return; | 1087 return; |
1083 if (!TTY_MEMORY_BELOW_FRAME (tty) | 1088 if (!FRAME_MEMORY_BELOW_FRAME (f) |
1084 && vpos + i >= FRAME_LINES (f)) | 1089 && vpos + i >= FRAME_LINES (f)) |
1085 return; | 1090 return; |
1086 | 1091 |
1087 if (multi) | 1092 if (multi) |
1088 { | 1093 { |
1089 raw_cursor_to (vpos, 0); | 1094 raw_cursor_to (vpos, 0); |
1090 background_highlight (tty); | 1095 background_highlight (tty); |
1091 buf = tparam (multi, 0, 0, i); | 1096 buf = tparam (multi, 0, 0, i); |
1111 background_highlight (tty); | 1116 background_highlight (tty); |
1112 while (--i >= 0) | 1117 while (--i >= 0) |
1113 OUTPUTL (tty, scroll, tty->specified_window - vpos); | 1118 OUTPUTL (tty, scroll, tty->specified_window - vpos); |
1114 set_scroll_region (0, tty->specified_window); | 1119 set_scroll_region (0, tty->specified_window); |
1115 } | 1120 } |
1116 | 1121 |
1117 if (!TTY_SCROLL_REGION_OK (tty) | 1122 if (!FRAME_SCROLL_REGION_OK (f) |
1118 && TTY_MEMORY_BELOW_FRAME (tty) | 1123 && FRAME_MEMORY_BELOW_FRAME (f) |
1119 && n < 0) | 1124 && n < 0) |
1120 { | 1125 { |
1121 cursor_to (FRAME_LINES (f) + n, 0); | 1126 cursor_to (FRAME_LINES (f) + n, 0); |
1122 clear_to_end (); | 1127 clear_to_end (); |
1123 } | 1128 } |
1241 | 1246 |
1242 void | 1247 void |
1243 calculate_costs (frame) | 1248 calculate_costs (frame) |
1244 FRAME_PTR frame; | 1249 FRAME_PTR frame; |
1245 { | 1250 { |
1246 struct tty_display_info *tty = FRAME_TTY (frame); | |
1247 register char *f = (tty->TS_set_scroll_region | |
1248 ? tty->TS_set_scroll_region | |
1249 : tty->TS_set_scroll_region_1); | |
1250 | |
1251 FRAME_COST_BAUD_RATE (frame) = baud_rate; | 1251 FRAME_COST_BAUD_RATE (frame) = baud_rate; |
1252 | 1252 |
1253 if (FRAME_TERMCAP_P (frame)) | 1253 if (FRAME_TERMCAP_P (frame)) |
1254 TTY_SCROLL_REGION_COST (FRAME_TTY (frame)) = string_cost (f); | 1254 { |
1255 | 1255 struct tty_display_info *tty = FRAME_TTY (frame); |
1256 /* These variables are only used for terminal stuff. They are allocated | 1256 register char *f = (tty->TS_set_scroll_region |
1257 once for the terminal frame of X-windows emacs, but not used afterwards. | 1257 ? tty->TS_set_scroll_region |
1258 | 1258 : tty->TS_set_scroll_region_1); |
1259 char_ins_del_vector (i.e., char_ins_del_cost) isn't used because | 1259 |
1260 X turns off char_ins_del_ok. */ | 1260 FRAME_SCROLL_REGION_COST (frame) = string_cost (f); |
1261 | 1261 |
1262 max_frame_lines = max (max_frame_lines, FRAME_LINES (frame)); | 1262 tty->costs_set = 1; |
1263 max_frame_cols = max (max_frame_cols, FRAME_COLS (frame)); | 1263 |
1264 | 1264 /* These variables are only used for terminal stuff. They are |
1265 tty->costs_set = 1; | 1265 allocated once for the terminal frame of X-windows emacs, but not |
1266 | 1266 used afterwards. |
1267 if (char_ins_del_vector != 0) | 1267 |
1268 char_ins_del_vector | 1268 char_ins_del_vector (i.e., char_ins_del_cost) isn't used because |
1269 = (int *) xrealloc (char_ins_del_vector, | 1269 X turns off char_ins_del_ok. */ |
1270 (sizeof (int) | 1270 |
1271 + 2 * max_frame_cols * sizeof (int))); | 1271 max_frame_lines = max (max_frame_lines, FRAME_LINES (frame)); |
1272 else | 1272 max_frame_cols = max (max_frame_cols, FRAME_COLS (frame)); |
1273 char_ins_del_vector | 1273 |
1274 = (int *) xmalloc (sizeof (int) | 1274 if (char_ins_del_vector != 0) |
1275 + 2 * max_frame_cols * sizeof (int)); | 1275 char_ins_del_vector |
1276 | 1276 = (int *) xrealloc (char_ins_del_vector, |
1277 bzero (char_ins_del_vector, (sizeof (int) | 1277 (sizeof (int) |
1278 + 2 * max_frame_cols * sizeof (int))); | 1278 + 2 * max_frame_cols * sizeof (int))); |
1279 | 1279 else |
1280 if (f && (!tty->TS_ins_line && !tty->TS_del_line)) | 1280 char_ins_del_vector |
1281 do_line_insertion_deletion_costs (frame, | 1281 = (int *) xmalloc (sizeof (int) |
1282 tty->TS_rev_scroll, tty->TS_ins_multi_lines, | 1282 + 2 * max_frame_cols * sizeof (int)); |
1283 tty->TS_fwd_scroll, tty->TS_del_multi_lines, | 1283 |
1284 f, f, 1); | 1284 bzero (char_ins_del_vector, (sizeof (int) |
1285 else | 1285 + 2 * max_frame_cols * sizeof (int))); |
1286 do_line_insertion_deletion_costs (frame, | 1286 |
1287 tty->TS_ins_line, tty->TS_ins_multi_lines, | 1287 |
1288 tty->TS_del_line, tty->TS_del_multi_lines, | 1288 if (f && (!tty->TS_ins_line && !tty->TS_del_line)) |
1289 0, 0, 1); | 1289 do_line_insertion_deletion_costs (frame, |
1290 | 1290 tty->TS_rev_scroll, tty->TS_ins_multi_lines, |
1291 calculate_ins_del_char_costs (frame); | 1291 tty->TS_fwd_scroll, tty->TS_del_multi_lines, |
1292 | 1292 f, f, 1); |
1293 /* Don't use TS_repeat if its padding is worse than sending the chars */ | 1293 else |
1294 if (tty->TS_repeat && per_line_cost (tty->TS_repeat) * baud_rate < 9000) | 1294 do_line_insertion_deletion_costs (frame, |
1295 tty->RPov = string_cost (tty->TS_repeat); | 1295 tty->TS_ins_line, tty->TS_ins_multi_lines, |
1296 else | 1296 tty->TS_del_line, tty->TS_del_multi_lines, |
1297 tty->RPov = FRAME_COLS (frame) * 2; | 1297 0, 0, 1); |
1298 | 1298 |
1299 cmcostinit (FRAME_TTY (frame)); /* set up cursor motion costs */ | 1299 calculate_ins_del_char_costs (frame); |
1300 | |
1301 /* Don't use TS_repeat if its padding is worse than sending the chars */ | |
1302 if (tty->TS_repeat && per_line_cost (tty->TS_repeat) * baud_rate < 9000) | |
1303 tty->RPov = string_cost (tty->TS_repeat); | |
1304 else | |
1305 tty->RPov = FRAME_COLS (frame) * 2; | |
1306 | |
1307 cmcostinit (FRAME_TTY (frame)); /* set up cursor motion costs */ | |
1308 } | |
1300 } | 1309 } |
1301 | 1310 |
1302 struct fkey_table { | 1311 struct fkey_table { |
1303 char *cap, *name; | 1312 char *cap, *name; |
1304 }; | 1313 }; |
2140 doc: /* Return the type of the TTY device that FRAME is displayed on. */) | 2149 doc: /* Return the type of the TTY device that FRAME is displayed on. */) |
2141 (frame) | 2150 (frame) |
2142 Lisp_Object frame; | 2151 Lisp_Object frame; |
2143 { | 2152 { |
2144 struct frame *f; | 2153 struct frame *f; |
2145 | 2154 |
2146 if (NILP (frame)) | 2155 if (NILP (frame)) |
2147 { | 2156 { |
2148 f = XFRAME (selected_frame); | 2157 f = XFRAME (selected_frame); |
2149 } | 2158 } |
2150 else | 2159 else |
2175 | 2184 |
2176 tty_list = xmalloc (sizeof (struct tty_display_info)); | 2185 tty_list = xmalloc (sizeof (struct tty_display_info)); |
2177 bzero (tty_list, sizeof (struct tty_display_info)); | 2186 bzero (tty_list, sizeof (struct tty_display_info)); |
2178 tty_list->name = 0; | 2187 tty_list->name = 0; |
2179 tty_list->input = stdin; | 2188 tty_list->input = stdin; |
2180 tty_list->input = stdout; | 2189 tty_list->output = stdout; |
2190 tty_list->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); | |
2191 tty_list->display_method = (struct display_method *) xmalloc (sizeof (struct display_method)); | |
2181 return tty_list; | 2192 return tty_list; |
2182 } | 2193 } |
2183 | 2194 |
2184 | 2195 |
2185 struct tty_display_info * | 2196 struct tty_display_info * |
2209 tty->next = tty_list; | 2220 tty->next = tty_list; |
2210 tty_list = tty; | 2221 tty_list = tty; |
2211 } | 2222 } |
2212 | 2223 |
2213 if (! tty->Wcm) | 2224 if (! tty->Wcm) |
2214 tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); | 2225 tty->Wcm = (struct cm *) xmalloc (sizeof (struct cm)); |
2226 | |
2227 if (! tty->display_method) | |
2228 tty->display_method = (struct display_method *) xmalloc (sizeof (struct display_method)); | |
2229 | |
2230 /* Initialize the common members in the new display method with our | |
2231 predefined template. */ | |
2232 *tty->display_method = tty_display_method_template; | |
2233 f->display_method = tty->display_method; | |
2234 | |
2235 /* Termcap-based displays don't support window-based redisplay. */ | |
2236 f->display_method->rif = 0; | |
2215 | 2237 |
2216 /* Make sure the frame is live; if an error happens, it must be | 2238 /* Make sure the frame is live; if an error happens, it must be |
2217 deleted. */ | 2239 deleted. */ |
2218 f->output_method = output_termcap; | 2240 f->output_method = output_termcap; |
2219 if (! f->output_data.tty) | 2241 if (! f->output_data.tty) |
2220 abort (); | 2242 abort (); |
2221 f->output_data.tty->display_info = tty; | 2243 f->output_data.tty->display_info = tty; |
2222 | |
2223 if (name) | 2244 if (name) |
2224 { | 2245 { |
2225 int fd; | 2246 int fd; |
2226 FILE *file; | 2247 FILE *file; |
2227 fd = emacs_open (name, O_RDWR, 0); | 2248 fd = emacs_open (name, O_RDWR, 0); |
2243 } | 2264 } |
2244 | 2265 |
2245 tty->type = xstrdup (terminal_type); | 2266 tty->type = xstrdup (terminal_type); |
2246 | 2267 |
2247 add_keyboard_wait_descriptor (fileno (tty->input)); | 2268 add_keyboard_wait_descriptor (fileno (tty->input)); |
2248 | 2269 |
2249 #ifdef WINDOWSNT | 2270 #ifdef WINDOWSNT |
2250 initialize_w32_display (); | 2271 initialize_w32_display (); |
2251 | 2272 |
2252 Wcm_clear (tty); | 2273 Wcm_clear (tty); |
2253 | 2274 |
2254 area = (char *) xmalloc (2044); | 2275 area = (char *) xmalloc (2044); |
2255 | 2276 |
2256 FrameRows = FRAME_LINES (f); | 2277 FrameRows (tty) = FRAME_LINES (f); |
2257 FrameCols = FRAME_COLS (f); | 2278 FrameCols (tty) = FRAME_COLS (f); |
2258 specified_window = FRAME_LINES (f); | 2279 tty->specified_window = FRAME_LINES (f); |
2259 | 2280 |
2260 delete_in_insert_mode = 1; | 2281 f->display_method->delete_in_insert_mode = 1; |
2261 | 2282 |
2262 UseTabs = 0; | 2283 UseTabs (tty) = 0; |
2263 TTY_SCROLL_REGION_OK (tty) = 0; | 2284 FRAME_SCROLL_REGION_OK (f) = 0; |
2264 | 2285 |
2265 /* Seems to insert lines when it's not supposed to, messing | 2286 /* Seems to insert lines when it's not supposed to, messing |
2266 up the display. In doing a trace, it didn't seem to be | 2287 up the display. In doing a trace, it didn't seem to be |
2267 called much, so I don't think we're losing anything by | 2288 called much, so I don't think we're losing anything by |
2268 turning it off. */ | 2289 turning it off. */ |
2269 TTY_LINE_INS_DEL_OK (tty) = 0; | 2290 FRAME_LINE_INS_DEL_OK (f) = 0; |
2270 | 2291 FRAME_CHAR_INS_DEL_OK (f) = 1; |
2271 TTY_CHAR_INS_DEL_OK (tty) = 1; | |
2272 | 2292 |
2273 baud_rate = 19200; | 2293 baud_rate = 19200; |
2274 | 2294 |
2275 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; | 2295 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; |
2276 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; | 2296 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; |
2447 | 2467 |
2448 MagicWrap (tty) = tgetflag ("xn"); | 2468 MagicWrap (tty) = tgetflag ("xn"); |
2449 /* Since we make MagicWrap terminals look like AutoWrap, we need to have | 2469 /* Since we make MagicWrap terminals look like AutoWrap, we need to have |
2450 the former flag imply the latter. */ | 2470 the former flag imply the latter. */ |
2451 AutoWrap (tty) = MagicWrap (tty) || tgetflag ("am"); | 2471 AutoWrap (tty) = MagicWrap (tty) || tgetflag ("am"); |
2452 TTY_MEMORY_BELOW_FRAME (tty) = tgetflag ("db"); | 2472 FRAME_MEMORY_BELOW_FRAME (f) = tgetflag ("db"); |
2453 tty->TF_hazeltine = tgetflag ("hz"); | 2473 tty->TF_hazeltine = tgetflag ("hz"); |
2454 TTY_MUST_WRITE_SPACES (tty) = tgetflag ("in"); | 2474 FRAME_MUST_WRITE_SPACES (f) = tgetflag ("in"); |
2455 tty->meta_key = tgetflag ("km") || tgetflag ("MT"); | 2475 tty->meta_key = tgetflag ("km") || tgetflag ("MT"); |
2456 tty->TF_insmode_motion = tgetflag ("mi"); | 2476 tty->TF_insmode_motion = tgetflag ("mi"); |
2457 tty->TF_standout_motion = tgetflag ("ms"); | 2477 tty->TF_standout_motion = tgetflag ("ms"); |
2458 tty->TF_underscore = tgetflag ("ul"); | 2478 tty->TF_underscore = tgetflag ("ul"); |
2459 tty->TF_teleray = tgetflag ("xt"); | 2479 tty->TF_teleray = tgetflag ("xt"); |
2487 FrameCols (tty), FrameRows (tty)); | 2507 FrameCols (tty), FrameRows (tty)); |
2488 } | 2508 } |
2489 } | 2509 } |
2490 | 2510 |
2491 #if 0 /* This is not used anywhere. */ | 2511 #if 0 /* This is not used anywhere. */ |
2492 TTY_MIN_PADDING_SPEED (tty) = tgetnum ("pb"); | 2512 f->display_method->min_padding_speed = tgetnum ("pb"); |
2493 #endif | 2513 #endif |
2494 | 2514 |
2495 TabWidth (tty) = tgetnum ("tw"); | 2515 TabWidth (tty) = tgetnum ("tw"); |
2496 | 2516 |
2497 #ifdef VMS | 2517 #ifdef VMS |
2565 | 2585 |
2566 /* Special handling for certain terminal types known to need it */ | 2586 /* Special handling for certain terminal types known to need it */ |
2567 | 2587 |
2568 if (!strcmp (terminal_type, "supdup")) | 2588 if (!strcmp (terminal_type, "supdup")) |
2569 { | 2589 { |
2570 TTY_MEMORY_BELOW_FRAME (tty) = 1; | 2590 FRAME_MEMORY_BELOW_FRAME (f) = 1; |
2571 tty->Wcm->cm_losewrap = 1; | 2591 tty->Wcm->cm_losewrap = 1; |
2572 } | 2592 } |
2573 if (!strncmp (terminal_type, "c10", 3) | 2593 if (!strncmp (terminal_type, "c10", 3) |
2574 || !strcmp (terminal_type, "perq")) | 2594 || !strcmp (terminal_type, "perq")) |
2575 { | 2595 { |
2576 /* Supply a makeshift :wi string. | 2596 /* Supply a makeshift :wi string. |
2577 This string is not valid in general since it works only | 2597 This string is not valid in general since it works only |
2578 for windows starting at the upper left corner; | 2598 for windows starting at the upper left corner; |
2579 but that is all Emacs uses. | 2599 but that is all Emacs uses. |
2580 | 2600 |
2581 This string works only if the frame is using | 2601 This string works only if the frame is using |
2582 the top of the video memory, because addressing is memory-relative. | 2602 the top of the video memory, because addressing is memory-relative. |
2583 So first check the :ti string to see if that is true. | 2603 So first check the :ti string to see if that is true. |
2584 | 2604 |
2585 It would be simpler if the :wi string could go in the termcap | 2605 It would be simpler if the :wi string could go in the termcap |
2592 p++; | 2612 p++; |
2593 if (*p) | 2613 if (*p) |
2594 tty->TS_set_window = "\033v%C %C %C %C "; | 2614 tty->TS_set_window = "\033v%C %C %C %C "; |
2595 } | 2615 } |
2596 /* Termcap entry often fails to have :in: flag */ | 2616 /* Termcap entry often fails to have :in: flag */ |
2597 TTY_MUST_WRITE_SPACES (tty) = 1; | 2617 FRAME_MUST_WRITE_SPACES (f) = 1; |
2598 /* :ti string typically fails to have \E^G! in it */ | 2618 /* :ti string typically fails to have \E^G! in it */ |
2599 /* This limits scope of insert-char to one line. */ | 2619 /* This limits scope of insert-char to one line. */ |
2600 strcpy (area, tty->TS_termcap_modes); | 2620 strcpy (area, tty->TS_termcap_modes); |
2601 strcat (area, "\033\007!"); | 2621 strcat (area, "\033\007!"); |
2602 tty->TS_termcap_modes = area; | 2622 tty->TS_termcap_modes = area; |
2647 to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", | 2667 to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", |
2648 terminal_type); | 2668 terminal_type); |
2649 # endif /* TERMINFO */ | 2669 # endif /* TERMINFO */ |
2650 #endif /*VMS */ | 2670 #endif /*VMS */ |
2651 } | 2671 } |
2652 | 2672 |
2653 if (FrameRows (tty) <= 0 || FrameCols (tty) <= 0) | 2673 if (FrameRows (tty) <= 0 || FrameCols (tty) <= 0) |
2654 { | 2674 { |
2655 if (name) | 2675 if (name) |
2656 { | 2676 { |
2657 delete_tty (tty); | 2677 delete_tty (tty); |
2669 && tty->TS_end_standout_mode | 2689 && tty->TS_end_standout_mode |
2670 && !strcmp (tty->TS_standout_mode, tty->TS_end_standout_mode)); | 2690 && !strcmp (tty->TS_standout_mode, tty->TS_end_standout_mode)); |
2671 | 2691 |
2672 UseTabs (tty) = tabs_safe_p (fileno (TTY_INPUT (tty))) && TabWidth (tty) == 8; | 2692 UseTabs (tty) = tabs_safe_p (fileno (TTY_INPUT (tty))) && TabWidth (tty) == 8; |
2673 | 2693 |
2674 TTY_SCROLL_REGION_OK (tty) | 2694 FRAME_SCROLL_REGION_OK (f) |
2675 = (tty->Wcm->cm_abs | 2695 = (tty->Wcm->cm_abs |
2676 && (tty->TS_set_window || tty->TS_set_scroll_region || tty->TS_set_scroll_region_1)); | 2696 && (tty->TS_set_window || tty->TS_set_scroll_region || tty->TS_set_scroll_region_1)); |
2677 | 2697 |
2678 TTY_LINE_INS_DEL_OK (tty) | 2698 FRAME_LINE_INS_DEL_OK (f) |
2679 = (((tty->TS_ins_line || tty->TS_ins_multi_lines) | 2699 = (((tty->TS_ins_line || tty->TS_ins_multi_lines) |
2680 && (tty->TS_del_line || tty->TS_del_multi_lines)) | 2700 && (tty->TS_del_line || tty->TS_del_multi_lines)) |
2681 || (TTY_SCROLL_REGION_OK (tty) | 2701 || (FRAME_SCROLL_REGION_OK (f) |
2682 && tty->TS_fwd_scroll && tty->TS_rev_scroll)); | 2702 && tty->TS_fwd_scroll && tty->TS_rev_scroll)); |
2683 | 2703 |
2684 TTY_CHAR_INS_DEL_OK (tty) | 2704 FRAME_CHAR_INS_DEL_OK (f) |
2685 = ((tty->TS_ins_char || tty->TS_insert_mode | 2705 = ((tty->TS_ins_char || tty->TS_insert_mode |
2686 || tty->TS_pad_inserted_char || tty->TS_ins_multi_chars) | 2706 || tty->TS_pad_inserted_char || tty->TS_ins_multi_chars) |
2687 && (tty->TS_del_char || tty->TS_del_multi_chars)); | 2707 && (tty->TS_del_char || tty->TS_del_multi_chars)); |
2688 | 2708 |
2689 TTY_FAST_CLEAR_END_OF_LINE (tty) = tty->TS_clr_line != 0; | 2709 FRAME_FAST_CLEAR_END_OF_LINE (f) = tty->TS_clr_line != 0; |
2690 | 2710 |
2691 init_baud_rate (fileno (TTY_INPUT (tty))); | 2711 init_baud_rate (fileno (TTY_INPUT (tty))); |
2692 if (read_socket_hook) /* Baudrate is somewhat | 2712 if (read_socket_hook) /* Baudrate is somewhat |
2693 meaningless in this case */ | 2713 meaningless in this case */ |
2694 baud_rate = 9600; | 2714 baud_rate = 9600; |
2695 | 2715 |
2696 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; | 2716 FRAME_CAN_HAVE_SCROLL_BARS (f) = 0; |
2697 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; | 2717 FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none; |
2698 | 2718 |
2719 #ifdef AIXHFT | |
2720 /* The HFT system on AIX doesn't optimize for scrolling, so it's | |
2721 really ugly at times. */ | |
2722 FRAME_LINE_INS_DEL_OK (f) = 0; | |
2723 FRAME_CHAR_INS_DEL_OK (f) = 0; | |
2724 #endif | |
2725 | |
2699 /* Don't do this. I think termcap may still need the buffer. */ | 2726 /* Don't do this. I think termcap may still need the buffer. */ |
2700 /* xfree (buffer); */ | 2727 /* xfree (buffer); */ |
2701 | 2728 |
2729 /* Set the top frame to the first frame on this display. */ | |
2702 tty->top_frame = frame; | 2730 tty->top_frame = frame; |
2703 | 2731 |
2704 /* Init system terminal modes (RAW or CBREAK, etc.). */ | 2732 /* Init system terminal modes (RAW or CBREAK, etc.). */ |
2705 init_sys_modes (tty); | 2733 init_sys_modes (tty); |
2706 | 2734 |
2707 tty_set_terminal_modes (tty); | 2735 tty_set_terminal_modes (tty); |
2708 | 2736 |
2709 return tty; | 2737 return tty; |
2710 #endif /* WINDOWSNT */ | 2738 #endif /* WINDOWSNT */ |
2711 } | 2739 } |
2731 { | 2759 { |
2732 struct tty_display_info *t; | 2760 struct tty_display_info *t; |
2733 char *name = 0; | 2761 char *name = 0; |
2734 | 2762 |
2735 CHECK_STRING (tty); | 2763 CHECK_STRING (tty); |
2736 | 2764 |
2737 if (SBYTES (tty) > 0) | 2765 if (SBYTES (tty) > 0) |
2738 { | 2766 { |
2739 name = (char *) alloca (SBYTES (tty) + 1); | 2767 name = (char *) alloca (SBYTES (tty) + 1); |
2740 strncpy (name, SDATA (tty), SBYTES (tty)); | 2768 strncpy (name, SDATA (tty), SBYTES (tty)); |
2741 name[SBYTES (tty)] = 0; | 2769 name[SBYTES (tty)] = 0; |
2743 | 2771 |
2744 t = get_named_tty (name); | 2772 t = get_named_tty (name); |
2745 | 2773 |
2746 if (! t) | 2774 if (! t) |
2747 error ("No such tty device: %s", name); | 2775 error ("No such tty device: %s", name); |
2748 | 2776 |
2749 delete_tty (t); | 2777 delete_tty (t); |
2750 } | 2778 } |
2751 | 2779 |
2752 static int deleting_tty = 0; | 2780 static int deleting_tty = 0; |
2753 | 2781 |
2754 void | 2782 void |
2755 delete_tty (struct tty_display_info *tty) | 2783 delete_tty (struct tty_display_info *tty) |
2756 { | 2784 { |
2757 Lisp_Object tail, frame; | 2785 Lisp_Object tail, frame; |
2758 | 2786 |
2759 if (deleting_tty) | 2787 if (deleting_tty) |
2760 /* We get a recursive call when we delete the last frame on this | 2788 /* We get a recursive call when we delete the last frame on this |
2761 tty. */ | 2789 tty. */ |
2762 return; | 2790 return; |
2763 | 2791 |
2764 deleting_tty = 1; | 2792 deleting_tty = 1; |
2765 | 2793 |
2766 if (tty == tty_list) | 2794 if (tty == tty_list) |
2767 tty_list = tty->next; | 2795 tty_list = tty->next; |
2768 else | 2796 else |
2769 { | 2797 { |
2770 struct tty_display_info *p; | 2798 struct tty_display_info *p; |
2780 } | 2808 } |
2781 | 2809 |
2782 FOR_EACH_FRAME (tail, frame) | 2810 FOR_EACH_FRAME (tail, frame) |
2783 { | 2811 { |
2784 struct frame *f = XFRAME (frame); | 2812 struct frame *f = XFRAME (frame); |
2785 if (FRAME_LIVE_P (f) && FRAME_TTY (f) == tty) | 2813 if (FRAME_TERMCAP_P (f) && FRAME_LIVE_P (f) && FRAME_TTY (f) == tty) |
2786 { | 2814 { |
2787 Fdelete_frame (frame, Qt); | 2815 Fdelete_frame (frame, Qt); |
2788 f->output_data.tty = 0; | 2816 f->output_data.tty = 0; |
2789 } | 2817 } |
2790 } | 2818 } |
2791 | 2819 |
2792 reset_sys_modes (tty); | 2820 reset_sys_modes (tty); |
2793 | 2821 |
2794 if (tty->name) | 2822 if (tty->name) |
2795 xfree (tty->name); | 2823 xfree (tty->name); |
2796 if (tty->type) | 2824 if (tty->type) |
2797 xfree (tty->type); | 2825 xfree (tty->type); |
2798 | 2826 |
2799 if (tty->input) | 2827 if (tty->input) |
2800 { | 2828 { |
2801 delete_keyboard_wait_descriptor (fileno (tty->input)); | 2829 delete_keyboard_wait_descriptor (fileno (tty->input)); |
2802 if (tty->input != stdin) | 2830 if (tty->input != stdin) |
2803 fclose (tty->input); | 2831 fclose (tty->input); |
2804 } | 2832 } |
2805 if (tty->output && tty->output != stdout && tty->output != tty->input) | 2833 if (tty->output && tty->output != stdout && tty->output != tty->input) |
2806 fclose (tty->output); | 2834 fclose (tty->output); |
2807 if (tty->termscript) | 2835 if (tty->termscript) |
2808 fclose (tty->termscript); | 2836 fclose (tty->termscript); |
2809 | 2837 |
2810 if (tty->old_tty) | 2838 if (tty->old_tty) |
2811 xfree (tty->old_tty); | 2839 xfree (tty->old_tty); |
2812 | 2840 |
2813 if (tty->Wcm) | 2841 if (tty->Wcm) |
2814 xfree (tty->Wcm); | 2842 xfree (tty->Wcm); |
2815 | 2843 |
2844 if (tty->display_method) | |
2845 xfree (tty->display_method); | |
2846 | |
2816 bzero (tty, sizeof (struct tty_display_info)); | 2847 bzero (tty, sizeof (struct tty_display_info)); |
2817 xfree (tty); | 2848 xfree (tty); |
2818 deleting_tty = 0; | 2849 deleting_tty = 0; |
2819 } | 2850 } |
2820 | 2851 |
2863 defsubr (&Stty_display_color_p); | 2894 defsubr (&Stty_display_color_p); |
2864 defsubr (&Stty_display_color_cells); | 2895 defsubr (&Stty_display_color_cells); |
2865 defsubr (&Sframe_tty_name); | 2896 defsubr (&Sframe_tty_name); |
2866 defsubr (&Sframe_tty_type); | 2897 defsubr (&Sframe_tty_type); |
2867 defsubr (&Sdelete_tty); | 2898 defsubr (&Sdelete_tty); |
2868 | 2899 |
2900 /* XXX tty_display_method_template initialization will go here. */ | |
2901 | |
2869 Fprovide (intern ("multi-tty"), Qnil); | 2902 Fprovide (intern ("multi-tty"), Qnil); |
2870 } | 2903 } |
2871 | 2904 |
2872 | 2905 |
2873 | 2906 |