changeset 678:93a1bf1cb633

updated for version 7.0203
author vimboss
date Tue, 21 Feb 2006 22:02:53 +0000
parents e649c78407e6
children e629de7618da
files runtime/doc/gui.txt runtime/doc/tabpage.txt src/buffer.c src/ex_docmd.c src/message.c src/netbeans.c
diffstat 6 files changed, 120 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/gui.txt
+++ b/runtime/doc/gui.txt
@@ -1,4 +1,4 @@
-*gui.txt*       For Vim version 7.0aa.  Last change: 2006 Feb 14
+*gui.txt*       For Vim version 7.0aa.  Last change: 2006 Feb 21
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -955,6 +955,9 @@ This section describes other features wh
 	    endif
 	endif
 
+A recommended Japanese font is MS Mincho.  You can find info here:
+http://www.lexikan.com/mincho.htm
+
 ==============================================================================
 7. Shell Commands					*gui-shell*
 
--- a/runtime/doc/tabpage.txt
+++ b/runtime/doc/tabpage.txt
@@ -1,4 +1,4 @@
-*tabpage.txt*   For Vim version 7.0aa.  Last change: 2006 Feb 20
+*tabpage.txt*   For Vim version 7.0aa.  Last change: 2006 Feb 21
 
 
 		  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -10,9 +10,10 @@ The commands which have been added to us
 here.  Additionally, there are explanations for commands that work differently
 when used in combination with more than one tab page.
 
