comparison src/term.c @ 765:e4093444f9f8

*** empty log message ***
author Jim Blandy <jimb@redhat.com>
date Mon, 13 Jul 1992 20:53:59 +0000
parents a8d94735277e
children ecc182062509
comparison
equal deleted inserted replaced
764:bb24f1180bb6 765:e4093444f9f8
24 #include "termchar.h" 24 #include "termchar.h"
25 #include "termopts.h" 25 #include "termopts.h"
26 #include "cm.h" 26 #include "cm.h"
27 #undef NULL 27 #undef NULL
28 #include "lisp.h" 28 #include "lisp.h"
29 #include "screen.h" 29 #include "frame.h"
30 #include "disptab.h" 30 #include "disptab.h"
31 #include "termhooks.h" 31 #include "termhooks.h"
32 #include "keyboard.h" 32 #include "keyboard.h"
33 33
34 #define max(a, b) ((a) > (b) ? (a) : (b)) 34 #define max(a, b) ((a) > (b) ? (a) : (b))
35 #define min(a, b) ((a) < (b) ? (a) : (b)) 35 #define min(a, b) ((a) < (b) ? (a) : (b))
36 36
37 #define OUTPUT(a) tputs (a, SCREEN_HEIGHT (selected_screen) - curY, cmputc) 37 #define OUTPUT(a) tputs (a, FRAME_HEIGHT (selected_frame) - curY, cmputc)
38 #define OUTPUT1(a) tputs (a, 1, cmputc) 38 #define OUTPUT1(a) tputs (a, 1, cmputc)
39 #define OUTPUTL(a, lines) tputs (a, lines, cmputc) 39 #define OUTPUTL(a, lines) tputs (a, lines, cmputc)
40 #define OUTPUT_IF(a) { if (a) tputs (a, SCREEN_HEIGHT (selected_screen) - curY, cmputc); } 40 #define OUTPUT_IF(a) { if (a) tputs (a, FRAME_HEIGHT (selected_frame) - curY, cmputc); }
41 #define OUTPUT1_IF(a) { if (a) tputs (a, 1, cmputc); } 41 #define OUTPUT1_IF(a) { if (a) tputs (a, 1, cmputc); }
42 42
43 /* Terminal charateristics that higher levels want to look at. 43 /* Terminal charateristics that higher levels want to look at.
44 These are all extern'd in termchar.h */ 44 These are all extern'd in termchar.h */
45 45
50 50
51 int line_ins_del_ok; /* Terminal can insert and delete lines */ 51 int line_ins_del_ok; /* Terminal can insert and delete lines */
52 int char_ins_del_ok; /* Terminal can insert and delete chars */ 52 int char_ins_del_ok; /* Terminal can insert and delete chars */
53 int scroll_region_ok; /* Terminal supports setting the 53 int scroll_region_ok; /* Terminal supports setting the
54 scroll window */ 54 scroll window */
55 int memory_below_screen; /* Terminal remembers lines 55 int memory_below_frame; /* Terminal remembers lines
56 scrolled off bottom */ 56 scrolled off bottom */
57 int fast_clear_end_of_line; /* Terminal has a `ce' string */ 57 int fast_clear_end_of_line; /* Terminal has a `ce' string */
58 58
59 int dont_calculate_costs; /* Nonzero means don't bother computing */ 59 int dont_calculate_costs; /* Nonzero means don't bother computing */
60 /* various cost tables; we won't use them. */ 60 /* various cost tables; we won't use them. */
61 61
62 /* Nonzero means no need to redraw the entire screen on resuming 62 /* Nonzero means no need to redraw the entire frame on resuming
63 a suspended Emacs. This is useful on terminals with multiple pages, 63 a suspended Emacs. This is useful on terminals with multiple pages,
64 where one page is used for Emacs and another for all else. */ 64 where one page is used for Emacs and another for all else. */
65 int no_redraw_on_reenter; 65 int no_redraw_on_reenter;
66 66
67 /* Hook functions that you can set to snap out the functions in this file. 67 /* Hook functions that you can set to snap out the functions in this file.
69 69
70 int (*cursor_to_hook) (); 70 int (*cursor_to_hook) ();
71 int (*raw_cursor_to_hook) (); 71 int (*raw_cursor_to_hook) ();
72 72
73 int (*clear_to_end_hook) (); 73 int (*clear_to_end_hook) ();
74 int (*clear_screen_hook) (); 74 int (*clear_frame_hook) ();
75 int (*clear_end_of_line_hook) (); 75 int (*clear_end_of_line_hook) ();
76 76
77 int (*ins_del_lines_hook) (); 77 int (*ins_del_lines_hook) ();
78 78
79 int (*change_line_highlight_hook) (); 79 int (*change_line_highlight_hook) ();
93 93
94 int (*read_socket_hook) (); 94 int (*read_socket_hook) ();
95 95
96 /* Return the current position of the mouse. This should clear 96 /* Return the current position of the mouse. This should clear
97 mouse_moved until the next motion event arrives. */ 97 mouse_moved until the next motion event arrives. */
98 void (*mouse_position_hook) ( /* SCREEN_PTR *s, 98 void (*mouse_position_hook) ( /* FRAME_PTR *f,
99 Lisp_Object *x, 99 Lisp_Object *x,
100 Lisp_Object *y, 100 Lisp_Object *y,
101 unsigned long *time */ ); 101 unsigned long *time */ );
102 102
103 /* When reading from a minibuffer in a different screen, Emacs wants 103 /* When reading from a minibuffer in a different frame, Emacs wants
104 to shift the highlight from the selected screen to the minibuffer's 104 to shift the highlight from the selected frame to the minibuffer's
105 screen; under X, this means it lies about where the focus is. 105 frame; under X, this means it lies about where the focus is.
106 This hook tells the window system code to re-decide where to put 106 This hook tells the window system code to re-decide where to put
107 the highlight. */ 107 the highlight. */
108 void (*screen_rehighlight_hook) ( /* SCREEN_PTR s */ ); 108 void (*frame_rehighlight_hook) ( /* FRAME_PTR f */ );
109 109
110 /* Strings, numbers and flags taken from the termcap entry. */ 110 /* Strings, numbers and flags taken from the termcap entry. */
111 111
112 char *TS_ins_line; /* termcap "al" */ 112 char *TS_ins_line; /* termcap "al" */
113 char *TS_ins_multi_lines; /* "AL" (one parameter, # lines to insert) */ 113 char *TS_ins_multi_lines; /* "AL" (one parameter, # lines to insert) */
114 char *TS_bell; /* "bl" */ 114 char *TS_bell; /* "bl" */
115 char *TS_clr_to_bottom; /* "cd" */ 115 char *TS_clr_to_bottom; /* "cd" */
116 char *TS_clr_line; /* "ce", clear to end of line */ 116 char *TS_clr_line; /* "ce", clear to end of line */
117 char *TS_clr_screen; /* "cl" */ 117 char *TS_clr_frame; /* "cl" */
118 char *TS_set_scroll_region; /* "cs" (2 params, first line and last line) */ 118 char *TS_set_scroll_region; /* "cs" (2 params, first line and last line) */
119 char *TS_set_scroll_region_1; /* "cS" (4 params: total lines, 119 char *TS_set_scroll_region_1; /* "cS" (4 params: total lines,
120 lines above scroll region, lines below it, 120 lines above scroll region, lines below it,
121 total lines again) */ 121 total lines again) */
122 char *TS_del_char; /* "dc" */ 122 char *TS_del_char; /* "dc" */
184 184
185 int insert_mode; /* Nonzero when in insert mode. */ 185 int insert_mode; /* Nonzero when in insert mode. */
186 int standout_mode; /* Nonzero when in standout mode. */ 186 int standout_mode; /* Nonzero when in standout mode. */
187 187
188 /* Size of window specified by higher levels. 188 /* Size of window specified by higher levels.
189 This is the number of lines, from the top of screen downwards, 189 This is the number of lines, from the top of frame downwards,
190 which can participate in insert-line/delete-line operations. 190 which can participate in insert-line/delete-line operations.
191 191
192 Effectively it excludes the bottom screen_height - specified_window_size 192 Effectively it excludes the bottom frame_height - specified_window_size
193 lines from those operations. */ 193 lines from those operations. */
194 194
195 int specified_window; 195 int specified_window;
196 196
197 /* Screen currently being redisplayed; 0 if not currently redisplaying. 197 /* Frame currently being redisplayed; 0 if not currently redisplaying.
198 (Direct output does not count). */ 198 (Direct output does not count). */
199 199
200 SCREEN_PTR updating_screen; 200 FRAME_PTR updating_frame;
201 201
202 char *tparam (); 202 char *tparam ();
203 203
204 ring_bell () 204 ring_bell ()
205 { 205 {
206 if (! SCREEN_IS_TERMCAP (selected_screen)) 206 if (! FRAME_IS_TERMCAP (selected_frame))
207 { 207 {
208 (*ring_bell_hook) (); 208 (*ring_bell_hook) ();
209 return; 209 return;
210 } 210 }
211 OUTPUT (TS_visible_bell && visible_bell ? TS_visible_bell : TS_bell); 211 OUTPUT (TS_visible_bell && visible_bell ? TS_visible_bell : TS_bell);
212 } 212 }
213 213
214 set_terminal_modes () 214 set_terminal_modes ()
215 { 215 {
216 if (! SCREEN_IS_TERMCAP (selected_screen)) 216 if (! FRAME_IS_TERMCAP (selected_frame))
217 { 217 {
218 (*set_terminal_modes_hook) (); 218 (*set_terminal_modes_hook) ();
219 return; 219 return;
220 } 220 }
221 OUTPUT_IF (TS_termcap_modes); 221 OUTPUT_IF (TS_termcap_modes);
224 losecursor (); 224 losecursor ();
225 } 225 }
226 226
227 reset_terminal_modes () 227 reset_terminal_modes ()
228 { 228 {
229 if (! SCREEN_IS_TERMCAP (selected_screen)) 229 if (! FRAME_IS_TERMCAP (selected_frame))
230 { 230 {
231 (*reset_terminal_modes_hook) (); 231 (*reset_terminal_modes_hook) ();
232 return; 232 return;
233 } 233 }
234 if (TN_standout_width < 0) 234 if (TN_standout_width < 0)
237 OUTPUT_IF (TS_end_keypad_mode); 237 OUTPUT_IF (TS_end_keypad_mode);
238 OUTPUT_IF (TS_end_visual_mode); 238 OUTPUT_IF (TS_end_visual_mode);
239 OUTPUT_IF (TS_end_termcap_modes); 239 OUTPUT_IF (TS_end_termcap_modes);
240 /* Output raw CR so kernel can track the cursor hpos. */ 240 /* Output raw CR so kernel can track the cursor hpos. */
241 /* But on magic-cookie terminals this can erase an end-standout marker and 241 /* But on magic-cookie terminals this can erase an end-standout marker and
242 cause the rest of the screen to be in standout, so move down first. */ 242 cause the rest of the frame to be in standout, so move down first. */
243 if (TN_standout_width >= 0) 243 if (TN_standout_width >= 0)
244 cmputc ('\n'); 244 cmputc ('\n');
245 cmputc ('\r'); 245 cmputc ('\r');
246 } 246 }
247 247
248 update_begin (s) 248 update_begin (f)
249 SCREEN_PTR s; 249 FRAME_PTR f;
250 { 250 {
251 updating_screen = s; 251 updating_frame = f;
252 if (! SCREEN_IS_TERMCAP (updating_screen)) 252 if (! FRAME_IS_TERMCAP (updating_frame))
253 (*update_begin_hook) (s); 253 (*update_begin_hook) (f);
254 } 254 }
255 255
256 update_end (s) 256 update_end (f)
257 SCREEN_PTR s; 257 FRAME_PTR f;
258 { 258 {
259 if (! SCREEN_IS_TERMCAP (updating_screen)) 259 if (! FRAME_IS_TERMCAP (updating_frame))
260 { 260 {
261 (*update_end_hook) (s); 261 (*update_end_hook) (f);
262 updating_screen = 0; 262 updating_frame = 0;
263 return; 263 return;
264 } 264 }
265 turn_off_insert (); 265 turn_off_insert ();
266 background_highlight (); 266 background_highlight ();
267 standout_requested = 0; 267 standout_requested = 0;
268 updating_screen = 0; 268 updating_frame = 0;
269 } 269 }
270 270
271 set_terminal_window (size) 271 set_terminal_window (size)
272 int size; 272 int size;
273 { 273 {
274 if (! SCREEN_IS_TERMCAP (updating_screen)) 274 if (! FRAME_IS_TERMCAP (updating_frame))
275 { 275 {
276 (*set_terminal_window_hook) (size); 276 (*set_terminal_window_hook) (size);
277 return; 277 return;
278 } 278 }
279 specified_window = size ? size : SCREEN_HEIGHT (selected_screen); 279 specified_window = size ? size : FRAME_HEIGHT (selected_frame);
280 if (!scroll_region_ok) 280 if (!scroll_region_ok)
281 return; 281 return;
282 set_scroll_region (0, specified_window); 282 set_scroll_region (0, specified_window);
283 } 283 }
284 284
291 buf = tparam (TS_set_scroll_region, 0, 0, start, stop - 1); 291 buf = tparam (TS_set_scroll_region, 0, 0, start, stop - 1);
292 } 292 }
293 else if (TS_set_scroll_region_1) 293 else if (TS_set_scroll_region_1)
294 { 294 {
295 buf = tparam (TS_set_scroll_region_1, 0, 0, 295 buf = tparam (TS_set_scroll_region_1, 0, 0,
296 SCREEN_HEIGHT (selected_screen), start, 296 FRAME_HEIGHT (selected_frame), start,
297 SCREEN_HEIGHT (selected_screen) - stop, 297 FRAME_HEIGHT (selected_frame) - stop,
298 SCREEN_HEIGHT (selected_screen)); 298 FRAME_HEIGHT (selected_frame));
299 } 299 }
300 else 300 else
301 { 301 {
302 buf = tparam (TS_set_window, 0, 0, start, 0, stop, SCREEN_WIDTH (selected_screen)); 302 buf = tparam (TS_set_window, 0, 0, start, 0, stop, FRAME_WIDTH (selected_frame));
303 } 303 }
304 OUTPUT (buf); 304 OUTPUT (buf);
305 free (buf); 305 free (buf);
306 losecursor (); 306 losecursor ();
307 } 307 }
374 turn_on_highlight (); 374 turn_on_highlight ();
375 } 375 }
376 376
377 /* Handle standout mode for terminals in which TN_standout_width >= 0. 377 /* Handle standout mode for terminals in which TN_standout_width >= 0.
378 On these terminals, standout is controlled by markers that 378 On these terminals, standout is controlled by markers that
379 live inside the screen memory. TN_standout_width is the width 379 live inside the terminal's memory. TN_standout_width is the width
380 that the marker occupies in memory. Standout runs from the marker 380 that the marker occupies in memory. Standout runs from the marker
381 to the end of the line on some terminals, or to the next 381 to the end of the line on some terminals, or to the next
382 turn-off-standout marker (TS_end_standout_mode) string 382 turn-off-standout marker (TS_end_standout_mode) string
383 on other terminals. */ 383 on other terminals. */
384 384
404 404
405 reassert_line_highlight (highlight, vpos) 405 reassert_line_highlight (highlight, vpos)
406 int highlight; 406 int highlight;
407 int vpos; 407 int vpos;
408 { 408 {
409 if (! SCREEN_IS_TERMCAP ((updating_screen ? updating_screen : selected_screen))) 409 if (! FRAME_IS_TERMCAP ((updating_frame ? updating_frame : selected_frame)))
410 { 410 {
411 (*reassert_line_highlight_hook) (highlight, vpos); 411 (*reassert_line_highlight_hook) (highlight, vpos);
412 return; 412 return;
413 } 413 }
414 if (TN_standout_width < 0) 414 if (TN_standout_width < 0)
425 425
426 change_line_highlight (new_highlight, vpos, first_unused_hpos) 426 change_line_highlight (new_highlight, vpos, first_unused_hpos)
427 int new_highlight, vpos, first_unused_hpos; 427 int new_highlight, vpos, first_unused_hpos;
428 { 428 {
429 standout_requested = new_highlight; 429 standout_requested = new_highlight;
430 if (! SCREEN_IS_TERMCAP (updating_screen)) 430 if (! FRAME_IS_TERMCAP (updating_frame))
431 { 431 {
432 (*change_line_highlight_hook) (new_highlight, vpos, first_unused_hpos); 432 (*change_line_highlight_hook) (new_highlight, vpos, first_unused_hpos);
433 return; 433 return;
434 } 434 }
435 435
442 { 442 {
443 turn_off_insert (); 443 turn_off_insert ();
444 /* On Teleray, make sure to erase the SO marker. */ 444 /* On Teleray, make sure to erase the SO marker. */
445 if (TF_teleray) 445 if (TF_teleray)
446 { 446 {
447 cmgoto (curY - 1, SCREEN_WIDTH (selected_screen) - 4); 447 cmgoto (curY - 1, FRAME_WIDTH (selected_frame) - 4);
448 OUTPUT ("\033S"); 448 OUTPUT ("\033S");
449 curY++; /* ESC S moves to next line where the TS_standout_mode was */ 449 curY++; /* ESC S moves to next line where the TS_standout_mode was */
450 curX = 0; 450 curX = 0;
451 } 451 }
452 else 452 else
460 /* Move to absolute position, specified origin 0 */ 460 /* Move to absolute position, specified origin 0 */
461 461
462 cursor_to (row, col) 462 cursor_to (row, col)
463 int row, col; 463 int row, col;
464 { 464 {
465 if (! SCREEN_IS_TERMCAP ((updating_screen 465 if (! FRAME_IS_TERMCAP ((updating_frame
466 ? updating_screen 466 ? updating_frame
467 : selected_screen)) 467 : selected_frame))
468 && cursor_to_hook) 468 && cursor_to_hook)
469 { 469 {
470 (*cursor_to_hook) (row, col); 470 (*cursor_to_hook) (row, col);
471 return; 471 return;
472 } 472 }
484 /* Similar but don't take any account of the wasted characters. */ 484 /* Similar but don't take any account of the wasted characters. */
485 485
486 raw_cursor_to (row, col) 486 raw_cursor_to (row, col)
487 int row, col; 487 int row, col;
488 { 488 {
489 if (! SCREEN_IS_TERMCAP ((updating_screen ? updating_screen : selected_screen))) 489 if (! FRAME_IS_TERMCAP ((updating_frame ? updating_frame : selected_frame)))
490 { 490 {
491 (*raw_cursor_to_hook) (row, col); 491 (*raw_cursor_to_hook) (row, col);
492 return; 492 return;
493 } 493 }
494 if (curY == row && curX == col) 494 if (curY == row && curX == col)
500 cmgoto (row, col); 500 cmgoto (row, col);
501 } 501 }
502 502
503 /* Erase operations */ 503 /* Erase operations */
504 504
505 /* clear from cursor to end of screen */ 505 /* clear from cursor to end of frame */
506 clear_to_end () 506 clear_to_end ()
507 { 507 {
508 register int i; 508 register int i;
509 509
510 if (clear_to_end_hook && SCREEN_IS_TERMCAP (updating_screen)) 510 if (clear_to_end_hook && FRAME_IS_TERMCAP (updating_frame))
511 { 511 {
512 (*clear_to_end_hook) (); 512 (*clear_to_end_hook) ();
513 return; 513 return;
514 } 514 }
515 if (TS_clr_to_bottom) 515 if (TS_clr_to_bottom)
516 { 516 {
517 background_highlight (); 517 background_highlight ();
518 OUTPUT (TS_clr_to_bottom); 518 OUTPUT (TS_clr_to_bottom);
519 bzero (chars_wasted + curY, SCREEN_HEIGHT (selected_screen) - curY); 519 bzero (chars_wasted + curY, FRAME_HEIGHT (selected_frame) - curY);
520 } 520 }
521 else 521 else
522 { 522 {
523 for (i = curY; i < SCREEN_HEIGHT (selected_screen); i++) 523 for (i = curY; i < FRAME_HEIGHT (selected_frame); i++)
524 { 524 {
525 cursor_to (i, 0); 525 cursor_to (i, 0);
526 clear_end_of_line_raw (SCREEN_WIDTH (selected_screen)); 526 clear_end_of_line_raw (FRAME_WIDTH (selected_frame));
527 } 527 }
528 } 528 }
529 } 529 }
530 530
531 /* Clear entire screen */ 531 /* Clear entire frame */
532 532
533 clear_screen () 533 clear_frame ()
534 { 534 {
535 if (clear_screen_hook 535 if (clear_frame_hook
536 && ! SCREEN_IS_TERMCAP ((updating_screen ? updating_screen : selected_screen))) 536 && ! FRAME_IS_TERMCAP ((updating_frame ? updating_frame : selected_frame)))
537 { 537 {
538 (*clear_screen_hook) (); 538 (*clear_frame_hook) ();
539 return; 539 return;
540 } 540 }
541 if (TS_clr_screen) 541 if (TS_clr_frame)
542 { 542 {
543 background_highlight (); 543 background_highlight ();
544 OUTPUT (TS_clr_screen); 544 OUTPUT (TS_clr_frame);
545 bzero (chars_wasted, SCREEN_HEIGHT (selected_screen)); 545 bzero (chars_wasted, FRAME_HEIGHT (selected_frame));
546 cmat (0, 0); 546 cmat (0, 0);
547 } 547 }
548 else 548 else
549 { 549 {
550 cursor_to (0, 0); 550 cursor_to (0, 0);
561 561
562 clear_end_of_line (first_unused_hpos) 562 clear_end_of_line (first_unused_hpos)
563 int first_unused_hpos; 563 int first_unused_hpos;
564 { 564 {
565 static GLYPH buf[1] = {SPACEGLYPH}; 565 static GLYPH buf[1] = {SPACEGLYPH};
566 if (SCREEN_IS_TERMCAP (selected_screen) 566 if (FRAME_IS_TERMCAP (selected_frame)
567 && TN_standout_width == 0 && curX == 0 && chars_wasted[curY] != 0) 567 && TN_standout_width == 0 && curX == 0 && chars_wasted[curY] != 0)
568 write_glyphs (buf, 1); 568 write_glyphs (buf, 1);
569 clear_end_of_line_raw (first_unused_hpos); 569 clear_end_of_line_raw (first_unused_hpos);
570 } 570 }
571 571
579 int first_unused_hpos; 579 int first_unused_hpos;
580 { 580 {
581 register int i; 581 register int i;
582 582
583 if (clear_end_of_line_hook 583 if (clear_end_of_line_hook
584 && ! SCREEN_IS_TERMCAP ((updating_screen 584 && ! FRAME_IS_TERMCAP ((updating_frame
585 ? updating_screen 585 ? updating_frame
586 : selected_screen))) 586 : selected_frame)))
587 { 587 {
588 (*clear_end_of_line_hook) (first_unused_hpos); 588 (*clear_end_of_line_hook) (first_unused_hpos);
589 return; 589 return;
590 } 590 }
591 591
603 else 603 else
604 { /* have to do it the hard way */ 604 { /* have to do it the hard way */
605 turn_off_insert (); 605 turn_off_insert ();
606 606
607 /* Do not write in last row last col with Autowrap on. */ 607 /* Do not write in last row last col with Autowrap on. */
608 if (AutoWrap && curY == SCREEN_HEIGHT (selected_screen) - 1 608 if (AutoWrap && curY == FRAME_HEIGHT (selected_frame) - 1
609 && first_unused_hpos == SCREEN_WIDTH (selected_screen)) 609 && first_unused_hpos == FRAME_WIDTH (selected_frame))
610 first_unused_hpos--; 610 first_unused_hpos--;
611 611
612 for (i = curX; i < first_unused_hpos; i++) 612 for (i = curX; i < first_unused_hpos; i++)
613 { 613 {
614 if (termscript) 614 if (termscript)
627 register GLYPH g; 627 register GLYPH g;
628 register int tlen = GLYPH_TABLE_LENGTH; 628 register int tlen = GLYPH_TABLE_LENGTH;
629 register Lisp_Object *tbase = GLYPH_TABLE_BASE; 629 register Lisp_Object *tbase = GLYPH_TABLE_BASE;
630 630
631 if (write_glyphs_hook 631 if (write_glyphs_hook
632 && ! SCREEN_IS_TERMCAP ((updating_screen ? updating_screen : selected_screen))) 632 && ! FRAME_IS_TERMCAP ((updating_frame ? updating_frame : selected_frame)))
633 { 633 {
634 (*write_glyphs_hook) (string, len); 634 (*write_glyphs_hook) (string, len);
635 return; 635 return;
636 } 636 }
637 637
638 highlight_if_desired (); 638 highlight_if_desired ();
639 turn_off_insert (); 639 turn_off_insert ();
640 640
641 /* Don't dare write in last column of bottom line, if AutoWrap, 641 /* Don't dare write in last column of bottom line, if AutoWrap,
642 since that would scroll the whole screen on some terminals. */ 642 since that would scroll the whole frame on some terminals. */
643 643
644 if (AutoWrap 644 if (AutoWrap
645 && curY + 1 == SCREEN_HEIGHT (selected_screen) 645 && curY + 1 == FRAME_HEIGHT (selected_frame)
646 && (curX + len - (chars_wasted[curY] & 077) 646 && (curX + len - (chars_wasted[curY] & 077)
647 == SCREEN_WIDTH (selected_screen))) 647 == FRAME_WIDTH (selected_frame)))
648 len --; 648 len --;
649 649
650 cmplus (len); 650 cmplus (len);
651 while (--len >= 0) 651 while (--len >= 0)
652 { 652 {
694 char *buf; 694 char *buf;
695 register GLYPH g; 695 register GLYPH g;
696 register int tlen = GLYPH_TABLE_LENGTH; 696 register int tlen = GLYPH_TABLE_LENGTH;
697 register Lisp_Object *tbase = GLYPH_TABLE_BASE; 697 register Lisp_Object *tbase = GLYPH_TABLE_BASE;
698 698
699 if (insert_glyphs_hook && ! SCREEN_IS_TERMCAP (updating_screen)) 699 if (insert_glyphs_hook && ! FRAME_IS_TERMCAP (updating_frame))
700 { 700 {
701 (*insert_glyphs_hook) (start, len); 701 (*insert_glyphs_hook) (start, len);
702 return; 702 return;
703 } 703 }
704 highlight_if_desired (); 704 highlight_if_desired ();
749 register int n; 749 register int n;
750 { 750 {
751 char *buf; 751 char *buf;
752 register int i; 752 register int i;
753 753
754 if (delete_glyphs_hook && ! SCREEN_IS_TERMCAP (updating_screen)) 754 if (delete_glyphs_hook && ! FRAME_IS_TERMCAP (updating_frame))
755 { 755 {
756 (*delete_glyphs_hook) (n); 756 (*delete_glyphs_hook) (n);
757 return; 757 return;
758 } 758 }
759 759
790 char *scroll = n > 0 ? TS_rev_scroll : TS_fwd_scroll; 790 char *scroll = n > 0 ? TS_rev_scroll : TS_fwd_scroll;
791 791
792 register int i = n > 0 ? n : -n; 792 register int i = n > 0 ? n : -n;
793 register char *buf; 793 register char *buf;
794 794
795 if (ins_del_lines_hook && ! SCREEN_IS_TERMCAP (updating_screen)) 795 if (ins_del_lines_hook && ! FRAME_IS_TERMCAP (updating_frame))
796 { 796 {
797 (*ins_del_lines_hook) (vpos, n); 797 (*ins_del_lines_hook) (vpos, n);
798 return; 798 return;
799 } 799 }
800 800
805 /* If the lines below the deletion are blank lines coming 805 /* If the lines below the deletion are blank lines coming
806 out of the end of the window, don't bother, 806 out of the end of the window, don't bother,
807 as there will be a matching inslines later that will flush them. */ 807 as there will be a matching inslines later that will flush them. */
808 if (scroll_region_ok && vpos + i >= specified_window) 808 if (scroll_region_ok && vpos + i >= specified_window)
809 return; 809 return;
810 if (!memory_below_screen && vpos + i >= SCREEN_HEIGHT (selected_screen)) 810 if (!memory_below_frame && vpos + i >= FRAME_HEIGHT (selected_frame))
811 return; 811 return;
812 812
813 if (multi) 813 if (multi)
814 { 814 {
815 raw_cursor_to (vpos, 0); 815 raw_cursor_to (vpos, 0);
843 if (TN_standout_width >= 0) 843 if (TN_standout_width >= 0)
844 { 844 {
845 register lower_limit 845 register lower_limit
846 = (scroll_region_ok 846 = (scroll_region_ok
847 ? specified_window 847 ? specified_window
848 : SCREEN_HEIGHT (selected_screen)); 848 : FRAME_HEIGHT (selected_frame));
849 849
850 if (n < 0) 850 if (n < 0)
851 { 851 {
852 bcopy (&chars_wasted[vpos - n], &chars_wasted[vpos], 852 bcopy (&chars_wasted[vpos - n], &chars_wasted[vpos],
853 lower_limit - vpos + n); 853 lower_limit - vpos + n);
859 bcopy (&copybuf[vpos], &chars_wasted[vpos + n], 859 bcopy (&copybuf[vpos], &chars_wasted[vpos + n],
860 lower_limit - vpos - n); 860 lower_limit - vpos - n);
861 bzero (&chars_wasted[vpos], n); 861 bzero (&chars_wasted[vpos], n);
862 } 862 }
863 } 863 }
864 if (!scroll_region_ok && memory_below_screen && n < 0) 864 if (!scroll_region_ok && memory_below_frame && n < 0)
865 { 865 {
866 cursor_to (SCREEN_HEIGHT (selected_screen) + n, 0); 866 cursor_to (FRAME_HEIGHT (selected_frame) + n, 0);
867 clear_to_end (); 867 clear_to_end ();
868 } 868 }
869 } 869 }
870 870
871 /* Compute cost of sending "str", in characters, 871 /* Compute cost of sending "str", in characters,
914 /* char_ins_del_cost[n] is cost of inserting N characters. 914 /* char_ins_del_cost[n] is cost of inserting N characters.
915 char_ins_del_cost[-n] is cost of deleting N characters. */ 915 char_ins_del_cost[-n] is cost of deleting N characters. */
916 916
917 int *char_ins_del_vector; 917 int *char_ins_del_vector;
918 918
919 #define char_ins_del_cost(s) (&char_ins_del_vector[SCREEN_WIDTH ((s))]) 919 #define char_ins_del_cost(f) (&char_ins_del_vector[FRAME_WIDTH ((f))])
920 #endif 920 #endif
921 921
922 /* ARGSUSED */ 922 /* ARGSUSED */
923 static void 923 static void
924 calculate_ins_del_char_costs (screen) 924 calculate_ins_del_char_costs (frame)
925 SCREEN_PTR screen; 925 FRAME_PTR frame;
926 { 926 {
927 int ins_startup_cost, del_startup_cost; 927 int ins_startup_cost, del_startup_cost;
928 int ins_cost_per_char, del_cost_per_char; 928 int ins_cost_per_char, del_cost_per_char;
929 register int i; 929 register int i;
930 register int *p; 930 register int *p;
966 del_startup_cost = 9999; 966 del_startup_cost = 9999;
967 del_cost_per_char = 0; 967 del_cost_per_char = 0;
968 } 968 }
969 969
970 /* Delete costs are at negative offsets */ 970 /* Delete costs are at negative offsets */
971 p = &char_ins_del_cost (screen)[0]; 971 p = &char_ins_del_cost (frame)[0];
972 for (i = SCREEN_WIDTH (selected_screen); --i >= 0;) 972 for (i = FRAME_WIDTH (selected_frame); --i >= 0;)
973 *--p = (del_startup_cost += del_cost_per_char); 973 *--p = (del_startup_cost += del_cost_per_char);
974 974
975 /* Doing nothing is free */ 975 /* Doing nothing is free */
976 p = &char_ins_del_cost (screen)[0]; 976 p = &char_ins_del_cost (frame)[0];
977 *p++ = 0; 977 *p++ = 0;
978 978
979 /* Insert costs are at positive offsets */ 979 /* Insert costs are at positive offsets */
980 for (i = SCREEN_WIDTH (screen); --i >= 0;) 980 for (i = FRAME_WIDTH (frame); --i >= 0;)
981 *p++ = (ins_startup_cost += ins_cost_per_char); 981 *p++ = (ins_startup_cost += ins_cost_per_char);
982 } 982 }
983 983
984 #ifdef HAVE_X_WINDOWS 984 #ifdef HAVE_X_WINDOWS
985 extern int x_screen_planes; 985 extern int x_frame_planes;
986 #endif 986 #endif
987 987
988 calculate_costs (screen) 988 calculate_costs (frame)
989 SCREEN_PTR screen; 989 FRAME_PTR frame;
990 { 990 {
991 register char *s = TS_set_scroll_region ? 991 register char *f = TS_set_scroll_region ?
992 TS_set_scroll_region 992 TS_set_scroll_region
993 : TS_set_scroll_region_1; 993 : TS_set_scroll_region_1;
994 994
995 if (dont_calculate_costs) 995 if (dont_calculate_costs)
996 return; 996 return;
997 997
998 #ifdef HAVE_X_WINDOWS 998 #ifdef HAVE_X_WINDOWS
999 if (SCREEN_IS_X (screen)) 999 if (FRAME_IS_X (frame))
1000 { 1000 {
1001 do_line_insertion_deletion_costs (screen, 0, ".5*", 0, ".5*", 1001 do_line_insertion_deletion_costs (frame, 0, ".5*", 0, ".5*",
1002 0, 0, x_screen_planes); 1002 0, 0, x_frame_planes);
1003 return; 1003 return;
1004 } 1004 }
1005 #endif 1005 #endif
1006 1006
1007 /* These variables are only used for terminal stuff. They are allocated 1007 /* These variables are only used for terminal stuff. They are allocated
1008 once for the terminal screen of X-windows emacs, but not used afterwards. 1008 once for the terminal frame of X-windows emacs, but not used afterwards.
1009 1009
1010 char_ins_del_vector (i.e., char_ins_del_cost) isn't used because 1010 char_ins_del_vector (i.e., char_ins_del_cost) isn't used because
1011 X turns off char_ins_del_ok. 1011 X turns off char_ins_del_ok.
1012 1012
1013 chars_wasted and copybuf are only used here in term.c in cases where 1013 chars_wasted and copybuf are only used here in term.c in cases where
1014 the term hook isn't called. */ 1014 the term hook isn't called. */
1015 1015
1016 if (chars_wasted != 0) 1016 if (chars_wasted != 0)
1017 chars_wasted = (char *) xrealloc (chars_wasted, SCREEN_HEIGHT (screen)); 1017 chars_wasted = (char *) xrealloc (chars_wasted, FRAME_HEIGHT (frame));
1018 else 1018 else
1019 chars_wasted = (char *) xmalloc (SCREEN_HEIGHT (screen)); 1019 chars_wasted = (char *) xmalloc (FRAME_HEIGHT (frame));
1020 1020
1021 if (copybuf != 0) 1021 if (copybuf != 0)
1022 copybuf = (char *) xrealloc (copybuf, SCREEN_HEIGHT (screen)); 1022 copybuf = (char *) xrealloc (copybuf, FRAME_HEIGHT (frame));
1023 else 1023 else
1024 copybuf = (char *) xmalloc (SCREEN_HEIGHT (screen)); 1024 copybuf = (char *) xmalloc (FRAME_HEIGHT (frame));
1025 1025
1026 if (char_ins_del_vector != 0) 1026 if (char_ins_del_vector != 0)
1027 char_ins_del_vector 1027 char_ins_del_vector
1028 = (int *) xrealloc (char_ins_del_vector, 1028 = (int *) xrealloc (char_ins_del_vector,
1029 (sizeof (int) 1029 (sizeof (int)
1030 + 2 * SCREEN_WIDTH (screen) * sizeof (int))); 1030 + 2 * FRAME_WIDTH (frame) * sizeof (int)));
1031 else 1031 else
1032 char_ins_del_vector 1032 char_ins_del_vector
1033 = (int *) xmalloc (sizeof (int) 1033 = (int *) xmalloc (sizeof (int)
1034 + 2 * SCREEN_WIDTH (screen) * sizeof (int)); 1034 + 2 * FRAME_WIDTH (frame) * sizeof (int));
1035 1035
1036 bzero (chars_wasted, SCREEN_HEIGHT (screen)); 1036 bzero (chars_wasted, FRAME_HEIGHT (frame));
1037 bzero (copybuf, SCREEN_HEIGHT (screen)); 1037 bzero (copybuf, FRAME_HEIGHT (frame));
1038 bzero (char_ins_del_vector, (sizeof (int) 1038 bzero (char_ins_del_vector, (sizeof (int)
1039 + 2 * SCREEN_WIDTH (screen) * sizeof (int))); 1039 + 2 * FRAME_WIDTH (frame) * sizeof (int)));
1040 1040
1041 if (s && (!TS_ins_line && !TS_del_line)) 1041 if (f && (!TS_ins_line && !TS_del_line))
1042 do_line_insertion_deletion_costs (screen, 1042 do_line_insertion_deletion_costs (frame,
1043 TS_rev_scroll, TS_ins_multi_lines, 1043 TS_rev_scroll, TS_ins_multi_lines,
1044 TS_fwd_scroll, TS_del_multi_lines, 1044 TS_fwd_scroll, TS_del_multi_lines,
1045 s, s, 1); 1045 f, f, 1);
1046 else 1046 else
1047 do_line_insertion_deletion_costs (screen, 1047 do_line_insertion_deletion_costs (frame,
1048 TS_ins_line, TS_ins_multi_lines, 1048 TS_ins_line, TS_ins_multi_lines,
1049 TS_del_line, TS_del_multi_lines, 1049 TS_del_line, TS_del_multi_lines,
1050 0, 0, 1); 1050 0, 0, 1);
1051 1051
1052 calculate_ins_del_char_costs (screen); 1052 calculate_ins_del_char_costs (frame);
1053 1053
1054 /* Don't use TS_repeat if its padding is worse than sending the chars */ 1054 /* Don't use TS_repeat if its padding is worse than sending the chars */
1055 if (TS_repeat && per_line_cost (TS_repeat) * baud_rate < 9000) 1055 if (TS_repeat && per_line_cost (TS_repeat) * baud_rate < 9000)
1056 RPov = string_cost (TS_repeat); 1056 RPov = string_cost (TS_repeat);
1057 else 1057 else
1058 RPov = SCREEN_WIDTH (screen) * 2; 1058 RPov = FRAME_WIDTH (frame) * 2;
1059 1059
1060 cmcostinit (); /* set up cursor motion costs */ 1060 cmcostinit (); /* set up cursor motion costs */
1061 } 1061 }
1062 1062
1063 /* Find the escape codes sent by the function keys for Vfunction_key_map. 1063 /* Find the escape codes sent by the function keys for Vfunction_key_map.
1149 TS_ins_multi_lines = tgetstr ("AL", address); 1149 TS_ins_multi_lines = tgetstr ("AL", address);
1150 TS_bell = tgetstr ("bl", address); 1150 TS_bell = tgetstr ("bl", address);
1151 BackTab = tgetstr ("bt", address); 1151 BackTab = tgetstr ("bt", address);
1152 TS_clr_to_bottom = tgetstr ("cd", address); 1152 TS_clr_to_bottom = tgetstr ("cd", address);
1153 TS_clr_line = tgetstr ("ce", address); 1153 TS_clr_line = tgetstr ("ce", address);
1154 TS_clr_screen = tgetstr ("cl", address); 1154 TS_clr_frame = tgetstr ("cl", address);
1155 ColPosition = tgetstr ("ch", address); 1155 ColPosition = tgetstr ("ch", address);
1156 AbsPosition = tgetstr ("cm", address); 1156 AbsPosition = tgetstr ("cm", address);
1157 CR = tgetstr ("cr", address); 1157 CR = tgetstr ("cr", address);
1158 TS_set_scroll_region = tgetstr ("cs", address); 1158 TS_set_scroll_region = tgetstr ("cs", address);
1159 TS_set_scroll_region_1 = tgetstr ("cS", address); 1159 TS_set_scroll_region_1 = tgetstr ("cS", address);
1207 MultiDown = tgetstr ("DO", address); 1207 MultiDown = tgetstr ("DO", address);
1208 MultiLeft = tgetstr ("LE", address); 1208 MultiLeft = tgetstr ("LE", address);
1209 MultiRight = tgetstr ("RI", address); 1209 MultiRight = tgetstr ("RI", address);
1210 1210
1211 AutoWrap = tgetflag ("am"); 1211 AutoWrap = tgetflag ("am");
1212 memory_below_screen = tgetflag ("db"); 1212 memory_below_frame = tgetflag ("db");
1213 TF_hazeltine = tgetflag ("hz"); 1213 TF_hazeltine = tgetflag ("hz");
1214 must_write_spaces = tgetflag ("in"); 1214 must_write_spaces = tgetflag ("in");
1215 meta_key = tgetflag ("km") || tgetflag ("MT"); 1215 meta_key = tgetflag ("km") || tgetflag ("MT");
1216 TF_insmode_motion = tgetflag ("mi"); 1216 TF_insmode_motion = tgetflag ("mi");
1217 TF_standout_motion = tgetflag ("ms"); 1217 TF_standout_motion = tgetflag ("ms");
1220 TF_xs = tgetflag ("xs"); 1220 TF_xs = tgetflag ("xs");
1221 TF_teleray = tgetflag ("xt"); 1221 TF_teleray = tgetflag ("xt");
1222 1222
1223 term_get_fkeys (address); 1223 term_get_fkeys (address);
1224 1224
1225 /* Get screen size from system, or else from termcap. */ 1225 /* Get frame size from system, or else from termcap. */
1226 get_screen_size (&SCREEN_WIDTH (selected_screen), 1226 get_frame_size (&FRAME_WIDTH (selected_frame),
1227 &SCREEN_HEIGHT (selected_screen)); 1227 &FRAME_HEIGHT (selected_frame));
1228 if (SCREEN_WIDTH (selected_screen) <= 0) 1228 if (FRAME_WIDTH (selected_frame) <= 0)
1229 SCREEN_WIDTH (selected_screen) = tgetnum ("co"); 1229 FRAME_WIDTH (selected_frame) = tgetnum ("co");
1230 if (SCREEN_HEIGHT (selected_screen) <= 0) 1230 if (FRAME_HEIGHT (selected_frame) <= 0)
1231 SCREEN_HEIGHT (selected_screen) = tgetnum ("li"); 1231 FRAME_HEIGHT (selected_frame) = tgetnum ("li");
1232 1232
1233 min_padding_speed = tgetnum ("pb"); 1233 min_padding_speed = tgetnum ("pb");
1234 TN_standout_width = tgetnum ("sg"); 1234 TN_standout_width = tgetnum ("sg");
1235 TabWidth = tgetnum ("tw"); 1235 TabWidth = tgetnum ("tw");
1236 1236
1283 1283
1284 /* Special handling for certain terminal types known to need it */ 1284 /* Special handling for certain terminal types known to need it */
1285 1285
1286 if (!strcmp (terminal_type, "supdup")) 1286 if (!strcmp (terminal_type, "supdup"))
1287 { 1287 {
1288 memory_below_screen = 1; 1288 memory_below_frame = 1;
1289 Wcm.cm_losewrap = 1; 1289 Wcm.cm_losewrap = 1;
1290 } 1290 }
1291 if (!strncmp (terminal_type, "c10", 3) 1291 if (!strncmp (terminal_type, "c10", 3)
1292 || !strcmp (terminal_type, "perq")) 1292 || !strcmp (terminal_type, "perq"))
1293 { 1293 {
1294 /* Supply a makeshift :wi string. 1294 /* Supply a makeshift :wi string.
1295 This string is not valid in general since it works only 1295 This string is not valid in general since it works only
1296 for windows starting at the upper left corner; 1296 for windows starting at the upper left corner;
1297 but that is all Emacs uses. 1297 but that is all Emacs uses.
1298 1298
1299 This string works only if the screen is using 1299 This string works only if the frame is using
1300 the top of the video memory, because addressing is memory-relative. 1300 the top of the video memory, because addressing is memory-relative.
1301 So first check the :ti string to see if that is true. 1301 So first check the :ti string to see if that is true.
1302 1302
1303 It would be simpler if the :wi string could go in the termcap 1303 It would be simpler if the :wi string could go in the termcap
1304 entry, but it can't because it is not fully valid. 1304 entry, but it can't because it is not fully valid.
1328 p[1] = 'C'; 1328 p[1] = 'C';
1329 p++; 1329 p++;
1330 } 1330 }
1331 } 1331 }
1332 1332
1333 ScreenRows = SCREEN_HEIGHT (selected_screen); 1333 FrameRows = FRAME_HEIGHT (selected_frame);
1334 ScreenCols = SCREEN_WIDTH (selected_screen); 1334 FrameCols = FRAME_WIDTH (selected_frame);
1335 specified_window = SCREEN_HEIGHT (selected_screen); 1335 specified_window = FRAME_HEIGHT (selected_frame);
1336 1336
1337 if (Wcm_init () == -1) /* can't do cursor motion */ 1337 if (Wcm_init () == -1) /* can't do cursor motion */
1338 #ifdef VMS 1338 #ifdef VMS
1339 fatal ("Terminal type \"%s\" is not powerful enough to run Emacs.\n\ 1339 fatal ("Terminal type \"%s\" is not powerful enough to run Emacs.\n\
1340 It lacks the ability to position the cursor.\n\ 1340 It lacks the ability to position the cursor.\n\
1348 If that is not the actual type of terminal you have,\n\ 1348 If that is not the actual type of terminal you have,\n\
1349 use the C-shell command `setenv TERM ...' to specify the correct type.\n\ 1349 use the C-shell command `setenv TERM ...' to specify the correct type.\n\
1350 It may be necessary to do `unsetenv TERMCAP' as well.\n", 1350 It may be necessary to do `unsetenv TERMCAP' as well.\n",
1351 terminal_type); 1351 terminal_type);
1352 #endif 1352 #endif
1353 if (SCREEN_HEIGHT (selected_screen) <= 0 1353 if (FRAME_HEIGHT (selected_frame) <= 0
1354 || SCREEN_WIDTH (selected_screen) <= 0) 1354 || FRAME_WIDTH (selected_frame) <= 0)
1355 fatal ("The screen size has not been specified."); 1355 fatal ("The frame size has not been specified.");
1356 1356
1357 delete_in_insert_mode 1357 delete_in_insert_mode
1358 = TS_delete_mode && TS_insert_mode 1358 = TS_delete_mode && TS_insert_mode
1359 && !strcmp (TS_delete_mode, TS_insert_mode); 1359 && !strcmp (TS_delete_mode, TS_insert_mode);
1360 1360
1362 && TS_end_standout_mode 1362 && TS_end_standout_mode
1363 && !strcmp (TS_standout_mode, TS_end_standout_mode)); 1363 && !strcmp (TS_standout_mode, TS_end_standout_mode));
1364 1364
1365 /* Remove width of standout marker from usable width of line */ 1365 /* Remove width of standout marker from usable width of line */
1366 if (TN_standout_width > 0) 1366 if (TN_standout_width > 0)
1367 SCREEN_WIDTH (selected_screen) -= TN_standout_width; 1367 FRAME_WIDTH (selected_frame) -= TN_standout_width;
1368 1368
1369 UseTabs = tabs_safe_p () && TabWidth == 8; 1369 UseTabs = tabs_safe_p () && TabWidth == 8;
1370 1370
1371 scroll_region_ok 1371 scroll_region_ok
1372 = (Wcm.cm_abs 1372 = (Wcm.cm_abs