aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c71
1 files changed, 63 insertions, 8 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 94706253133..eccc484a27d 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -7170,7 +7170,8 @@ echo_area_display (update_frame_p)
7170 ***********************************************************************/ 7170 ***********************************************************************/
7171 7171
7172 7172
7173#ifdef HAVE_WINDOW_SYSTEM 7173/* The frame title buffering code is also used by Fformat_mode_line.
7174 So it is not conditioned by HAVE_WINDOW_SYSTEM. */
7174 7175
7175/* A buffer for constructing frame titles in it; allocated from the 7176/* A buffer for constructing frame titles in it; allocated from the
7176 heap in init_xdisp and resized as needed in store_frame_title_char. */ 7177 heap in init_xdisp and resized as needed in store_frame_title_char. */
@@ -7238,6 +7239,7 @@ store_frame_title (str, field_width, precision)
7238 return n; 7239 return n;
7239} 7240}
7240 7241
7242#ifdef HAVE_WINDOW_SYSTEM
7241 7243
7242/* Set the title of FRAME, if it has changed. The title format is 7244/* Set the title of FRAME, if it has changed. The title format is
7243 Vicon_title_format if FRAME is iconified, otherwise it is 7245 Vicon_title_format if FRAME is iconified, otherwise it is
@@ -7302,11 +7304,6 @@ x_consider_frame_title (frame)
7302 } 7304 }
7303} 7305}
7304 7306
7305#else /* not HAVE_WINDOW_SYSTEM */
7306
7307#define frame_title_ptr ((char *)0)
7308#define store_frame_title(str, mincol, maxcol) 0
7309
7310#endif /* not HAVE_WINDOW_SYSTEM */ 7307#endif /* not HAVE_WINDOW_SYSTEM */
7311 7308
7312 7309
@@ -14018,6 +14015,65 @@ display_mode_element (it, depth, field_width, precision, elt, props, risky)
14018} 14015}
14019 14016
14020 14017
14018DEFUN ("format-mode-line", Fformat_mode_line, Sformat_mode_line,
14019 0, 2, 0,
14020 doc: /* Return the mode-line of selected window as a string.
14021First optional arg FORMAT specifies a different format string (see
14022`mode-line-format' for for details) to use. If FORMAT is t, return
14023the buffer's header-line. Second optional arg WINDOW specifies a
14024different window to use as the context for the formatting. */)
14025 (format, window)
14026 Lisp_Object format, window;
14027{
14028 struct it it;
14029 struct face *face;
14030 int len;
14031 struct window *w;
14032 struct buffer *old_buffer = NULL;
14033
14034 if (NILP (window))
14035 window = selected_window;
14036 CHECK_WINDOW (window);
14037 w = XWINDOW (window);
14038 CHECK_BUFFER (w->buffer);
14039
14040 if (XBUFFER (w->buffer) != current_buffer)
14041 {
14042 old_buffer = current_buffer;
14043 set_buffer_internal_1 (XBUFFER (w->buffer));
14044 }
14045
14046 if (NILP (format) || EQ (format, Qt))
14047 format = NILP (format)
14048 ? current_buffer->mode_line_format
14049 : current_buffer->header_line_format;
14050
14051 init_iterator (&it, w, -1, -1, NULL, DEFAULT_FACE_ID);
14052
14053 frame_title_ptr = frame_title_buf;
14054
14055 push_frame_kboard (it.f);
14056 display_mode_element (&it, 0, 0, 0, format, Qnil, 0);
14057 pop_frame_kboard ();
14058
14059 if (old_buffer)
14060 set_buffer_internal_1 (old_buffer);
14061
14062 len = frame_title_ptr - frame_title_buf;
14063 if (len > 0 && frame_title_ptr[-1] == '-')
14064 {
14065 /* Mode lines typically ends with numerous dashes; reduce to two dashes. */
14066 while (frame_title_ptr > frame_title_buf && *--frame_title_ptr == '-')
14067 ;
14068 frame_title_ptr += 3; /* restore last non-dash + two dashes */
14069 if (len > frame_title_ptr - frame_title_buf)
14070 len = frame_title_ptr - frame_title_buf;
14071 }
14072
14073 frame_title_ptr = NULL;
14074 return make_string (frame_title_buf, len);
14075}
14076
14021/* Write a null-terminated, right justified decimal representation of 14077/* Write a null-terminated, right justified decimal representation of
14022 the positive integer D to BUF using a minimal field width WIDTH. */ 14078 the positive integer D to BUF using a minimal field width WIDTH. */
14023 14079
@@ -14900,6 +14956,7 @@ syms_of_xdisp ()
14900#ifdef HAVE_WINDOW_SYSTEM 14956#ifdef HAVE_WINDOW_SYSTEM
14901 defsubr (&Stool_bar_lines_needed); 14957 defsubr (&Stool_bar_lines_needed);
14902#endif 14958#endif
14959 defsubr (&Sformat_mode_line);
14903 14960
14904 staticpro (&Qmenu_bar_update_hook); 14961 staticpro (&Qmenu_bar_update_hook);
14905 Qmenu_bar_update_hook = intern ("menu-bar-update-hook"); 14962 Qmenu_bar_update_hook = intern ("menu-bar-update-hook");
@@ -15295,7 +15352,6 @@ init_xdisp ()
15295 default_invis_vector[i] = make_number ('.'); 15352 default_invis_vector[i] = make_number ('.');
15296 } 15353 }
15297 15354
15298#ifdef HAVE_WINDOW_SYSTEM
15299 { 15355 {
15300 /* Allocate the buffer for frame titles. */ 15356 /* Allocate the buffer for frame titles. */
15301 int size = 100; 15357 int size = 100;
@@ -15303,7 +15359,6 @@ init_xdisp ()
15303 frame_title_buf_end = frame_title_buf + size; 15359 frame_title_buf_end = frame_title_buf + size;
15304 frame_title_ptr = NULL; 15360 frame_title_ptr = NULL;
15305 } 15361 }
15306#endif /* HAVE_WINDOW_SYSTEM */
15307 15362
15308 help_echo_showing_p = 0; 15363 help_echo_showing_p = 0;
15309} 15364}