emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] Changes to emacs/src/xdisp.c


From: Kim F. Storm
Subject: [Emacs-diffs] Changes to emacs/src/xdisp.c
Date: Tue, 11 Jun 2002 18:27:13 -0400

Index: emacs/src/xdisp.c
diff -c emacs/src/xdisp.c:1.753 emacs/src/xdisp.c:1.754
*** emacs/src/xdisp.c:1.753     Sat Jun  8 14:30:02 2002
--- emacs/src/xdisp.c   Tue Jun 11 18:27:11 2002
***************
*** 7170,7176 ****
   ***********************************************************************/
  
  
! #ifdef HAVE_WINDOW_SYSTEM
  
  /* A buffer for constructing frame titles in it; allocated from the
     heap in init_xdisp and resized as needed in store_frame_title_char.  */
--- 7170,7177 ----
   ***********************************************************************/
  
  
! /* The frame title buffering code is also used by Fformat_mode_line.
!    So it is not conditioned by HAVE_WINDOW_SYSTEM.  */
  
  /* A buffer for constructing frame titles in it; allocated from the
     heap in init_xdisp and resized as needed in store_frame_title_char.  */
***************
*** 7238,7243 ****
--- 7239,7245 ----
    return n;
  }
  
+ #ifdef HAVE_WINDOW_SYSTEM
  
  /* Set the title of FRAME, if it has changed.  The title format is
     Vicon_title_format if FRAME is iconified, otherwise it is
***************
*** 7302,7312 ****
      }
  }
  
- #else /* not HAVE_WINDOW_SYSTEM */
- 
- #define frame_title_ptr ((char *)0)
- #define store_frame_title(str, mincol, maxcol) 0
- 
  #endif /* not HAVE_WINDOW_SYSTEM */
  
  
--- 7304,7309 ----
***************
*** 14018,14023 ****
--- 14015,14079 ----
  }
  
  
+ DEFUN ("format-mode-line", Fformat_mode_line, Sformat_mode_line,
+        0, 2, 0,
+        doc: /* Return the mode-line of selected window as a string.
+ First optional arg FORMAT specifies a different format string (see
+ `mode-line-format' for for details) to use.  If FORMAT is t, return
+ the buffer's header-line.  Second optional arg WINDOW specifies a
+ different window to use as the context for the formatting.  */)
+      (format, window)
+      Lisp_Object format, window;
+ {
+   struct it it;
+   struct face *face;
+   int len;
+   struct window *w;
+   struct buffer *old_buffer = NULL;
+ 
+   if (NILP (window))
+     window = selected_window;
+   CHECK_WINDOW (window);
+   w = XWINDOW (window);
+   CHECK_BUFFER (w->buffer);
+ 
+   if (XBUFFER (w->buffer) != current_buffer)
+     {
+       old_buffer = current_buffer;
+       set_buffer_internal_1 (XBUFFER (w->buffer));
+     }
+ 
+   if (NILP (format) || EQ (format, Qt))
+     format = NILP (format) 
+       ? current_buffer->mode_line_format
+       : current_buffer->header_line_format;
+ 
+   init_iterator (&it, w, -1, -1, NULL, DEFAULT_FACE_ID);
+ 
+   frame_title_ptr = frame_title_buf;
+ 
+   push_frame_kboard (it.f);
+   display_mode_element (&it, 0, 0, 0, format, Qnil, 0);
+   pop_frame_kboard ();
+ 
+   if (old_buffer)
+     set_buffer_internal_1 (old_buffer);
+ 
+   len = frame_title_ptr - frame_title_buf;
+   if (len > 0 && frame_title_ptr[-1] == '-')
+     {
+       /* Mode lines typically ends with numerous dashes; reduce to two 
dashes.  */
+       while (frame_title_ptr > frame_title_buf && *--frame_title_ptr == '-')
+       ;
+       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;
+     }
+ 
+   frame_title_ptr = NULL;
+   return make_string (frame_title_buf, len);
+ }
+ 
  /* Write a null-terminated, right justified decimal representation of
     the positive integer D to BUF using a minimal field width WIDTH.  */
  
***************
*** 14900,14905 ****
--- 14956,14962 ----
  #ifdef HAVE_WINDOW_SYSTEM
    defsubr (&Stool_bar_lines_needed);
  #endif
+   defsubr (&Sformat_mode_line);
  
    staticpro (&Qmenu_bar_update_hook);
    Qmenu_bar_update_hook = intern ("menu-bar-update-hook");
***************
*** 15295,15301 ****
        default_invis_vector[i] = make_number ('.');
      }
  
- #ifdef HAVE_WINDOW_SYSTEM
    {
      /* Allocate the buffer for frame titles.  */
      int size = 100;
--- 15352,15357 ----
***************
*** 15303,15309 ****
      frame_title_buf_end = frame_title_buf + size;
      frame_title_ptr = NULL;
    }
- #endif /* HAVE_WINDOW_SYSTEM */
  
    help_echo_showing_p = 0;
  }
--- 15359,15364 ----



reply via email to

[Prev in Thread] Current Thread [Next in Thread]