#include "dispextern.h"
#include "window.h"
+#ifdef HAVE_TERMCAP_H
+#include <termcap.h>
+#endif
+
#include "cm.h"
#ifdef HAVE_X_WINDOWS
#include "xterm.h"
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
-#define OUTPUT(a) tputs (a, (int) (FRAME_HEIGHT (selected_frame) - curY), cmputc)
+#define OUTPUT(a) \
+ tputs (a, (int) (FRAME_HEIGHT (XFRAME (selected_frame)) - curY), cmputc)
#define OUTPUT1(a) tputs (a, 1, cmputc)
#define OUTPUTL(a, lines) tputs (a, lines, cmputc)
#define OUTPUT_IF(a) \
- if (a) \
- tputs (a, (int) (FRAME_HEIGHT (selected_frame) - curY), cmputc); \
- else \
- (void) 0
+ do { \
+ if (a) \
+ tputs (a, (int) (FRAME_HEIGHT (XFRAME (selected_frame)) \
+ - curY), cmputc); \
+ } while (0)
-#define OUTPUT1_IF(a) if (a) tputs (a, 1, cmputc); else (void) 0
+#define OUTPUT1_IF(a) do { if (a) tputs (a, 1, cmputc); } while (0)
/* Function to use to ring the bell. */
return;
}
- if (! FRAME_TERMCAP_P (selected_frame))
+ if (! FRAME_TERMCAP_P (XFRAME (selected_frame)))
{
(*ring_bell_hook) ();
return;
void
set_terminal_modes ()
{
- if (! FRAME_TERMCAP_P (selected_frame))
+ if (! FRAME_TERMCAP_P (XFRAME (selected_frame)))
{
(*set_terminal_modes_hook) ();
return;
void
reset_terminal_modes ()
{
- if (! FRAME_TERMCAP_P (selected_frame))
+ if (! FRAME_TERMCAP_P (XFRAME (selected_frame)))
{
if (reset_terminal_modes_hook)
(*reset_terminal_modes_hook) ();
(*set_terminal_window_hook) (size);
return;
}
- specified_window = size ? size : FRAME_HEIGHT (selected_frame);
+ specified_window = size ? size : FRAME_HEIGHT (XFRAME (selected_frame));
if (!scroll_region_ok)
return;
set_scroll_region (0, specified_window);
int start, stop;
{
char *buf;
+ struct frame *sf = XFRAME (selected_frame);
+
if (TS_set_scroll_region)
{
buf = tparam (TS_set_scroll_region, 0, 0, start, stop - 1);
else if (TS_set_scroll_region_1)
{
buf = tparam (TS_set_scroll_region_1, 0, 0,
- FRAME_HEIGHT (selected_frame), start,
- FRAME_HEIGHT (selected_frame) - stop,
- FRAME_HEIGHT (selected_frame));
+ FRAME_HEIGHT (sf), start,
+ FRAME_HEIGHT (sf) - stop,
+ FRAME_HEIGHT (sf));
}
else
{
- buf = tparam (TS_set_window, 0, 0, start, 0, stop, FRAME_WIDTH (selected_frame));
+ buf = tparam (TS_set_window, 0, 0, start, 0, stop, FRAME_WIDTH (sf));
}
OUTPUT (buf);
xfree (buf);
int highlight;
int vpos;
{
- if (! FRAME_TERMCAP_P ((updating_frame ? updating_frame : selected_frame)))
+ struct frame *f = updating_frame ? updating_frame : XFRAME (selected_frame);
+ if (! FRAME_TERMCAP_P (f))
{
(*reassert_line_highlight_hook) (highlight, vpos);
return;
/* On Teleray, make sure to erase the SO marker. */
if (TF_teleray)
{
- cmgoto (curY - 1, FRAME_WIDTH (selected_frame) - 4);
+ 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;
cursor_to (vpos, hpos)
int vpos, hpos;
{
- if (! FRAME_TERMCAP_P ((updating_frame ? updating_frame : selected_frame))
- && cursor_to_hook)
+ struct frame *f = updating_frame ? updating_frame : XFRAME (selected_frame);
+
+ if (! FRAME_TERMCAP_P (f) && cursor_to_hook)
{
(*cursor_to_hook) (vpos, hpos);
return;
raw_cursor_to (row, col)
int row, col;
{
- if (! FRAME_TERMCAP_P ((updating_frame ? updating_frame : selected_frame)))
+ struct frame *f = updating_frame ? updating_frame : XFRAME (selected_frame);
+ if (! FRAME_TERMCAP_P (f))
{
(*raw_cursor_to_hook) (row, col);
return;
{
background_highlight ();
OUTPUT (TS_clr_to_bottom);
- bzero (chars_wasted + curY, FRAME_HEIGHT (selected_frame) - curY);
+ bzero (chars_wasted + curY,
+ FRAME_HEIGHT (XFRAME (selected_frame)) - curY);
}
else
{
- for (i = curY; i < FRAME_HEIGHT (selected_frame); i++)
+ for (i = curY; i < FRAME_HEIGHT (XFRAME (selected_frame)); i++)
{
cursor_to (i, 0);
- clear_end_of_line_raw (FRAME_WIDTH (selected_frame));
+ clear_end_of_line_raw (FRAME_WIDTH (XFRAME (selected_frame)));
}
}
}
void
clear_frame ()
{
+ struct frame *sf = XFRAME (selected_frame);
+
if (clear_frame_hook
- && ! FRAME_TERMCAP_P ((updating_frame ? updating_frame : selected_frame)))
+ && ! FRAME_TERMCAP_P ((updating_frame ? updating_frame : sf)))
{
(*clear_frame_hook) ();
return;
{
background_highlight ();
OUTPUT (TS_clr_frame);
- bzero (chars_wasted, FRAME_HEIGHT (selected_frame));
+ bzero (chars_wasted, FRAME_HEIGHT (sf));
cmat (0, 0);
}
else
clear_end_of_line (first_unused_hpos)
int first_unused_hpos;
{
- if (FRAME_TERMCAP_P (selected_frame)
+ 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);
if (clear_end_of_line_hook
&& ! FRAME_TERMCAP_P ((updating_frame
? updating_frame
- : selected_frame)))
+ : XFRAME (selected_frame))))
{
(*clear_end_of_line_hook) (first_unused_hpos);
return;
}
else
{ /* have to do it the hard way */
+ struct frame *sf = XFRAME (selected_frame);
turn_off_insert ();
/* Do not write in last row last col with Auto-wrap on. */
- if (AutoWrap && curY == FRAME_HEIGHT (selected_frame) - 1
- && first_unused_hpos == FRAME_WIDTH (selected_frame))
+ if (AutoWrap && curY == FRAME_HEIGHT (sf) - 1
+ && first_unused_hpos == FRAME_WIDTH (sf))
first_unused_hpos--;
for (i = curX; i < first_unused_hpos; i++)
unsigned char *dst_start = dst, *dst_end = dst + dst_len;
register GLYPH g;
unsigned int c;
- unsigned char workbuf[4], *buf;
+ unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *buf;
int len;
register int tlen = GLYPH_TABLE_LENGTH;
register Lisp_Object *tbase = GLYPH_TABLE_BASE;
if (! GLYPH_CHAR_VALID_P (c))
{
c = ' ';
- g = MAKE_GLYPH (selected_frame, c,
- GLYPH_FACE (selected_frame, g));
- }
- if (COMPOSITE_CHAR_P (c))
- {
- /* If C is a composite character, we can display
- only the first component. */
- g = cmpchar_table[COMPOSITE_CHAR_ID (c)]->glyph[0],
- c = GLYPH_CHAR (selected_frame, g);
+ g = MAKE_GLYPH (sf, c, GLYPH_FACE (sf, g));
}
if (c < tlen)
{
/* G has an entry in Vglyph_table,
so process any alias before testing for simpleness. */
GLYPH_FOLLOW_ALIASES (tbase, tlen, g);
- c = GLYPH_CHAR (selected_frame, g);
+ c = GLYPH_CHAR (sf, g);
}
if (GLYPH_SIMPLE_P (tbase, tlen, g))
- /* We set the multi-byte form of C at BUF. */
- len = CHAR_STRING (c, workbuf, buf);
+ {
+ /* We set the multi-byte form of C at WORKBUF. */
+ len = CHAR_STRING (c, workbuf);
+ buf = workbuf;
+ }
else
{
/* We have a string in Vglyph_table. */
register int len;
{
int produced, consumed;
- struct frame *f = updating_frame ? updating_frame : selected_frame;
+ struct frame *sf = XFRAME (selected_frame);
+ struct frame *f = updating_frame ? updating_frame : sf;
if (write_glyphs_hook
&& ! FRAME_TERMCAP_P (f))
since that would scroll the whole frame on some terminals. */
if (AutoWrap
- && curY + 1 == FRAME_HEIGHT (selected_frame)
- && (curX + len - (chars_wasted[curY] & 077)
- == FRAME_WIDTH (selected_frame)))
+ && curY + 1 == FRAME_HEIGHT (sf)
+ && (curX + len - (chars_wasted[curY] & 077) == FRAME_WIDTH (sf)))
len --;
if (len <= 0)
return;
{
char *buf;
GLYPH g;
- struct frame *f;
+ struct frame *f, *sf;
if (len <= 0)
return;
return;
}
- f = updating_frame ? updating_frame : selected_frame;
+ sf = XFRAME (selected_frame);
+ f = updating_frame ? updating_frame : sf;
highlight_if_desired ();
if (TS_ins_multi_chars)
char *multi = n > 0 ? TS_ins_multi_lines : TS_del_multi_lines;
char *single = n > 0 ? TS_ins_line : TS_del_line;
char *scroll = n > 0 ? TS_rev_scroll : TS_fwd_scroll;
+ struct frame *sf;
register int i = n > 0 ? n : -n;
register char *buf;
return;
}
+ sf = XFRAME (selected_frame);
+
/* If the lines below the insertion are being pushed
into the end of the window, this is the same as clearing;
and we know the lines are already clear, since the matching
as there will be a matching inslines later that will flush them. */
if (scroll_region_ok && vpos + i >= specified_window)
return;
- if (!memory_below_frame && vpos + i >= FRAME_HEIGHT (selected_frame))
+ if (!memory_below_frame && vpos + i >= FRAME_HEIGHT (sf))
return;
if (multi)
register int lower_limit
= (scroll_region_ok
? specified_window
- : FRAME_HEIGHT (selected_frame));
+ : FRAME_HEIGHT (sf));
if (n < 0)
{
}
if (!scroll_region_ok && memory_below_frame && n < 0)
{
- cursor_to (FRAME_HEIGHT (selected_frame) + n, 0);
+ cursor_to (FRAME_HEIGHT (sf) + n, 0);
clear_to_end ();
}
}
{
/* If a hook is installed, let it do the work. */
xassert (it->what == IT_CHARACTER
+ || it->what == IT_COMPOSITION
|| it->what == IT_IMAGE
|| it->what == IT_STRETCH);
- /* Nothing but characters are supported on terminal frames. */
- xassert (it->what == IT_CHARACTER);
+ /* Nothing but characters are supported on terminal frames. For a
+ composition sequence, it->c is the first character of the
+ sequence. */
+ xassert (it->what == IT_CHARACTER
+ || it->what == IT_COMPOSITION);
if (it->c >= 040 && it->c < 0177)
{
}
else
{
- /* A multi-byte character. The display width is a per character
- value for characters of set CHARSET_COMPOSITION; otherwise
- it is fixed for all characters of the set. Some of the
- glyphs may have to be ignored because they are already
- displayed in a continued line. */
+ /* A multi-byte character. The display width is fixed for all
+ characters of the set. Some of the glyphs may have to be
+ ignored because they are already displayed in a continued
+ line. */
int charset = CHAR_CHARSET (it->c);
- if (charset == CHARSET_COMPOSITION)
- it->pixel_width = cmpchar_table[COMPOSITE_CHAR_ID (it->c)]->width;
- else
- it->pixel_width = CHARSET_WIDTH (charset);
+ it->pixel_width = CHARSET_WIDTH (charset);
it->nglyphs = it->pixel_width;
if (it->glyph_row)
the caller. */
if (it->area == TEXT_AREA)
it->current_x += it->pixel_width;
- it->ascent = it->max_ascent = 0;
- it->descent = it->max_descent = 1;
+ it->ascent = it->max_ascent = it->phys_ascent = it->max_phys_ascent = 0;
+ it->descent = it->max_descent = it->phys_descent = it->max_phys_descent = 1;
}
&& TN_magic_cookie_glitch_ul <= 0)
OUTPUT1_IF (TS_enter_underline_mode);
- if (face->tty_reverse_p)
+ if (face->tty_reverse_p
+ || face->foreground == FACE_TTY_DEFAULT_BG_COLOR
+ || face->background == FACE_TTY_DEFAULT_FG_COLOR)
OUTPUT1_IF (TS_enter_reverse_mode);
if (TN_max_colors > 0)
char *p;
if (face->foreground != FACE_TTY_DEFAULT_COLOR
+ && face->foreground != FACE_TTY_DEFAULT_FG_COLOR
+ && face->foreground != FACE_TTY_DEFAULT_BG_COLOR
&& TS_set_foreground)
{
p = tparam (TS_set_foreground, NULL, 0, (int) face->foreground);
}
if (face->background != FACE_TTY_DEFAULT_COLOR
+ && face->background != FACE_TTY_DEFAULT_BG_COLOR
+ && face->background != FACE_TTY_DEFAULT_FG_COLOR
&& TS_set_background)
{
p = tparam (TS_set_background, NULL, 0, (int) face->background);
int face_id;
{
struct face *face = FACE_FROM_ID (f, face_id);
- Lisp_Object entry;
xassert (face != NULL);
/* Switch back to default colors. */
if (TN_max_colors > 0
- && (face->foreground != FACE_TTY_DEFAULT_COLOR
- || face->background != FACE_TTY_DEFAULT_COLOR))
+ && ((face->foreground != FACE_TTY_DEFAULT_COLOR
+ && face->foreground != FACE_TTY_DEFAULT_FG_COLOR)
+ || (face->background != FACE_TTY_DEFAULT_COLOR
+ && face->background != FACE_TTY_DEFAULT_BG_COLOR)))
OUTPUT1_IF (TS_orig_pair);
}
char buffer[2044];
register char *p;
int status;
+ struct frame *sf = XFRAME (selected_frame);
#ifdef WINDOWSNT
initialize_w32_display ();
if (area == 0)
abort ();
- FrameRows = FRAME_HEIGHT (selected_frame);
- FrameCols = FRAME_WIDTH (selected_frame);
- specified_window = FRAME_HEIGHT (selected_frame);
+ FrameRows = FRAME_HEIGHT (sf);
+ FrameCols = FRAME_WIDTH (sf);
+ specified_window = FRAME_HEIGHT (sf);
delete_in_insert_mode = 1;
baud_rate = 19200;
- FRAME_CAN_HAVE_SCROLL_BARS (selected_frame) = 0;
- FRAME_VERTICAL_SCROLL_BAR_TYPE (selected_frame) = vertical_scroll_bar_none;
+ FRAME_CAN_HAVE_SCROLL_BARS (sf) = 0;
+ FRAME_VERTICAL_SCROLL_BAR_TYPE (sf) = vertical_scroll_bar_none;
return;
#else /* not WINDOWSNT */
MultiLeft = tgetstr ("LE", address);
MultiRight = tgetstr ("RI", address);
- /* SVr4/ANSI color suppert. */
+ /* SVr4/ANSI color suppert. If "op" isn't available, don't support
+ color because we can't switch back to the default foreground and
+ background. */
TS_orig_pair = tgetstr ("op", address);
- TS_set_foreground = tgetstr ("AF", address);
- TS_set_background = tgetstr ("AB", address);
- if (!TS_set_foreground)
+ if (TS_orig_pair)
{
- /* SVr4. */
- TS_set_foreground = tgetstr ("Sf", address);
- TS_set_background = tgetstr ("Sb", address);
+ TS_set_foreground = tgetstr ("AF", address);
+ TS_set_background = tgetstr ("AB", address);
+ if (!TS_set_foreground)
+ {
+ /* SVr4. */
+ TS_set_foreground = tgetstr ("Sf", address);
+ TS_set_background = tgetstr ("Sb", address);
+ }
+ TN_max_colors = tgetnum ("Co");
+ TN_max_pairs = tgetnum ("pa");
}
- TN_max_colors = tgetnum ("Co");
- TN_max_pairs = tgetnum ("pa");
MagicWrap = tgetflag ("xn");
/* Since we make MagicWrap terminals look like AutoWrap, we need to have
{
int height, width;
get_frame_size (&width, &height);
- FRAME_WIDTH (selected_frame) = width;
- FRAME_HEIGHT (selected_frame) = height;
+ FRAME_WIDTH (sf) = width;
+ FRAME_HEIGHT (sf) = height;
}
- if (FRAME_WIDTH (selected_frame) <= 0)
- SET_FRAME_WIDTH (selected_frame, tgetnum ("co"));
+ if (FRAME_WIDTH (sf) <= 0)
+ SET_FRAME_WIDTH (sf, tgetnum ("co"));
else
/* Keep width and external_width consistent */
- SET_FRAME_WIDTH (selected_frame, FRAME_WIDTH (selected_frame));
- if (FRAME_HEIGHT (selected_frame) <= 0)
- FRAME_HEIGHT (selected_frame) = tgetnum ("li");
+ SET_FRAME_WIDTH (sf, FRAME_WIDTH (sf));
+ if (FRAME_HEIGHT (sf) <= 0)
+ FRAME_HEIGHT (sf) = tgetnum ("li");
- if (FRAME_HEIGHT (selected_frame) < 3
- || FRAME_WIDTH (selected_frame) < 3)
+ if (FRAME_HEIGHT (sf) < 3 || FRAME_WIDTH (sf) < 3)
fatal ("Screen size %dx%d is too small",
- FRAME_HEIGHT (selected_frame), FRAME_WIDTH (selected_frame));
+ FRAME_HEIGHT (sf), FRAME_WIDTH (sf));
min_padding_speed = tgetnum ("pb");
TN_standout_width = tgetnum ("sg");
}
}
- FrameRows = FRAME_HEIGHT (selected_frame);
- FrameCols = FRAME_WIDTH (selected_frame);
- specified_window = FRAME_HEIGHT (selected_frame);
+ FrameRows = FRAME_HEIGHT (sf);
+ FrameCols = FRAME_WIDTH (sf);
+ specified_window = FRAME_HEIGHT (sf);
if (Wcm_init () == -1) /* can't do cursor motion */
#ifdef VMS
terminal_type);
# endif /* TERMINFO */
#endif /*VMS */
- if (FRAME_HEIGHT (selected_frame) <= 0
- || FRAME_WIDTH (selected_frame) <= 0)
+ if (FRAME_HEIGHT (sf) <= 0
+ || FRAME_WIDTH (sf) <= 0)
fatal ("The frame size has not been specified");
delete_in_insert_mode
/* Remove width of standout marker from usable width of line */
if (TN_standout_width > 0)
- SET_FRAME_WIDTH (selected_frame,
- FRAME_WIDTH (selected_frame) - TN_standout_width);
+ SET_FRAME_WIDTH (sf, FRAME_WIDTH (sf) - TN_standout_width);
UseTabs = tabs_safe_p () && TabWidth == 8;
/* meaningless in this case */
baud_rate = 9600;
- FRAME_CAN_HAVE_SCROLL_BARS (selected_frame) = 0;
- FRAME_VERTICAL_SCROLL_BAR_TYPE (selected_frame) = vertical_scroll_bar_none;
+ FRAME_CAN_HAVE_SCROLL_BARS (sf) = 0;
+ FRAME_VERTICAL_SCROLL_BAR_TYPE (sf) = vertical_scroll_bar_none;
#endif /* WINDOWSNT */
}