843 |
struct text_pos)); |
struct text_pos)); |
844 |
static void reconsider_clip_changes P_ ((struct window *, struct buffer *)); |
static void reconsider_clip_changes P_ ((struct window *, struct buffer *)); |
845 |
static int text_outside_line_unchanged_p P_ ((struct window *, int, int)); |
static int text_outside_line_unchanged_p P_ ((struct window *, int, int)); |
846 |
static void store_frame_title_char P_ ((char)); |
static void store_mode_line_noprop_char P_ ((char)); |
847 |
static int store_frame_title P_ ((const unsigned char *, int, int)); |
static int store_mode_line_noprop P_ ((const unsigned char *, int, int)); |
848 |
static void x_consider_frame_title P_ ((Lisp_Object)); |
static void x_consider_frame_title P_ ((Lisp_Object)); |
849 |
static void handle_stop P_ ((struct it *)); |
static void handle_stop P_ ((struct it *)); |
850 |
static int tool_bar_lines_needed P_ ((struct frame *)); |
static int tool_bar_lines_needed P_ ((struct frame *)); |
8159 |
|
|
8160 |
|
|
8161 |
/*********************************************************************** |
/*********************************************************************** |
8162 |
Frame Titles |
Mode Lines and Frame Titles |
8163 |
***********************************************************************/ |
***********************************************************************/ |
8164 |
|
|
8165 |
|
/* A buffer for constructing non-propertized mode-line strings and |
8166 |
|
frame titles in it; allocated from the heap in init_xdisp and |
8167 |
|
resized as needed in store_mode_line_noprop_char. */ |
8168 |
|
|
8169 |
/* The frame title buffering code is also used by Fformat_mode_line. |
static char *mode_line_noprop_buf; |
|
So it is not conditioned by HAVE_WINDOW_SYSTEM. */ |
|
8170 |
|
|
8171 |
/* A buffer for constructing frame titles in it; allocated from the |
/* The buffer's end, and a current output position in it. */ |
|
heap in init_xdisp and resized as needed in store_frame_title_char. */ |
|
8172 |
|
|
8173 |
static char *frame_title_buf; |
static char *mode_line_noprop_buf_end; |
8174 |
|
static char *mode_line_noprop_ptr; |
8175 |
|
|
8176 |
/* The buffer's end, and a current output position in it. */ |
static enum { |
8177 |
|
MODE_LINE_DISPLAY = 0, |
8178 |
|
MODE_LINE_TITLE, |
8179 |
|
MODE_LINE_NOPROP, |
8180 |
|
MODE_LINE_STRING |
8181 |
|
} mode_line_target; |
8182 |
|
|
8183 |
static char *frame_title_buf_end; |
/* Alist that caches the results of :propertize. |
8184 |
static char *frame_title_ptr; |
Each element is (PROPERTIZED-STRING . PROPERTY-LIST). */ |
8185 |
|
static Lisp_Object mode_line_proptrans_alist; |
8186 |
|
|
8187 |
|
/* List of strings making up the mode-line. */ |
8188 |
|
static Lisp_Object mode_line_string_list; |
8189 |
|
|
8190 |
/* Store a single character C for the frame title in frame_title_buf. |
/* Base face property when building propertized mode line string. */ |
8191 |
Re-allocate frame_title_buf if necessary. */ |
static Lisp_Object mode_line_string_face; |
8192 |
|
static Lisp_Object mode_line_string_face_prop; |
8193 |
|
|
8194 |
|
|
8195 |
|
/* Unwind data for mode line strings */ |
8196 |
|
|
8197 |
|
static Lisp_Object Vmode_line_unwind_vector; |
8198 |
|
|
8199 |
|
static Lisp_Object |
8200 |
|
format_mode_line_unwind_data (obuf) |
8201 |
|
struct buffer *obuf; |
8202 |
|
{ |
8203 |
|
int i = 0; |
8204 |
|
Lisp_Object vector; |
8205 |
|
|
8206 |
|
/* Reduce consing by keeping one vector in |
8207 |
|
Vwith_echo_area_save_vector. */ |
8208 |
|
vector = Vmode_line_unwind_vector; |
8209 |
|
Vmode_line_unwind_vector = Qnil; |
8210 |
|
|
8211 |
|
if (NILP (vector)) |
8212 |
|
vector = Fmake_vector (make_number (7), Qnil); |
8213 |
|
|
8214 |
|
AREF (vector, 0) = make_number (mode_line_target); |
8215 |
|
AREF (vector, 1) = make_number (mode_line_noprop_ptr - mode_line_noprop_buf); |
8216 |
|
AREF (vector, 2) = mode_line_string_list; |
8217 |
|
AREF (vector, 3) = mode_line_proptrans_alist; |
8218 |
|
AREF (vector, 4) = mode_line_string_face; |
8219 |
|
AREF (vector, 5) = mode_line_string_face_prop; |
8220 |
|
|
8221 |
|
if (obuf) |
8222 |
|
XSETBUFFER (AREF (vector, 6), obuf); |
8223 |
|
else |
8224 |
|
AREF (vector, 6) = Qnil; |
8225 |
|
|
8226 |
|
return vector; |
8227 |
|
} |
8228 |
|
|
8229 |
|
static Lisp_Object |
8230 |
|
unwind_format_mode_line (vector) |
8231 |
|
Lisp_Object vector; |
8232 |
|
{ |
8233 |
|
mode_line_target = XINT (AREF (vector, 0)); |
8234 |
|
mode_line_noprop_ptr = mode_line_noprop_buf + XINT (AREF (vector, 1)); |
8235 |
|
mode_line_string_list = AREF (vector, 2); |
8236 |
|
mode_line_proptrans_alist = AREF (vector, 3); |
8237 |
|
mode_line_string_face = AREF (vector, 4); |
8238 |
|
mode_line_string_face_prop = AREF (vector, 5); |
8239 |
|
|
8240 |
|
if (!NILP (AREF (vector, 6))) |
8241 |
|
{ |
8242 |
|
set_buffer_internal_1 (XBUFFER (AREF (vector, 6))); |
8243 |
|
AREF (vector, 6) = Qnil; |
8244 |
|
} |
8245 |
|
|
8246 |
|
Vmode_line_unwind_vector = vector; |
8247 |
|
return Qnil; |
8248 |
|
} |
8249 |
|
|
8250 |
|
|
8251 |
|
/* Store a single character C for the frame title in mode_line_noprop_buf. |
8252 |
|
Re-allocate mode_line_noprop_buf if necessary. */ |
8253 |
|
|
8254 |
static void |
static void |
8255 |
#ifdef PROTOTYPES |
#ifdef PROTOTYPES |
8256 |
store_frame_title_char (char c) |
store_mode_line_noprop_char (char c) |
8257 |
#else |
#else |
8258 |
store_frame_title_char (c) |
store_mode_line_noprop_char (c) |
8259 |
char c; |
char c; |
8260 |
#endif |
#endif |
8261 |
{ |
{ |
8262 |
/* If output position has reached the end of the allocated buffer, |
/* If output position has reached the end of the allocated buffer, |
8263 |
double the buffer's size. */ |
double the buffer's size. */ |
8264 |
if (frame_title_ptr == frame_title_buf_end) |
if (mode_line_noprop_ptr == mode_line_noprop_buf_end) |
8265 |
{ |
{ |
8266 |
int len = frame_title_ptr - frame_title_buf; |
int len = mode_line_noprop_ptr - mode_line_noprop_buf; |
8267 |
int new_size = 2 * len * sizeof *frame_title_buf; |
int new_size = 2 * len * sizeof *mode_line_noprop_buf; |
8268 |
frame_title_buf = (char *) xrealloc (frame_title_buf, new_size); |
mode_line_noprop_buf = (char *) xrealloc (mode_line_noprop_buf, new_size); |
8269 |
frame_title_buf_end = frame_title_buf + new_size; |
mode_line_noprop_buf_end = mode_line_noprop_buf + new_size; |
8270 |
frame_title_ptr = frame_title_buf + len; |
mode_line_noprop_ptr = mode_line_noprop_buf + len; |
8271 |
} |
} |
8272 |
|
|
8273 |
*frame_title_ptr++ = c; |
*mode_line_noprop_ptr++ = c; |
8274 |
} |
} |
8275 |
|
|
8276 |
|
|
8277 |
/* Store part of a frame title in frame_title_buf, beginning at |
/* Store part of a frame title in mode_line_noprop_buf, beginning at |
8278 |
frame_title_ptr. STR is the string to store. Do not copy |
mode_line_noprop_ptr. STR is the string to store. Do not copy |
8279 |
characters that yield more columns than PRECISION; PRECISION <= 0 |
characters that yield more columns than PRECISION; PRECISION <= 0 |
8280 |
means copy the whole string. Pad with spaces until FIELD_WIDTH |
means copy the whole string. Pad with spaces until FIELD_WIDTH |
8281 |
number of characters have been copied; FIELD_WIDTH <= 0 means don't |
number of characters have been copied; FIELD_WIDTH <= 0 means don't |
8283 |
frame title. */ |
frame title. */ |
8284 |
|
|
8285 |
static int |
static int |
8286 |
store_frame_title (str, field_width, precision) |
store_mode_line_noprop (str, field_width, precision) |
8287 |
const unsigned char *str; |
const unsigned char *str; |
8288 |
int field_width, precision; |
int field_width, precision; |
8289 |
{ |
{ |
8294 |
nbytes = strlen (str); |
nbytes = strlen (str); |
8295 |
n += c_string_width (str, nbytes, precision, &dummy, &nbytes); |
n += c_string_width (str, nbytes, precision, &dummy, &nbytes); |
8296 |
while (nbytes--) |
while (nbytes--) |
8297 |
store_frame_title_char (*str++); |
store_mode_line_noprop_char (*str++); |
8298 |
|
|
8299 |
/* Fill up with spaces until FIELD_WIDTH reached. */ |
/* Fill up with spaces until FIELD_WIDTH reached. */ |
8300 |
while (field_width > 0 |
while (field_width > 0 |
8301 |
&& n < field_width) |
&& n < field_width) |
8302 |
{ |
{ |
8303 |
store_frame_title_char (' '); |
store_mode_line_noprop_char (' '); |
8304 |
++n; |
++n; |
8305 |
} |
} |
8306 |
|
|
8307 |
return n; |
return n; |
8308 |
} |
} |
8309 |
|
|
8310 |
|
/*********************************************************************** |
8311 |
|
Frame Titles |
8312 |
|
***********************************************************************/ |
8313 |
|
|
8314 |
#ifdef HAVE_WINDOW_SYSTEM |
#ifdef HAVE_WINDOW_SYSTEM |
8315 |
|
|
8316 |
/* Set the title of FRAME, if it has changed. The title format is |
/* Set the title of FRAME, if it has changed. The title format is |
8330 |
/* Do we have more than one visible frame on this X display? */ |
/* Do we have more than one visible frame on this X display? */ |
8331 |
Lisp_Object tail; |
Lisp_Object tail; |
8332 |
Lisp_Object fmt; |
Lisp_Object fmt; |
8333 |
struct buffer *obuf; |
char *title_start; |
8334 |
int len; |
int len; |
8335 |
struct it it; |
struct it it; |
8336 |
|
int count = SPECPDL_INDEX (); |
8337 |
|
|
8338 |
for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) |
for (tail = Vframe_list; CONSP (tail); tail = XCDR (tail)) |
8339 |
{ |
{ |
8352 |
multiple_frames = CONSP (tail); |
multiple_frames = CONSP (tail); |
8353 |
|
|
8354 |
/* Switch to the buffer of selected window of the frame. Set up |
/* Switch to the buffer of selected window of the frame. Set up |
8355 |
frame_title_ptr so that display_mode_element will output into it; |
mode_line_noprop_ptr so that display_mode_element will output into it; |
8356 |
then display the title. */ |
then display the title. */ |
8357 |
obuf = current_buffer; |
record_unwind_protect (unwind_format_mode_line, |
8358 |
|
format_mode_line_unwind_data (current_buffer)); |
8359 |
|
|
8360 |
set_buffer_internal_1 (XBUFFER (XWINDOW (f->selected_window)->buffer)); |
set_buffer_internal_1 (XBUFFER (XWINDOW (f->selected_window)->buffer)); |
8361 |
fmt = FRAME_ICONIFIED_P (f) ? Vicon_title_format : Vframe_title_format; |
fmt = FRAME_ICONIFIED_P (f) ? Vicon_title_format : Vframe_title_format; |
8362 |
frame_title_ptr = frame_title_buf; |
|
8363 |
|
mode_line_target = MODE_LINE_TITLE; |
8364 |
|
title_start = mode_line_noprop_ptr; |
8365 |
init_iterator (&it, XWINDOW (f->selected_window), -1, -1, |
init_iterator (&it, XWINDOW (f->selected_window), -1, -1, |
8366 |
NULL, DEFAULT_FACE_ID); |
NULL, DEFAULT_FACE_ID); |
8367 |
display_mode_element (&it, 0, -1, -1, fmt, Qnil, 0); |
display_mode_element (&it, 0, -1, -1, fmt, Qnil, 0); |
8368 |
len = frame_title_ptr - frame_title_buf; |
len = mode_line_noprop_ptr - title_start; |
8369 |
frame_title_ptr = NULL; |
|
8370 |
set_buffer_internal_1 (obuf); |
unbind_to (count, Qnil); |
8371 |
|
|
8372 |
/* Set the title only if it's changed. This avoids consing in |
/* Set the title only if it's changed. This avoids consing in |
8373 |
the common case where it hasn't. (If it turns out that we've |
the common case where it hasn't. (If it turns out that we've |
8376 |
higher level than this.) */ |
higher level than this.) */ |
8377 |
if (! STRINGP (f->name) |
if (! STRINGP (f->name) |
8378 |
|| SBYTES (f->name) != len |
|| SBYTES (f->name) != len |
8379 |
|| bcmp (frame_title_buf, SDATA (f->name), len) != 0) |
|| bcmp (title_start, SDATA (f->name), len) != 0) |
8380 |
x_implicitly_set_name (f, make_string (frame_title_buf, len), Qnil); |
x_implicitly_set_name (f, make_string (title_start, len), Qnil); |
8381 |
} |
} |
8382 |
} |
} |
8383 |
|
|
15711 |
return it.glyph_row->height; |
return it.glyph_row->height; |
15712 |
} |
} |
15713 |
|
|
|
/* Alist that caches the results of :propertize. |
|
|
Each element is (PROPERTIZED-STRING . PROPERTY-LIST). */ |
|
|
Lisp_Object mode_line_proptrans_alist; |
|
|
|
|
|
/* List of strings making up the mode-line. */ |
|
|
Lisp_Object mode_line_string_list; |
|
|
|
|
|
/* Base face property when building propertized mode line string. */ |
|
|
static Lisp_Object mode_line_string_face; |
|
|
static Lisp_Object mode_line_string_face_prop; |
|
|
|
|
|
|
|
15714 |
/* Contribute ELT to the mode line for window IT->w. How it |
/* Contribute ELT to the mode line for window IT->w. How it |
15715 |
translates into text depends on its data type. |
translates into text depends on its data type. |
15716 |
|
|
15731 |
If RISKY is nonzero, remove (disregard) any properties in any string |
If RISKY is nonzero, remove (disregard) any properties in any string |
15732 |
we encounter, and ignore :eval and :propertize. |
we encounter, and ignore :eval and :propertize. |
15733 |
|
|
15734 |
If the global variable `frame_title_ptr' is non-NULL, then the output |
The global variable `mode_line_target' determines whether the |
15735 |
is passed to `store_frame_title' instead of `display_string'. */ |
output is passed to `store_mode_line_noprop', |
15736 |
|
`store_mode_line_string', or `display_string'. */ |
15737 |
|
|
15738 |
static int |
static int |
15739 |
display_mode_element (it, depth, field_width, precision, elt, props, risky) |
display_mode_element (it, depth, field_width, precision, elt, props, risky) |
15822 |
if (literal) |
if (literal) |
15823 |
{ |
{ |
15824 |
prec = precision - n; |
prec = precision - n; |
15825 |
if (frame_title_ptr) |
switch (mode_line_target) |
15826 |
n += store_frame_title (SDATA (elt), -1, prec); |
{ |
15827 |
else if (!NILP (mode_line_string_list)) |
case MODE_LINE_NOPROP: |
15828 |
n += store_mode_line_string (NULL, elt, 1, 0, prec, Qnil); |
case MODE_LINE_TITLE: |
15829 |
else |
n += store_mode_line_noprop (SDATA (elt), -1, prec); |
15830 |
n += display_string (NULL, elt, Qnil, 0, 0, it, |
break; |
15831 |
0, prec, 0, STRING_MULTIBYTE (elt)); |
case MODE_LINE_STRING: |
15832 |
|
n += store_mode_line_string (NULL, elt, 1, 0, prec, Qnil); |
15833 |
|
break; |
15834 |
|
case MODE_LINE_DISPLAY: |
15835 |
|
n += display_string (NULL, elt, Qnil, 0, 0, it, |
15836 |
|
0, prec, 0, STRING_MULTIBYTE (elt)); |
15837 |
|
break; |
15838 |
|
} |
15839 |
|
|
15840 |
break; |
break; |
15841 |
} |
} |
15842 |
|
|
15843 |
while ((precision <= 0 || n < precision) |
while ((precision <= 0 || n < precision) |
15844 |
&& *this |
&& *this |
15845 |
&& (frame_title_ptr |
&& (mode_line_target != MODE_LINE_DISPLAY |
|
|| !NILP (mode_line_string_list) |
|
15846 |
|| it->current_x < it->last_visible_x)) |
|| it->current_x < it->last_visible_x)) |
15847 |
{ |
{ |
15848 |
const unsigned char *last = this; |
const unsigned char *last = this; |
15863 |
prec = c_string_width (last, this - last, precision - n, |
prec = c_string_width (last, this - last, precision - n, |
15864 |
&nchars, &nbytes); |
&nchars, &nbytes); |
15865 |
|
|
15866 |
if (frame_title_ptr) |
switch (mode_line_target) |
|
n += store_frame_title (last, 0, prec); |
|
|
else if (!NILP (mode_line_string_list)) |
|
15867 |
{ |
{ |
15868 |
int bytepos = last - lisp_string; |
case MODE_LINE_NOPROP: |
15869 |
int charpos = string_byte_to_char (elt, bytepos); |
case MODE_LINE_TITLE: |
15870 |
int endpos = (precision <= 0 |
n += store_mode_line_noprop (last, 0, prec); |
15871 |
? string_byte_to_char (elt, |
break; |
15872 |
this - lisp_string) |
case MODE_LINE_STRING: |
15873 |
: charpos + nchars); |
{ |
15874 |
|
int bytepos = last - lisp_string; |
15875 |
n += store_mode_line_string (NULL, |
int charpos = string_byte_to_char (elt, bytepos); |
15876 |
Fsubstring (elt, make_number (charpos), |
int endpos = (precision <= 0 |
15877 |
make_number (endpos)), |
? string_byte_to_char (elt, |
15878 |
0, 0, 0, Qnil); |
this - lisp_string) |
15879 |
} |
: charpos + nchars); |
15880 |
else |
|
15881 |
{ |
n += store_mode_line_string (NULL, |
15882 |
int bytepos = last - lisp_string; |
Fsubstring (elt, make_number (charpos), |
15883 |
int charpos = string_byte_to_char (elt, bytepos); |
make_number (endpos)), |
15884 |
n += display_string (NULL, elt, Qnil, 0, charpos, |
0, 0, 0, Qnil); |
15885 |
it, 0, prec, 0, |
} |
15886 |
STRING_MULTIBYTE (elt)); |
break; |
15887 |
|
case MODE_LINE_DISPLAY: |
15888 |
|
{ |
15889 |
|
int bytepos = last - lisp_string; |
15890 |
|
int charpos = string_byte_to_char (elt, bytepos); |
15891 |
|
n += display_string (NULL, elt, Qnil, 0, charpos, |
15892 |
|
it, 0, prec, 0, |
15893 |
|
STRING_MULTIBYTE (elt)); |
15894 |
|
} |
15895 |
|
break; |
15896 |
} |
} |
15897 |
} |
} |
15898 |
else /* c == '%' */ |
else /* c == '%' */ |
15930 |
spec |
spec |
15931 |
= decode_mode_spec (it->w, c, field, prec, &multibyte); |
= decode_mode_spec (it->w, c, field, prec, &multibyte); |
15932 |
|
|
15933 |
if (frame_title_ptr) |
switch (mode_line_target) |
|
n += store_frame_title (spec, field, prec); |
|
|
else if (!NILP (mode_line_string_list)) |
|
15934 |
{ |
{ |
15935 |
int len = strlen (spec); |
case MODE_LINE_NOPROP: |
15936 |
Lisp_Object tem = make_string (spec, len); |
case MODE_LINE_TITLE: |
15937 |
props = Ftext_properties_at (make_number (charpos), elt); |
n += store_mode_line_noprop (spec, field, prec); |
15938 |
/* Should only keep face property in props */ |
break; |
15939 |
n += store_mode_line_string (NULL, tem, 0, field, prec, props); |
case MODE_LINE_STRING: |
15940 |
} |
{ |
15941 |
else |
int len = strlen (spec); |
15942 |
{ |
Lisp_Object tem = make_string (spec, len); |
15943 |
int nglyphs_before, nwritten; |
props = Ftext_properties_at (make_number (charpos), elt); |
15944 |
|
/* Should only keep face property in props */ |
15945 |
|
n += store_mode_line_string (NULL, tem, 0, field, prec, props); |
15946 |
|
} |
15947 |
|
break; |
15948 |
|
case MODE_LINE_DISPLAY: |
15949 |
|
{ |
15950 |
|
int nglyphs_before, nwritten; |
15951 |
|
|
15952 |
nglyphs_before = it->glyph_row->used[TEXT_AREA]; |
nglyphs_before = it->glyph_row->used[TEXT_AREA]; |
15953 |
nwritten = display_string (spec, Qnil, elt, |
nwritten = display_string (spec, Qnil, elt, |
15954 |
charpos, 0, it, |
charpos, 0, it, |
15955 |
field, prec, 0, |
field, prec, 0, |
15956 |
multibyte); |
multibyte); |
15957 |
|
|
15958 |
/* Assign to the glyphs written above the |
/* Assign to the glyphs written above the |
15959 |
string where the `%x' came from, position |
string where the `%x' came from, position |
15960 |
of the `%'. */ |
of the `%'. */ |
15961 |
if (nwritten > 0) |
if (nwritten > 0) |
15962 |
{ |
{ |
15963 |
struct glyph *glyph |
struct glyph *glyph |
15964 |
= (it->glyph_row->glyphs[TEXT_AREA] |
= (it->glyph_row->glyphs[TEXT_AREA] |
15965 |
+ nglyphs_before); |
+ nglyphs_before); |
15966 |
int i; |
int i; |
|
|
|
|
for (i = 0; i < nwritten; ++i) |
|
|
{ |
|
|
glyph[i].object = elt; |
|
|
glyph[i].charpos = charpos; |
|
|
} |
|
15967 |
|
|
15968 |
n += nwritten; |
for (i = 0; i < nwritten; ++i) |
15969 |
} |
{ |
15970 |
|
glyph[i].object = elt; |
15971 |
|
glyph[i].charpos = charpos; |
15972 |
|
} |
15973 |
|
|
15974 |
|
n += nwritten; |
15975 |
|
} |
15976 |
|
} |
15977 |
|
break; |
15978 |
} |
} |
15979 |
} |
} |
15980 |
else /* c == 0 */ |
else /* c == 0 */ |
16145 |
/* Pad to FIELD_WIDTH. */ |
/* Pad to FIELD_WIDTH. */ |
16146 |
if (field_width > 0 && n < field_width) |
if (field_width > 0 && n < field_width) |
16147 |
{ |
{ |
16148 |
if (frame_title_ptr) |
switch (mode_line_target) |
16149 |
n += store_frame_title ("", field_width - n, 0); |
{ |
16150 |
else if (!NILP (mode_line_string_list)) |
case MODE_LINE_NOPROP: |
16151 |
n += store_mode_line_string ("", Qnil, 0, field_width - n, 0, Qnil); |
case MODE_LINE_TITLE: |
16152 |
else |
n += store_mode_line_noprop ("", field_width - n, 0); |
16153 |
n += display_string ("", Qnil, Qnil, 0, 0, it, field_width - n, |
break; |
16154 |
0, 0, 0); |
case MODE_LINE_STRING: |
16155 |
|
n += store_mode_line_string ("", Qnil, 0, field_width - n, 0, Qnil); |
16156 |
|
break; |
16157 |
|
case MODE_LINE_DISPLAY: |
16158 |
|
n += display_string ("", Qnil, Qnil, 0, 0, it, field_width - n, |
16159 |
|
0, 0, 0); |
16160 |
|
break; |
16161 |
|
} |
16162 |
} |
} |
16163 |
|
|
16164 |
return n; |
return n; |
16290 |
struct buffer *old_buffer = NULL; |
struct buffer *old_buffer = NULL; |
16291 |
int face_id = -1; |
int face_id = -1; |
16292 |
int no_props = INTEGERP (face); |
int no_props = INTEGERP (face); |
16293 |
|
int count = SPECPDL_INDEX (); |
16294 |
|
Lisp_Object str; |
16295 |
|
char *string_start = NULL; |
16296 |
|
|
16297 |
if (NILP (window)) |
if (NILP (window)) |
16298 |
window = selected_window; |
window = selected_window; |
16320 |
face_id = DEFAULT_FACE_ID; |
face_id = DEFAULT_FACE_ID; |
16321 |
|
|
16322 |
if (XBUFFER (buffer) != current_buffer) |
if (XBUFFER (buffer) != current_buffer) |
16323 |
{ |
old_buffer = current_buffer; |
16324 |
old_buffer = current_buffer; |
|
16325 |
set_buffer_internal_1 (XBUFFER (buffer)); |
record_unwind_protect (unwind_format_mode_line, |
16326 |
} |
format_mode_line_unwind_data (old_buffer)); |
16327 |
|
|
16328 |
|
if (old_buffer) |
16329 |
|
set_buffer_internal_1 (XBUFFER (buffer)); |
16330 |
|
|
16331 |
init_iterator (&it, w, -1, -1, NULL, face_id); |
init_iterator (&it, w, -1, -1, NULL, face_id); |
16332 |
|
|
16333 |
if (!no_props) |
if (no_props) |
16334 |
{ |
{ |
16335 |
mode_line_string_face = face; |
mode_line_target = MODE_LINE_NOPROP; |
16336 |
mode_line_string_face_prop |
mode_line_string_face_prop = Qnil; |
16337 |
= (NILP (face) ? Qnil : Fcons (Qface, Fcons (face, Qnil))); |
mode_line_string_list = Qnil; |
16338 |
|
string_start = mode_line_noprop_ptr; |
|
/* We need a dummy last element in mode_line_string_list to |
|
|
indicate we are building the propertized mode-line string. |
|
|
Using mode_line_string_face_prop here GC protects it. */ |
|
|
mode_line_string_list |
|
|
= Fcons (mode_line_string_face_prop, Qnil); |
|
|
frame_title_ptr = NULL; |
|
16339 |
} |
} |
16340 |
else |
else |
16341 |
{ |
{ |
16342 |
mode_line_string_face_prop = Qnil; |
mode_line_target = MODE_LINE_STRING; |
16343 |
mode_line_string_list = Qnil; |
mode_line_string_list = Qnil; |
16344 |
frame_title_ptr = frame_title_buf; |
mode_line_string_face = face; |
16345 |
|
mode_line_string_face_prop |
16346 |
|
= (NILP (face) ? Qnil : Fcons (Qface, Fcons (face, Qnil))); |
16347 |
|
|
16348 |
|
string_start = NULL; |
16349 |
} |
} |
16350 |
|
|
16351 |
push_frame_kboard (it.f); |
push_frame_kboard (it.f); |
16352 |
display_mode_element (&it, 0, 0, 0, format, Qnil, 0); |
display_mode_element (&it, 0, 0, 0, format, Qnil, 0); |
16353 |
pop_frame_kboard (); |
pop_frame_kboard (); |
16354 |
|
|
16355 |
if (old_buffer) |
if (no_props) |
|
set_buffer_internal_1 (old_buffer); |
|
|
|
|
|
if (!no_props) |
|
16356 |
{ |
{ |
16357 |
Lisp_Object str; |
len = mode_line_noprop_ptr - string_start; |
16358 |
mode_line_string_list = Fnreverse (mode_line_string_list); |
str = make_string (string_start, len); |
|
str = Fmapconcat (intern ("identity"), XCDR (mode_line_string_list), |
|
|
make_string ("", 0)); |
|
|
mode_line_string_face_prop = Qnil; |
|
|
mode_line_string_list = Qnil; |
|
|
return str; |
|
16359 |
} |
} |
16360 |
|
else |
|
len = frame_title_ptr - frame_title_buf; |
|
|
if (len > 0 && frame_title_ptr[-1] == '-') |
|
16361 |
{ |
{ |
16362 |
/* Mode lines typically ends with numerous dashes; reduce to two dashes. */ |
mode_line_string_list = Fnreverse (mode_line_string_list); |
16363 |
while (frame_title_ptr > frame_title_buf && *--frame_title_ptr == '-') |
str = Fmapconcat (intern ("identity"), mode_line_string_list, |
16364 |
; |
make_string ("", 0)); |
|
frame_title_ptr += 3; /* restore last non-dash + two dashes */ |
|
|
if (len > frame_title_ptr - frame_title_buf) |
|
|
len = frame_title_ptr - frame_title_buf; |
|
16365 |
} |
} |
16366 |
|
|
16367 |
frame_title_ptr = NULL; |
unbind_to (count, Qnil); |
16368 |
return make_string (frame_title_buf, len); |
return str; |
16369 |
} |
} |
16370 |
|
|
16371 |
/* Write a null-terminated, right justified decimal representation of |
/* Write a null-terminated, right justified decimal representation of |
16683 |
register int i; |
register int i; |
16684 |
|
|
16685 |
/* Let lots_of_dashes be a string of infinite length. */ |
/* Let lots_of_dashes be a string of infinite length. */ |
16686 |
if (!NILP (mode_line_string_list)) |
if (mode_line_target == MODE_LINE_NOPROP || |
16687 |
|
mode_line_target == MODE_LINE_STRING) |
16688 |
return "--"; |
return "--"; |
16689 |
if (field_width <= 0 |
if (field_width <= 0 |
16690 |
|| field_width > sizeof (lots_of_dashes)) |
|| field_width > sizeof (lots_of_dashes)) |
22777 |
|
|
22778 |
mode_line_proptrans_alist = Qnil; |
mode_line_proptrans_alist = Qnil; |
22779 |
staticpro (&mode_line_proptrans_alist); |
staticpro (&mode_line_proptrans_alist); |
|
|
|
22780 |
mode_line_string_list = Qnil; |
mode_line_string_list = Qnil; |
22781 |
staticpro (&mode_line_string_list); |
staticpro (&mode_line_string_list); |
22782 |
|
mode_line_string_face = Qnil; |
22783 |
|
staticpro (&mode_line_string_face); |
22784 |
|
mode_line_string_face_prop = Qnil; |
22785 |
|
staticpro (&mode_line_string_face_prop); |
22786 |
|
Vmode_line_unwind_vector = Qnil; |
22787 |
|
staticpro (&Vmode_line_unwind_vector); |
22788 |
|
|
22789 |
help_echo_string = Qnil; |
help_echo_string = Qnil; |
22790 |
staticpro (&help_echo_string); |
staticpro (&help_echo_string); |
23134 |
/* Allocate the buffer for frame titles. |
/* Allocate the buffer for frame titles. |
23135 |
Also used for `format-mode-line'. */ |
Also used for `format-mode-line'. */ |
23136 |
int size = 100; |
int size = 100; |
23137 |
frame_title_buf = (char *) xmalloc (size); |
mode_line_noprop_buf = (char *) xmalloc (size); |
23138 |
frame_title_buf_end = frame_title_buf + size; |
mode_line_noprop_buf_end = mode_line_noprop_buf + size; |
23139 |
frame_title_ptr = NULL; |
mode_line_noprop_ptr = mode_line_noprop_buf; |
23140 |
|
mode_line_target = MODE_LINE_DISPLAY; |
23141 |
} |
} |
23142 |
|
|
23143 |
help_echo_showing_p = 0; |
help_echo_showing_p = 0; |