diff options
| author | Karoly Lorentey | 2004-01-02 01:15:26 +0000 |
|---|---|---|
| committer | Karoly Lorentey | 2004-01-02 01:15:26 +0000 |
| commit | daf0170133e658c41f3ae2fc8558c5ab74227c1d (patch) | |
| tree | fa6577e49c4c63a6ad6e672f9e3bd1a018cb61d0 /src/term.c | |
| parent | 28d7d09f841801cd052bb4ba0df92016b9245870 (diff) | |
| download | emacs-daf0170133e658c41f3ae2fc8558c5ab74227c1d.tar.gz emacs-daf0170133e658c41f3ae2fc8558c5ab74227c1d.zip | |
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
Diffstat (limited to 'src/term.c')
| -rw-r--r-- | src/term.c | 239 |
1 files changed, 136 insertions, 103 deletions
diff --git a/src/term.c b/src/term.c index cce411debe7..c8310b5b85b 100644 --- a/src/term.c +++ b/src/term.c | |||
| @@ -267,6 +267,10 @@ int max_frame_cols; | |||
| 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 | ||
| @@ -370,6 +374,8 @@ 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 | } |
| @@ -401,7 +407,7 @@ set_terminal_window (size) | |||
| 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 |
| @@ -537,7 +543,7 @@ cursor_to (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); |
| @@ -595,7 +601,7 @@ clear_to_end () | |||
| 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) (); |
| @@ -624,7 +630,7 @@ 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) (); |
| @@ -655,9 +661,8 @@ clear_end_of_line (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; |
| @@ -822,8 +827,7 @@ write_glyphs (string, len) | |||
| 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; |
| @@ -924,17 +928,18 @@ insert_glyphs (start, len) | |||
| 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) |
| @@ -1034,7 +1039,7 @@ delete_glyphs (n) | |||
| 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); |
| @@ -1066,10 +1071,10 @@ ins_del_lines (vpos, n) | |||
| 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 |
| @@ -1077,13 +1082,13 @@ ins_del_lines (vpos, n) | |||
| 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); |
| @@ -1113,9 +1118,9 @@ ins_del_lines (vpos, n) | |||
| 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); |
| @@ -1243,60 +1248,64 @@ 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 | struct tty_display_info *tty = FRAME_TTY (frame); | ||
| 1256 | register char *f = (tty->TS_set_scroll_region | ||
| 1257 | ? tty->TS_set_scroll_region | ||
| 1258 | : tty->TS_set_scroll_region_1); | ||
| 1255 | 1259 | ||
| 1256 | /* These variables are only used for terminal stuff. They are allocated | 1260 | FRAME_SCROLL_REGION_COST (frame) = string_cost (f); |
| 1257 | once for the terminal frame of X-windows emacs, but not used afterwards. | ||
| 1258 | 1261 | ||
| 1259 | char_ins_del_vector (i.e., char_ins_del_cost) isn't used because | 1262 | tty->costs_set = 1; |
| 1260 | X turns off char_ins_del_ok. */ | ||
| 1261 | 1263 | ||
| 1262 | max_frame_lines = max (max_frame_lines, FRAME_LINES (frame)); | 1264 | /* These variables are only used for terminal stuff. They are |
| 1263 | max_frame_cols = max (max_frame_cols, FRAME_COLS (frame)); | 1265 | allocated once for the terminal frame of X-windows emacs, but not |
| 1266 | used afterwards. | ||
| 1264 | 1267 | ||
| 1265 | tty->costs_set = 1; | 1268 | char_ins_del_vector (i.e., char_ins_del_cost) isn't used because |
| 1269 | X turns off char_ins_del_ok. */ | ||
| 1266 | 1270 | ||
| 1267 | if (char_ins_del_vector != 0) | 1271 | max_frame_lines = max (max_frame_lines, FRAME_LINES (frame)); |
| 1268 | char_ins_del_vector | 1272 | max_frame_cols = max (max_frame_cols, FRAME_COLS (frame)); |
| 1269 | = (int *) xrealloc (char_ins_del_vector, | ||
| 1270 | (sizeof (int) | ||
| 1271 | + 2 * max_frame_cols * sizeof (int))); | ||
| 1272 | else | ||
| 1273 | char_ins_del_vector | ||
| 1274 | = (int *) xmalloc (sizeof (int) | ||
| 1275 | + 2 * max_frame_cols * sizeof (int)); | ||
| 1276 | |||
| 1277 | bzero (char_ins_del_vector, (sizeof (int) | ||
| 1278 | + 2 * max_frame_cols * sizeof (int))); | ||
| 1279 | |||
| 1280 | if (f && (!tty->TS_ins_line && !tty->TS_del_line)) | ||
| 1281 | do_line_insertion_deletion_costs (frame, | ||
| 1282 | tty->TS_rev_scroll, tty->TS_ins_multi_lines, | ||
| 1283 | tty->TS_fwd_scroll, tty->TS_del_multi_lines, | ||
| 1284 | f, f, 1); | ||
| 1285 | else | ||
| 1286 | do_line_insertion_deletion_costs (frame, | ||
| 1287 | tty->TS_ins_line, tty->TS_ins_multi_lines, | ||
| 1288 | tty->TS_del_line, tty->TS_del_multi_lines, | ||
| 1289 | 0, 0, 1); | ||
| 1290 | 1273 | ||
| 1291 | calculate_ins_del_char_costs (frame); | 1274 | if (char_ins_del_vector != 0) |
| 1275 | char_ins_del_vector | ||
| 1276 | = (int *) xrealloc (char_ins_del_vector, | ||
| 1277 | (sizeof (int) | ||
| 1278 | + 2 * max_frame_cols * sizeof (int))); | ||
| 1279 | else | ||
| 1280 | char_ins_del_vector | ||
| 1281 | = (int *) xmalloc (sizeof (int) | ||
| 1282 | + 2 * max_frame_cols * sizeof (int)); | ||
| 1292 | 1283 | ||
| 1293 | /* Don't use TS_repeat if its padding is worse than sending the chars */ | 1284 | bzero (char_ins_del_vector, (sizeof (int) |
| 1294 | if (tty->TS_repeat && per_line_cost (tty->TS_repeat) * baud_rate < 9000) | 1285 | + 2 * max_frame_cols * sizeof (int))); |
| 1295 | tty->RPov = string_cost (tty->TS_repeat); | 1286 | |
| 1296 | else | 1287 | |
| 1297 | tty->RPov = FRAME_COLS (frame) * 2; | 1288 | if (f && (!tty->TS_ins_line && !tty->TS_del_line)) |
| 1289 | do_line_insertion_deletion_costs (frame, | ||
| 1290 | tty->TS_rev_scroll, tty->TS_ins_multi_lines, | ||
| 1291 | tty->TS_fwd_scroll, tty->TS_del_multi_lines, | ||
| 1292 | f, f, 1); | ||
| 1293 | else | ||
| 1294 | do_line_insertion_deletion_costs (frame, | ||
| 1295 | tty->TS_ins_line, tty->TS_ins_multi_lines, | ||
| 1296 | tty->TS_del_line, tty->TS_del_multi_lines, | ||
| 1297 | 0, 0, 1); | ||
| 1298 | |||
| 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; | ||
| 1298 | 1306 | ||
| 1299 | cmcostinit (FRAME_TTY (frame)); /* set up cursor motion costs */ | 1307 | cmcostinit (FRAME_TTY (frame)); /* set up cursor motion costs */ |
| 1308 | } | ||
| 1300 | } | 1309 | } |
| 1301 | 1310 | ||
| 1302 | struct fkey_table { | 1311 | struct fkey_table { |
| @@ -2142,7 +2151,7 @@ DEFUN ("frame-tty-type", Fframe_tty_type, Sframe_tty_type, 0, 1, 0, | |||
| 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); |
| @@ -2177,7 +2186,9 @@ term_dummy_init (void) | |||
| 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 | ||
| @@ -2211,7 +2222,18 @@ term_init (Lisp_Object frame, char *name, char *terminal_type) | |||
| 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. */ |
| @@ -2219,7 +2241,6 @@ term_init (Lisp_Object frame, char *name, char *terminal_type) | |||
| 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; |
| @@ -2245,7 +2266,7 @@ term_init (Lisp_Object frame, char *name, char *terminal_type) | |||
| 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 | ||
| @@ -2253,22 +2274,21 @@ term_init (Lisp_Object frame, char *name, char *terminal_type) | |||
| 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 | ||
| @@ -2449,9 +2469,9 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", | |||
| 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"); |
| @@ -2489,7 +2509,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", | |||
| 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"); |
| @@ -2567,7 +2587,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", | |||
| 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) |
| @@ -2577,7 +2597,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", | |||
| 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. |
| @@ -2594,7 +2614,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", | |||
| 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); |
| @@ -2649,7 +2669,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", | |||
| 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) |
| @@ -2671,22 +2691,22 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", | |||
| 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 |
| @@ -2696,14 +2716,22 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.", | |||
| 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; |
| @@ -2733,7 +2761,7 @@ DEFUN ("delete-tty", Fdelete_tty, Sdelete_tty, 0, 1, 0, | |||
| 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); |
| @@ -2745,7 +2773,7 @@ DEFUN ("delete-tty", Fdelete_tty, Sdelete_tty, 0, 1, 0, | |||
| 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 | ||
| @@ -2755,14 +2783,14 @@ 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 |
| @@ -2782,20 +2810,20 @@ delete_tty (struct tty_display_info *tty) | |||
| 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)); |
| @@ -2806,13 +2834,16 @@ delete_tty (struct tty_display_info *tty) | |||
| 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; |
| @@ -2865,7 +2896,9 @@ The function should accept no arguments. */); | |||
| 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 | ||