comparison src/term.c @ 40086:050b19294988

(TN_standout_width, TF_xs, TN_magic_cookie_glitch_ul): Variables removed. (term_init): Don't set them. Turn off any standout/underline modes that require magic cookies. (ins_del_lines, highlight_if_desired, background_highlight) (turn_on_highlight, turn_off_highlight, reset_terminal_modes): Remove special processing for magic-cookie standout modes. (turn_off_face, turn_on_face): Remove special processing for underline magic-cookie glitch.
author Miles Bader <miles@gnu.org>
date Sat, 20 Oct 2001 10:32:22 +0000
parents 07d7dbf18784
children 706558f91b28
comparison
equal deleted inserted replaced
40085:09c1c5193715 40086:050b19294988
320 320
321 /* "us"/"ue" -- start/end underlining. */ 321 /* "us"/"ue" -- start/end underlining. */
322 322
323 char *TS_exit_underline_mode, *TS_enter_underline_mode; 323 char *TS_exit_underline_mode, *TS_enter_underline_mode;
324 324
325 /* "ug" -- number of blanks left by underline. */
326
327 int TN_magic_cookie_glitch_ul;
328
329 /* "as"/"ae" -- start/end alternate character set. Not really 325 /* "as"/"ae" -- start/end alternate character set. Not really
330 supported, yet. */ 326 supported, yet. */
331 327
332 char *TS_enter_alt_charset_mode, *TS_exit_alt_charset_mode; 328 char *TS_enter_alt_charset_mode, *TS_exit_alt_charset_mode;
333 329
359 int TF_underscore; /* termcap ul flag: _ underlines if over-struck on 355 int TF_underscore; /* termcap ul flag: _ underlines if over-struck on
360 non-blank position. Must clear before writing _. */ 356 non-blank position. Must clear before writing _. */
361 int TF_teleray; /* termcap xt flag: many weird consequences. 357 int TF_teleray; /* termcap xt flag: many weird consequences.
362 For t1061. */ 358 For t1061. */
363 359
364 int TF_xs; /* Nonzero for "xs". If set together with
365 TN_standout_width == 0, it means don't bother
366 to write any end-standout cookies. */
367
368 int TN_standout_width; /* termcap sg number: width occupied by standout
369 markers */
370
371 static int RPov; /* # chars to start a TS_repeat */ 360 static int RPov; /* # chars to start a TS_repeat */
372 361
373 static int delete_in_insert_mode; /* delete mode == insert mode */ 362 static int delete_in_insert_mode; /* delete mode == insert mode */
374 363
375 static int se_is_so; /* 1 if same string both enters and leaves 364 static int se_is_so; /* 1 if same string both enters and leaves
473 void 462 void
474 reset_terminal_modes () 463 reset_terminal_modes ()
475 { 464 {
476 if (FRAME_TERMCAP_P (XFRAME (selected_frame))) 465 if (FRAME_TERMCAP_P (XFRAME (selected_frame)))
477 { 466 {
478 if (TN_standout_width < 0) 467 turn_off_highlight ();
479 turn_off_highlight ();
480 turn_off_insert (); 468 turn_off_insert ();
481 OUTPUT_IF (TS_end_keypad_mode); 469 OUTPUT_IF (TS_end_keypad_mode);
482 OUTPUT_IF (TS_cursor_normal); 470 OUTPUT_IF (TS_cursor_normal);
483 OUTPUT_IF (TS_end_termcap_modes); 471 OUTPUT_IF (TS_end_termcap_modes);
484 OUTPUT_IF (TS_orig_pair); 472 OUTPUT_IF (TS_orig_pair);
485 /* Output raw CR so kernel can track the cursor hpos. */ 473 /* Output raw CR so kernel can track the cursor hpos. */
486 /* But on magic-cookie terminals this can erase an end-standout
487 marker and cause the rest of the frame to be in standout, so
488 move down first. */
489 if (TN_standout_width >= 0)
490 cmputc ('\n');
491 cmputc ('\r'); 474 cmputc ('\r');
492 } 475 }
493 else if (reset_terminal_modes_hook) 476 else if (reset_terminal_modes_hook)
494 (*reset_terminal_modes_hook) (); 477 (*reset_terminal_modes_hook) ();
495 } 478 }
571 if (insert_mode) 554 if (insert_mode)
572 OUTPUT (TS_end_insert_mode); 555 OUTPUT (TS_end_insert_mode);
573 insert_mode = 0; 556 insert_mode = 0;
574 } 557 }
575 558
576 /* Handle highlighting when TN_standout_width (termcap sg) is not specified. 559 /* Handle highlighting. */
577 In these terminals, output is affected by the value of standout
578 mode when the output is written.
579
580 These functions are called on all terminals, but do nothing
581 on terminals whose standout mode does not work that way. */
582 560
583 void 561 void
584 turn_off_highlight () 562 turn_off_highlight ()
585 { 563 {
586 if (TN_standout_width < 0) 564 if (standout_mode)
587 { 565 OUTPUT_IF (TS_end_standout_mode);
588 if (standout_mode) 566 standout_mode = 0;
589 OUTPUT_IF (TS_end_standout_mode);
590 standout_mode = 0;
591 }
592 } 567 }
593 568
594 static void 569 static void
595 turn_on_highlight () 570 turn_on_highlight ()
596 { 571 {
597 if (TN_standout_width < 0) 572 if (!standout_mode)
598 { 573 OUTPUT_IF (TS_standout_mode);
599 if (!standout_mode) 574 standout_mode = 1;
600 OUTPUT_IF (TS_standout_mode);
601 standout_mode = 1;
602 }
603 } 575 }
604 576
605 static void 577 static void
606 toggle_highlight () 578 toggle_highlight ()
607 { 579 {
644 depends on the user option inverse-video. */ 616 depends on the user option inverse-video. */
645 617
646 void 618 void
647 background_highlight () 619 background_highlight ()
648 { 620 {
649 if (TN_standout_width >= 0)
650 return;
651 if (inverse_video) 621 if (inverse_video)
652 turn_on_highlight (); 622 turn_on_highlight ();
653 else 623 else
654 turn_off_highlight (); 624 turn_off_highlight ();
655 } 625 }
657 /* Set standout mode to the mode specified for the text to be output. */ 627 /* Set standout mode to the mode specified for the text to be output. */
658 628
659 static void 629 static void
660 highlight_if_desired () 630 highlight_if_desired ()
661 { 631 {
662 if (TN_standout_width >= 0)
663 return;
664 if (inverse_video) 632 if (inverse_video)
665 turn_on_highlight (); 633 turn_on_highlight ();
666 else 634 else
667 turn_off_highlight (); 635 turn_off_highlight ();
668 } 636 }
1220 while (--i >= 0) 1188 while (--i >= 0)
1221 OUTPUTL (scroll, specified_window - vpos); 1189 OUTPUTL (scroll, specified_window - vpos);
1222 set_scroll_region (0, specified_window); 1190 set_scroll_region (0, specified_window);
1223 } 1191 }
1224 1192
1225 if (TN_standout_width >= 0)
1226 {
1227 register int lower_limit
1228 = (scroll_region_ok
1229 ? specified_window
1230 : FRAME_HEIGHT (sf));
1231 }
1232 if (!scroll_region_ok && memory_below_frame && n < 0) 1193 if (!scroll_region_ok && memory_below_frame && n < 0)
1233 { 1194 {
1234 cursor_to (FRAME_HEIGHT (sf) + n, 0); 1195 cursor_to (FRAME_HEIGHT (sf) + n, 0);
1235 clear_to_end (); 1196 clear_to_end ();
1236 } 1197 }
1933 1894
1934 if (face->tty_blinking_p 1895 if (face->tty_blinking_p
1935 && MAY_USE_WITH_COLORS_P (NC_BLINK)) 1896 && MAY_USE_WITH_COLORS_P (NC_BLINK))
1936 OUTPUT1_IF (TS_enter_blink_mode); 1897 OUTPUT1_IF (TS_enter_blink_mode);
1937 1898
1938 if (face->tty_underline_p 1899 if (face->tty_underline_p && MAY_USE_WITH_COLORS_P (NC_UNDERLINE))
1939 /* Don't underline if that's difficult. */
1940 && TN_magic_cookie_glitch_ul <= 0
1941 && MAY_USE_WITH_COLORS_P (NC_UNDERLINE))
1942 OUTPUT1_IF (TS_enter_underline_mode); 1900 OUTPUT1_IF (TS_enter_underline_mode);
1943 1901
1944 if (TN_max_colors > 0) 1902 if (TN_max_colors > 0)
1945 { 1903 {
1946 char *p; 1904 char *p;
1998 /* If we don't have "me" we can only have those appearances 1956 /* If we don't have "me" we can only have those appearances
1999 that have exit sequences defined. */ 1957 that have exit sequences defined. */
2000 if (face->tty_alt_charset_p) 1958 if (face->tty_alt_charset_p)
2001 OUTPUT_IF (TS_exit_alt_charset_mode); 1959 OUTPUT_IF (TS_exit_alt_charset_mode);
2002 1960
2003 if (face->tty_underline_p 1961 if (face->tty_underline_p)
2004 /* We don't underline if that's difficult. */
2005 && TN_magic_cookie_glitch_ul <= 0)
2006 OUTPUT_IF (TS_exit_underline_mode); 1962 OUTPUT_IF (TS_exit_underline_mode);
2007 } 1963 }
2008 1964
2009 /* Switch back to default colors. */ 1965 /* Switch back to default colors. */
2010 if (TN_max_colors > 0 1966 if (TN_max_colors > 0
2178 TS_cursor_invisible = tgetstr ("vi", address); 2134 TS_cursor_invisible = tgetstr ("vi", address);
2179 TS_set_window = tgetstr ("wi", address); 2135 TS_set_window = tgetstr ("wi", address);
2180 2136
2181 TS_enter_underline_mode = tgetstr ("us", address); 2137 TS_enter_underline_mode = tgetstr ("us", address);
2182 TS_exit_underline_mode = tgetstr ("ue", address); 2138 TS_exit_underline_mode = tgetstr ("ue", address);
2183 TN_magic_cookie_glitch_ul = tgetnum ("ug");
2184 TS_enter_bold_mode = tgetstr ("md", address); 2139 TS_enter_bold_mode = tgetstr ("md", address);
2185 TS_enter_dim_mode = tgetstr ("mh", address); 2140 TS_enter_dim_mode = tgetstr ("mh", address);
2186 TS_enter_blink_mode = tgetstr ("mb", address); 2141 TS_enter_blink_mode = tgetstr ("mb", address);
2187 TS_enter_reverse_mode = tgetstr ("mr", address); 2142 TS_enter_reverse_mode = tgetstr ("mr", address);
2188 TS_enter_alt_charset_mode = tgetstr ("as", address); 2143 TS_enter_alt_charset_mode = tgetstr ("as", address);
2226 must_write_spaces = tgetflag ("in"); 2181 must_write_spaces = tgetflag ("in");
2227 meta_key = tgetflag ("km") || tgetflag ("MT"); 2182 meta_key = tgetflag ("km") || tgetflag ("MT");
2228 TF_insmode_motion = tgetflag ("mi"); 2183 TF_insmode_motion = tgetflag ("mi");
2229 TF_standout_motion = tgetflag ("ms"); 2184 TF_standout_motion = tgetflag ("ms");
2230 TF_underscore = tgetflag ("ul"); 2185 TF_underscore = tgetflag ("ul");
2231 TF_xs = tgetflag ("xs");
2232 TF_teleray = tgetflag ("xt"); 2186 TF_teleray = tgetflag ("xt");
2233 2187
2234 term_get_fkeys (address); 2188 term_get_fkeys (address);
2235 2189
2236 /* Get frame size from system, or else from termcap. */ 2190 /* Get frame size from system, or else from termcap. */
2252 if (FRAME_HEIGHT (sf) < 3 || FRAME_WIDTH (sf) < 3) 2206 if (FRAME_HEIGHT (sf) < 3 || FRAME_WIDTH (sf) < 3)
2253 fatal ("Screen size %dx%d is too small", 2207 fatal ("Screen size %dx%d is too small",
2254 FRAME_HEIGHT (sf), FRAME_WIDTH (sf)); 2208 FRAME_HEIGHT (sf), FRAME_WIDTH (sf));
2255 2209
2256 min_padding_speed = tgetnum ("pb"); 2210 min_padding_speed = tgetnum ("pb");
2257 TN_standout_width = tgetnum ("sg");
2258 TabWidth = tgetnum ("tw"); 2211 TabWidth = tgetnum ("tw");
2259 2212
2260 #ifdef VMS 2213 #ifdef VMS
2261 /* These capabilities commonly use ^J. 2214 /* These capabilities commonly use ^J.
2262 I don't know why, but sending them on VMS does not work; 2215 I don't know why, but sending them on VMS does not work;
2281 and newer termcap doc does not seem to say there is a default. 2234 and newer termcap doc does not seem to say there is a default.
2282 if (!Wcm.cm_tab) 2235 if (!Wcm.cm_tab)
2283 Wcm.cm_tab = "\t"; 2236 Wcm.cm_tab = "\t";
2284 */ 2237 */
2285 2238
2239 /* We don't support standout modes that use `magic cookies', so
2240 turn off any that do. */
2241 if (TS_standout_mode && tgetnum ("sg") >= 0)
2242 {
2243 TS_standout_mode = 0;
2244 TS_end_standout_mode = 0;
2245 }
2246 if (TS_enter_underline_mode && tgetnum ("ug") >= 0)
2247 {
2248 TS_enter_underline_mode = 0;
2249 TS_exit_underline_mode = 0;
2250 }
2251
2252 /* If there's no standout mode, try to use underlining instead. */
2286 if (TS_standout_mode == 0) 2253 if (TS_standout_mode == 0)
2287 { 2254 {
2288 TN_standout_width = tgetnum ("ug"); 2255 TS_standout_mode = TS_enter_underline_mode;
2289 TS_end_standout_mode = tgetstr ("ue", address); 2256 TS_end_standout_mode = TS_exit_underline_mode;
2290 TS_standout_mode = tgetstr ("us", address);
2291 } 2257 }
2292 2258
2293 /* If no `se' string, try using a `me' string instead. 2259 /* If no `se' string, try using a `me' string instead.
2294 If that fails, we can't use standout mode at all. */ 2260 If that fails, we can't use standout mode at all. */
2295 if (TS_end_standout_mode == 0) 2261 if (TS_end_standout_mode == 0)
2302 } 2268 }
2303 2269
2304 if (TF_teleray) 2270 if (TF_teleray)
2305 { 2271 {
2306 Wcm.cm_tab = 0; 2272 Wcm.cm_tab = 0;
2307 /* Teleray: most programs want a space in front of TS_standout_mode, 2273 /* We can't support standout mode, because it uses magic cookies. */
2308 but Emacs can do without it (and give one extra column). */ 2274 TS_standout_mode = 0;
2309 TS_standout_mode = "\033RD";
2310 TN_standout_width = 1;
2311 /* But that means we cannot rely on ^M to go to column zero! */ 2275 /* But that means we cannot rely on ^M to go to column zero! */
2312 CR = 0; 2276 CR = 0;
2313 /* LF can't be trusted either -- can alter hpos */ 2277 /* LF can't be trusted either -- can alter hpos */
2314 /* if move at column 0 thru a line with TS_standout_mode */ 2278 /* if move at column 0 thru a line with TS_standout_mode */
2315 Down = 0; 2279 Down = 0;
2405 2369
2406 se_is_so = (TS_standout_mode 2370 se_is_so = (TS_standout_mode
2407 && TS_end_standout_mode 2371 && TS_end_standout_mode
2408 && !strcmp (TS_standout_mode, TS_end_standout_mode)); 2372 && !strcmp (TS_standout_mode, TS_end_standout_mode));
2409 2373
2410 /* Remove width of standout marker from usable width of line */
2411 if (TN_standout_width > 0)
2412 SET_FRAME_WIDTH (sf, FRAME_WIDTH (sf) - TN_standout_width);
2413
2414 UseTabs = tabs_safe_p () && TabWidth == 8; 2374 UseTabs = tabs_safe_p () && TabWidth == 8;
2415 2375
2416 scroll_region_ok 2376 scroll_region_ok
2417 = (Wcm.cm_abs 2377 = (Wcm.cm_abs
2418 && (TS_set_window || TS_set_scroll_region || TS_set_scroll_region_1)); 2378 && (TS_set_window || TS_set_scroll_region || TS_set_scroll_region_1));