+2013-10-14 Dmitry Antipov <dmantipov@yandex.ru>
+
+ * termhooks.h (FRAME_MUST_WRITE_SPACES, FRAME_LINE_INS_DEL_OK)
+ (FRAME_CHAR_INS_DEL_OK, FRAME_SCROLL_REGION_OK)
+ (FRAME_SCROLL_REGION_COST, FRAME_MEMORY_BELOW_FRAME):
+ Adjust to match the change described below.
+ (struct terminal): Move must_write_spaces, line_ins_del_ok,
+ char_ins_del_ok, scroll_region_ok, scroll_region_cost and
+ memory_below_frame members to...
+ * termchar.h (struct tty_display_info): ...here because they're
+ relevant only on TTYs. Prefer unsigned bitfield where appropriate.
+ * term.c (init_tty):
+ * nsterm.m (ns_create_terminal):
+ * w32term.c (w32_create_terminal):
+ * xterm.c (x_create_terminal): Adjust users.
+ * dispnew.c (line_hash_code, line_draw_cost): Pass frame arg
+ to filter out non-TTY frames. Adjust comment.
+ (scrolling): Adjust user. Prefer eassert for debugging check.
+
2013-10-14 Dmitry Antipov <dmantipov@yandex.ru>
* xfaces.c (PT_PER_INCH): Remove unused macro.
}
-/* Return a hash code for glyph row ROW. */
+/* Return a hash code for glyph row ROW, which may
+ be from current or desired matrix of frame F. */
static int
-line_hash_code (struct glyph_row *row)
+line_hash_code (struct frame *f, struct glyph_row *row)
{
int hash = 0;
{
int c = glyph->u.ch;
int face_id = glyph->face_id;
- if (FRAME_MUST_WRITE_SPACES (SELECTED_FRAME ())) /* XXX Is SELECTED_FRAME OK here? */
+ if (FRAME_MUST_WRITE_SPACES (f))
c -= SPACEGLYPH;
hash = (((hash << 4) + (hash >> 24)) & 0x0fffffff) + c;
hash = (((hash << 4) + (hash >> 24)) & 0x0fffffff) + face_id;
}
-/* Return the cost of drawing line VPOS in MATRIX. The cost equals
- the number of characters in the line. If must_write_spaces is
- zero, leading and trailing spaces are ignored. */
+/* Return the cost of drawing line VPOS in MATRIX, which may
+ be current or desired matrix of frame F. The cost equals
+ the number of characters in the line. If must_write_spaces
+ is zero, leading and trailing spaces are ignored. */
static int
-line_draw_cost (struct glyph_matrix *matrix, int vpos)
+line_draw_cost (struct frame *f, struct glyph_matrix *matrix, int vpos)
{
struct glyph_row *row = matrix->rows + vpos;
struct glyph *beg = row->glyphs[TEXT_AREA];
ptrdiff_t glyph_table_len = GLYPH_TABLE_LENGTH;
/* Ignore trailing and leading spaces if we can. */
- if (!FRAME_MUST_WRITE_SPACES (SELECTED_FRAME ())) /* XXX Is SELECTED_FRAME OK here? */
+ if (!FRAME_MUST_WRITE_SPACES (f))
{
/* Skip from the end over trailing spaces. */
while (end > beg && CHAR_GLYPH_SPACE_P (*(end - 1)))
struct glyph_matrix *current_matrix = frame->current_matrix;
struct glyph_matrix *desired_matrix = frame->desired_matrix;
- if (!current_matrix)
- emacs_abort ();
+ eassert (current_matrix);
/* Compute hash codes of all the lines. Also calculate number of
changed lines, number of unchanged lines at the beginning, and
/* Give up on this scrolling if some old lines are not enabled. */
if (!MATRIX_ROW_ENABLED_P (current_matrix, i))
return 0;
- old_hash[i] = line_hash_code (MATRIX_ROW (current_matrix, i));
+ old_hash[i] = line_hash_code (frame, MATRIX_ROW (current_matrix, i));
if (! MATRIX_ROW_ENABLED_P (desired_matrix, i))
{
/* This line cannot be redrawn, so don't let scrolling mess it. */
}
else
{
- new_hash[i] = line_hash_code (MATRIX_ROW (desired_matrix, i));
- draw_cost[i] = line_draw_cost (desired_matrix, i);
+ new_hash[i] = line_hash_code (frame, MATRIX_ROW (desired_matrix, i));
+ draw_cost[i] = line_draw_cost (frame, desired_matrix, i);
}
if (old_hash[i] != new_hash[i])
}
else if (i == unchanged_at_top)
unchanged_at_top++;
- old_draw_cost[i] = line_draw_cost (current_matrix, i);
+ old_draw_cost[i] = line_draw_cost (frame, current_matrix, i);
}
/* If changed lines are few, don't allow preemption, don't scroll. */
terminal->delete_frame_hook = x_destroy_window;
terminal->delete_terminal_hook = ns_delete_terminal;
- terminal->scroll_region_ok = 1;
- terminal->char_ins_del_ok = 1;
- terminal->line_ins_del_ok = 1;
- terminal->memory_below_frame = 0;
-
return terminal;
}
/* Since we make MagicWrap terminals look like AutoWrap, we need to have
the former flag imply the latter. */
AutoWrap (tty) = MagicWrap (tty) || tgetflag ("am");
- terminal->memory_below_frame = tgetflag ("db");
+ tty->memory_below_frame = tgetflag ("db");
tty->TF_hazeltine = tgetflag ("hz");
- terminal->must_write_spaces = tgetflag ("in");
+ tty->must_write_spaces = tgetflag ("in");
tty->meta_key = tgetflag ("km") || tgetflag ("MT");
tty->TF_insmode_motion = tgetflag ("mi");
tty->TF_standout_motion = tgetflag ("ms");
tty->specified_window = height;
FRAME_VERTICAL_SCROLL_BAR_TYPE (f) = vertical_scroll_bar_none;
- terminal->char_ins_del_ok = 1;
+ tty->char_ins_del_ok = 1;
baud_rate = 19200;
}
#else /* MSDOS */
get_tty_size (fileno (tty->input), &width, &height);
FrameCols (tty) = width;
FrameRows (tty) = height;
- terminal->char_ins_del_ok = 0;
+ tty->char_ins_del_ok = 0;
init_baud_rate (fileno (tty->input));
}
#endif /* MSDOS */
tty->delete_in_insert_mode = 1;
UseTabs (tty) = 0;
- terminal->scroll_region_ok = 0;
+ tty->scroll_region_ok = 0;
/* Seems to insert lines when it's not supposed to, messing up the
display. In doing a trace, it didn't seem to be called much, so I
don't think we're losing anything by turning it off. */
- terminal->line_ins_del_ok = 0;
+ tty->line_ins_del_ok = 0;
tty->TN_max_colors = 16; /* Must be non-zero for tty-display-color-p. */
#endif /* DOS_NT */
UseTabs (tty) = tabs_safe_p (fileno (tty->input)) && TabWidth (tty) == 8;
- terminal->scroll_region_ok
+ tty->scroll_region_ok
= (tty->Wcm->cm_abs
&& (tty->TS_set_window || tty->TS_set_scroll_region || tty->TS_set_scroll_region_1));
- terminal->line_ins_del_ok
+ tty->line_ins_del_ok
= (((tty->TS_ins_line || tty->TS_ins_multi_lines)
&& (tty->TS_del_line || tty->TS_del_multi_lines))
- || (terminal->scroll_region_ok
+ || (tty->scroll_region_ok
&& tty->TS_fwd_scroll && tty->TS_rev_scroll));
- terminal->char_ins_del_ok
+ tty->char_ins_del_ok
= ((tty->TS_ins_char || tty->TS_insert_mode
|| tty->TS_pad_inserted_char || tty->TS_ins_multi_chars)
&& (tty->TS_del_char || tty->TS_del_multi_chars));
/* Non-zero means we are displaying a TTY menu on this tty. */
unsigned showing_menu : 1;
+
+ /* Nonzero means spaces in the text must actually be output;
+ can't just skip over some columns to leave them blank. */
+ unsigned must_write_spaces : 1;
+
+ /* Nonzero if TTY can insert and delete lines. */
+ unsigned line_ins_del_ok : 1;
+
+ /* Nonzero if TTY can insert and delete chars. */
+ unsigned char_ins_del_ok : 1;
+
+ /* Nonzero if TTY supports setting the scroll window. */
+ unsigned scroll_region_ok : 1;
+
+ /* Nonzero if TTY remembers lines scrolled off bottom. */
+ unsigned memory_below_frame : 1;
+
+ /* Cost of setting the scroll window, measured in characters. */
+ int scroll_region_cost;
};
/* A chain of structures for all tty devices currently in use. */
the function `set-keyboard-coding-system'. */
struct coding_system *keyboard_coding;
- /* Terminal characteristics. */
- /* XXX Are these really used on non-termcap displays? */
-
- int must_write_spaces; /* Nonzero means spaces in the text must
- actually be output; can't just skip over
- some columns to leave them blank. */
- int line_ins_del_ok; /* Terminal can insert and delete lines. */
- int char_ins_del_ok; /* Terminal can insert and delete chars. */
- int scroll_region_ok; /* Terminal supports setting the scroll
- window. */
- int scroll_region_cost; /* Cost of setting the scroll window,
- measured in characters. */
- int memory_below_frame; /* Terminal remembers lines scrolled
- off bottom. */
-
/* Window-based redisplay interface for this device (0 for tty
devices). */
struct redisplay_interface *rif;
/* Chain of all terminal devices currently in use. */
extern struct terminal *terminal_list;
-#define FRAME_MUST_WRITE_SPACES(f) ((f)->terminal->must_write_spaces)
-#define FRAME_LINE_INS_DEL_OK(f) ((f)->terminal->line_ins_del_ok)
-#define FRAME_CHAR_INS_DEL_OK(f) ((f)->terminal->char_ins_del_ok)
-#define FRAME_SCROLL_REGION_OK(f) ((f)->terminal->scroll_region_ok)
-#define FRAME_SCROLL_REGION_COST(f) ((f)->terminal->scroll_region_cost)
-#define FRAME_MEMORY_BELOW_FRAME(f) ((f)->terminal->memory_below_frame)
+#define FRAME_MUST_WRITE_SPACES(f) (FRAME_TTY (f)->must_write_spaces)
+#define FRAME_LINE_INS_DEL_OK(f) (FRAME_TTY (f)->line_ins_del_ok)
+#define FRAME_CHAR_INS_DEL_OK(f) (FRAME_TTY (f)->char_ins_del_ok)
+#define FRAME_SCROLL_REGION_OK(f) (FRAME_TTY (f)->scroll_region_ok)
+#define FRAME_SCROLL_REGION_COST(f) (FRAME_TTY (f)->scroll_region_cost)
+#define FRAME_MEMORY_BELOW_FRAME(f) (FRAME_TTY (f)->memory_below_frame)
#define FRAME_TERMINAL_CODING(f) ((f)->terminal->terminal_coding)
#define FRAME_KEYBOARD_CODING(f) ((f)->terminal->keyboard_coding)
terminal->delete_terminal_hook = x_delete_terminal;
terminal->rif = &w32_redisplay_interface;
- terminal->scroll_region_ok = 1; /* We'll scroll partial frames. */
- terminal->char_ins_del_ok = 1;
- terminal->line_ins_del_ok = 1; /* We'll just blt 'em. */
- terminal->memory_below_frame = 0; /* We don't remember what scrolls
- off the bottom. */
/* We don't yet support separate terminals on W32, so don't try to share
keyboards between virtual terminals that are on the same physical
terminal->delete_terminal_hook = x_delete_terminal;
terminal->rif = &x_redisplay_interface;
- terminal->scroll_region_ok = 1; /* We'll scroll partial frames. */
- terminal->char_ins_del_ok = 1;
- terminal->line_ins_del_ok = 1; /* We'll just blt 'em. */
- terminal->memory_below_frame = 0; /* We don't remember what scrolls
- off the bottom. */
return terminal;
}