To: vim_dev@googlegroups.com
Subject: Patch 7.3.826
Fcc: outbox
From: Bram Moolenaar <Bram@moolenaar.net>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
------------

Patch 7.3.826
Problem:    List of features in :version output is hard to read.
Solution:   Make columns. (Nazri Ramliy)
Files:	    src/version.c


*** ../vim-7.3.825/src/version.c	2013-02-20 16:09:35.000000000 +0100
--- src/version.c	2013-02-20 16:27:44.000000000 +0100
***************
*** 34,39 ****
--- 34,42 ----
  # if (defined(VMS) && defined(VAXC)) || defined(PROTO)
  char	longVersion[sizeof(VIM_VERSION_LONG_DATE) + sizeof(__DATE__)
  						      + sizeof(__TIME__) + 3];
+ 
+ static void list_features __ARGS((void));
+ 
      void
  make_version()
  {
***************
*** 2435,2440 ****
--- 2440,2513 ----
      }
  }
  
+ /*
+  * List all features aligned in columns, dictionary style.
+  */
+     static void
+ list_features()
+ {
+     int		i;
+     int		ncol;
+     int		nrow;
+     int		nfeat = 0;
+     int		width = 0;
+ 
+     /* Find the length of the longest feature name, use that + 1 as the column
+      * width */
+     for (i = 0; features[i] != NULL; ++i)
+     {
+ 	int l = STRLEN(features[i]);
+ 
+ 	if (l > width)
+ 	    width = l;
+ 	++nfeat;
+     }
+     width += 1;
+ 
+     if (Columns < width)
+     {
+ 	/* Not enough screen columns - show one per line */
+ 	for (i = 0; features[i] != NULL; ++i)
+ 	{
+ 	    version_msg(features[i]);
+ 	    if (msg_col > 0)
+ 		msg_putchar('\n');
+ 	}
+ 	return;
+     }
+ 
+     ncol = (int) Columns / width;
+     /* The rightmost column doesn't need a separator.
+      * Sacrifice it to fit in one more column if possible. */
+     if (Columns % width == width - 1)
+ 	ncol++;
+ 
+     nrow = nfeat / ncol + (nfeat % ncol ? 1 : 0);
+ 
+     for (i = 0; !got_int && i < nrow * ncol; ++i)
+     {
+ 	int idx = (i / ncol) + (i % ncol) * nrow;
+ 
+ 	if (idx < nfeat)
+ 	{
+ 	    int last_col = (i + 1) % ncol == 0;
+ 
+ 	    msg_puts((char_u *)features[idx]);
+ 	    if (last_col)
+ 	    {
+ 		if (msg_col > 0)
+ 		    msg_putchar('\n');
+ 	    }
+ 	    else
+ 	    {
+ 		while (msg_col % width)
+ 		    msg_putchar(' ');
+ 	    }
+ 	}
+ 	else
+ 	    msg_putchar('\n');
+     }
+ }
      void
  list_version()
  {
***************
*** 2632,2646 ****
  #endif
      version_msg(_("  Features included (+) or not (-):\n"));
  
!     /* print all the features */
!     for (i = 0; features[i] != NULL; ++i)
!     {
! 	version_msg(features[i]);
! 	if (msg_col > 0)
! 	    version_msg(" ");
!     }
  
-     version_msg("\n");
  #ifdef SYS_VIMRC_FILE
      version_msg(_("   system vimrc file: \""));
      version_msg(SYS_VIMRC_FILE);
--- 2705,2712 ----
  #endif
      version_msg(_("  Features included (+) or not (-):\n"));
  
!     list_features();
  
  #ifdef SYS_VIMRC_FILE
      version_msg(_("   system vimrc file: \""));
      version_msg(SYS_VIMRC_FILE);
*** ../vim-7.3.825/src/version.c	2013-02-20 16:09:35.000000000 +0100
--- src/version.c	2013-02-20 16:27:44.000000000 +0100
***************
*** 727,728 ****
--- 730,733 ----
  {   /* Add new patch number below this line */
+ /**/
+     826,
  /**/

-- 
Mrs Abbott: I'm a paediatrician.
     Basil: Feet?
Mrs Abbott: Children.
     Sybil: Oh, Basil!
     Basil: Well, children have feet, don't they? That's how they move
            around, my dear. You must take a look next time, it's most
            interesting.                               (Fawlty Towers)

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
