Karsten Hopp 787ee8
To: vim_dev@googlegroups.com
Karsten Hopp 787ee8
Subject: Patch 7.3.826
Karsten Hopp 787ee8
Fcc: outbox
Karsten Hopp 787ee8
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 787ee8
Mime-Version: 1.0
Karsten Hopp 787ee8
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 787ee8
Content-Transfer-Encoding: 8bit
Karsten Hopp 787ee8
------------
Karsten Hopp 787ee8
Karsten Hopp 787ee8
Patch 7.3.826
Karsten Hopp 787ee8
Problem:    List of features in :version output is hard to read.
Karsten Hopp 787ee8
Solution:   Make columns. (Nazri Ramliy)
Karsten Hopp 787ee8
Files:	    src/version.c
Karsten Hopp 787ee8
Karsten Hopp 787ee8
Karsten Hopp 787ee8
*** ../vim-7.3.825/src/version.c	2013-02-20 16:09:35.000000000 +0100
Karsten Hopp 787ee8
--- src/version.c	2013-02-20 16:27:44.000000000 +0100
Karsten Hopp 787ee8
***************
Karsten Hopp 787ee8
*** 34,39 ****
Karsten Hopp 787ee8
--- 34,42 ----
Karsten Hopp 787ee8
  # if (defined(VMS) && defined(VAXC)) || defined(PROTO)
Karsten Hopp 787ee8
  char	longVersion[sizeof(VIM_VERSION_LONG_DATE) + sizeof(__DATE__)
Karsten Hopp 787ee8
  						      + sizeof(__TIME__) + 3];
Karsten Hopp 787ee8
+ 
Karsten Hopp 787ee8
+ static void list_features __ARGS((void));
Karsten Hopp 787ee8
+ 
Karsten Hopp 787ee8
      void
Karsten Hopp 787ee8
  make_version()
Karsten Hopp 787ee8
  {
Karsten Hopp 787ee8
***************
Karsten Hopp 787ee8
*** 2435,2440 ****
Karsten Hopp 787ee8
--- 2440,2513 ----
Karsten Hopp 787ee8
      }
Karsten Hopp 787ee8
  }
Karsten Hopp 787ee8
  
Karsten Hopp 787ee8
+ /*
Karsten Hopp 787ee8
+  * List all features aligned in columns, dictionary style.
Karsten Hopp 787ee8
+  */
Karsten Hopp 787ee8
+     static void
Karsten Hopp 787ee8
+ list_features()
Karsten Hopp 787ee8
+ {
Karsten Hopp 787ee8
+     int		i;
Karsten Hopp 787ee8
+     int		ncol;
Karsten Hopp 787ee8
+     int		nrow;
Karsten Hopp 787ee8
+     int		nfeat = 0;
Karsten Hopp 787ee8
+     int		width = 0;
Karsten Hopp 787ee8
+ 
Karsten Hopp 787ee8
+     /* Find the length of the longest feature name, use that + 1 as the column
Karsten Hopp 787ee8
+      * width */
Karsten Hopp 787ee8
+     for (i = 0; features[i] != NULL; ++i)
Karsten Hopp 787ee8
+     {
Karsten Hopp 787ee8
+ 	int l = STRLEN(features[i]);
Karsten Hopp 787ee8
+ 
Karsten Hopp 787ee8
+ 	if (l > width)
Karsten Hopp 787ee8
+ 	    width = l;
Karsten Hopp 787ee8
+ 	++nfeat;
Karsten Hopp 787ee8
+     }
Karsten Hopp 787ee8
+     width += 1;
Karsten Hopp 787ee8
+ 
Karsten Hopp 787ee8
+     if (Columns < width)
Karsten Hopp 787ee8
+     {
Karsten Hopp 787ee8
+ 	/* Not enough screen columns - show one per line */
Karsten Hopp 787ee8
+ 	for (i = 0; features[i] != NULL; ++i)
Karsten Hopp 787ee8
+ 	{
Karsten Hopp 787ee8
+ 	    version_msg(features[i]);
Karsten Hopp 787ee8
+ 	    if (msg_col > 0)
Karsten Hopp 787ee8
+ 		msg_putchar('\n');
Karsten Hopp 787ee8
+ 	}
Karsten Hopp 787ee8
+ 	return;
Karsten Hopp 787ee8
+     }
Karsten Hopp 787ee8
+ 
Karsten Hopp 787ee8
+     ncol = (int) Columns / width;
Karsten Hopp 787ee8
+     /* The rightmost column doesn't need a separator.
Karsten Hopp 787ee8
+      * Sacrifice it to fit in one more column if possible. */
Karsten Hopp 787ee8
+     if (Columns % width == width - 1)
Karsten Hopp 787ee8
+ 	ncol++;
Karsten Hopp 787ee8
+ 
Karsten Hopp 787ee8
+     nrow = nfeat / ncol + (nfeat % ncol ? 1 : 0);
Karsten Hopp 787ee8
+ 
Karsten Hopp 787ee8
+     for (i = 0; !got_int && i < nrow * ncol; ++i)
Karsten Hopp 787ee8
+     {
Karsten Hopp 787ee8
+ 	int idx = (i / ncol) + (i % ncol) * nrow;
Karsten Hopp 787ee8
+ 
Karsten Hopp 787ee8
+ 	if (idx < nfeat)
Karsten Hopp 787ee8
+ 	{
Karsten Hopp 787ee8
+ 	    int last_col = (i + 1) % ncol == 0;
Karsten Hopp 787ee8
+ 
Karsten Hopp 787ee8
+ 	    msg_puts((char_u *)features[idx]);
Karsten Hopp 787ee8
+ 	    if (last_col)
Karsten Hopp 787ee8
+ 	    {
Karsten Hopp 787ee8
+ 		if (msg_col > 0)
Karsten Hopp 787ee8
+ 		    msg_putchar('\n');
Karsten Hopp 787ee8
+ 	    }
Karsten Hopp 787ee8
+ 	    else
Karsten Hopp 787ee8
+ 	    {
Karsten Hopp 787ee8
+ 		while (msg_col % width)
Karsten Hopp 787ee8
+ 		    msg_putchar(' ');
Karsten Hopp 787ee8
+ 	    }
Karsten Hopp 787ee8
+ 	}
Karsten Hopp 787ee8
+ 	else
Karsten Hopp 787ee8
+ 	    msg_putchar('\n');
Karsten Hopp 787ee8
+     }
Karsten Hopp 787ee8
+ }
Karsten Hopp 787ee8
      void
