#include <stdio.h>
#include <ctype.h>
#include <string.h>
+
#include "termchar.h"
#include "termopts.h"
-#define DOC_STRINGS_IN_COMMENTS
#include "lisp.h"
#include "charset.h"
#include "coding.h"
void (*ins_del_lines_hook) P_ ((int, int));
-void (*change_line_highlight_hook) P_ ((int, int, int, int));
-void (*reassert_line_highlight_hook) P_ ((int, int));
-
void (*delete_glyphs_hook) P_ ((int));
void (*ring_bell_hook) P_ ((void));
char *TS_exit_underline_mode, *TS_enter_underline_mode;
-/* "ug" -- number of blanks left by underline. */
-
-int TN_magic_cookie_glitch_ul;
-
/* "as"/"ae" -- start/end alternate character set. Not really
supported, yet. */
int TF_teleray; /* termcap xt flag: many weird consequences.
For t1061. */
-int TF_xs; /* Nonzero for "xs". If set together with
- TN_standout_width == 0, it means don't bother
- to write any end-standout cookies. */
-
-int TN_standout_width; /* termcap sg number: width occupied by standout
- markers */
-
static int RPov; /* # chars to start a TS_repeat */
static int delete_in_insert_mode; /* delete mode == insert mode */
int max_frame_height;
-/* Number of chars of space used for standout marker at beginning of line,
- or'd with 0100. Zero if no standout marker at all.
- The length of these vectors is max_frame_height.
-
- Used IFF TN_standout_width >= 0. */
-
-static char *chars_wasted;
-static char *copybuf;
-
-/* nonzero means supposed to write text in standout mode. */
-
-int standout_requested;
+int costs_set = 0; /* Nonzero if costs have been calculated. */
int insert_mode; /* Nonzero when in insert mode. */
int standout_mode; /* Nonzero when in standout mode. */
{
if (FRAME_TERMCAP_P (XFRAME (selected_frame)))
{
- if (TN_standout_width < 0)
- turn_off_highlight ();
+ turn_off_highlight ();
turn_off_insert ();
OUTPUT_IF (TS_end_keypad_mode);
OUTPUT_IF (TS_cursor_normal);
OUTPUT_IF (TS_end_termcap_modes);
OUTPUT_IF (TS_orig_pair);
/* Output raw CR so kernel can track the cursor hpos. */
- /* But on magic-cookie terminals this can erase an end-standout
- marker and cause the rest of the frame to be in standout, so
- move down first. */
- if (TN_standout_width >= 0)
- cmputc ('\n');
cmputc ('\r');
}
else if (reset_terminal_modes_hook)
tty_show_cursor ();
turn_off_insert ();
background_highlight ();
- standout_requested = 0;
}
else
update_end_hook (f);
insert_mode = 0;
}
\f
-/* Handle highlighting when TN_standout_width (termcap sg) is not specified.
- In these terminals, output is affected by the value of standout
- mode when the output is written.
-
- These functions are called on all terminals, but do nothing
- on terminals whose standout mode does not work that way. */
+/* Handle highlighting. */
void
turn_off_highlight ()
{
- if (TN_standout_width < 0)
- {
- if (standout_mode)
- OUTPUT_IF (TS_end_standout_mode);
- standout_mode = 0;
- }
+ if (standout_mode)
+ OUTPUT_IF (TS_end_standout_mode);
+ standout_mode = 0;
}
static void
turn_on_highlight ()
{
- if (TN_standout_width < 0)
- {
- if (!standout_mode)
- OUTPUT_IF (TS_standout_mode);
- standout_mode = 1;
- }
+ if (!standout_mode)
+ OUTPUT_IF (TS_standout_mode);
+ standout_mode = 1;
}
static void
void
background_highlight ()
{
- if (TN_standout_width >= 0)
- return;
if (inverse_video)
turn_on_highlight ();
else
static void
highlight_if_desired ()
{
- if (TN_standout_width >= 0)
- return;
- if (!inverse_video == !standout_requested)
- turn_off_highlight ();
- else
+ if (inverse_video)
turn_on_highlight ();
-}
-\f
-/* Handle standout mode for terminals in which TN_standout_width >= 0.
- On these terminals, standout is controlled by markers that
- live inside the terminal's memory. TN_standout_width is the width
- that the marker occupies in memory. Standout runs from the marker
- to the end of the line on some terminals, or to the next
- turn-off-standout marker (TS_end_standout_mode) string
- on other terminals. */
-
-/* Write a standout marker or end-standout marker at the front of the line
- at vertical position vpos. */
-
-static void
-write_standout_marker (flag, vpos)
- int flag, vpos;
-{
- if (flag
- || (TS_end_standout_mode && !TF_teleray && !se_is_so
- && !(TF_xs && TN_standout_width == 0)))
- {
- cmgoto (vpos, 0);
- cmplus (TN_standout_width);
- OUTPUT (flag ? TS_standout_mode : TS_end_standout_mode);
- chars_wasted[curY] = TN_standout_width | 0100;
- }
-}
-\f
-/* External interface to control of standout mode.
- Call this when about to modify line at position VPOS
- and not change whether it is highlighted. */
-
-void
-reassert_line_highlight (highlight, vpos)
- int highlight;
- int vpos;
-{
- struct frame *f = updating_frame ? updating_frame : XFRAME (selected_frame);
- if (! FRAME_TERMCAP_P (f))
- {
- (*reassert_line_highlight_hook) (highlight, vpos);
- return;
- }
- if (TN_standout_width < 0)
- /* Handle terminals where standout takes affect at output time */
- standout_requested = highlight;
- else if (chars_wasted && chars_wasted[vpos] == 0)
- /* For terminals with standout markers, write one on this line
- if there isn't one already. */
- write_standout_marker (inverse_video ? !highlight : highlight, vpos);
-}
-
-/* Call this when about to modify line at position VPOS
- and change whether it is highlighted. */
-
-void
-change_line_highlight (new_highlight, vpos, y, first_unused_hpos)
- int new_highlight, vpos, y, first_unused_hpos;
-{
- standout_requested = new_highlight;
- if (! FRAME_TERMCAP_P (updating_frame))
- {
- (*change_line_highlight_hook) (new_highlight, vpos, y, first_unused_hpos);
- return;
- }
-
- cursor_to (vpos, 0);
-
- if (TN_standout_width < 0)
- background_highlight ();
- /* If line starts with a marker, delete the marker */
- else if (TS_clr_line && chars_wasted[curY])
- {
- turn_off_insert ();
- /* On Teleray, make sure to erase the SO marker. */
- if (TF_teleray)
- {
- cmgoto (curY - 1, FRAME_WIDTH (XFRAME (selected_frame)) - 4);
- OUTPUT ("\033S");
- curY++; /* ESC S moves to next line where the TS_standout_mode was */
- curX = 0;
- }
- else
- cmgoto (curY, 0); /* reposition to kill standout marker */
- }
- clear_end_of_line_raw (first_unused_hpos);
- reassert_line_highlight (new_highlight, curY);
+ else
+ turn_off_highlight ();
}
\f
/* Detect the case where we are called from reset_sys_modes
and the costs have never been calculated. Do nothing. */
- if (chars_wasted == 0)
+ if (! costs_set)
return;
- hpos += chars_wasted[vpos] & 077;
if (curY == vpos && curX == hpos)
return;
if (!TF_standout_motion)
{
background_highlight ();
OUTPUT (TS_clr_to_bottom);
- bzero (chars_wasted + curY,
- FRAME_HEIGHT (XFRAME (selected_frame)) - curY);
}
else
{
for (i = curY; i < FRAME_HEIGHT (XFRAME (selected_frame)); i++)
{
cursor_to (i, 0);
- clear_end_of_line_raw (FRAME_WIDTH (XFRAME (selected_frame)));
+ clear_end_of_line (FRAME_WIDTH (XFRAME (selected_frame)));
}
}
}
{
background_highlight ();
OUTPUT (TS_clr_frame);
- bzero (chars_wasted, FRAME_HEIGHT (sf));
cmat (0, 0);
}
else
}
}
-/* Clear to end of line, but do not clear any standout marker.
- Assumes that the cursor is positioned at a character of real text,
- which implies it cannot be before a standout marker
- unless the marker has zero width.
-
- Note that the cursor may be moved. */
-
-void
-clear_end_of_line (first_unused_hpos)
- int first_unused_hpos;
-{
- if (FRAME_TERMCAP_P (XFRAME (selected_frame))
- && chars_wasted != 0
- && TN_standout_width == 0 && curX == 0 && chars_wasted[curY] != 0)
- write_glyphs (&space_glyph, 1);
- clear_end_of_line_raw (first_unused_hpos);
-}
-
/* Clear from cursor to end of line.
Assume that the line is already clear starting at column first_unused_hpos.
- If the cursor is at a standout marker, erase the marker.
Note that the cursor may be moved, on terminals lacking a `ce' string. */
void
-clear_end_of_line_raw (first_unused_hpos)
+clear_end_of_line (first_unused_hpos)
int first_unused_hpos;
{
register int i;
/* Detect the case where we are called from reset_sys_modes
and the costs have never been calculated. Do nothing. */
- if (chars_wasted == 0)
+ if (! costs_set)
return;
- first_unused_hpos += chars_wasted[curY] & 077;
if (curX >= first_unused_hpos)
return;
- /* Notice if we are erasing a magic cookie */
- if (curX == 0)
- chars_wasted[curY] = 0;
background_highlight ();
if (TS_clr_line)
{
if (AutoWrap
&& curY + 1 == FRAME_HEIGHT (sf)
- && (curX + len - (chars_wasted[curY] & 077) == FRAME_WIDTH (sf)))
+ && (curX + len) == FRAME_WIDTH (sf))
len --;
if (len <= 0)
return;
set_scroll_region (0, specified_window);
}
- if (TN_standout_width >= 0)
- {
- register int lower_limit
- = (scroll_region_ok
- ? specified_window
- : FRAME_HEIGHT (sf));
-
- if (n < 0)
- {
- bcopy (&chars_wasted[vpos - n], &chars_wasted[vpos],
- lower_limit - vpos + n);
- bzero (&chars_wasted[lower_limit + n], - n);
- }
- else
- {
- bcopy (&chars_wasted[vpos], ©buf[vpos], lower_limit - vpos - n);
- bcopy (©buf[vpos], &chars_wasted[vpos + n],
- lower_limit - vpos - n);
- bzero (&chars_wasted[vpos], n);
- }
- }
if (!scroll_region_ok && memory_below_frame && n < 0)
{
cursor_to (FRAME_HEIGHT (sf) + n, 0);
once for the terminal frame of X-windows emacs, but not used afterwards.
char_ins_del_vector (i.e., char_ins_del_cost) isn't used because
- X turns off char_ins_del_ok.
-
- chars_wasted and copybuf are only used here in term.c in cases where
- the term hook isn't called. */
+ X turns off char_ins_del_ok. */
max_frame_height = max (max_frame_height, FRAME_HEIGHT (frame));
max_frame_width = max (max_frame_width, FRAME_WIDTH (frame));
- if (chars_wasted != 0)
- chars_wasted = (char *) xrealloc (chars_wasted, max_frame_height);
- else
- chars_wasted = (char *) xmalloc (max_frame_height);
-
- if (copybuf != 0)
- copybuf = (char *) xrealloc (copybuf, max_frame_height);
- else
- copybuf = (char *) xmalloc (max_frame_height);
+ costs_set = 1;
if (char_ins_del_vector != 0)
char_ins_del_vector
= (int *) xmalloc (sizeof (int)
+ 2 * max_frame_width * sizeof (int));
- bzero (chars_wasted, max_frame_height);
- bzero (copybuf, max_frame_height);
bzero (char_ins_del_vector, (sizeof (int)
+ 2 * max_frame_width * sizeof (int)));
&& MAY_USE_WITH_COLORS_P (NC_BLINK))
OUTPUT1_IF (TS_enter_blink_mode);
- if (face->tty_underline_p
- /* Don't underline if that's difficult. */
- && TN_magic_cookie_glitch_ul <= 0
- && MAY_USE_WITH_COLORS_P (NC_UNDERLINE))
+ if (face->tty_underline_p && MAY_USE_WITH_COLORS_P (NC_UNDERLINE))
OUTPUT1_IF (TS_enter_underline_mode);
if (TN_max_colors > 0)
if (face->tty_alt_charset_p)
OUTPUT_IF (TS_exit_alt_charset_mode);
- if (face->tty_underline_p
- /* We don't underline if that's difficult. */
- && TN_magic_cookie_glitch_ul <= 0)
+ if (face->tty_underline_p)
OUTPUT_IF (TS_exit_underline_mode);
}
DEFUN ("tty-display-color-p", Ftty_display_color_p, Stty_display_color_p,
0, 1, 0,
- /* Return non-nil if TTY can display colors on FRAME. */
- (frame))
+ doc: /* Return non-nil if TTY can display colors on FRAME. */)
+ (frame)
Lisp_Object frame;
{
return TN_max_colors > 0 ? Qt : Qnil;
TS_enter_underline_mode = tgetstr ("us", address);
TS_exit_underline_mode = tgetstr ("ue", address);
- TN_magic_cookie_glitch_ul = tgetnum ("ug");
TS_enter_bold_mode = tgetstr ("md", address);
TS_enter_dim_mode = tgetstr ("mh", address);
TS_enter_blink_mode = tgetstr ("mb", address);
TF_insmode_motion = tgetflag ("mi");
TF_standout_motion = tgetflag ("ms");
TF_underscore = tgetflag ("ul");
- TF_xs = tgetflag ("xs");
TF_teleray = tgetflag ("xt");
term_get_fkeys (address);
FRAME_HEIGHT (sf), FRAME_WIDTH (sf));
min_padding_speed = tgetnum ("pb");
- TN_standout_width = tgetnum ("sg");
TabWidth = tgetnum ("tw");
#ifdef VMS
Wcm.cm_tab = "\t";
*/
+ /* We don't support standout modes that use `magic cookies', so
+ turn off any that do. */
+ if (TS_standout_mode && tgetnum ("sg") >= 0)
+ {
+ TS_standout_mode = 0;
+ TS_end_standout_mode = 0;
+ }
+ if (TS_enter_underline_mode && tgetnum ("ug") >= 0)
+ {
+ TS_enter_underline_mode = 0;
+ TS_exit_underline_mode = 0;
+ }
+
+ /* If there's no standout mode, try to use underlining instead. */
if (TS_standout_mode == 0)
{
- TN_standout_width = tgetnum ("ug");
- TS_end_standout_mode = tgetstr ("ue", address);
- TS_standout_mode = tgetstr ("us", address);
+ TS_standout_mode = TS_enter_underline_mode;
+ TS_end_standout_mode = TS_exit_underline_mode;
}
/* If no `se' string, try using a `me' string instead.
if (TF_teleray)
{
Wcm.cm_tab = 0;
- /* Teleray: most programs want a space in front of TS_standout_mode,
- but Emacs can do without it (and give one extra column). */
- TS_standout_mode = "\033RD";
- TN_standout_width = 1;
+ /* We can't support standout mode, because it uses magic cookies. */
+ TS_standout_mode = 0;
/* But that means we cannot rely on ^M to go to column zero! */
CR = 0;
/* LF can't be trusted either -- can alter hpos */
&& TS_end_standout_mode
&& !strcmp (TS_standout_mode, TS_end_standout_mode));
- /* Remove width of standout marker from usable width of line */
- if (TN_standout_width > 0)
- SET_FRAME_WIDTH (sf, FRAME_WIDTH (sf) - TN_standout_width);
-
UseTabs = tabs_safe_p () && TabWidth == 8;
scroll_region_ok
void
syms_of_term ()
{
- DEFVAR_BOOL ("system-uses-terminfo", &system_uses_terminfo
- /* Non-nil means the system uses terminfo rather than termcap.
+ DEFVAR_BOOL ("system-uses-terminfo", &system_uses_terminfo,
+ doc: /* Non-nil means the system uses terminfo rather than termcap.
This variable can be used by terminal emulator packages. */);
#ifdef TERMINFO
system_uses_terminfo = 1;
system_uses_terminfo = 0;
#endif
- DEFVAR_LISP ("ring-bell-function", &Vring_bell_function
- /* Non-nil means call this function to ring the bell.
+ DEFVAR_LISP ("ring-bell-function", &Vring_bell_function,
+ doc: /* Non-nil means call this function to ring the bell.
The function should accept no arguments. */);
Vring_bell_function = Qnil;