aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKaroly Lorentey2003-12-24 18:55:24 +0000
committerKaroly Lorentey2003-12-24 18:55:24 +0000
commit8a56675df17bbd27cf45bd60a2d6e94c8f2c2281 (patch)
tree1958036a29188aee654682dab877e738dd23d2eb /src
parentda1492a4cf822e50f489992115f1e0c0e23b895c (diff)
downloademacs-8a56675df17bbd27cf45bd60a2d6e94c8f2c2281.tar.gz
emacs-8a56675df17bbd27cf45bd60a2d6e94c8f2c2281.zip
Add a level of indirection to terminal characteristics.
* src/termchar.h (struct terminal): New struct. (must_write_spaces, min_padding_speed, line_ins_del_ok) (char_ins_del_ok, scroll_region_ok, scroll_region_cost) (memory_below_frame, fast_clear_end_of_line): Moved to struct terminal. (current_terminal): New variable. (CURRENT_TERMINAL, TERMINAL_*): New accessor macros. (min_padding_speed, dont_calculate_costs): Commented out (unused). * src/term.c (_current_terminal): New variable. Will be removed when true multi-tty support is implemented. * src/termopts.h (no_redraw_on_reenter): Moved here. * src/term.c (set_terminal_window, ins_del_lines, calculate_costs) (term_init): Use the accessor macros for terminal characteristics. * src/dispnew.c (line_hash_code, line_draw_cost) (direct_output_for_insert, update_frame_1, scrolling) (update_frame_line): Ditto. * src/macterm.c (mac_initialize): Ditto. * src/msdos.c (internal_terminal_init): Ditto. * src/scroll.c (calculate_scrolling, calculate_direct_scrolling) (scrolling_1, scroll_cost): Ditto. * src/sysdep.c (hft_init): Ditto. * src/w32term.c (w32_initialize): Ditto. * src/xdisp.c (try_window_id): Ditto. * src/xterm.c (x_initialize): Ditto. * etc/TODO: Add pointer to my tla archive. git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-1
Diffstat (limited to 'src')
-rw-r--r--src/dispnew.c27
-rw-r--r--src/macterm.c13
-rw-r--r--src/msdos.c2
-rw-r--r--src/scroll.c10
-rw-r--r--src/sysdep.c3
-rw-r--r--src/term.c77
-rw-r--r--src/termchar.h69
-rw-r--r--src/termopts.h5
-rw-r--r--src/w32term.c13
-rw-r--r--src/xdisp.c6
-rw-r--r--src/xterm.c13
11 files changed, 133 insertions, 105 deletions
diff --git a/src/dispnew.c b/src/dispnew.c
index 279c1f10e58..9eb69ebf79d 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -1397,7 +1397,7 @@ line_hash_code (row)
1397 { 1397 {
1398 int c = glyph->u.ch; 1398 int c = glyph->u.ch;
1399 int face_id = glyph->face_id; 1399 int face_id = glyph->face_id;
1400 if (must_write_spaces) 1400 if (TERMINAL_MUST_WRITE_SPACES (CURRENT_TERMINAL ()))
1401 c -= SPACEGLYPH; 1401 c -= SPACEGLYPH;
1402 hash = (((hash << 4) + (hash >> 24)) & 0x0fffffff) + c; 1402 hash = (((hash << 4) + (hash >> 24)) & 0x0fffffff) + c;
1403 hash = (((hash << 4) + (hash >> 24)) & 0x0fffffff) + face_id; 1403 hash = (((hash << 4) + (hash >> 24)) & 0x0fffffff) + face_id;
@@ -1429,7 +1429,7 @@ line_draw_cost (matrix, vpos)
1429 int glyph_table_len = GLYPH_TABLE_LENGTH; 1429 int glyph_table_len = GLYPH_TABLE_LENGTH;
1430 1430
1431 /* Ignore trailing and leading spaces if we can. */ 1431 /* Ignore trailing and leading spaces if we can. */
1432 if (!must_write_spaces) 1432 if (!TERMINAL_MUST_WRITE_SPACES (CURRENT_TERMINAL ()))
1433 { 1433 {
1434 /* Skip from the end over trailing spaces. */ 1434 /* Skip from the end over trailing spaces. */
1435 while (end > beg && CHAR_GLYPH_SPACE_P (*(end - 1))) 1435 while (end > beg && CHAR_GLYPH_SPACE_P (*(end - 1)))
@@ -3462,7 +3462,7 @@ direct_output_for_insert (g)
3462 3462
3463 /* If we can't insert glyphs, we can use this method only 3463 /* If we can't insert glyphs, we can use this method only
3464 at the end of a line. */ 3464 at the end of a line. */
3465 if (!char_ins_del_ok) 3465 if (!TERMINAL_CHAR_INS_DEL_OK (CURRENT_TERMINAL ()))
3466 if (PT != ZV && FETCH_BYTE (PT_BYTE) != '\n') 3466 if (PT != ZV && FETCH_BYTE (PT_BYTE) != '\n')
3467 return 0; 3467 return 0;
3468 3468
@@ -5075,7 +5075,7 @@ update_frame_1 (f, force_p, inhibit_id_p)
5075 } 5075 }
5076 5076
5077 /* If we cannot insert/delete lines, it's no use trying it. */ 5077 /* If we cannot insert/delete lines, it's no use trying it. */
5078 if (!line_ins_del_ok) 5078 if (!TERMINAL_LINE_INS_DEL_OK (CURRENT_TERMINAL ()))
5079 inhibit_id_p = 1; 5079 inhibit_id_p = 1;
5080 5080
5081 /* See if any of the desired lines are enabled; don't compute for 5081 /* See if any of the desired lines are enabled; don't compute for
@@ -5293,21 +5293,23 @@ scrolling (frame)
5293 } 5293 }
5294 5294
5295 /* If changed lines are few, don't allow preemption, don't scroll. */ 5295 /* If changed lines are few, don't allow preemption, don't scroll. */
5296 if ((!scroll_region_ok && changed_lines < baud_rate / 2400) 5296 if ((!TERMINAL_SCROLL_REGION_OK (CURRENT_TERMINAL ())
5297 && changed_lines < baud_rate / 2400)
5297 || unchanged_at_bottom == FRAME_LINES (frame)) 5298 || unchanged_at_bottom == FRAME_LINES (frame))
5298 return 1; 5299 return 1;
5299 5300
5300 window_size = (FRAME_LINES (frame) - unchanged_at_top 5301 window_size = (FRAME_LINES (frame) - unchanged_at_top
5301 - unchanged_at_bottom); 5302 - unchanged_at_bottom);
5302 5303
5303 if (scroll_region_ok) 5304 if (TERMINAL_SCROLL_REGION_OK (CURRENT_TERMINAL ()))
5304 free_at_end_vpos -= unchanged_at_bottom; 5305 free_at_end_vpos -= unchanged_at_bottom;
5305 else if (memory_below_frame) 5306 else if (TERMINAL_MEMORY_BELOW_FRAME (CURRENT_TERMINAL ()))
5306 free_at_end_vpos = -1; 5307 free_at_end_vpos = -1;
5307 5308
5308 /* If large window, fast terminal and few lines in common between 5309 /* If large window, fast terminal and few lines in common between
5309 current frame and desired frame, don't bother with i/d calc. */ 5310 current frame and desired frame, don't bother with i/d calc. */
5310 if (!scroll_region_ok && window_size >= 18 && baud_rate > 2400 5311 if (!TERMINAL_SCROLL_REGION_OK (CURRENT_TERMINAL ())
5312 && window_size >= 18 && baud_rate > 2400
5311 && (window_size >= 5313 && (window_size >=
5312 10 * scrolling_max_lines_saved (unchanged_at_top, 5314 10 * scrolling_max_lines_saved (unchanged_at_top,
5313 FRAME_LINES (frame) - unchanged_at_bottom, 5315 FRAME_LINES (frame) - unchanged_at_bottom,
@@ -5387,7 +5389,7 @@ update_frame_line (f, vpos)
5387 struct glyph_row *current_row = MATRIX_ROW (current_matrix, vpos); 5389 struct glyph_row *current_row = MATRIX_ROW (current_matrix, vpos);
5388 struct glyph_row *desired_row = MATRIX_ROW (desired_matrix, vpos); 5390 struct glyph_row *desired_row = MATRIX_ROW (desired_matrix, vpos);
5389 int must_write_whole_line_p; 5391 int must_write_whole_line_p;
5390 int write_spaces_p = must_write_spaces; 5392 int write_spaces_p = TERMINAL_MUST_WRITE_SPACES (CURRENT_TERMINAL ());
5391 int colored_spaces_p = (FACE_FROM_ID (f, DEFAULT_FACE_ID)->background 5393 int colored_spaces_p = (FACE_FROM_ID (f, DEFAULT_FACE_ID)->background
5392 != FACE_TTY_DEFAULT_BG_COLOR); 5394 != FACE_TTY_DEFAULT_BG_COLOR);
5393 5395
@@ -5466,7 +5468,7 @@ update_frame_line (f, vpos)
5466 nlen--; 5468 nlen--;
5467 5469
5468 /* If there's no i/d char, quickly do the best we can without it. */ 5470 /* If there's no i/d char, quickly do the best we can without it. */
5469 if (!char_ins_del_ok) 5471 if (!TERMINAL_CHAR_INS_DEL_OK (CURRENT_TERMINAL ()))
5470 { 5472 {
5471 int i, j; 5473 int i, j;
5472 5474
@@ -5569,7 +5571,8 @@ update_frame_line (f, vpos)
5569 5571
5570 tem = (nlen - nsp) - (olen - osp); 5572 tem = (nlen - nsp) - (olen - osp);
5571 if (endmatch && tem 5573 if (endmatch && tem
5572 && (!char_ins_del_ok || endmatch <= char_ins_del_cost (f)[tem])) 5574 && (!TERMINAL_CHAR_INS_DEL_OK (CURRENT_TERMINAL ())
5575 || endmatch <= char_ins_del_cost (f)[tem]))
5573 endmatch = 0; 5576 endmatch = 0;
5574 5577
5575 /* nsp - osp is the distance to insert or delete. 5578 /* nsp - osp is the distance to insert or delete.
@@ -5578,7 +5581,7 @@ update_frame_line (f, vpos)
5578 Is it worth it? */ 5581 Is it worth it? */
5579 5582
5580 if (nsp != osp 5583 if (nsp != osp
5581 && (!char_ins_del_ok 5584 && (!TERMINAL_CHAR_INS_DEL_OK (CURRENT_TERMINAL ())
5582 || begmatch + endmatch <= char_ins_del_cost (f)[nsp - osp])) 5585 || begmatch + endmatch <= char_ins_del_cost (f)[nsp - osp]))
5583 { 5586 {
5584 begmatch = 0; 5587 begmatch = 0;
diff --git a/src/macterm.c b/src/macterm.c
index f0f5a3f4722..7d27e5430eb 100644
--- a/src/macterm.c
+++ b/src/macterm.c
@@ -8674,12 +8674,13 @@ mac_initialize ()
8674 redeem_scroll_bar_hook = XTredeem_scroll_bar; 8674 redeem_scroll_bar_hook = XTredeem_scroll_bar;
8675 judge_scroll_bars_hook = XTjudge_scroll_bars; 8675 judge_scroll_bars_hook = XTjudge_scroll_bars;
8676 8676
8677 scroll_region_ok = 1; /* we'll scroll partial frames */ 8677 TERMINAL_SCROLL_REGION_OK (CURRENT_TERMINAL ()) = 1; /* we'll scroll partial frames */
8678 char_ins_del_ok = 1; 8678 TERMINAL_CHAR_INS_DEL_OK (CURRENT_TERMINAL ()) = 1;
8679 line_ins_del_ok = 1; /* we'll just blt 'em */ 8679 TERMINAL_LINE_INS_DEL_OK (CURRENT_TERMINAL ()) = 1; /* we'll just blt 'em */
8680 fast_clear_end_of_line = 1; /* X does this well */ 8680 TERMINAL_FAST_CLEAR_END_OF_LINE (CURRENT_TERMINAL ()) = 1; /* X does this well */
8681 memory_below_frame = 0; /* we don't remember what scrolls 8681 TERMINAL_MEMORY_BELOW_FRAME (CURRENT_TERMINAL ()) = 0; /* we don't remember what
8682 off the bottom */ 8682 scrolls off the
8683 bottom */
8683 baud_rate = 19200; 8684 baud_rate = 19200;
8684 8685
8685 x_noop_count = 0; 8686 x_noop_count = 0;
diff --git a/src/msdos.c b/src/msdos.c
index a2fd011e74c..103094141bf 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -2580,7 +2580,7 @@ internal_terminal_init ()
2580 set_terminal_modes_hook = IT_set_terminal_modes; 2580 set_terminal_modes_hook = IT_set_terminal_modes;
2581 reset_terminal_modes_hook = IT_reset_terminal_modes; 2581 reset_terminal_modes_hook = IT_reset_terminal_modes;
2582 set_terminal_window_hook = IT_set_terminal_window; 2582 set_terminal_window_hook = IT_set_terminal_window;
2583 char_ins_del_ok = 0; 2583 TERMINAL_CHAR_INS_DEL_OK (CURRENT_TERMINAL ()) = 0;
2584#endif 2584#endif
2585} 2585}
2586 2586
diff --git a/src/scroll.c b/src/scroll.c
index 6c6aa4abf98..a786d3c2cf4 100644
--- a/src/scroll.c
+++ b/src/scroll.c
@@ -100,7 +100,8 @@ calculate_scrolling (frame, matrix, window_size, lines_below,
100 register struct matrix_elt *p, *p1; 100 register struct matrix_elt *p, *p1;
101 register int cost, cost1; 101 register int cost, cost1;
102 102
103 int lines_moved = window_size + (scroll_region_ok ? 0 : lines_below); 103 int lines_moved = window_size
104 + (TERMINAL_SCROLL_REGION_OK (CURRENT_TERMINAL ()) ? 0 : lines_below);
104 /* first_insert_cost[I] is the cost of doing the first insert-line 105 /* first_insert_cost[I] is the cost of doing the first insert-line
105 at the i'th line of the lines we are considering, 106 at the i'th line of the lines we are considering,
106 where I is origin 1 (as it is below). */ 107 where I is origin 1 (as it is below). */
@@ -466,7 +467,8 @@ calculate_direct_scrolling (frame, matrix, window_size, lines_below,
466 /* Overhead of setting the scroll window, plus the extra cost 467 /* Overhead of setting the scroll window, plus the extra cost
467 cost of scrolling by a distance of one. The extra cost is 468 cost of scrolling by a distance of one. The extra cost is
468 added once for consistency with the cost vectors */ 469 added once for consistency with the cost vectors */
469 scroll_overhead = scroll_region_cost + extra_cost; 470 scroll_overhead
471 = TERMINAL_SCROLL_REGION_COST (CURRENT_TERMINAL ()) + extra_cost;
470 472
471 /* initialize the top left corner of the matrix */ 473 /* initialize the top left corner of the matrix */
472 matrix->writecost = 0; 474 matrix->writecost = 0;
@@ -818,7 +820,7 @@ scrolling_1 (frame, window_size, unchanged_at_top, unchanged_at_bottom,
818 matrix = ((struct matrix_elt *) 820 matrix = ((struct matrix_elt *)
819 alloca ((window_size + 1) * (window_size + 1) * sizeof *matrix)); 821 alloca ((window_size + 1) * (window_size + 1) * sizeof *matrix));
820 822
821 if (scroll_region_ok) 823 if (TERMINAL_SCROLL_REGION_OK (CURRENT_TERMINAL ()))
822 { 824 {
823 calculate_direct_scrolling (frame, matrix, window_size, 825 calculate_direct_scrolling (frame, matrix, window_size,
824 unchanged_at_bottom, 826 unchanged_at_bottom,
@@ -914,7 +916,7 @@ scroll_cost (frame, from, to, amount)
914 if (amount == 0) 916 if (amount == 0)
915 return 0; 917 return 0;
916 918
917 if (! scroll_region_ok) 919 if (! TERMINAL_SCROLL_REGION_OK (CURRENT_TERMINAL ()))
918 limit = height; 920 limit = height;
919 else if (amount > 0) 921 else if (amount > 0)
920 limit += amount; 922 limit += amount;
diff --git a/src/sysdep.c b/src/sysdep.c
index 441b36290e1..b83e01635cc 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -5126,7 +5126,8 @@ hft_init ()
5126 } 5126 }
5127 /* The HFT system on AIX doesn't optimize for scrolling, so it's really ugly 5127 /* The HFT system on AIX doesn't optimize for scrolling, so it's really ugly
5128 at times. */ 5128 at times. */
5129 line_ins_del_ok = char_ins_del_ok = 0; 5129 TERMINAL_LINE_INS_DEL_OK (CURRENT_TERMINAL ()) = 0;
5130 TERMINAL_CHAR_INS_DEL_OK (CURRENT_TERMINAL ()) = 0;
5130} 5131}
5131 5132
5132/* Reset the rubout key to backspace. */ 5133/* Reset the rubout key to backspace. */
diff --git a/src/term.c b/src/term.c
index 5c25c7419dc..50d47a1dac1 100644
--- a/src/term.c
+++ b/src/term.c
@@ -83,28 +83,13 @@ static void tty_hide_cursor P_ ((void));
83 83
84Lisp_Object Vring_bell_function; 84Lisp_Object Vring_bell_function;
85 85
86/* Terminal characteristics that higher levels want to look at. 86/* Terminal characteristics that higher levels want to look at. */
87 These are all extern'd in termchar.h */ 87static struct terminal _current_terminal;
88 88TERMINAL_PTR current_terminal = &_current_terminal;
89int must_write_spaces; /* Nonzero means spaces in the text
90 must actually be output; can't just skip
91 over some columns to leave them blank. */
92int min_padding_speed; /* Speed below which no padding necessary */
93
94int line_ins_del_ok; /* Terminal can insert and delete lines */
95int char_ins_del_ok; /* Terminal can insert and delete chars */
96int scroll_region_ok; /* Terminal supports setting the
97 scroll window */
98int scroll_region_cost; /* Cost of setting a scroll window,
99 measured in characters */
100int memory_below_frame; /* Terminal remembers lines
101 scrolled off bottom */
102int fast_clear_end_of_line; /* Terminal has a `ce' string */
103 89
104/* Nonzero means no need to redraw the entire frame on resuming 90/* Nonzero means no need to redraw the entire frame on resuming
105 a suspended Emacs. This is useful on terminals with multiple pages, 91 a suspended Emacs. This is useful on terminals with multiple pages,
106 where one page is used for Emacs and another for all else. */ 92 where one page is used for Emacs and another for all else. */
107
108int no_redraw_on_reenter; 93int no_redraw_on_reenter;
109 94
110/* Hook functions that you can set to snap out the functions in this file. 95/* Hook functions that you can set to snap out the functions in this file.
@@ -505,7 +490,7 @@ set_terminal_window (size)
505 if (FRAME_TERMCAP_P (updating_frame)) 490 if (FRAME_TERMCAP_P (updating_frame))
506 { 491 {
507 specified_window = size ? size : FRAME_LINES (updating_frame); 492 specified_window = size ? size : FRAME_LINES (updating_frame);
508 if (scroll_region_ok) 493 if (TERMINAL_SCROLL_REGION_OK (CURRENT_TERMINAL ()))
509 set_scroll_region (0, specified_window); 494 set_scroll_region (0, specified_window);
510 } 495 }
511 else 496 else
@@ -1151,9 +1136,11 @@ ins_del_lines (vpos, n)
1151 /* If the lines below the deletion are blank lines coming 1136 /* If the lines below the deletion are blank lines coming
1152 out of the end of the window, don't bother, 1137 out of the end of the window, don't bother,
1153 as there will be a matching inslines later that will flush them. */ 1138 as there will be a matching inslines later that will flush them. */
1154 if (scroll_region_ok && vpos + i >= specified_window) 1139 if (TERMINAL_SCROLL_REGION_OK (CURRENT_TERMINAL ())
1140 && vpos + i >= specified_window)
1155 return; 1141 return;
1156 if (!memory_below_frame && vpos + i >= FRAME_LINES (sf)) 1142 if (!TERMINAL_MEMORY_BELOW_FRAME (CURRENT_TERMINAL ())
1143 && vpos + i >= FRAME_LINES (sf))
1157 return; 1144 return;
1158 1145
1159 if (multi) 1146 if (multi)
@@ -1186,7 +1173,9 @@ ins_del_lines (vpos, n)
1186 set_scroll_region (0, specified_window); 1173 set_scroll_region (0, specified_window);
1187 } 1174 }
1188 1175
1189 if (!scroll_region_ok && memory_below_frame && n < 0) 1176 if (!TERMINAL_SCROLL_REGION_OK (CURRENT_TERMINAL ())
1177 && TERMINAL_MEMORY_BELOW_FRAME (CURRENT_TERMINAL ())
1178 && n < 0)
1190 { 1179 {
1191 cursor_to (FRAME_LINES (sf) + n, 0); 1180 cursor_to (FRAME_LINES (sf) + n, 0);
1192 clear_to_end (); 1181 clear_to_end ();
@@ -1317,7 +1306,7 @@ calculate_costs (frame)
1317 1306
1318 FRAME_COST_BAUD_RATE (frame) = baud_rate; 1307 FRAME_COST_BAUD_RATE (frame) = baud_rate;
1319 1308
1320 scroll_region_cost = string_cost (f); 1309 TERMINAL_SCROLL_REGION_COST (CURRENT_TERMINAL ()) = string_cost (f);
1321 1310
1322 /* These variables are only used for terminal stuff. They are allocated 1311 /* These variables are only used for terminal stuff. They are allocated
1323 once for the terminal frame of X-windows emacs, but not used afterwards. 1312 once for the terminal frame of X-windows emacs, but not used afterwards.
@@ -2185,15 +2174,15 @@ term_init (terminal_type)
2185 delete_in_insert_mode = 1; 2174 delete_in_insert_mode = 1;
2186 2175
2187 UseTabs = 0; 2176 UseTabs = 0;
2188 scroll_region_ok = 0; 2177 TERMINAL_SCROLL_REGION_OK (CURRENT_TERMINAL ()) = 0;
2189 2178
2190 /* Seems to insert lines when it's not supposed to, messing 2179 /* Seems to insert lines when it's not supposed to, messing
2191 up the display. In doing a trace, it didn't seem to be 2180 up the display. In doing a trace, it didn't seem to be
2192 called much, so I don't think we're losing anything by 2181 called much, so I don't think we're losing anything by
2193 turning it off. */ 2182 turning it off. */
2194 2183
2195 line_ins_del_ok = 0; 2184 TERMINAL_LINE_INS_DEL_OK (CURRENT_TERMINAL ()) = 0;
2196 char_ins_del_ok = 1; 2185 TERMINAL_CHAR_INS_DEL_OK (CURRENT_TERMINAL ()) = 1;
2197 2186
2198 baud_rate = 19200; 2187 baud_rate = 19200;
2199 2188
@@ -2346,9 +2335,9 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
2346 /* Since we make MagicWrap terminals look like AutoWrap, we need to have 2335 /* Since we make MagicWrap terminals look like AutoWrap, we need to have
2347 the former flag imply the latter. */ 2336 the former flag imply the latter. */
2348 AutoWrap = MagicWrap || tgetflag ("am"); 2337 AutoWrap = MagicWrap || tgetflag ("am");
2349 memory_below_frame = tgetflag ("db"); 2338 TERMINAL_MEMORY_BELOW_FRAME (CURRENT_TERMINAL ()) = tgetflag ("db");
2350 TF_hazeltine = tgetflag ("hz"); 2339 TF_hazeltine = tgetflag ("hz");
2351 must_write_spaces = tgetflag ("in"); 2340 TERMINAL_MUST_WRITE_SPACES (CURRENT_TERMINAL ()) = tgetflag ("in");
2352 meta_key = tgetflag ("km") || tgetflag ("MT"); 2341 meta_key = tgetflag ("km") || tgetflag ("MT");
2353 TF_insmode_motion = tgetflag ("mi"); 2342 TF_insmode_motion = tgetflag ("mi");
2354 TF_standout_motion = tgetflag ("ms"); 2343 TF_standout_motion = tgetflag ("ms");
@@ -2377,7 +2366,10 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
2377 fatal ("Screen size %dx%d is too small", 2366 fatal ("Screen size %dx%d is too small",
2378 FRAME_LINES (sf), FRAME_COLS (sf)); 2367 FRAME_LINES (sf), FRAME_COLS (sf));
2379 2368
2380 min_padding_speed = tgetnum ("pb"); 2369#if 0 /* This is not used anywhere. */
2370 TERMINAL_MIN_PADDING_SPEED (CURRENT_TERMINAL ()) = tgetnum ("pb");
2371#endif
2372
2381 TabWidth = tgetnum ("tw"); 2373 TabWidth = tgetnum ("tw");
2382 2374
2383#ifdef VMS 2375#ifdef VMS
@@ -2453,7 +2445,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
2453 2445
2454 if (!strcmp (terminal_type, "supdup")) 2446 if (!strcmp (terminal_type, "supdup"))
2455 { 2447 {
2456 memory_below_frame = 1; 2448 TERMINAL_MEMORY_BELOW_FRAME (CURRENT_TERMINAL ()) = 1;
2457 Wcm.cm_losewrap = 1; 2449 Wcm.cm_losewrap = 1;
2458 } 2450 }
2459 if (!strncmp (terminal_type, "c10", 3) 2451 if (!strncmp (terminal_type, "c10", 3)
@@ -2480,7 +2472,7 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
2480 TS_set_window = "\033v%C %C %C %C "; 2472 TS_set_window = "\033v%C %C %C %C ";
2481 } 2473 }
2482 /* Termcap entry often fails to have :in: flag */ 2474 /* Termcap entry often fails to have :in: flag */
2483 must_write_spaces = 1; 2475 TERMINAL_MUST_WRITE_SPACES (CURRENT_TERMINAL ()) = 1;
2484 /* :ti string typically fails to have \E^G! in it */ 2476 /* :ti string typically fails to have \E^G! in it */
2485 /* This limits scope of insert-char to one line. */ 2477 /* This limits scope of insert-char to one line. */
2486 strcpy (area, TS_termcap_modes); 2478 strcpy (area, TS_termcap_modes);
@@ -2543,19 +2535,22 @@ to do `unset TERMCAP' (C-shell: `unsetenv TERMCAP') as well.",
2543 2535
2544 UseTabs = tabs_safe_p () && TabWidth == 8; 2536 UseTabs = tabs_safe_p () && TabWidth == 8;
2545 2537
2546 scroll_region_ok 2538 TERMINAL_SCROLL_REGION_OK (CURRENT_TERMINAL ())
2547 = (Wcm.cm_abs 2539 = (Wcm.cm_abs
2548 && (TS_set_window || TS_set_scroll_region || TS_set_scroll_region_1)); 2540 && (TS_set_window || TS_set_scroll_region || TS_set_scroll_region_1));
2549 2541
2550 line_ins_del_ok = (((TS_ins_line || TS_ins_multi_lines) 2542 TERMINAL_LINE_INS_DEL_OK (CURRENT_TERMINAL ())
2551 && (TS_del_line || TS_del_multi_lines)) 2543 = (((TS_ins_line || TS_ins_multi_lines)
2552 || (scroll_region_ok && TS_fwd_scroll && TS_rev_scroll)); 2544 && (TS_del_line || TS_del_multi_lines))
2553 2545 || (TERMINAL_SCROLL_REGION_OK (CURRENT_TERMINAL ())
2554 char_ins_del_ok = ((TS_ins_char || TS_insert_mode 2546 && TS_fwd_scroll && TS_rev_scroll));
2555 || TS_pad_inserted_char || TS_ins_multi_chars) 2547
2556 && (TS_del_char || TS_del_multi_chars)); 2548 TERMINAL_CHAR_INS_DEL_OK (CURRENT_TERMINAL ())
2557 2549 = ((TS_ins_char || TS_insert_mode
2558 fast_clear_end_of_line = TS_clr_line != 0; 2550 || TS_pad_inserted_char || TS_ins_multi_chars)
2551 && (TS_del_char || TS_del_multi_chars));
2552
2553 TERMINAL_FAST_CLEAR_END_OF_LINE (CURRENT_TERMINAL ()) = TS_clr_line != 0;
2559 2554
2560 init_baud_rate (); 2555 init_baud_rate ();
2561 if (read_socket_hook) /* Baudrate is somewhat */ 2556 if (read_socket_hook) /* Baudrate is somewhat */
diff --git a/src/termchar.h b/src/termchar.h
index b1d941adc27..b7c82d04936 100644
--- a/src/termchar.h
+++ b/src/termchar.h
@@ -18,32 +18,51 @@ along with GNU Emacs; see the file COPYING. If not, write to
18the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19Boston, MA 02111-1307, USA. */ 19Boston, MA 02111-1307, USA. */
20 20
21struct terminal
22{
23
24 /* EMACS_INT baud_rate; */ /* Output speed in baud */
25 int must_write_spaces; /* Nonzero means spaces in the text must
26 actually be output; can't just skip over
27 some columns to leave them blank. */
28 int fast_clear_end_of_line; /* Nonzero means terminal has a `ce' string */
29
30 int line_ins_del_ok; /* Terminal can insert and delete lines */
31 int char_ins_del_ok; /* Terminal can insert and delete chars */
32 int scroll_region_ok; /* Terminal supports setting the scroll
33 window */
34 int scroll_region_cost; /* Cost of setting the scroll window,
35 measured in characters. */
36 int memory_below_frame; /* Terminal remembers lines scrolled
37 off bottom */
21 38
22/* extern EMACS_INT baud_rate; */ /* Output speed in baud */ 39#if 0 /* These are not used anywhere. */
23extern int must_write_spaces; /* Nonzero means spaces in the text 40 int min_padding_speed; /* Speed below which no padding necessary. */
24 must actually be output; can't just skip 41 int dont_calculate_costs; /* Nonzero means don't bother computing
25 over some columns to leave them blank. */ 42 various cost tables; we won't use them. */
26extern int min_padding_speed; /* Speed below which no padding necessary */ 43#endif
27extern int fast_clear_end_of_line; /* Nonzero means terminal has 44};
28 command for this */ 45
29 46typedef struct terminal *TERMINAL_PTR;
30extern int line_ins_del_ok; /* Terminal can insert and delete lines */ 47
31extern int char_ins_del_ok; /* Terminal can insert and delete chars */ 48extern TERMINAL_PTR current_terminal;
32extern int scroll_region_ok; /* Terminal supports setting the scroll 49
33 window */ 50#define CURRENT_TERMINAL() \
34extern int scroll_region_cost; /* Cost of setting the scroll window, 51 (current_terminal ? current_terminal : (abort(), (TERMINAL_PTR) 0))
35 measured in characters */ 52
36extern int memory_below_frame; /* Terminal remembers lines scrolled 53#define TERMINAL_MUST_WRITE_SPACES(t) ((t)->must_write_spaces)
37 off bottom */ 54#define TERMINAL_FAST_CLEAR_END_OF_LINE(t) ((t)->fast_clear_end_of_line)
38extern int fast_clear_end_of_line; /* Terminal has a `ce' string */ 55#define TERMINAL_LINE_INS_DEL_OK(t) ((t)->line_ins_del_ok)
39 56#define TERMINAL_CHAR_INS_DEL_OK(t) ((t)->char_ins_del_ok)
40extern int dont_calculate_costs; /* Nonzero means don't bother computing 57#define TERMINAL_SCROLL_REGION_OK(t) ((t)->scroll_region_ok)
41 various cost tables; we won't use them. */ 58#define TERMINAL_SCROLL_REGION_COST(t) ((t)->scroll_region_cost)
42 59#define TERMINAL_MEMORY_BELOW_FRAME(t) ((t)->memory_below_frame)
43/* Nonzero means no need to redraw the entire frame on resuming 60
44 a suspended Emacs. This is useful on terminals with multiple pages, 61#if 0
45 where one page is used for Emacs and another for all else. */ 62/* These are not used anywhere. */
46extern int no_redraw_on_reenter; 63#define TERMINAL_MIN_PADDING_SPEED(t) ((t)->min_padding_speed)
64#define TERMINAL_DONT_CALCULATE_COSTS(t) ((t)->dont_calculate_costs)
65#endif
47 66
48/* arch-tag: bf9f0d49-842b-42fb-9348-ec8759b27193 67/* arch-tag: bf9f0d49-842b-42fb-9348-ec8759b27193
49 (do not change this comment) */ 68 (do not change this comment) */
diff --git a/src/termopts.h b/src/termopts.h
index 2dc798ea2c4..10f0083a667 100644
--- a/src/termopts.h
+++ b/src/termopts.h
@@ -40,5 +40,10 @@ extern int meta_key;
40/* Nonzero means truncate lines in all windows less wide than the frame */ 40/* Nonzero means truncate lines in all windows less wide than the frame */
41extern int truncate_partial_width_windows; 41extern int truncate_partial_width_windows;
42 42
43/* Nonzero means no need to redraw the entire frame on resuming a suspended
44 Emacs. This is useful on terminals with multiple pages, where one page is
45 used for Emacs and another for all else. */
46extern int no_redraw_on_reenter;
47
43/* arch-tag: 35d4d284-dc1a-4fff-97fa-0154a21aebdb 48/* arch-tag: 35d4d284-dc1a-4fff-97fa-0154a21aebdb
44 (do not change this comment) */ 49 (do not change this comment) */
diff --git a/src/w32term.c b/src/w32term.c
index 3e4543471c3..cf8d07a18ff 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -6366,12 +6366,13 @@ w32_initialize ()
6366 redeem_scroll_bar_hook = w32_redeem_scroll_bar; 6366 redeem_scroll_bar_hook = w32_redeem_scroll_bar;
6367 judge_scroll_bars_hook = w32_judge_scroll_bars; 6367 judge_scroll_bars_hook = w32_judge_scroll_bars;
6368 6368
6369 scroll_region_ok = 1; /* we'll scroll partial frames */ 6369 TERMINAL_SCROLL_REGION_OK (CURRENT_TERMINAL ()) = 1; /* we'll scroll partial frames */
6370 char_ins_del_ok = 1; 6370 TERMINAL_CHAR_INS_DEL_OK (CURRENT_TERMINAL ()) = 1;
6371 line_ins_del_ok = 1; /* we'll just blt 'em */ 6371 TERMINAL_LINE_INS_DEL_OK (CURRENT_TERMINAL ()) = 1; /* we'll just blt 'em */
6372 fast_clear_end_of_line = 1; /* X does this well */ 6372 TERMINAL_FAST_CLEAR_END_OF_LINE (CURRENT_TERMINAL ()) = 1; /* X does this well */
6373 memory_below_frame = 0; /* we don't remember what scrolls 6373 TERMINAL_MEMORY_BELOW_FRAME (CURRENT_TERMINAL ()) = 0; /* we don't remember what
6374 off the bottom */ 6374 scrolls off the
6375 bottom */
6375 baud_rate = 19200; 6376 baud_rate = 19200;
6376 6377
6377 w32_system_caret_hwnd = NULL; 6378 w32_system_caret_hwnd = NULL;
diff --git a/src/xdisp.c b/src/xdisp.c
index c2717552cc5..252c6c824b3 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -12889,7 +12889,7 @@ try_window_id (w)
12889 12889
12890 /* Window must either use window-based redisplay or be full width. */ 12890 /* Window must either use window-based redisplay or be full width. */
12891 if (!FRAME_WINDOW_P (f) 12891 if (!FRAME_WINDOW_P (f)
12892 && (!line_ins_del_ok 12892 && (!TERMINAL_LINE_INS_DEL_OK (CURRENT_TERMINAL ())
12893 || !WINDOW_FULL_WIDTH_P (w))) 12893 || !WINDOW_FULL_WIDTH_P (w)))
12894 GIVE_UP (4); 12894 GIVE_UP (4);
12895 12895
@@ -13322,7 +13322,7 @@ try_window_id (w)
13322 13322
13323 /* On dumb terminals delete dvpos lines at the end 13323 /* On dumb terminals delete dvpos lines at the end
13324 before inserting dvpos empty lines. */ 13324 before inserting dvpos empty lines. */
13325 if (!scroll_region_ok) 13325 if (!TERMINAL_SCROLL_REGION_OK (CURRENT_TERMINAL ()))
13326 ins_del_lines (end - dvpos, -dvpos); 13326 ins_del_lines (end - dvpos, -dvpos);
13327 13327
13328 /* Insert dvpos empty lines in front of 13328 /* Insert dvpos empty lines in front of
@@ -13343,7 +13343,7 @@ try_window_id (w)
13343 13343
13344 /* On a dumb terminal insert dvpos empty lines at the 13344 /* On a dumb terminal insert dvpos empty lines at the
13345 end. */ 13345 end. */
13346 if (!scroll_region_ok) 13346 if (!TERMINAL_SCROLL_REGION_OK (CURRENT_TERMINAL ()))
13347 ins_del_lines (end + dvpos, -dvpos); 13347 ins_del_lines (end + dvpos, -dvpos);
13348 } 13348 }
13349 13349
diff --git a/src/xterm.c b/src/xterm.c
index a3117846702..8718d76bc31 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -10852,12 +10852,13 @@ x_initialize ()
10852 redeem_scroll_bar_hook = XTredeem_scroll_bar; 10852 redeem_scroll_bar_hook = XTredeem_scroll_bar;
10853 judge_scroll_bars_hook = XTjudge_scroll_bars; 10853 judge_scroll_bars_hook = XTjudge_scroll_bars;
10854 10854
10855 scroll_region_ok = 1; /* we'll scroll partial frames */ 10855 TERMINAL_SCROLL_REGION_OK (CURRENT_TERMINAL ()) = 1; /* we'll scroll partial frames */
10856 char_ins_del_ok = 1; 10856 TERMINAL_CHAR_INS_DEL_OK (CURRENT_TERMINAL ()) = 1;
10857 line_ins_del_ok = 1; /* we'll just blt 'em */ 10857 TERMINAL_LINE_INS_DEL_OK (CURRENT_TERMINAL ()) = 1; /* we'll just blt 'em */
10858 fast_clear_end_of_line = 1; /* X does this well */ 10858 TERMINAL_FAST_CLEAR_END_OF_LINE (CURRENT_TERMINAL ()) = 1; /* X does this well */
10859 memory_below_frame = 0; /* we don't remember what scrolls 10859 TERMINAL_MEMORY_BELOW_FRAME (CURRENT_TERMINAL ()) = 0; /* we don't remember what
10860 off the bottom */ 10860 scrolls off the
10861 bottom */
10861 baud_rate = 19200; 10862 baud_rate = 19200;
10862 10863
10863 x_noop_count = 0; 10864 x_noop_count = 0;