Mercurial > vim
comparison src/version.c @ 4147:646cb6b6ff23 v7.3.826
updated for version 7.3.826
Problem: List of features in :version output is hard to read.
Solution: Make columns. (Nazri Ramliy)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 20 Feb 2013 16:47:36 +0100 |
parents | 6b1f3fc893cd |
children | 5e17a12a3b14 |
comparison
equal
deleted
inserted
replaced
4146:102ec4ce5f68 | 4147:646cb6b6ff23 |
---|---|
32 | 32 |
33 #if defined(HAVE_DATE_TIME) || defined(PROTO) | 33 #if defined(HAVE_DATE_TIME) || defined(PROTO) |
34 # if (defined(VMS) && defined(VAXC)) || defined(PROTO) | 34 # if (defined(VMS) && defined(VAXC)) || defined(PROTO) |
35 char longVersion[sizeof(VIM_VERSION_LONG_DATE) + sizeof(__DATE__) | 35 char longVersion[sizeof(VIM_VERSION_LONG_DATE) + sizeof(__DATE__) |
36 + sizeof(__TIME__) + 3]; | 36 + sizeof(__TIME__) + 3]; |
37 | |
38 static void list_features __ARGS((void)); | |
39 | |
37 void | 40 void |
38 make_version() | 41 make_version() |
39 { | 42 { |
40 /* | 43 /* |
41 * Construct the long version string. Necessary because | 44 * Construct the long version string. Necessary because |
724 }; | 727 }; |
725 | 728 |
726 static int included_patches[] = | 729 static int included_patches[] = |
727 { /* Add new patch number below this line */ | 730 { /* Add new patch number below this line */ |
728 /**/ | 731 /**/ |
732 826, | |
733 /**/ | |
729 825, | 734 825, |
730 /**/ | 735 /**/ |
731 824, | 736 824, |
732 /**/ | 737 /**/ |
733 823, | 738 823, |
2433 msg_putchar('\n'); | 2438 msg_putchar('\n'); |
2434 list_version(); | 2439 list_version(); |
2435 } | 2440 } |
2436 } | 2441 } |
2437 | 2442 |
2443 /* | |
2444 * List all features aligned in columns, dictionary style. | |
2445 */ | |
2446 static void | |
2447 list_features() | |
2448 { | |
2449 int i; | |
2450 int ncol; | |
2451 int nrow; | |
2452 int nfeat = 0; | |
2453 int width = 0; | |
2454 | |
2455 /* Find the length of the longest feature name, use that + 1 as the column | |
2456 * width */ | |
2457 for (i = 0; features[i] != NULL; ++i) | |
2458 { | |
2459 int l = STRLEN(features[i]); | |
2460 | |
2461 if (l > width) | |
2462 width = l; | |
2463 ++nfeat; | |
2464 } | |
2465 width += 1; | |
2466 | |
2467 if (Columns < width) | |
2468 { | |
2469 /* Not enough screen columns - show one per line */ | |
2470 for (i = 0; features[i] != NULL; ++i) | |
2471 { | |
2472 version_msg(features[i]); | |
2473 if (msg_col > 0) | |
2474 msg_putchar('\n'); | |
2475 } | |
2476 return; | |
2477 } | |
2478 | |
2479 ncol = (int) Columns / width; | |
2480 /* The rightmost column doesn't need a separator. | |
2481 * Sacrifice it to fit in one more column if possible. */ | |
2482 if (Columns % width == width - 1) | |
2483 ncol++; | |
2484 | |
2485 nrow = nfeat / ncol + (nfeat % ncol ? 1 : 0); | |
2486 | |
2487 for (i = 0; !got_int && i < nrow * ncol; ++i) | |
2488 { | |
2489 int idx = (i / ncol) + (i % ncol) * nrow; | |
2490 | |
2491 if (idx < nfeat) | |
2492 { | |
2493 int last_col = (i + 1) % ncol == 0; | |
2494 | |
2495 msg_puts((char_u *)features[idx]); | |
2496 if (last_col) | |
2497 { | |
2498 if (msg_col > 0) | |
2499 msg_putchar('\n'); | |
2500 } | |
2501 else | |
2502 { | |
2503 while (msg_col % width) | |
2504 msg_putchar(' '); | |
2505 } | |
2506 } | |
2507 else | |
2508 msg_putchar('\n'); | |
2509 } | |
2510 } | |
2438 void | 2511 void |
2439 list_version() | 2512 list_version() |
2440 { | 2513 { |
2441 int i; | 2514 int i; |
2442 int first; | 2515 int first; |
2630 # endif | 2703 # endif |
2631 # endif | 2704 # endif |
2632 #endif | 2705 #endif |
2633 version_msg(_(" Features included (+) or not (-):\n")); | 2706 version_msg(_(" Features included (+) or not (-):\n")); |
2634 | 2707 |
2635 /* print all the features */ | 2708 list_features(); |
2636 for (i = 0; features[i] != NULL; ++i) | 2709 |
2637 { | |
2638 version_msg(features[i]); | |
2639 if (msg_col > 0) | |
2640 version_msg(" "); | |
2641 } | |
2642 | |
2643 version_msg("\n"); | |
2644 #ifdef SYS_VIMRC_FILE | 2710 #ifdef SYS_VIMRC_FILE |
2645 version_msg(_(" system vimrc file: \"")); | 2711 version_msg(_(" system vimrc file: \"")); |
2646 version_msg(SYS_VIMRC_FILE); | 2712 version_msg(SYS_VIMRC_FILE); |
2647 version_msg("\"\n"); | 2713 version_msg("\"\n"); |
2648 #endif | 2714 #endif |