aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKarl Heuer1994-09-16 03:29:33 +0000
committerKarl Heuer1994-09-16 03:29:33 +0000
commitd39b6696746dc6af2c5b74a355889848969a22a6 (patch)
treec9471dbc890d605c379be8b0e26862e99b7e3d91 /src
parentf43754f6a0907d0b25d8ca844ecab0688d466398 (diff)
downloademacs-d39b6696746dc6af2c5b74a355889848969a22a6.tar.gz
emacs-d39b6696746dc6af2c5b74a355889848969a22a6.zip
(multiple_frames, Vframe_title_format, Vicon_title_format): New variables.
(store_frame_title): New function. (x_consider_frame_title): Format title according to template. (display_mode_element): Handle frame title as well as mode line. (decode_mode_spec): Use w->buffer, not current_buffer.
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c201
1 files changed, 140 insertions, 61 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index 4369f5154be..ed0adc6bf51 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -85,6 +85,10 @@ char *previous_echo_glyphs;
85/* Nonzero means truncate lines in all windows less wide than the frame */ 85/* Nonzero means truncate lines in all windows less wide than the frame */
86int truncate_partial_width_windows; 86int truncate_partial_width_windows;
87 87
88/* Nonzero means we have more than one non-minibuffer-only frame.
89 Not guaranteed to be accurate except while parsing frame-title-format. */
90int multiple_frames;
91
88Lisp_Object Vglobal_mode_string; 92Lisp_Object Vglobal_mode_string;
89 93
90/* Marker for where to display an arrow on top of the buffer text. */ 94/* Marker for where to display an arrow on top of the buffer text. */
@@ -93,6 +97,12 @@ Lisp_Object Voverlay_arrow_position;
93/* String to display for the arrow. */ 97/* String to display for the arrow. */
94Lisp_Object Voverlay_arrow_string; 98Lisp_Object Voverlay_arrow_string;
95 99
100/* Like mode-line-format, but for the titlebar on a visible frame. */
101Lisp_Object Vframe_title_format;
102
103/* Like mode-line-format, but for the titlebar on an iconified frame. */
104Lisp_Object Vicon_title_format;
105
96/* Values of those variables at last redisplay. */ 106/* Values of those variables at last redisplay. */
97static Lisp_Object last_arrow_position, last_arrow_string; 107static Lisp_Object last_arrow_position, last_arrow_string;
98 108
@@ -394,31 +404,53 @@ echo_area_display ()
394} 404}
395 405
396#ifdef HAVE_X_WINDOWS 406#ifdef HAVE_X_WINDOWS
397/* I'm trying this out because I saw Unimpress use it, but it's 407static char frame_title_buf[512];
398 possible that this may mess adversely with some window managers. -jla 408static char *frame_title_ptr;
399 409
400 Wouldn't it be nice to use something like mode-line-format to 410static int
401 describe frame titles? -JimB */ 411store_frame_title (str, mincol, maxcol)
412 char *str;
413 int mincol, maxcol;
414{
415 char *limit;
416 if (maxcol < 0 || maxcol >= sizeof(frame_title_buf))
417 maxcol = sizeof (frame_title_buf);
418 limit = &frame_title_buf[maxcol];
419 while (*str != '\0' && frame_title_ptr < limit)
420 *frame_title_ptr++ = *str++;
421 while (frame_title_ptr < &frame_title_buf[mincol])
422 *frame_title_ptr++ = ' ';
423 return frame_title_ptr - frame_title_buf;
424}
402 425
403/* Change the title of the frame to the name of the buffer displayed
404 in the currently selected window. Don't do this for minibuffer frames,
405 and don't do it when there's only one non-minibuffer frame. */
406static void 426static void
407x_consider_frame_title (frame) 427x_consider_frame_title (frame)
408 Lisp_Object frame; 428 Lisp_Object frame;
409{ 429{
430 Lisp_Object fmt;
431 struct buffer *obuf;
432 int len;
410 FRAME_PTR f = XFRAME (frame); 433 FRAME_PTR f = XFRAME (frame);
411 434
412 if (FRAME_X_P (f) && ! FRAME_MINIBUF_ONLY_P (f)) 435 if (!FRAME_X_P (f) || FRAME_MINIBUF_ONLY_P (f) || f->explicit_name)
413 { 436 return;
414 Lisp_Object title; 437 multiple_frames = !EQ (Fnext_frame (frame, Qnil), frame);
415 438 obuf = current_buffer;
416 title = Qnil; 439 Fset_buffer (XWINDOW (f->selected_window)->buffer);
417 if (! EQ (Fnext_frame (frame, Qnil), frame)) 440 fmt = (FRAME_ICONIFIED_P (f) ? Vicon_title_format : Vframe_title_format);
418 title = XBUFFER (XWINDOW (f->selected_window)->buffer)->name; 441 frame_title_ptr = frame_title_buf;
419 442 len = display_mode_element (XWINDOW (f->selected_window), 0, 0, 0,
420 x_implicitly_set_name (f, title, Qnil); 443 0, sizeof (frame_title_buf), fmt);
421 } 444 frame_title_ptr = 0;
445 set_buffer_internal (obuf);
446 /* Set the name only if it's changed. This avoids consing
447 in the common case where it hasn't. (If it turns out that we've
448 already wasted too much time by walking through the list with
449 display_mode_element, then we might need to optimize at a higher
450 level than this.) */
451 if (! STRINGP (f->name) || XSTRING (f->name)->size != len
452 || bcmp (frame_title_buf, XSTRING (f->name)->data, len) != 0)
453 x_implicitly_set_name (f, make_string (frame_title_buf, len), Qnil);
422} 454}
423#endif 455#endif
424 456
@@ -2681,8 +2713,11 @@ display_mode_element (w, vpos, hpos, depth, minendcol, maxendcol, elt)
2681 if (this - 1 != last) 2713 if (this - 1 != last)
2682 { 2714 {
2683 register int lim = --this - last + hpos; 2715 register int lim = --this - last + hpos;
2684 hpos = display_string (w, vpos, last, -1, hpos, 0, 1, 2716 if (frame_title_ptr)
2685 hpos, min (lim, maxendcol)); 2717 hpos = store_frame_title (last, hpos, min (lim, maxendcol));
2718 else
2719 hpos = display_string (w, vpos, last, -1, hpos, 0, 1,
2720 hpos, min (lim, maxendcol));
2686 } 2721 }
2687 else /* c == '%' */ 2722 else /* c == '%' */
2688 { 2723 {
@@ -2707,11 +2742,15 @@ display_mode_element (w, vpos, hpos, depth, minendcol, maxendcol, elt)
2707 spec_width, maxendcol, 2742 spec_width, maxendcol,
2708 Vglobal_mode_string); 2743 Vglobal_mode_string);
2709 else if (c != 0) 2744 else if (c != 0)
2710 hpos = display_string (w, vpos, 2745 {
2711 decode_mode_spec (w, c, 2746 char *spec = decode_mode_spec (w, c, maxendcol - hpos);
2712 maxendcol - hpos), 2747 if (frame_title_ptr)
2713 -1, 2748 hpos = store_frame_title (spec, spec_width, maxendcol);
2714 hpos, 0, 1, spec_width, maxendcol); 2749 else
2750 hpos = display_string (w, vpos, spec, -1,
2751 hpos, 0, 1,
2752 spec_width, maxendcol);
2753 }
2715 } 2754 }
2716 } 2755 }
2717 } 2756 }
@@ -2731,9 +2770,15 @@ display_mode_element (w, vpos, hpos, depth, minendcol, maxendcol, elt)
2731 /* If value is a string, output that string literally: 2770 /* If value is a string, output that string literally:
2732 don't check for % within it. */ 2771 don't check for % within it. */
2733 if (XTYPE (tem) == Lisp_String) 2772 if (XTYPE (tem) == Lisp_String)
2734 hpos = display_string (w, vpos, XSTRING (tem)->data, 2773 {
2735 XSTRING (tem)->size, 2774 if (frame_title_ptr)
2736 hpos, 0, 1, minendcol, maxendcol); 2775 hpos = store_frame_title (XSTRING (tem)->data,
2776 minendcol, maxendcol);
2777 else
2778 hpos = display_string (w, vpos, XSTRING (tem)->data,
2779 XSTRING (tem)->size,
2780 hpos, 0, 1, minendcol, maxendcol);
2781 }
2737 /* Give up right away for nil or t. */ 2782 /* Give up right away for nil or t. */
2738 else if (!EQ (tem, elt)) 2783 else if (!EQ (tem, elt))
2739 { elt = tem; goto tail_recurse; } 2784 { elt = tem; goto tail_recurse; }
@@ -2822,13 +2867,19 @@ display_mode_element (w, vpos, hpos, depth, minendcol, maxendcol, elt)
2822 2867
2823 default: 2868 default:
2824 invalid: 2869 invalid:
2825 return (display_string (w, vpos, "*invalid*", -1, hpos, 0, 1, 2870 if (frame_title_ptr)
2826 minendcol, maxendcol)); 2871 hpos = store_frame_title ("*invalid*", minendcol, maxendcol);
2872 else
2873 hpos = display_string (w, vpos, "*invalid*", -1, hpos, 0, 1,
2874 minendcol, maxendcol);
2875 return hpos;
2827 } 2876 }
2828 2877
2829 end:
2830 if (minendcol > hpos) 2878 if (minendcol > hpos)
2831 hpos = display_string (w, vpos, "", 0, hpos, 0, 1, minendcol, maxendcol); 2879 if (frame_title_ptr)
2880 hpos = store_frame_title ("", minendcol, maxendcol);
2881 else
2882 hpos = display_string (w, vpos, "", 0, hpos, 0, 1, minendcol, maxendcol);
2832 return hpos; 2883 return hpos;
2833} 2884}
2834 2885
@@ -2846,6 +2897,7 @@ decode_mode_spec (w, c, maxwidth)
2846 Lisp_Object obj; 2897 Lisp_Object obj;
2847 FRAME_PTR f = XFRAME (WINDOW_FRAME (w)); 2898 FRAME_PTR f = XFRAME (WINDOW_FRAME (w));
2848 char *decode_mode_spec_buf = (char *) FRAME_TEMP_GLYPHS (f)->total_contents; 2899 char *decode_mode_spec_buf = (char *) FRAME_TEMP_GLYPHS (f)->total_contents;
2900 struct buffer *b = XBUFFER (w->buffer);
2849 2901
2850 obj = Qnil; 2902 obj = Qnil;
2851 if (maxwidth > FRAME_WIDTH (f)) 2903 if (maxwidth > FRAME_WIDTH (f))
@@ -2854,7 +2906,7 @@ decode_mode_spec (w, c, maxwidth)
2854 switch (c) 2906 switch (c)
2855 { 2907 {
2856 case 'b': 2908 case 'b':
2857 obj = current_buffer->name; 2909 obj = b->name;
2858#if 0 2910#if 0
2859 if (maxwidth >= 3 && XSTRING (obj)->size > maxwidth) 2911 if (maxwidth >= 3 && XSTRING (obj)->size > maxwidth)
2860 { 2912 {
@@ -2867,7 +2919,7 @@ decode_mode_spec (w, c, maxwidth)
2867 break; 2919 break;
2868 2920
2869 case 'f': 2921 case 'f':
2870 obj = current_buffer->filename; 2922 obj = b->filename;
2871#if 0 2923#if 0
2872 if (NILP (obj)) 2924 if (NILP (obj))
2873 return "[none]"; 2925 return "[none]";
@@ -2895,7 +2947,7 @@ decode_mode_spec (w, c, maxwidth)
2895 return "??"; 2947 return "??";
2896 2948
2897 /* If the buffer is very big, don't waste time. */ 2949 /* If the buffer is very big, don't waste time. */
2898 if (ZV - BEGV > line_number_display_limit) 2950 if (BUF_ZV (b) - BUF_BEGV (b) > line_number_display_limit)
2899 { 2951 {
2900 w->base_line_pos = Qnil; 2952 w->base_line_pos = Qnil;
2901 w->base_line_number = Qnil; 2953 w->base_line_number = Qnil;
@@ -2912,7 +2964,7 @@ decode_mode_spec (w, c, maxwidth)
2912 else 2964 else
2913 { 2965 {
2914 line = 1; 2966 line = 1;
2915 linepos = BEGV; 2967 linepos = BUF_BEGV (b);
2916 } 2968 }
2917 2969
2918 /* Count lines from base line to window start position. */ 2970 /* Count lines from base line to window start position. */
@@ -2924,15 +2976,15 @@ decode_mode_spec (w, c, maxwidth)
2924 or too far away, or if we did not have one. 2976 or too far away, or if we did not have one.
2925 "Too close" means it's plausible a scroll-down would 2977 "Too close" means it's plausible a scroll-down would
2926 go back past it. */ 2978 go back past it. */
2927 if (startpos == BEGV) 2979 if (startpos == BUF_BEGV (b))
2928 { 2980 {
2929 XFASTINT (w->base_line_number) = topline; 2981 XFASTINT (w->base_line_number) = topline;
2930 XFASTINT (w->base_line_pos) = BEGV; 2982 XFASTINT (w->base_line_pos) = BUF_BEGV (b);
2931 } 2983 }
2932 else if (nlines < height + 25 || nlines > height * 3 + 50 2984 else if (nlines < height + 25 || nlines > height * 3 + 50
2933 || linepos == BEGV) 2985 || linepos == BUF_BEGV (b))
2934 { 2986 {
2935 int limit = BEGV; 2987 int limit = BUF_BEGV (b);
2936 int position; 2988 int position;
2937 int distance = (height * 2 + 30) * 200; 2989 int distance = (height * 2 + 30) * 200;
2938 2990
@@ -2969,38 +3021,38 @@ decode_mode_spec (w, c, maxwidth)
2969 break; 3021 break;
2970 3022
2971 case 'm': 3023 case 'm':
2972 obj = current_buffer->mode_name; 3024 obj = b->mode_name;
2973 break; 3025 break;
2974 3026
2975 case 'n': 3027 case 'n':
2976 if (BEGV > BEG || ZV < Z) 3028 if (BUF_BEGV (b) > BUF_BEG (b) || BUF_ZV (b) < BUF_Z (b))
2977 return " Narrow"; 3029 return " Narrow";
2978 break; 3030 break;
2979 3031
2980 case '*': 3032 case '*':
2981 if (!NILP (current_buffer->read_only)) 3033 if (!NILP (b->read_only))
2982 return "%"; 3034 return "%";
2983 if (MODIFF > current_buffer->save_modified) 3035 if (BUF_MODIFF (b) > b->save_modified)
2984 return "*"; 3036 return "*";
2985 return "-"; 3037 return "-";
2986 3038
2987 case '+': 3039 case '+':
2988 /* This differs from %* only for a modified read-only buffer. */ 3040 /* This differs from %* only for a modified read-only buffer. */
2989 if (MODIFF > current_buffer->save_modified) 3041 if (BUF_MODIFF (b) > b->save_modified)
2990 return "*"; 3042 return "*";
2991 if (!NILP (current_buffer->read_only)) 3043 if (!NILP (b->read_only))
2992 return "%"; 3044 return "%";
2993 return "-"; 3045 return "-";
2994 3046
2995 case '&': 3047 case '&':
2996 /* This differs from %* in ignoring read-only-ness. */ 3048 /* This differs from %* in ignoring read-only-ness. */
2997 if (MODIFF > current_buffer->save_modified) 3049 if (BUF_MODIFF (b) > b->save_modified)
2998 return "*"; 3050 return "*";
2999 return "-"; 3051 return "-";
3000 3052
3001 case 's': 3053 case 's':
3002 /* status of process */ 3054 /* status of process */
3003 obj = Fget_buffer_process (Fcurrent_buffer ()); 3055 obj = Fget_buffer_process (w->buffer);
3004 if (NILP (obj)) 3056 if (NILP (obj))
3005 return "no process"; 3057 return "no process";
3006#ifdef subprocesses 3058#ifdef subprocesses
@@ -3010,7 +3062,7 @@ decode_mode_spec (w, c, maxwidth)
3010 3062
3011 case 't': /* indicate TEXT or BINARY */ 3063 case 't': /* indicate TEXT or BINARY */
3012#ifdef MSDOS 3064#ifdef MSDOS
3013 return NILP (current_buffer->buffer_file_type) ? "T" : "B"; 3065 return NILP (b->buffer_file_type) ? "T" : "B";
3014#else /* not MSDOS */ 3066#else /* not MSDOS */
3015 return "T"; 3067 return "T";
3016#endif /* not MSDOS */ 3068#endif /* not MSDOS */
@@ -3018,20 +3070,20 @@ decode_mode_spec (w, c, maxwidth)
3018 case 'p': 3070 case 'p':
3019 { 3071 {
3020 int pos = marker_position (w->start); 3072 int pos = marker_position (w->start);
3021 int total = ZV - BEGV; 3073 int total = BUF_ZV (b) - BUF_BEGV (b);
3022 3074
3023 if (XFASTINT (w->window_end_pos) <= Z - ZV) 3075 if (XFASTINT (w->window_end_pos) <= BUF_Z (b) - BUF_ZV (b))
3024 { 3076 {
3025 if (pos <= BEGV) 3077 if (pos <= BUF_BEGV (b))
3026 return "All"; 3078 return "All";
3027 else 3079 else
3028 return "Bottom"; 3080 return "Bottom";
3029 } 3081 }
3030 else if (pos <= BEGV) 3082 else if (pos <= BUF_BEGV (b))
3031 return "Top"; 3083 return "Top";
3032 else 3084 else
3033 { 3085 {
3034 total = ((pos - BEGV) * 100 + total - 1) / total; 3086 total = ((pos - BUF_BEGV (b)) * 100 + total - 1) / total;
3035 /* We can't normally display a 3-digit number, 3087 /* We can't normally display a 3-digit number,
3036 so get us a 2-digit number that is close. */ 3088 so get us a 2-digit number that is close. */
3037 if (total == 100) 3089 if (total == 100)
@@ -3045,24 +3097,24 @@ decode_mode_spec (w, c, maxwidth)
3045 case 'P': 3097 case 'P':
3046 { 3098 {
3047 int toppos = marker_position (w->start); 3099 int toppos = marker_position (w->start);
3048 int botpos = Z - XFASTINT (w->window_end_pos); 3100 int botpos = BUF_Z (b) - XFASTINT (w->window_end_pos);
3049 int total = ZV - BEGV; 3101 int total = BUF_ZV (b) - BUF_BEGV (b);
3050 3102
3051 if (botpos >= ZV) 3103 if (botpos >= BUF_ZV (b))
3052 { 3104 {
3053 if (toppos <= BEGV) 3105 if (toppos <= BUF_BEGV (b))
3054 return "All"; 3106 return "All";
3055 else 3107 else
3056 return "Bottom"; 3108 return "Bottom";
3057 } 3109 }
3058 else 3110 else
3059 { 3111 {
3060 total = ((botpos - BEGV) * 100 + total - 1) / total; 3112 total = ((botpos - BUF_BEGV (b)) * 100 + total - 1) / total;
3061 /* We can't normally display a 3-digit number, 3113 /* We can't normally display a 3-digit number,
3062 so get us a 2-digit number that is close. */ 3114 so get us a 2-digit number that is close. */
3063 if (total == 100) 3115 if (total == 100)
3064 total = 99; 3116 total = 99;
3065 if (toppos <= BEGV) 3117 if (toppos <= BUF_BEGV (b))
3066 sprintf (decode_mode_spec_buf, "Top%2d%%", total); 3118 sprintf (decode_mode_spec_buf, "Top%2d%%", total);
3067 else 3119 else
3068 sprintf (decode_mode_spec_buf, "%2d%%", total); 3120 sprintf (decode_mode_spec_buf, "%2d%%", total);
@@ -3100,7 +3152,7 @@ decode_mode_spec (w, c, maxwidth)
3100 *p = 0; 3152 *p = 0;
3101 return decode_mode_spec_buf; 3153 return decode_mode_spec_buf;
3102 } 3154 }
3103 3155
3104 case '-': 3156 case '-':
3105 { 3157 {
3106 register char *p; 3158 register char *p;
@@ -3117,7 +3169,7 @@ decode_mode_spec (w, c, maxwidth)
3117 return decode_mode_spec_buf; 3169 return decode_mode_spec_buf;
3118 } 3170 }
3119 } 3171 }
3120 3172
3121 if (XTYPE (obj) == Lisp_String) 3173 if (XTYPE (obj) == Lisp_String)
3122 return (char *) XSTRING (obj)->data; 3174 return (char *) XSTRING (obj)->data;
3123 else 3175 else
@@ -3479,6 +3531,33 @@ If this is zero, point is always centered after it moves off frame.");
3479 DEFVAR_BOOL ("highlight-nonselected-windows", &highlight_nonselected_windows, 3531 DEFVAR_BOOL ("highlight-nonselected-windows", &highlight_nonselected_windows,
3480 "*Non-nil means highlight region even in nonselected windows."); 3532 "*Non-nil means highlight region even in nonselected windows.");
3481 highlight_nonselected_windows = 1; 3533 highlight_nonselected_windows = 1;
3534
3535 DEFVAR_BOOL ("multiple-frames", &multiple_frames,
3536 "Non-nil means more than one frame is in use, not counting minibuffer frames.\n\
3537Not guaranteed to be accurate except while parsing frame-title-format.");
3538
3539 DEFVAR_LISP ("frame-title-format", &Vframe_title_format,
3540 "Template for displaying the titlebar of visible frames.\n\
3541\(Assuming the window manager supports this feature.)\n\
3542This variable has the same structure as `mode-line-format' (which see),\n\
3543and is used only on frames for which no explicit name has been set\n\
3544\(see `modify-frame-parameters').");
3545 DEFVAR_LISP ("icon-title-format", &Vicon_title_format,
3546 "Template for displaying the titlebar of an iconified frame.\n\
3547\(Assuming the window manager supports this feature.)\n\
3548This variable has the same structure as `mode-line-format' (which see),\n\
3549and is used only on frames for which no explicit name has been set\n\
3550\(see `modify-frame-parameters').");
3551 Vicon_title_format
3552 = Vframe_title_format
3553 = Fcons (intern ("multiple-frames"),
3554 Fcons (build_string ("%b"),
3555 Fcons (Fcons (build_string (""),
3556 Fcons (intern ("invocation-name"),
3557 Fcons (build_string ("@"),
3558 Fcons (intern ("system-name"),
3559 Qnil)))),
3560 Qnil)));
3482} 3561}
3483 3562
3484/* initialize the window system */ 3563/* initialize the window system */