/* Display generation from window structure and buffer text.
Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995,
1997, 1998, 1999, 2000, 2001, 2002, 2003,
- 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+ 2004, 2005, 2006, 2007, 2008, 2009, 2010
+ Free Software Foundation, Inc.
This file is part of GNU Emacs.
static int display_mode_line P_ ((struct window *, enum face_id, Lisp_Object));
static int display_mode_element P_ ((struct it *, int, int, int, Lisp_Object, Lisp_Object, int));
static int store_mode_line_string P_ ((char *, Lisp_Object, int, int, int, Lisp_Object));
-static char *decode_mode_spec P_ ((struct window *, int, int, int, int *));
+static char *decode_mode_spec P_ ((struct window *, int, int, int,
+ Lisp_Object *));
static void display_menu_bar P_ ((struct window *));
static int display_count_lines P_ ((int, int, int, int, int *));
static int display_string P_ ((unsigned char *, Lisp_Object, Lisp_Object,
visible_p = 1;
if (visible_p)
{
- if (it_method == GET_FROM_BUFFER)
- {
- Lisp_Object window, prop;
-
- XSETWINDOW (window, w);
- prop = Fget_char_property (make_number (charpos),
- Qinvisible, window);
-
- /* If charpos coincides with invisible text covered with an
- ellipsis, use the first glyph of the ellipsis to compute
- the pixel positions. */
- if (TEXT_PROP_MEANS_INVISIBLE (prop) == 2)
- {
- struct glyph_row *row = it.glyph_row;
- struct glyph *glyph = row->glyphs[TEXT_AREA];
- struct glyph *end = glyph + row->used[TEXT_AREA];
- int x = row->x;
-
- for (; glyph < end
- && (!BUFFERP (glyph->object)
- || glyph->charpos < charpos);
- glyph++)
- x += glyph->pixel_width;
- top_x = x;
- }
- }
- else if (it_method == GET_FROM_DISPLAY_VECTOR)
+ if (it_method == GET_FROM_DISPLAY_VECTOR)
{
/* We stopped on the last glyph of a display vector.
Try and recompute. Hack alert! */
it->dp = XCHAR_TABLE (Vstandard_display_table);
it->stop_charpos = charpos;
+ if (s == NULL && it->multibyte_p)
+ {
+ EMACS_INT endpos = SCHARS (it->string);
+ if (endpos > it->end_charpos)
+ endpos = it->end_charpos;
+ composition_compute_stop_pos (&it->cmp_it, charpos, -1, endpos,
+ it->string);
+ }
CHECK_IT (it);
}
/* Return 1 iff a character at CHARPOS (and BYTEPOS) is composed
(possibly with the following characters). */
-#define CHAR_COMPOSED_P(IT,CHARPOS,BYTEPOS) \
+#define CHAR_COMPOSED_P(IT,CHARPOS,BYTEPOS,END_CHARPOS) \
((IT)->cmp_it.id >= 0 \
|| ((IT)->cmp_it.stop_pos == (CHARPOS) \
&& composition_reseat_it (&(IT)->cmp_it, CHARPOS, BYTEPOS, \
- (IT)->end_charpos, (IT)->w, \
+ END_CHARPOS, (IT)->w, \
FACE_FROM_ID ((IT)->f, (IT)->face_id), \
(IT)->string)))
return 0;
}
else if (CHAR_COMPOSED_P (it, IT_STRING_CHARPOS (*it),
- IT_STRING_BYTEPOS (*it))
+ IT_STRING_BYTEPOS (*it), SCHARS (it->string))
&& next_element_from_composition (it))
{
return 1;
CHARPOS (position) = BYTEPOS (position) = -1;
}
else if (CHAR_COMPOSED_P (it, IT_STRING_CHARPOS (*it),
- IT_STRING_BYTEPOS (*it))
+ IT_STRING_BYTEPOS (*it), it->string_nchars)
&& next_element_from_composition (it))
{
return 1;
struct it *it;
{
it->what = IT_IMAGE;
+ it->ignore_overlay_strings_at_pos_p = 0;
return 1;
}
&& IT_CHARPOS (*it) >= it->redisplay_end_trigger_charpos)
run_redisplay_end_trigger_hook (it);
- if (CHAR_COMPOSED_P (it, IT_CHARPOS (*it), IT_BYTEPOS (*it))
+ if (CHAR_COMPOSED_P (it, IT_CHARPOS (*it), IT_BYTEPOS (*it),
+ it->end_charpos)
&& next_element_from_composition (it))
{
return 1;
if (! STRINGP (f->name)
|| SBYTES (f->name) != len
|| bcmp (title, SDATA (f->name), len) != 0)
- {
-#ifdef HAVE_NS
- if (FRAME_NS_P (f))
- {
- if (!MINI_WINDOW_P(XWINDOW(f->selected_window)))
- {
- if (EQ (fmt, Qt))
- ns_set_name_as_filename (f);
- else
- x_implicitly_set_name (f, make_string(title, len),
- Qnil);
- }
- }
- else
-#endif
- x_implicitly_set_name (f, make_string (title, len), Qnil);
- }
-#ifdef HAVE_NS
- if (FRAME_NS_P (f))
- {
- /* do this also for frames with explicit names */
- ns_implicitly_set_icon_type(f);
- ns_set_doc_edited(f, Fbuffer_modified_p
- (XWINDOW (f->selected_window)->buffer), Qnil);
- }
-#endif
+ x_implicitly_set_name (f, make_string (title, len), Qnil);
}
}
menu_bar_hooks_run = update_menu_bar (f, 0, menu_bar_hooks_run);
#ifdef HAVE_WINDOW_SYSTEM
update_tool_bar (f, 0);
+#endif
+#ifdef HAVE_NS
+ if (windows_or_buffers_changed
+ && FRAME_NS_P (f))
+ ns_set_doc_edited (f, Fbuffer_modified_p
+ (XWINDOW (f->selected_window)->buffer));
#endif
UNGCPRO;
}
(*FRAME_TERMINAL (f)->redeem_scroll_bar_hook) (w);
}
- /* Restore current_buffer and value of point in it. */
- TEMP_SET_PT_BOTH (CHARPOS (opoint), BYTEPOS (opoint));
+ /* Restore current_buffer and value of point in it. The window
+ update may have changed the buffer, so first make sure `opoint'
+ is still valid (Bug#6177). */
+ if (CHARPOS (opoint) < BEGV)
+ TEMP_SET_PT_BOTH (BEGV, BEGV_BYTE);
+ else if (CHARPOS (opoint) > ZV)
+ TEMP_SET_PT_BOTH (Z, Z_BYTE);
+ else
+ TEMP_SET_PT_BOTH (CHARPOS (opoint), BYTEPOS (opoint));
+
set_buffer_internal_1 (old);
/* Avoid an abort in TEMP_SET_PT_BOTH if the buffer has become
shorter. This can be caused by log truncation in *Messages*. */
int multibyte;
int bytepos, charpos;
unsigned char *spec;
+ Lisp_Object string;
bytepos = percent_position;
charpos = (STRING_MULTIBYTE (elt)
? string_byte_to_char (elt, bytepos)
: bytepos);
- spec
- = decode_mode_spec (it->w, c, field, prec, &multibyte);
+ spec = decode_mode_spec (it->w, c, field, prec, &string);
+ multibyte = STRINGP (string) && STRING_MULTIBYTE (string);
switch (mode_line_target)
{
int nglyphs_before, nwritten;
nglyphs_before = it->glyph_row->used[TEXT_AREA];
- nwritten = display_string (spec, Qnil, elt,
+ nwritten = display_string (spec, string, elt,
charpos, 0, it,
field, prec, 0,
multibyte);
/* Return a string for the output of a mode line %-spec for window W,
generated by character C. PRECISION >= 0 means don't return a
string longer than that value. FIELD_WIDTH > 0 means pad the
- string returned with spaces to that value. Return 1 in *MULTIBYTE
- if the result is multibyte text.
+ string returned with spaces to that value. Return a Lisp string in
+ *STRING if the resulting string is taken from that Lisp string.
Note we operate on the current buffer for most purposes,
the exception being w->base_line_pos. */
static char lots_of_dashes[] = "--------------------------------------------------------------------------------------------------------------------------------------------";
static char *
-decode_mode_spec (w, c, field_width, precision, multibyte)
+decode_mode_spec (w, c, field_width, precision, string)
struct window *w;
register int c;
int field_width, precision;
- int *multibyte;
+ Lisp_Object *string;
{
Lisp_Object obj;
struct frame *f = XFRAME (WINDOW_FRAME (w));
struct buffer *b = current_buffer;
obj = Qnil;
- *multibyte = 0;
+ *string = Qnil;
switch (c)
{
if (STRINGP (obj))
{
- *multibyte = STRING_MULTIBYTE (obj);
+ *string = obj;
return (char *) SDATA (obj);
}
else
/* Display a NUL-terminated string, starting with index START.
If STRING is non-null, display that C string. Otherwise, the Lisp
- string LISP_STRING is displayed.
+ string LISP_STRING is displayed. There's a case that STRING is
+ non-null and LISP_STRING is not nil. It means STRING is a string
+ data of LISP_STRING. In that case, we display LISP_STRING while
+ ignoring its text properties.
If FACE_STRING is not nil, FACE_STRING_POS is a position in
FACE_STRING. Display STRING or LISP_STRING with the face at
/* Initialize the iterator IT for iteration over STRING beginning
with index START. */
- reseat_to_string (it, string, lisp_string, start,
+ reseat_to_string (it, NILP (lisp_string) ? string : NULL, lisp_string, start,
precision, field_width, multibyte);
+ if (string && STRINGP (lisp_string))
+ /* LISP_STRING is the one returned by decode_mode_spec. We should
+ ignore its text properties. */
+ it->stop_charpos = -1;
/* If displaying STRING, set up the face of the iterator
from LISP_STRING, if that's given. */
j = i;
BUILD_GLYPH_STRINGS (j, start, h, t,
overlap_hl, dummy_x, last_x);
+ start = i;
compute_overhangs_and_x (t, head->x, 1);
prepend_glyph_string_lists (&head, &tail, h, t);
clip_head = head;
BUILD_GLYPH_STRINGS (end, i, h, t,
overlap_hl, x, last_x);
+ /* Because BUILD_GLYPH_STRINGS updates the first argument,
+ we don't have `end = i;' here. */
compute_overhangs_and_x (h, tail->x + tail->width, 0);
append_glyph_string_lists (&head, &tail, h, t);
clip_tail = tail;
/* Switch the display of W's cursor on or off, according to the value
of ON. */
-#ifndef HAVE_NS
-static
-#endif
void
update_window_cursor (w, on)
struct window *w;
#endif
if (NILP (Vmouse_highlight)
- || !f->glyphs_initialized_p)
+ || !f->glyphs_initialized_p
+ || f->pointer_invisible)
return;
dpyinfo->mouse_face_mouse_x = x;