int
window_box_width (struct window *w, int area)
{
- int cols = XFASTINT (w->total_cols);
+ int cols = w->total_cols;
int pixels = 0;
if (!w->pseudo_window_p)
at character position CHARPOS. CHARPOS < 0 means that no buffer
position is specified which is useful when the iterator is assigned
a position later. BYTEPOS is the byte position corresponding to
- CHARPOS. BYTEPOS < 0 means compute it from CHARPOS.
+ CHARPOS.
If ROW is not null, calls to produce_glyphs with IT as parameter
will produce glyphs in that row.
and IT->region_end_charpos to the start and end of a visible region
in window IT->w. Set both to -1 to indicate no region. */
markpos = markpos_of_region ();
- if (0 <= markpos
+ if (markpos >= 0
/* Maybe highlight only in selected window. */
&& (/* Either show region everywhere. */
highlight_nonselected_windows
if (charpos >= BUF_BEG (current_buffer))
{
it->end_charpos = ZV;
+ eassert (charpos == BYTE_TO_CHAR (bytepos));
IT_CHARPOS (*it) = charpos;
+ IT_BYTEPOS (*it) = bytepos;
/* We will rely on `reseat' to set this up properly, via
handle_face_prop. */
it->face_id = it->base_face_id;
- /* Compute byte position if not specified. */
- if (bytepos < charpos)
- IT_BYTEPOS (*it) = CHAR_TO_BYTE (charpos);
- else
- IT_BYTEPOS (*it) = bytepos;
-
it->start = it->current;
/* Do we need to reorder bidirectional text? Not if this is a
unibyte buffer: by definition, none of the single-byte
static void
back_to_previous_line_start (struct it *it)
{
- IT_CHARPOS (*it) = find_newline_no_quit (IT_CHARPOS (*it) - 1, -1,
- &IT_BYTEPOS (*it));
+ ptrdiff_t cp = IT_CHARPOS (*it), bp = IT_BYTEPOS (*it);
+
+ DEC_BOTH (cp, bp);
+ IT_CHARPOS (*it) = find_newline_no_quit (cp, bp, -1, &IT_BYTEPOS (*it));
}
if (!newline_found_p)
{
ptrdiff_t bytepos, start = IT_CHARPOS (*it);
- ptrdiff_t limit = find_newline_no_quit (start, 1, &bytepos);
+ ptrdiff_t limit = find_newline_no_quit (start, IT_BYTEPOS (*it),
+ 1, &bytepos);
Lisp_Object pos;
eassert (!STRINGP (it->string));
if (string_p)
it->bidi_it.charpos = it->bidi_it.bytepos = 0;
else
- it->bidi_it.charpos = find_newline_no_quit (IT_CHARPOS (*it), -1,
+ it->bidi_it.charpos = find_newline_no_quit (IT_CHARPOS (*it),
+ IT_BYTEPOS (*it), -1,
&it->bidi_it.bytepos);
bidi_paragraph_init (it->paragraph_embedding, &it->bidi_it, 1);
do
&& IT_CHARPOS (*it) > BEGV
&& FETCH_BYTE (IT_BYTEPOS (*it) - 1) != '\n')
{
- ptrdiff_t nl_pos = find_newline_no_quit (IT_CHARPOS (*it) - 1, -1,
- NULL);
+ ptrdiff_t cp = IT_CHARPOS (*it), bp = IT_BYTEPOS (*it);
- move_it_to (it, nl_pos, -1, -1, -1, MOVE_TO_POS);
+ DEC_BOTH (cp, bp);
+ cp = find_newline_no_quit (cp, bp, -1, NULL);
+ move_it_to (it, cp, -1, -1, -1, MOVE_TO_POS);
}
bidi_unshelve_cache (it3data, 1);
}
no additional border below the possibly empty tool-bar lines.
So to make the extra empty lines look "normal", we have to
use the tool-bar face for the border too. */
- if (!row->displays_text_p && !EQ (Vauto_resize_tool_bars, Qgrow_only))
+ if (!MATRIX_ROW_DISPLAYS_TEXT_P (row)
+ && !EQ (Vauto_resize_tool_bars, Qgrow_only))
it->face_id = DEFAULT_FACE_ID;
extend_face_to_end_of_line (it);
compute_line_metrics (it);
/* If line is empty, make it occupy the rest of the tool-bar. */
- if (!row->displays_text_p)
+ if (!MATRIX_ROW_DISPLAYS_TEXT_P (row))
{
row->height = row->phys_height = it->last_visible_y - row->y;
row->visible_height = row->height;
/* If there are blank lines at the end, except for a partially
visible blank line at the end that is smaller than
FRAME_LINE_HEIGHT, change the tool-bar's height. */
- if (!row->displays_text_p
+ if (!MATRIX_ROW_DISPLAYS_TEXT_P (row)
&& row->height >= FRAME_LINE_HEIGHT (f))
change_height_p = 1;
/* If row displays tool-bar items, but is partially visible,
change the tool-bar's height. */
- if (row->displays_text_p
+ if (MATRIX_ROW_DISPLAYS_TEXT_P (row)
&& MATRIX_ROW_BOTTOM_Y (row) > it.last_visible_y
&& MATRIX_ROW_BOTTOM_Y (row) < max_tool_bar_height)
change_height_p = 1;
/* If this row displays text now but previously didn't,
or vice versa, w->window_end_vpos may have to be
adjusted. */
- if ((it.glyph_row - 1)->displays_text_p)
+ if (MATRIX_ROW_DISPLAYS_TEXT_P (it.glyph_row - 1))
{
if (XFASTINT (w->window_end_vpos) < this_line_vpos)
wset_window_end_vpos (w, make_number (this_line_vpos));
PT == w->last_point
/* Make sure the cursor was last displayed
in this window. Otherwise we have to reposition it. */
- && 0 <= w->cursor.vpos
- && WINDOW_TOTAL_LINES (w) > w->cursor.vpos)
+ && w->cursor.vpos >= 0
+ && w->cursor.vpos < WINDOW_TOTAL_LINES (w))
{
if (!must_finish)
{
/* Skip over glyphs not having an object at the start and the end of
the row. These are special glyphs like truncation marks on
terminal frames. */
- if (row->displays_text_p)
+ if (MATRIX_ROW_DISPLAYS_TEXT_P (row))
{
if (!row->reversed_p)
{
we would rather display cursor in the next line. */
while (MATRIX_ROW_BOTTOM_Y (row) < last_y
&& MATRIX_ROW_END_CHARPOS (row) == PT
- && row < w->current_matrix->rows
- + w->current_matrix->nrows - 1
+ && row < MATRIX_MODE_LINE_ROW (w->current_matrix)
&& MATRIX_ROW_START_CHARPOS (row+1) == PT
&& !cursor_row_p (row))
++row;
/* If we are highlighting the region, then we just changed
the region, so redisplay to show it. */
- if (0 <= markpos_of_region ())
+ if (markpos_of_region () >= 0)
{
clear_glyph_matrix (w->desired_matrix);
if (!try_window (window, startp, 0))
wset_window_end_vpos
(w, make_number (MATRIX_ROW_VPOS (last_text_row, w->desired_matrix)));
eassert
- (MATRIX_ROW (w->desired_matrix,
- XFASTINT (w->window_end_vpos))->displays_text_p);
+ (MATRIX_ROW_DISPLAYS_TEXT_P (MATRIX_ROW (w->desired_matrix,
+ XFASTINT (w->window_end_vpos))));
}
else
{
return 0;
/* Can't do this if region may have changed. */
- if (0 <= markpos_of_region ()
+ if (markpos_of_region () >= 0
|| w->region_showing
|| !NILP (Vshow_trailing_whitespace))
return 0;
/* Can't use this if highlighting a region because a cursor movement
will do more than just set the cursor. */
- if (0 <= markpos_of_region ())
+ if (markpos_of_region () >= 0)
GIVE_UP (9);
/* Likewise if highlighting trailing whitespace. */
struct glyph_row *last_row = MATRIX_ROW (current_matrix, last_vpos);
/* If last_row is the window end line, it should display text. */
- eassert (last_row->displays_text_p);
+ eassert (MATRIX_ROW_DISPLAYS_TEXT_P (last_row));
/* If window end line was partially visible before, begin
displaying at that line. Otherwise begin displaying with the
matrix. Set row to the last row displaying text in current
matrix starting at first_unchanged_at_end_row, after
scrolling. */
- eassert (first_unchanged_at_end_row->displays_text_p);
+ eassert (MATRIX_ROW_DISPLAYS_TEXT_P (first_unchanged_at_end_row));
row = find_last_row_displaying_text (w->current_matrix, &it,
first_unchanged_at_end_row);
eassert (row && MATRIX_ROW_DISPLAYS_TEXT_P (row));
{
if (desired_row->enabled_p)
{
- if (desired_row->displays_text_p)
+ if (MATRIX_ROW_DISPLAYS_TEXT_P (desired_row))
row = desired_row;
}
- else if (current_row->displays_text_p)
+ else if (MATRIX_ROW_DISPLAYS_TEXT_P (current_row))
row = current_row;
}
row->truncated_on_right_p,
row->continued_p,
MATRIX_ROW_CONTINUATION_LINE_P (row),
- row->displays_text_p,
+ MATRIX_ROW_DISPLAYS_TEXT_P (row),
row->ends_at_zv_p,
row->fill_line_p,
row->ends_in_middle_of_char_p,
face = FACE_FROM_ID (f, it->face_id);
if (FRAME_WINDOW_P (f)
- && it->glyph_row->displays_text_p
+ && MATRIX_ROW_DISPLAYS_TEXT_P (it->glyph_row)
&& face->box == FACE_NO_BOX
&& face->background == FRAME_BACKGROUND_PIXEL (f)
&& !face->stipple
mark this glyph row as the one containing the overlay arrow.
This is clearly a mess with variable size fonts. It would be
better to let it be displayed like cursors under X. */
- if ((row->displays_text_p || !overlay_arrow_seen)
+ if ((MATRIX_ROW_DISPLAYS_TEXT_P (row) || !overlay_arrow_seen)
&& (overlay_arrow_string = overlay_arrow_at_row (it, row),
!NILP (overlay_arrow_string)))
{
if (it->glyph_row < MATRIX_BOTTOM_TEXT_ROW (it->w->desired_matrix, it->w))
it->glyph_row->reversed_p = row->reversed_p;
it->start = row->end;
- return row->displays_text_p;
+ return MATRIX_ROW_DISPLAYS_TEXT_P (row);
#undef RECORD_MAX_MIN_POS
}
return;
#endif /* HAVE_NS */
-#ifdef USE_X_TOOLKIT
+#if defined (USE_X_TOOLKIT) || defined (USE_GTK)
eassert (!FRAME_WINDOW_P (f));
init_iterator (&it, w, -1, -1, f->desired_matrix->rows, MENU_FACE_ID);
it.first_visible_x = 0;
it.last_visible_x = FRAME_TOTAL_COLS (f) * FRAME_COLUMN_WIDTH (f);
-#else /* not USE_X_TOOLKIT */
+#elif defined (HAVE_X_WINDOWS) /* X without toolkit. */
if (FRAME_WINDOW_P (f))
{
/* Menu bar lines are displayed in the desired matrix of the
dummy window menu_bar_window. */
struct window *menu_w;
- eassert (WINDOWP (f->menu_bar_window));
menu_w = XWINDOW (f->menu_bar_window);
init_iterator (&it, menu_w, -1, -1, menu_w->desired_matrix->rows,
MENU_FACE_ID);
it.last_visible_x = FRAME_TOTAL_COLS (f) * FRAME_COLUMN_WIDTH (f);
}
else
+#endif /* not USE_X_TOOLKIT and not USE_GTK */
{
/* This is a TTY frame, i.e. character hpos/vpos are used as
pixel x/y. */
it.first_visible_x = 0;
it.last_visible_x = FRAME_COLS (f);
}
-#endif /* not USE_X_TOOLKIT */
/* FIXME: This should be controlled by a user option. See the
comments in redisplay_tool_bar and display_mode_line about
char * psuffix;
char * p;
- if (1000 <= quotient)
+ if (quotient >= 1000)
{
/* Scale to the appropriate EXPONENT. */
do
quotient /= 1000;
exponent++;
}
- while (1000 <= quotient);
+ while (quotient >= 1000);
/* Round to nearest and decide whether to use TENTHS or not. */
if (quotient <= 9)
{
tenths = remainder / 100;
- if (50 <= remainder % 100)
+ if (remainder % 100 >= 50)
{
if (tenths < 9)
tenths++;
}
}
else
- if (500 <= remainder)
+ if (remainder >= 500)
{
if (quotient < 999)
quotient++;
*/
-#define NUMVAL(X) \
- ((INTEGERP (X) || FLOATP (X)) \
- ? XFLOATINT (X) \
- : - 1)
-
static int
calc_pixel_width_or_height (double *res, struct it *it, Lisp_Object prop,
struct font *font, int width_p, int *align_to)
pixels = 0;
if (pixels > 0)
{
- double ppi;
-#ifdef HAVE_WINDOW_SYSTEM
- if (FRAME_WINDOW_P (it->f)
- && (ppi = (width_p
- ? FRAME_X_DISPLAY_INFO (it->f)->resx
- : FRAME_X_DISPLAY_INFO (it->f)->resy),
- ppi > 0))
- return OK_PIXELS (ppi / pixels);
-#endif
+ double ppi = (width_p ? FRAME_RES_X (it->f)
+ : FRAME_RES_Y (it->f));
- if ((ppi = NUMVAL (Vdisplay_pixels_per_inch), ppi > 0)
- || (CONSP (Vdisplay_pixels_per_inch)
- && (ppi = (width_p
- ? NUMVAL (XCAR (Vdisplay_pixels_per_inch))
- : NUMVAL (XCDR (Vdisplay_pixels_per_inch))),
- ppi > 0)))
+ if (ppi > 0)
return OK_PIXELS (ppi / pixels);
-
return 0;
}
}
XChar2b *char2b, int display_p)
{
struct face *face = FACE_FROM_ID (f, face_id);
+ unsigned code = 0;
if (face->font)
{
- unsigned code = face->font->driver->encode_char (face->font, c);
+ code = face->font->driver->encode_char (face->font, c);
- if (code != FONT_INVALID_CODE)
- STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF));
- else
- STORE_XCHAR2B (char2b, 0, 0);
+ if (code == FONT_INVALID_CODE)
+ code = 0;
}
+ STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF));
/* Make sure X resources of the face are allocated. */
#ifdef HAVE_X_WINDOWS
XChar2b *char2b, int *two_byte_p)
{
struct face *face;
+ unsigned code = 0;
eassert (glyph->type == CHAR_GLYPH);
face = FACE_FROM_ID (f, glyph->face_id);
+ /* Make sure X resources of the face are allocated. */
+ eassert (face != NULL);
+ PREPARE_FACE_FOR_DISPLAY (f, face);
+
if (two_byte_p)
*two_byte_p = 0;
if (face->font)
{
- unsigned code;
-
if (CHAR_BYTE8_P (glyph->u.ch))
code = CHAR_TO_BYTE8 (glyph->u.ch);
else
code = face->font->driver->encode_char (face->font, glyph->u.ch);
- if (code != FONT_INVALID_CODE)
- STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF));
- else
- STORE_XCHAR2B (char2b, 0, 0);
+ if (code == FONT_INVALID_CODE)
+ code = 0;
}
- /* Make sure X resources of the face are allocated. */
- eassert (face != NULL);
- PREPARE_FACE_FOR_DISPLAY (f, face);
+ STORE_XCHAR2B (char2b, (code >> 8), (code & 0xFF));
return face;
}
get_per_char_metric (struct font *font, XChar2b *char2b)
{
static struct font_metrics metrics;
- unsigned code = (XCHAR2B_BYTE1 (char2b) << 8) | XCHAR2B_BYTE2 (char2b);
+ unsigned code;
- if (! font || code == FONT_INVALID_CODE)
+ if (! font)
+ return NULL;
+ code = (XCHAR2B_BYTE1 (char2b) << 8) | XCHAR2B_BYTE2 (char2b);
+ if (code == FONT_INVALID_CODE)
return NULL;
font->driver->text_extents (font, &code, 1, &metrics);
return &metrics;
if (w->phys_cursor.vpos < 0
|| w->phys_cursor.vpos >= w->current_matrix->nrows
|| (row = w->current_matrix->rows + w->phys_cursor.vpos,
- !(row->enabled_p && row->displays_text_p)))
+ !(row->enabled_p && MATRIX_ROW_DISPLAYS_TEXT_P (row))))
return;
if (row->cursor_in_fringe_p)
x = r1->x;
/* Skip truncation glyphs at the start of the glyph row. */
- if (r1->displays_text_p)
+ if (MATRIX_ROW_DISPLAYS_TEXT_P (r1))
for (; glyph < end
&& INTEGERP (glyph->object)
&& glyph->charpos < 0;
glyph = end + r1->used[TEXT_AREA];
/* Skip truncation glyphs at the start of the glyph row. */
- if (r1->displays_text_p)
+ if (MATRIX_ROW_DISPLAYS_TEXT_P (r1))
for (; glyph > end
&& INTEGERP (glyph->object)
&& glyph->charpos < 0;
}
*y = best_row->y;
- *vpos = best_row - w->current_matrix->rows;
+ *vpos = MATRIX_ROW_VPOS (best_row, w->current_matrix);
}
return best_glyph != NULL;
if (EQ (g->object, object)
&& startpos <= g->charpos && g->charpos <= endpos)
{
- hlinfo->mouse_face_beg_row = r - w->current_matrix->rows;
+ hlinfo->mouse_face_beg_row
+ = MATRIX_ROW_VPOS (r, w->current_matrix);
hlinfo->mouse_face_beg_y = r->y;
hlinfo->mouse_face_beg_col = g - r->glyphs[TEXT_AREA];
hlinfo->mouse_face_beg_x = gx;
if (EQ ((g-1)->object, object)
&& startpos <= (g-1)->charpos && (g-1)->charpos <= endpos)
{
- hlinfo->mouse_face_beg_row = r - w->current_matrix->rows;
+ hlinfo->mouse_face_beg_row
+ = MATRIX_ROW_VPOS (r, w->current_matrix);
hlinfo->mouse_face_beg_y = r->y;
hlinfo->mouse_face_beg_col = g - r->glyphs[TEXT_AREA];
for (gx = r->x, g1 = r->glyphs[TEXT_AREA]; g1 < g; ++g1)
r--;
/* Set the end row and its vertical pixel coordinate. */
- hlinfo->mouse_face_end_row = r - w->current_matrix->rows;
+ hlinfo->mouse_face_end_row = MATRIX_ROW_VPOS (r, w->current_matrix);
hlinfo->mouse_face_end_y = r->y;
/* Compute and set the end column and the end column's horizontal
/* Clear mouse face if X/Y not over text. */
if (glyph == NULL
|| area != TEXT_AREA
- || !MATRIX_ROW (w->current_matrix, vpos)->displays_text_p
+ || !MATRIX_ROW_DISPLAYS_TEXT_P (MATRIX_ROW (w->current_matrix, vpos))
/* Glyph's OBJECT is an integer for glyphs inserted by the
display engine for its internal purposes, like truncation
and continuation glyphs and blanks beyond the end of
all beyond the end of text. Treat such stretch glyphs
like we do with NULL glyphs in L2R rows. */
|| (MATRIX_ROW (w->current_matrix, vpos)->reversed_p
- && glyph == MATRIX_ROW (w->current_matrix, vpos)->glyphs[TEXT_AREA]
+ && glyph == MATRIX_ROW_GLYPH_START (w->current_matrix, vpos)
&& glyph->type == STRETCH_GLYPH
&& glyph->avoid_cursor_p))
{
#ifdef HAVE_X_WINDOWS
#ifndef MSDOS
-#ifndef USE_X_TOOLKIT
+#if ! defined (USE_X_TOOLKIT) && ! defined (USE_GTK)
if (WINDOWP (f->menu_bar_window))
mouse_face_overwritten_p
|= expose_window (XWINDOW (f->menu_bar_window), &r);
-#endif /* not USE_X_TOOLKIT */
+#endif /* not USE_X_TOOLKIT and not USE_GTK */
#endif
#endif
echo_area_window = minibuf_window;
- wset_top_line (r, make_number (FRAME_TOP_MARGIN (f)));
- wset_total_lines
- (r, make_number (FRAME_LINES (f) - 1 - FRAME_TOP_MARGIN (f)));
- wset_total_cols (r, make_number (FRAME_COLS (f)));
- wset_top_line (m, make_number (FRAME_LINES (f) - 1));
- wset_total_lines (m, make_number (1));
- wset_total_cols (m, make_number (FRAME_COLS (f)));
+ r->top_line = FRAME_TOP_MARGIN (f);
+ r->total_lines = FRAME_LINES (f) - 1 - FRAME_TOP_MARGIN (f);
+ r->total_cols = FRAME_COLS (f);
+
+ m->top_line = FRAME_LINES (f) - 1;
+ m->total_lines = 1;
+ m->total_cols = FRAME_COLS (f);
scratch_glyph_row.glyphs[TEXT_AREA] = scratch_glyphs;
scratch_glyph_row.glyphs[TEXT_AREA + 1]