-1.  Introduction			|tab-page-intro|
-2.  Commands				|tab-page-commands|
-3.  Other items				|tab-page-other|
+1. Introduction			|tab-page-intro|
+2. Commands			|tab-page-commands|
+3. Other items			|tab-page-other|
+4. Setting 'tabline'		|setting-tabline|
 
 {Vi does not have any of these commands}
 {not able to use multiple tab pages when the |+windows| feature was disabled
@@ -111,12 +112,6 @@ Other commands:
 ==============================================================================
 3. Other items						*tab-page-other*
 
-You can use the 'tabline' option to specify when you want the line with tab
-page labels to appear: never, when there is more than one tab page or always.
-
-The highlighting of the tab pages line is set with the groups TabLine
-TabLineSel and TabLineFill.  |hl-TabLine| |hl-TabLineSel| |hl-TabLineFill|
-
 Diff mode works per tab page.  You can see the diffs between several files
 within one tab page.  Other tab pages can show differences between other
 files.
@@ -133,7 +128,7 @@ triggers:
 	BufLeave		leave current buffer
 	BufEnter		enter new empty buffer
 
-For switching to another tab page the order is:
+When switching to another tab page the order is:
 	BufLeave
 	WinLeave
 	TabLeave
@@ -141,5 +136,58 @@ For switching to another tab page the or
 	WinEnter
 	BufEnter
 
+==============================================================================
+4. Setting 'tabline'					*setting-tabline*
+
+You can use the 'showtabline' option to specify when you want the line with
+tab page labels to appear: never, when there is more than one tab page or
+always.
+
+The highlighting of the tab pages line is set with the groups TabLine
+TabLineSel and TabLineFill.  |hl-TabLine| |hl-TabLineSel| |hl-TabLineFill|
+
+The 'tabline' option allows you to define your preferred way to tab pages
+labels.  This isn't easy, thus an example will be given here.
+
+For basics see the 'statusline' option.  The same items can be used in the
+'tabline' option.  Additionally, the |tabpagebuflist()|, |tabpagenr()| and
+|tabpagewinnr()| functions are useful.
+
+Since the number of tab labels will vary, you need to use an expresion for the
+whole option.  Something like: >
+	:set tabline=%!MyTabLine()
+
+Then define the MyTabLine() function to list all the tab pages labels.  A
+convenient method is to split it in two parts:  First go over all the tab
+pages and define labels for them.  Then get the label for each tab page. >
+
+	function MyTabLine()
+	  let s = ''
+	  for i in range(tabpagenr('$'))
+	    if i + 1 == tabpagenr()
+	      let s .= '%#TabLineSel#'
+	    else
+	      let s .= '%#TabLine#'
+	    endif
+	    let s .= ' %{MyTabLabel(' . (i + 1) . ')} '
+	  endfor
+	  let s .= '%#TabLineFill#'
+	  return s
+	endfunction
+
+Now the MyTabLabel() function is called for each tab page to get its label. >
+
+	function MyTabLabel(n)
+	  let buflist = tabpagebuflist(a:n)
+	  let winnr = tabpagewinnr(a:n)
+	  return bufname(buflist[winnr - 1])
+	endfunction
+
+This is just a simplistic example that results in a tab pages line that
+resembles the default, but without adding a + for a modified buffer or
+trunctating the names.  You will want to reduce the width of labels in a
+clever way when there is not enough room.  Check the 'columns' option for the
+space available, keeping in mind that the "X" at the right will take one more
+position.
 
  vim:tw=78:ts=8:ft=help:norl:
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2947,15 +2947,12 @@ fileinfo(fullname, shorthelp, dont_trunc
     {
 	p = msg_trunc_attr(buffer, FALSE, 0);
 	if (restart_edit != 0 || (msg_scrolled && !need_wait_return))
-	{
 	    /* Need to repeat the message after redrawing when:
 	     * - When restart_edit is set (otherwise there will be a delay
 	     *   before redrawing).
 	     * - When the screen was scrolled but there is no wait-return
 	     *   prompt. */
-	    set_keep_msg(p);
-	    keep_msg_attr = 0;
-	}
+	    set_keep_msg(p, 0);
     }
 
     vim_free(buffer);
@@ -3271,6 +3268,20 @@ build_stl_str_hl(wp, out, outlen, fmt, u
     char_u	opt;
 #define TMPLEN 70
     char_u	tmp[TMPLEN];
+    char_u	*usefmt = fmt;
+
+#ifdef FEAT_EVAL
+    /*
+     * When the format starts with "%!" then evaluate it as an expression and
+     * use the result as the actual format string.
+     */
+    if (fmt[0] == '%' && fmt[1] == '!')
+    {
+	usefmt = eval_to_string_safe(fmt + 2, NULL, use_sandbox);
+	if (usefmt == NULL)
+	    usefmt = (char_u *)"";
+    }
+#endif
 
     if (fillchar == 0)
 	fillchar = ' ';
@@ -3286,7 +3297,7 @@ build_stl_str_hl(wp, out, outlen, fmt, u
     curitem = 0;
     prevchar_isflag = TRUE;
     prevchar_isitem = FALSE;
-    for (s = fmt; *s;)
+    for (s = usefmt; *s; )
     {
 	if (*s != NUL && *s != '%')
 	    prevchar_isflag = prevchar_isitem = FALSE;
@@ -3432,7 +3443,7 @@ build_stl_str_hl(wp, out, outlen, fmt, u
 	    if (minwid < 0)	/* overflow */
 		minwid = 0;
 	}
-	if (*s == STL_HIGHLIGHT)
+	if (*s == STL_USER_HL)
 	{
 	    item[curitem].type = Highlight;
 	    item[curitem].start = p;
@@ -3698,6 +3709,20 @@ build_stl_str_hl(wp, out, outlen, fmt, u
 		case 7: str = (char_u *)",+-"; break;
 	    }
 	    break;
+
+	case STL_HIGHLIGHT:
+	    t = s;
+	    while (*s != '#' && *s != NUL)
+		++s;
+	    if (*s == '#')
+	    {
+		item[curitem].type = Highlight;
+		item[curitem].start = p;
+		item[curitem].minwid = -syn_namen2id(t, s - t);
+		curitem++;
+	    }
+	    ++s;
+	    continue;
 	}
 
 	item[curitem].start = p;
@@ -3814,6 +3839,11 @@ build_stl_str_hl(wp, out, outlen, fmt, u
     *p = NUL;
     itemcnt = curitem;
 
+#ifdef FEAT_EVAL
+    if (usefmt != fmt)
+	vim_free(usefmt);
+#endif
+
     width = vim_strsize(out);
     if (maxwidth > 0 && width > maxwidth)
     {
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -7029,7 +7029,7 @@ ex_tabs(eap)
 	out_flush();	    /* output one line at a time */
 	ui_breakcheck();
 
-	if (tp->tp_topframe == topframe)
+	if (tp  == curtab)
 	    wp = firstwin;
 	else
 	    wp = tp->tp_firstwin;
--- a/src/message.c
+++ b/src/message.c
@@ -180,10 +180,7 @@ msg_attr_keep(s, attr, keep)
 
     if (keep && retval && vim_strsize(s) < (int)(Rows - cmdline_row - 1)
 							   * Columns + sc_col)
-    {
-	set_keep_msg(s);
-	keep_msg_attr = 0;
-    }
+	set_keep_msg(s, 0);
 
     vim_free(buf);
     --entered;
@@ -1077,8 +1074,9 @@ hit_return_msg()
  * Set "keep_msg" to "s".  Free the old value and check for NULL pointer.
  */
     void
-set_keep_msg(s)
+set_keep_msg(s, attr)
     char_u	*s;
+    int		attr;
 {
     vim_free(keep_msg);
     if (s != NULL && msg_silent == 0)
@@ -1086,8 +1084,23 @@ set_keep_msg(s)
     else
 	keep_msg = NULL;
     keep_msg_more = FALSE;
+    keep_msg_attr = attr;
 }
 
+#if defined(FEAT_TERMRESPONSE) || defined(PROTO)
+/*
+ * If there currently is a message being displayed, set "keep_msg" to it, so
+ * that it will be displayed again after redraw.
+ */
+    void
+set_keep_msg_from_hist()
+{
+    if (keep_msg == NULL && last_msg_hist != NULL && msg_scrolled == 0
+							  && (State & NORMAL))
+	set_keep_msg(last_msg_hist->msg, last_msg_hist->attr);
+}
+#endif
+
 /*
  * Prepare for outputting characters in the command line.
  */
@@ -3161,7 +3174,7 @@ give_warning(message, hl)
     else
 	keep_msg_attr = 0;
     if (msg_attr(message, keep_msg_attr) && msg_scrolled == 0)
-	set_keep_msg(message);
+	set_keep_msg(message, keep_msg_attr);
     msg_didout = FALSE;	    /* overwrite this message */
     msg_nowait = TRUE;	    /* don't wait for this message */
     msg_col = 0;
--- a/src/netbeans.c
+++ b/src/netbeans.c
@@ -3442,8 +3442,7 @@ print_save_msg(buf, nchars)
 	     *   before redrawing).
 	     * - When the screen was scrolled but there is no wait-return
 	     *   prompt. */
-	    set_keep_msg(p);
-	    keep_msg_attr = 0;
+	    set_keep_msg(p, 0);
 	}
 	msg_scrolled_ign = FALSE;
 	/* add_to_input_buf((char_u *)"\f", 1); */