if (encode_terminal_src_size - nbytes < required)
{
- ptrdiff_t size;
- if (min (PTRDIFF_MAX, SIZE_MAX) - nbytes < required)
- memory_full (SIZE_MAX);
- size = nbytes + required;
- encode_terminal_src = xrealloc (encode_terminal_src, size);
- encode_terminal_src_size = size;
+ encode_terminal_src =
+ xpalloc (encode_terminal_src, &encode_terminal_src_size,
+ required - (encode_terminal_src_size - nbytes),
+ -1, 1);
buf = encode_terminal_src + nbytes;
}
{
int c = COMPOSITION_GLYPH (cmp, i);
+ /* TAB in a composition means display glyphs with
+ padding space on the left or right. */
if (c == '\t')
continue;
if (char_charset (c, charset_list, NULL))
nbytes = buf - encode_terminal_src;
if (encode_terminal_src_size - nbytes < MAX_MULTIBYTE_LENGTH)
{
- ptrdiff_t size;
- if (min (PTRDIFF_MAX, SIZE_MAX) - MAX_MULTIBYTE_LENGTH
- < nbytes)
- memory_full (SIZE_MAX);
- size = nbytes + MAX_MULTIBYTE_LENGTH;
- encode_terminal_src = xrealloc (encode_terminal_src, size);
- encode_terminal_src_size = size;
+ encode_terminal_src =
+ xpalloc (encode_terminal_src, &encode_terminal_src_size,
+ MAX_MULTIBYTE_LENGTH, -1, 1);
buf = encode_terminal_src + nbytes;
}
if (CHAR_BYTE8_P (c)
nbytes = buf - encode_terminal_src;
if (encode_terminal_src_size - nbytes < SBYTES (string))
{
- ptrdiff_t size;
- if (min (PTRDIFF_MAX, SIZE_MAX) - SBYTES (string) < nbytes)
- memory_full (SIZE_MAX);
- size = nbytes + SBYTES (string);
- encode_terminal_src = xrealloc (encode_terminal_src, size);
- encode_terminal_src_size = size;
+ encode_terminal_src =
+ xpalloc (encode_terminal_src, &encode_terminal_src_size,
+ (SBYTES (string)
+ - (encode_terminal_src_size - nbytes)),
+ -1, 1);
buf = encode_terminal_src + nbytes;
}
memcpy (buf, SDATA (string), SBYTES (string));
X turns off char_ins_del_ok. */
max_frame_cols = max (max_frame_cols, FRAME_COLS (frame));
- if ((min (PTRDIFF_MAX, SIZE_MAX) / sizeof (int) - 1) / 2 < max_frame_cols)
+ if ((min (PTRDIFF_MAX, SIZE_MAX) / sizeof (int) - 1) / 2
+ < max_frame_cols)
memory_full (SIZE_MAX);
- char_ins_del_vector
- = (int *) xrealloc (char_ins_del_vector,
- (sizeof (int)
- + 2 * max_frame_cols * sizeof (int)));
+ char_ins_del_vector =
+ xrealloc (char_ins_del_vector,
+ (sizeof (int) + 2 * sizeof (int) * max_frame_cols));
memset (char_ins_del_vector, 0,
- (sizeof (int) + 2 * max_frame_cols * sizeof (int)));
+ (sizeof (int) + 2 * sizeof (int) * max_frame_cols));
if (f && (!tty->TS_ins_line && !tty->TS_del_line))
Character Display Information
***********************************************************************/
static void append_glyph (struct it *);
-static void produce_stretch_glyph (struct it *);
static void append_composite_glyph (struct it *);
static void produce_composite_glyph (struct it *);
static void append_glyphless_glyph (struct it *, int, const char *);
}
}
+/* For external use. */
+void
+tty_append_glyph (struct it *it)
+{
+ append_glyph (it);
+}
+
+
/* Produce glyphs for the display element described by IT. *IT
specifies what we want to produce a glyph for (character, image, ...),
and where in the glyph matrix we currently are (glyph row and hpos).
it->descent = it->max_descent = it->phys_descent = it->max_phys_descent = 1;
}
-
-/* Produce a stretch glyph for iterator IT. IT->object is the value
- of the glyph property displayed. The value must be a list
- `(space KEYWORD VALUE ...)' with the following KEYWORD/VALUE pairs
- being recognized:
-
- 1. `:width WIDTH' specifies that the space should be WIDTH *
- canonical char width wide. WIDTH may be an integer or floating
- point number.
-
- 2. `:align-to HPOS' specifies that the space should be wide enough
- to reach HPOS, a value in canonical character units. */
-
-static void
-produce_stretch_glyph (struct it *it)
-{
- /* (space :width WIDTH ...) */
- Lisp_Object prop, plist;
- int width = 0, align_to = -1;
- int zero_width_ok_p = 0;
- double tem;
-
- /* List should start with `space'. */
- xassert (CONSP (it->object) && EQ (XCAR (it->object), Qspace));
- plist = XCDR (it->object);
-
- /* Compute the width of the stretch. */
- if ((prop = Fplist_get (plist, QCwidth), !NILP (prop))
- && calc_pixel_width_or_height (&tem, it, prop, 0, 1, 0))
- {
- /* Absolute width `:width WIDTH' specified and valid. */
- zero_width_ok_p = 1;
- width = (int)(tem + 0.5);
- }
- else if ((prop = Fplist_get (plist, QCalign_to), !NILP (prop))
- && calc_pixel_width_or_height (&tem, it, prop, 0, 1, &align_to))
- {
- if (it->glyph_row == NULL || !it->glyph_row->mode_line_p)
- align_to = (align_to < 0
- ? 0
- : align_to - window_box_left_offset (it->w, TEXT_AREA));
- else if (align_to < 0)
- align_to = window_box_left_offset (it->w, TEXT_AREA);
- width = max (0, (int)(tem + 0.5) + align_to - it->current_x);
- zero_width_ok_p = 1;
- }
- else
- /* Nothing specified -> width defaults to canonical char width. */
- width = FRAME_COLUMN_WIDTH (it->f);
-
- if (width <= 0 && (width < 0 || !zero_width_ok_p))
- width = 1;
-
- if (width > 0 && it->line_wrap != TRUNCATE
- && it->current_x + width > it->last_visible_x)
- width = it->last_visible_x - it->current_x - 1;
-
- if (width > 0 && it->glyph_row)
- {
- Lisp_Object o_object = it->object;
- Lisp_Object object = it->stack[it->sp - 1].string;
- int n = width;
-
- if (!STRINGP (object))
- object = it->w->buffer;
- it->object = object;
- it->char_to_display = ' ';
- it->pixel_width = it->len = 1;
- while (n--)
- append_glyph (it);
- it->object = o_object;
- }
- it->pixel_width = width;
- it->nglyphs = width;
-}
-
-
/* Append glyphs to IT's glyph_row for the composition IT->cmp_id.
Called from produce_composite_glyph for terminal frames if
IT->glyph_row != NULL. IT->face_id contains the character's
{
int face_id;
int len;
- char buf[9];
+ char buf[sizeof "\\x" + max (6, (sizeof it->c * CHAR_BIT + 3) / 4)];
char const *str = " ";
/* Get a face ID for the glyph by utilizing a cache (the same way as
else
SET_GLYPH_FROM_CHAR (glyph, '\\');
if (it->dp
- && (gc = DISP_CONTINUE_GLYPH (it->dp), GLYPH_CODE_P (gc))
- && GLYPH_CODE_CHAR_VALID_P (gc))
+ && (gc = DISP_CONTINUE_GLYPH (it->dp), GLYPH_CODE_P (gc)))
{
/* FIXME: Should we mirror GC for R2L lines? */
SET_GLYPH_FROM_GLYPH_CODE (glyph, gc);
/* Truncation glyph. */
SET_GLYPH_FROM_CHAR (glyph, '$');
if (it->dp
- && (gc = DISP_TRUNC_GLYPH (it->dp), GLYPH_CODE_P (gc))
- && GLYPH_CODE_CHAR_VALID_P (gc))
+ && (gc = DISP_TRUNC_GLYPH (it->dp), GLYPH_CODE_P (gc)))
{
/* FIXME: Should we mirror GC for R2L lines? */
SET_GLYPH_FROM_GLYPH_CODE (glyph, gc);
else
color_mode = Qnil;
- mode = INTEGERP (color_mode) ? XINT (color_mode) : 0;
+ mode = TYPE_RANGED_INTEGERP (int, color_mode) ? XINT (color_mode) : 0;
if (mode != tty->previous_color_mode)
{
encode_terminal_src_size = 0;
encode_terminal_dst_size = 0;
-#ifdef HAVE_GPM
- terminal->mouse_position_hook = term_mouse_position;
- tty->mouse_highlight.mouse_face_window = Qnil;
-#endif
-
#ifndef DOS_NT
set_tty_hooks (terminal);
tty->TN_max_colors = 16; /* Required to be non-zero for tty-display-color-p */
#endif /* DOS_NT */
+#ifdef HAVE_GPM
+ terminal->mouse_position_hook = term_mouse_position;
+ tty->mouse_highlight.mouse_face_window = Qnil;
+#endif
+
terminal->kboard = (KBOARD *) xmalloc (sizeof (KBOARD));
init_kboard (terminal->kboard);
KVAR (terminal->kboard, Vwindow_system) = Qnil;