@@ -57,7 +57,6 @@ char *longVersion = VIM_VERSION_LONG;
5757#endif
5858
5959static void list_features (void );
60- static void version_msg (char * s );
6160
6261static char * (features []) =
6362{
@@ -762,6 +761,8 @@ static char *(features[]) =
762761
763762static int included_patches [] =
764763{ /* Add new patch number below this line */
764+ /**/
765+ 1738 ,
765766/**/
766767 1737 ,
767768/**/
@@ -4294,36 +4295,76 @@ ex_version(exarg_T *eap)
42944295 }
42954296}
42964297
4298+ /*
4299+ * Output a string for the version message. If it's going to wrap, output a
4300+ * newline, unless the message is too long to fit on the screen anyway.
4301+ * When "wrap" is TRUE wrap the string in [].
4302+ */
4303+ static void
4304+ version_msg_wrap (char_u * s , int wrap )
4305+ {
4306+ int len = (int )vim_strsize (s ) + (wrap ? 2 : 0 );
4307+
4308+ if (!got_int && len < (int )Columns && msg_col + len >= (int )Columns
4309+ && * s != '\n' )
4310+ msg_putchar ('\n' );
4311+ if (!got_int )
4312+ {
4313+ if (wrap )
4314+ MSG_PUTS ("[" );
4315+ MSG_PUTS (s );
4316+ if (wrap )
4317+ MSG_PUTS ("]" );
4318+ }
4319+ }
4320+
4321+ static void
4322+ version_msg (char * s )
4323+ {
4324+ version_msg_wrap ((char_u * )s , FALSE);
4325+ }
4326+
42974327/*
42984328 * List all features aligned in columns, dictionary style.
42994329 */
43004330 static void
43014331list_features (void )
4332+ {
4333+ list_in_columns ((char_u * * )features , -1 , -1 );
4334+ }
4335+
4336+ /*
4337+ * List string items nicely aligned in columns.
4338+ * When "size" is < 0 then the last entry is marked with NULL.
4339+ * The entry with index "current" is inclosed in [].
4340+ */
4341+ void
4342+ list_in_columns (char_u * * items , int size , int current )
43024343{
43034344 int i ;
43044345 int ncol ;
43054346 int nrow ;
4306- int nfeat = 0 ;
4347+ int item_count = 0 ;
43074348 int width = 0 ;
43084349
4309- /* Find the length of the longest feature name , use that + 1 as the column
4310- * width */
4311- for (i = 0 ; features [i ] != NULL ; ++ i )
4350+ /* Find the length of the longest item , use that + 1 as the column
4351+ * width. */
4352+ for (i = 0 ; size < 0 ? items [i ] != NULL : i < size ; ++ i )
43124353 {
4313- int l = (int )STRLEN ( features [i ]);
4354+ int l = (int )vim_strsize ( items [i ]) + ( i == current ? 2 : 0 );
43144355
43154356 if (l > width )
43164357 width = l ;
4317- ++ nfeat ;
4358+ ++ item_count ;
43184359 }
43194360 width += 1 ;
43204361
43214362 if (Columns < width )
43224363 {
43234364 /* Not enough screen columns - show one per line */
4324- for (i = 0 ; features [i ] != NULL ; ++ i )
4365+ for (i = 0 ; items [i ] != NULL ; ++ i )
43254366 {
4326- version_msg ( features [i ]);
4367+ version_msg_wrap ( items [i ], i == current );
43274368 if (msg_col > 0 )
43284369 msg_putchar ('\n' );
43294370 }
@@ -4333,18 +4374,22 @@ list_features(void)
43334374 /* The rightmost column doesn't need a separator.
43344375 * Sacrifice it to fit in one more column if possible. */
43354376 ncol = (int ) (Columns + 1 ) / width ;
4336- nrow = nfeat / ncol + (nfeat % ncol ? 1 : 0 );
4377+ nrow = item_count / ncol + (item_count % ncol ? 1 : 0 );
43374378
43384379 /* i counts columns then rows. idx counts rows then columns. */
43394380 for (i = 0 ; !got_int && i < nrow * ncol ; ++ i )
43404381 {
43414382 int idx = (i / ncol ) + (i % ncol ) * nrow ;
43424383
4343- if (idx < nfeat )
4384+ if (idx < item_count )
43444385 {
43454386 int last_col = (i + 1 ) % ncol == 0 ;
43464387
4347- msg_puts ((char_u * )features [idx ]);
4388+ if (idx == current )
4389+ msg_putchar ('[' );
4390+ msg_puts (items [idx ]);
4391+ if (idx == current )
4392+ msg_putchar (']' );
43484393 if (last_col )
43494394 {
43504395 if (msg_col > 0 )
@@ -4636,22 +4681,6 @@ list_version(void)
46364681#endif
46374682}
46384683
4639- /*
4640- * Output a string for the version message. If it's going to wrap, output a
4641- * newline, unless the message is too long to fit on the screen anyway.
4642- */
4643- static void
4644- version_msg (char * s )
4645- {
4646- int len = (int )STRLEN (s );
4647-
4648- if (!got_int && len < (int )Columns && msg_col + len >= (int )Columns
4649- && * s != '\n' )
4650- msg_putchar ('\n' );
4651- if (!got_int )
4652- MSG_PUTS (s );
4653- }
4654-
46554684static void do_intro_line (int row , char_u * mesg , int add_version , int attr );
46564685
46574686/*
0 commit comments