Karsten Hopp 787ee8
  list_version()
Karsten Hopp 787ee8
  {
Karsten Hopp 787ee8
***************
Karsten Hopp 787ee8
*** 2632,2646 ****
Karsten Hopp 787ee8
  #endif
Karsten Hopp 787ee8
      version_msg(_("  Features included (+) or not (-):\n"));
Karsten Hopp 787ee8
  
Karsten Hopp 787ee8
!     /* print all the features */
Karsten Hopp 787ee8
!     for (i = 0; features[i] != NULL; ++i)
Karsten Hopp 787ee8
!     {
Karsten Hopp 787ee8
! 	version_msg(features[i]);
Karsten Hopp 787ee8
! 	if (msg_col > 0)
Karsten Hopp 787ee8
! 	    version_msg(" ");
Karsten Hopp 787ee8
!     }
Karsten Hopp 787ee8
  
Karsten Hopp 787ee8
-     version_msg("\n");
Karsten Hopp 787ee8
  #ifdef SYS_VIMRC_FILE
Karsten Hopp 787ee8
      version_msg(_("   system vimrc file: \""));
Karsten Hopp 787ee8
      version_msg(SYS_VIMRC_FILE);
Karsten Hopp 787ee8
--- 2705,2712 ----
Karsten Hopp 787ee8
  #endif
Karsten Hopp 787ee8
      version_msg(_("  Features included (+) or not (-):\n"));
Karsten Hopp 787ee8
  
Karsten Hopp 787ee8
!     list_features();
Karsten Hopp 787ee8
  
Karsten Hopp 787ee8
  #ifdef SYS_VIMRC_FILE
Karsten Hopp 787ee8
      version_msg(_("   system vimrc file: \""));
Karsten Hopp 787ee8
      version_msg(SYS_VIMRC_FILE);
Karsten Hopp 787ee8
*** ../vim-7.3.825/src/version.c	2013-02-20 16:09:35.000000000 +0100
Karsten Hopp 787ee8
--- src/version.c	2013-02-20 16:27:44.000000000 +0100
Karsten Hopp 787ee8
***************
Karsten Hopp 787ee8
*** 727,728 ****
Karsten Hopp 787ee8
--- 730,733 ----
Karsten Hopp 787ee8
  {   /* Add new patch number below this line */
Karsten Hopp 787ee8
+ /**/
Karsten Hopp 787ee8
+     826,
Karsten Hopp 787ee8
  /**/
Karsten Hopp 787ee8
Karsten Hopp 787ee8
-- 
Karsten Hopp 787ee8
Mrs Abbott: I'm a paediatrician.
Karsten Hopp 787ee8
     Basil: Feet?
Karsten Hopp 787ee8
Mrs Abbott: Children.
Karsten Hopp 787ee8
     Sybil: Oh, Basil!
Karsten Hopp 787ee8
     Basil: Well, children have feet, don't they? That's how they move
Karsten Hopp 787ee8
            around, my dear. You must take a look next time, it's most
Karsten Hopp 787ee8
            interesting.                               (Fawlty Towers)
Karsten Hopp 787ee8
Karsten Hopp 787ee8
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 787ee8
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 787ee8
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 787ee8
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///