1 | // This is an open source non-commercial project. Dear PVS-Studio, please check |
2 | // it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com |
3 | |
4 | /// @file version.c |
5 | /// |
6 | /// Nvim was forked from Vim 7.4.160. |
7 | /// Vim originated from Stevie version 3.6 (Fish disk 217) by GRWalter (Fred). |
8 | |
9 | #include <inttypes.h> |
10 | #include <assert.h> |
11 | #include <limits.h> |
12 | |
13 | #include "nvim/api/private/helpers.h" |
14 | #include "nvim/vim.h" |
15 | #include "nvim/ascii.h" |
16 | #include "nvim/iconv.h" |
17 | #include "nvim/version.h" |
18 | #include "nvim/charset.h" |
19 | #include "nvim/macros.h" |
20 | #include "nvim/memline.h" |
21 | #include "nvim/memory.h" |
22 | #include "nvim/message.h" |
23 | #include "nvim/screen.h" |
24 | #include "nvim/strings.h" |
25 | #include "nvim/lua/executor.h" |
26 | |
27 | // version info generated by the build system |
28 | #include "auto/versiondef.h" |
29 | |
30 | // for ":version", ":intro", and "nvim --version" |
31 | #ifndef NVIM_VERSION_MEDIUM |
32 | #define NVIM_VERSION_MEDIUM "v" STR(NVIM_VERSION_MAJOR)\ |
33 | "." STR(NVIM_VERSION_MINOR) "." STR(NVIM_VERSION_PATCH)\ |
34 | NVIM_VERSION_PRERELEASE |
35 | #endif |
36 | #define NVIM_VERSION_LONG "NVIM " NVIM_VERSION_MEDIUM |
37 | |
38 | |
39 | char *Version = VIM_VERSION_SHORT; |
40 | char *longVersion = NVIM_VERSION_LONG; |
41 | char *version_buildtype = "Build type: " NVIM_VERSION_BUILD_TYPE; |
42 | char *version_cflags = "Compilation: " NVIM_VERSION_CFLAGS; |
43 | |
44 | #ifdef INCLUDE_GENERATED_DECLARATIONS |
45 | # include "version.c.generated.h" |
46 | #endif |
47 | |
48 | static char *features[] = { |
49 | #ifdef HAVE_ACL |
50 | "+acl" , |
51 | #else |
52 | "-acl" , |
53 | #endif |
54 | |
55 | #if defined(HAVE_ICONV) |
56 | "+iconv" , |
57 | #else |
58 | "-iconv" , |
59 | #endif |
60 | |
61 | #ifdef FEAT_TUI |
62 | "+tui" , |
63 | #else |
64 | "-tui" , |
65 | #endif |
66 | NULL |
67 | }; |
68 | |
69 | // clang-format off |
70 | static const int included_patches[] = { |
71 | 1850, |
72 | 1849, |
73 | 1848, |
74 | 1847, |
75 | 1846, |
76 | 1845, |
77 | 1844, |
78 | 1843, |
79 | 1842, |
80 | 1841, |
81 | 1840, |
82 | 1839, |
83 | 1838, |
84 | 1837, |
85 | 1836, |
86 | // 1835, |
87 | 1834, |
88 | 1833, |
89 | 1832, |
90 | 1831, |
91 | 1830, |
92 | 1829, |
93 | 1828, |
94 | 1827, |
95 | 1826, |
96 | 1825, |
97 | 1824, |
98 | 1823, |
99 | 1822, |
100 | 1821, |
101 | 1820, |
102 | 1819, |
103 | 1818, |
104 | // 1817, |
105 | 1816, |
106 | 1815, |
107 | 1814, |
108 | 1813, |
109 | // 1812, |
110 | 1811, |
111 | 1810, |
112 | 1809, |
113 | 1808, |
114 | 1807, |
115 | 1806, |
116 | 1805, |
117 | // 1804, |
118 | 1803, |
119 | 1802, |
120 | 1801, |
121 | 1800, |
122 | 1799, |
123 | // 1798, |
124 | 1797, |
125 | 1796, |
126 | 1795, |
127 | // 1794, |
128 | // 1793, |
129 | 1792, |
130 | 1791, |
131 | 1790, |
132 | // 1789, |
133 | 1788, |
134 | 1787, |
135 | // 1786, |
136 | 1785, |
137 | 1784, |
138 | // 1783, |
139 | 1782, |
140 | 1781, |
141 | 1780, |
142 | 1779, |
143 | 1778, |
144 | 1777, |
145 | // 1776, |
146 | 1775, |
147 | // 1774, |
148 | 1773, |
149 | // 1772, |
150 | // 1771, |
151 | // 1770, |
152 | // 1769, |
153 | 1768, |
154 | // 1767, |
155 | 1766, |
156 | 1765, |
157 | 1764, |
158 | 1763, |
159 | 1762, |
160 | 1761, |
161 | 1760, |
162 | 1759, |
163 | 1758, |
164 | 1757, |
165 | 1756, |
166 | 1755, |
167 | // 1754, |
168 | 1753, |
169 | 1752, |
170 | 1751, |
171 | 1750, |
172 | 1749, |
173 | 1748, |
174 | // 1747, |
175 | 1746, |
176 | // 1745, |
177 | // 1744, |
178 | // 1743, |
179 | // 1742, |
180 | 1741, |
181 | 1740, |
182 | 1739, |
183 | 1738, |
184 | 1737, |
185 | 1736, |
186 | 1735, |
187 | 1734, |
188 | // 1733, |
189 | // 1732, |
190 | 1731, |
191 | 1730, |
192 | 1729, |
193 | 1728, |
194 | 1727, |
195 | 1726, |
196 | // 1725, |
197 | 1724, |
198 | 1723, |
199 | // 1722, |
200 | 1721, |
201 | 1720, |
202 | 1719, |
203 | 1718, |
204 | 1717, |
205 | 1716, |
206 | 1715, |
207 | 1714, |
208 | 1713, |
209 | // 1712, |
210 | // 1711, |
211 | 1710, |
212 | 1709, |
213 | 1708, |
214 | 1707, |
215 | // 1706, |
216 | 1705, |
217 | 1704, |
218 | 1703, |
219 | 1702, |
220 | 1701, |
221 | 1700, |
222 | 1699, |
223 | 1698, |
224 | 1697, |
225 | 1696, |
226 | 1695, |
227 | 1694, |
228 | 1693, |
229 | 1692, |
230 | 1691, |
231 | 1690, |
232 | 1689, |
233 | 1688, |
234 | 1687, |
235 | 1686, |
236 | // 1685, |
237 | 1684, |
238 | 1683, |
239 | 1682, |
240 | 1681, |
241 | 1680, |
242 | 1679, |
243 | 1678, |
244 | 1677, |
245 | 1676, |
246 | 1675, |
247 | 1674, |
248 | 1673, |
249 | 1672, |
250 | 1671, |
251 | 1670, |
252 | 1669, |
253 | // 1668, |
254 | 1667, |
255 | // 1666, |
256 | // 1665, |
257 | 1664, |
258 | 1663, |
259 | 1662, |
260 | 1661, |
261 | // 1660, |
262 | 1659, |
263 | 1658, |
264 | 1657, |
265 | 1656, |
266 | 1655, |
267 | 1654, |
268 | 1653, |
269 | 1652, |
270 | // 1651, |
271 | 1650, |
272 | 1649, |
273 | 1648, |
274 | 1647, |
275 | 1646, |
276 | 1645, |
277 | 1644, |
278 | 1643, |
279 | 1642, |
280 | 1641, |
281 | 1640, |
282 | 1639, |
283 | 1638, |
284 | 1637, |
285 | 1636, |
286 | 1635, |
287 | 1634, |
288 | 1633, |
289 | 1632, |
290 | 1631, |
291 | 1630, |
292 | 1629, |
293 | 1628, |
294 | 1627, |
295 | 1626, |
296 | 1625, |
297 | // 1624, |
298 | 1623, |
299 | 1622, |
300 | // 1621, |
301 | 1620, |
302 | // 1619, |
303 | 1618, |
304 | // 1617, |
305 | // 1616, |
306 | 1615, |
307 | 1614, |
308 | 1613, |
309 | 1612, |
310 | 1611, |
311 | 1610, |
312 | // 1609, |
313 | 1608, |
314 | 1607, |
315 | 1606, |
316 | 1605, |
317 | 1604, |
318 | 1603, |
319 | 1602, |
320 | 1601, |
321 | 1600, |
322 | 1599, |
323 | 1598, |
324 | 1597, |
325 | 1596, |
326 | 1595, |
327 | 1594, |
328 | // 1593, |
329 | // 1592, |
330 | // 1591, |
331 | 1590, |
332 | // 1589, |
333 | // 1588, |
334 | // 1587, |
335 | 1586, |
336 | 1585, |
337 | 1584, |
338 | 1583, |
339 | // 1582, |
340 | 1581, |
341 | 1580, |
342 | 1579, |
343 | 1578, |
344 | 1577, |
345 | 1576, |
346 | 1575, |
347 | // 1574, |
348 | 1573, |
349 | 1572, |
350 | 1571, |
351 | // 1570, |
352 | 1569, |
353 | 1568, |
354 | 1567, |
355 | 1566, |
356 | 1565, |
357 | 1564, |
358 | 1563, |
359 | // 1562, |
360 | 1561, |
361 | 1560, |
362 | 1559, |
363 | // 1558, |
364 | 1557, |
365 | 1556, |
366 | 1555, |
367 | // 1554, |
368 | 1553, |
369 | 1552, |
370 | 1551, |
371 | 1550, |
372 | 1549, |
373 | 1548, |
374 | 1547, |
375 | 1546, |
376 | 1545, |
377 | // 1544, |
378 | // 1543, |
379 | 1542, |
380 | 1541, |
381 | // 1540, |
382 | // 1539, |
383 | // 1538, |
384 | 1537, |
385 | 1536, |
386 | 1535, |
387 | 1534, |
388 | 1533, |
389 | 1532, |
390 | // 1531, |
391 | 1530, |
392 | // 1529, |
393 | 1528, |
394 | 1527, |
395 | 1526, |
396 | // 1525, |
397 | 1524, |
398 | // 1523, |
399 | // 1522, |
400 | 1521, |
401 | // 1520, |
402 | 1519, |
403 | 1518, |
404 | 1517, |
405 | 1516, |
406 | 1515, |
407 | 1514, |
408 | 1513, |
409 | 1512, |
410 | // 1511, |
411 | 1510, |
412 | 1509, |
413 | 1508, |
414 | 1507, |
415 | 1506, |
416 | // 1505, |
417 | 1504, |
418 | 1503, |
419 | 1502, |
420 | 1501, |
421 | 1500, |
422 | 1499, |
423 | 1498, |
424 | 1497, |
425 | 1496, |
426 | // 1495, |
427 | 1494, |
428 | 1493, |
429 | // 1492, |
430 | // 1491, |
431 | 1490, |
432 | 1489, |
433 | 1488, |
434 | 1487, |
435 | 1486, |
436 | 1485, |
437 | 1484, |
438 | 1483, |
439 | 1482, |
440 | 1481, |
441 | 1480, |
442 | 1479, |
443 | 1478, |
444 | 1477, |
445 | 1476, |
446 | 1475, |
447 | 1474, |
448 | 1473, |
449 | 1472, |
450 | 1471, |
451 | 1470, |
452 | 1469, |
453 | 1468, |
454 | 1467, |
455 | 1466, |
456 | 1465, |
457 | 1464, |
458 | // 1463, |
459 | 1462, |
460 | // 1461, |
461 | // 1460, |
462 | // 1459, |
463 | 1458, |
464 | 1457, |
465 | 1456, |
466 | // 1455, |
467 | // 1454, |
468 | 1453, |
469 | 1452, |
470 | // 1451, |
471 | 1450, |
472 | // 1449, |
473 | // 1448, |
474 | 1447, |
475 | 1446, |
476 | 1445, |
477 | 1444, |
478 | 1443, |
479 | 1442, |
480 | 1441, |
481 | 1440, |
482 | 1439, |
483 | 1438, |
484 | 1437, |
485 | 1436, |
486 | 1435, |
487 | 1434, |
488 | 1433, |
489 | 1432, |
490 | 1431, |
491 | 1430, |
492 | 1429, |
493 | 1428, |
494 | 1427, |
495 | 1426, |
496 | 1425, |
497 | 1424, |
498 | 1423, |
499 | // 1422, |
500 | 1421, |
501 | 1420, |
502 | 1419, |
503 | 1418, |
504 | 1417, |
505 | 1416, |
506 | 1415, |
507 | 1414, |
508 | 1413, |
509 | 1412, |
510 | 1411, |
511 | 1410, |
512 | 1409, |
513 | 1408, |
514 | 1407, |
515 | 1406, |
516 | // 1405, |
517 | 1404, |
518 | 1403, |
519 | 1402, |
520 | 1401, |
521 | 1400, |
522 | 1399, |
523 | 1398, |
524 | 1397, |
525 | 1396, |
526 | 1395, |
527 | 1394, |
528 | 1393, |
529 | 1392, |
530 | 1391, |
531 | 1390, |
532 | 1389, |
533 | // 1388, |
534 | 1387, |
535 | 1386, |
536 | 1385, |
537 | 1384, |
538 | 1383, |
539 | 1382, |
540 | 1381, |
541 | 1380, |
542 | 1379, |
543 | 1378, |
544 | 1377, |
545 | 1376, |
546 | // 1375, |
547 | 1374, |
548 | 1373, |
549 | 1372, |
550 | // 1371, |
551 | 1370, |
552 | 1369, |
553 | 1368, |
554 | // 1367, |
555 | // 1366, |
556 | 1365, |
557 | 1364, |
558 | 1363, |
559 | 1362, |
560 | 1361, |
561 | 1360, |
562 | 1359, |
563 | // 1358, |
564 | 1357, |
565 | // 1356, |
566 | // 1355, |
567 | // 1354, |
568 | 1353, |
569 | 1352, |
570 | 1351, |
571 | 1350, |
572 | 1349, |
573 | 1348, |
574 | 1347, |
575 | 1346, |
576 | // 1345, |
577 | 1344, |
578 | 1343, |
579 | 1342, |
580 | 1341, |
581 | 1340, |
582 | // 1339, |
583 | 1338, |
584 | 1337, |
585 | 1336, |
586 | // 1335, |
587 | // 1334, |
588 | 1333, |
589 | 1332, |
590 | 1331, |
591 | 1330, |
592 | 1329, |
593 | 1328, |
594 | 1327, |
595 | 1326, |
596 | 1325, |
597 | 1324, |
598 | 1323, |
599 | 1322, |
600 | 1321, |
601 | 1320, |
602 | 1319, |
603 | 1318, |
604 | 1317, |
605 | 1316, |
606 | 1315, |
607 | 1314, |
608 | 1313, |
609 | 1312, |
610 | 1311, |
611 | 1310, |
612 | 1309, |
613 | 1308, |
614 | // 1307, |
615 | 1306, |
616 | 1305, |
617 | 1304, |
618 | 1303, |
619 | 1302, |
620 | 1301, |
621 | // 1300, |
622 | 1299, |
623 | 1298, |
624 | 1297, |
625 | 1296, |
626 | 1295, |
627 | 1294, |
628 | 1293, |
629 | // 1292, |
630 | 1291, |
631 | 1290, |
632 | 1289, |
633 | 1288, |
634 | // 1287, |
635 | 1286, |
636 | 1285, |
637 | 1284, |
638 | 1283, |
639 | 1282, |
640 | 1281, |
641 | 1280, |
642 | 1279, |
643 | 1278, |
644 | 1277, |
645 | 1276, |
646 | 1275, |
647 | 1274, |
648 | 1273, |
649 | 1272, |
650 | 1271, |
651 | 1270, |
652 | 1269, |
653 | 1268, |
654 | 1267, |
655 | 1266, |
656 | 1265, |
657 | 1264, |
658 | 1263, |
659 | 1262, |
660 | 1261, |
661 | 1260, |
662 | 1259, |
663 | 1258, |
664 | 1257, |
665 | 1256, |
666 | 1255, |
667 | 1254, |
668 | 1253, |
669 | 1252, |
670 | 1251, |
671 | 1250, |
672 | 1249, |
673 | 1248, |
674 | 1247, |
675 | 1246, |
676 | 1245, |
677 | 1244, |
678 | 1243, |
679 | 1242, |
680 | 1241, |
681 | 1240, |
682 | 1239, |
683 | 1238, |
684 | 1237, |
685 | 1236, |
686 | 1235, |
687 | 1234, |
688 | 1233, |
689 | 1232, |
690 | 1231, |
691 | 1230, |
692 | 1229, |
693 | 1228, |
694 | 1227, |
695 | 1226, |
696 | 1225, |
697 | 1224, |
698 | 1223, |
699 | 1222, |
700 | 1221, |
701 | 1220, |
702 | 1219, |
703 | 1218, |
704 | 1217, |
705 | 1216, |
706 | 1215, |
707 | 1214, |
708 | 1213, |
709 | 1212, |
710 | 1211, |
711 | 1210, |
712 | 1209, |
713 | 1208, |
714 | 1207, |
715 | 1206, |
716 | 1205, |
717 | 1204, |
718 | 1203, |
719 | 1202, |
720 | 1201, |
721 | 1200, |
722 | 1199, |
723 | 1198, |
724 | 1197, |
725 | 1196, |
726 | 1195, |
727 | 1194, |
728 | 1193, |
729 | 1192, |
730 | 1191, |
731 | 1190, |
732 | 1189, |
733 | 1188, |
734 | 1187, |
735 | 1186, |
736 | 1185, |
737 | 1184, |
738 | 1183, |
739 | 1182, |
740 | 1181, |
741 | 1180, |
742 | 1179, |
743 | 1178, |
744 | 1177, |
745 | // 1176, |
746 | 1175, |
747 | 1174, |
748 | 1173, |
749 | 1172, |
750 | 1171, |
751 | 1170, |
752 | 1169, |
753 | 1168, |
754 | 1167, |
755 | 1166, |
756 | 1165, |
757 | 1164, |
758 | 1163, |
759 | 1162, |
760 | 1161, |
761 | 1160, |
762 | 1159, |
763 | 1158, |
764 | 1157, |
765 | 1156, |
766 | 1155, |
767 | 1154, |
768 | 1153, |
769 | 1152, |
770 | 1151, |
771 | 1150, |
772 | 1149, |
773 | 1148, |
774 | 1147, |
775 | 1146, |
776 | 1145, |
777 | 1144, |
778 | 1143, |
779 | // 1142, |
780 | 1141, |
781 | 1140, |
782 | // 1139, |
783 | 1138, |
784 | 1137, |
785 | 1136, |
786 | 1135, |
787 | // 1134, |
788 | 1133, |
789 | 1132, |
790 | 1131, |
791 | 1130, |
792 | // 1129, |
793 | 1128, |
794 | // 1127, |
795 | 1126, |
796 | // 1125, |
797 | 1124, |
798 | // 1123, |
799 | 1122, |
800 | 1121, |
801 | 1120, |
802 | // 1119, |
803 | 1118, |
804 | 1117, |
805 | 1116, |
806 | 1115, |
807 | 1114, |
808 | 1113, |
809 | 1112, |
810 | 1111, |
811 | 1110, |
812 | // 1109, |
813 | 1108, |
814 | 1107, |
815 | 1106, |
816 | 1105, |
817 | 1104, |
818 | 1103, |
819 | 1102, |
820 | 1101, |
821 | 1100, |
822 | 1099, |
823 | 1098, |
824 | 1097, |
825 | 1096, |
826 | 1095, |
827 | 1094, |
828 | 1093, |
829 | 1092, |
830 | 1091, |
831 | 1090, |
832 | 1089, |
833 | 1088, |
834 | 1087, |
835 | 1086, |
836 | 1085, |
837 | 1084, |
838 | 1083, |
839 | 1082, |
840 | 1081, |
841 | 1080, |
842 | 1079, |
843 | 1078, |
844 | 1077, |
845 | 1076, |
846 | 1075, |
847 | 1074, |
848 | 1073, |
849 | 1072, |
850 | 1071, |
851 | 1070, |
852 | 1069, |
853 | 1068, |
854 | 1067, |
855 | 1066, |
856 | 1065, |
857 | 1064, |
858 | 1063, |
859 | 1062, |
860 | 1061, |
861 | 1060, |
862 | 1059, |
863 | 1058, |
864 | 1057, |
865 | 1056, |
866 | 1055, |
867 | 1054, |
868 | 1053, |
869 | 1052, |
870 | 1051, |
871 | 1050, |
872 | 1049, |
873 | 1048, |
874 | 1047, |
875 | 1046, |
876 | 1045, |
877 | 1044, |
878 | 1043, |
879 | 1042, |
880 | 1041, |
881 | 1040, |
882 | 1039, |
883 | // 1038, |
884 | 1037, |
885 | 1036, |
886 | 1035, |
887 | 1034, |
888 | 1033, |
889 | 1032, |
890 | 1031, |
891 | 1030, |
892 | 1029, |
893 | 1028, |
894 | 1027, |
895 | 1026, |
896 | 1025, |
897 | 1024, |
898 | 1023, |
899 | 1022, |
900 | 1021, |
901 | 1020, |
902 | 1019, |
903 | 1018, |
904 | 1017, |
905 | 1016, |
906 | 1015, |
907 | 1014, |
908 | 1013, |
909 | 1012, |
910 | 1011, |
911 | 1010, |
912 | 1009, |
913 | 1008, |
914 | 1007, |
915 | 1006, |
916 | 1005, |
917 | 1004, |
918 | 1003, |
919 | 1002, |
920 | 1001, |
921 | 1000, |
922 | 999, |
923 | 998, |
924 | 997, |
925 | 996, |
926 | 995, |
927 | 994, |
928 | 993, |
929 | 992, |
930 | 991, |
931 | 990, |
932 | 989, |
933 | 988, |
934 | 987, |
935 | 986, |
936 | 985, |
937 | 984, |
938 | 983, |
939 | 982, |
940 | 981, |
941 | 980, |
942 | 979, |
943 | 978, |
944 | 977, |
945 | 976, |
946 | 975, |
947 | 974, |
948 | 973, |
949 | 972, |
950 | 971, |
951 | // 970, |
952 | 969, |
953 | 968, |
954 | 967, |
955 | 966, |
956 | 965, |
957 | 964, |
958 | 963, |
959 | 962, |
960 | 961, |
961 | 960, |
962 | 959, |
963 | 958, |
964 | 957, |
965 | 956, |
966 | 955, |
967 | 954, |
968 | 953, |
969 | 952, |
970 | 951, |
971 | 950, |
972 | 949, |
973 | 948, |
974 | 947, |
975 | 946, |
976 | 945, |
977 | 944, |
978 | 943, |
979 | 942, |
980 | // 941, |
981 | 940, |
982 | 939, |
983 | 938, |
984 | // 937, |
985 | 936, |
986 | 935, |
987 | // 934, |
988 | 933, |
989 | 932, |
990 | 931, |
991 | 930, |
992 | 929, |
993 | 928, |
994 | 927, |
995 | 926, |
996 | 925, |
997 | 924, |
998 | 923, |
999 | 922, |
1000 | 921, |
1001 | 920, |
1002 | 919, |
1003 | 918, |
1004 | 917, |
1005 | 916, |
1006 | 915, |
1007 | // 914, |
1008 | 913, |
1009 | 912, |
1010 | 911, |
1011 | 910, |
1012 | 909, |
1013 | 908, |
1014 | 907, |
1015 | 906, |
1016 | 905, |
1017 | 904, |
1018 | 903, |
1019 | // 902, |
1020 | 901, |
1021 | 900, |
1022 | 899, |
1023 | 898, |
1024 | 897, |
1025 | 896, |
1026 | 895, |
1027 | 894, |
1028 | 893, |
1029 | 892, |
1030 | 891, |
1031 | 890, |
1032 | 889, |
1033 | 888, |
1034 | 887, |
1035 | 886, |
1036 | 885, |
1037 | 884, |
1038 | 883, |
1039 | 882, |
1040 | 881, |
1041 | 880, |
1042 | 879, |
1043 | 878, |
1044 | 877, |
1045 | 876, |
1046 | 875, |
1047 | 874, |
1048 | 873, |
1049 | 872, |
1050 | 871, |
1051 | 870, |
1052 | 869, |
1053 | 868, |
1054 | 867, |
1055 | 866, |
1056 | 865, |
1057 | 864, |
1058 | 863, |
1059 | 862, |
1060 | 861, |
1061 | 860, |
1062 | 859, |
1063 | 858, |
1064 | 857, |
1065 | 856, |
1066 | 855, |
1067 | 854, |
1068 | 853, |
1069 | 852, |
1070 | 851, |
1071 | 850, |
1072 | 849, |
1073 | 848, |
1074 | 847, |
1075 | 846, |
1076 | 845, |
1077 | 844, |
1078 | 843, |
1079 | 842, |
1080 | 841, |
1081 | 840, |
1082 | 839, |
1083 | 838, |
1084 | 837, |
1085 | 836, |
1086 | 835, |
1087 | 834, |
1088 | 833, |
1089 | 832, |
1090 | 831, |
1091 | 830, |
1092 | 829, |
1093 | 828, |
1094 | 827, |
1095 | 826, |
1096 | // 825, |
1097 | 824, |
1098 | 823, |
1099 | 822, |
1100 | 821, |
1101 | 820, |
1102 | 819, |
1103 | 818, |
1104 | 817, |
1105 | 816, |
1106 | 815, |
1107 | 814, |
1108 | 813, |
1109 | 812, |
1110 | 811, |
1111 | 810, |
1112 | 809, |
1113 | 808, |
1114 | 807, |
1115 | 806, |
1116 | 805, |
1117 | 804, |
1118 | 803, |
1119 | 802, |
1120 | 801, |
1121 | 800, |
1122 | 799, |
1123 | 798, |
1124 | 797, |
1125 | 796, |
1126 | 795, |
1127 | 794, |
1128 | 793, |
1129 | 792, |
1130 | 791, |
1131 | 790, |
1132 | 789, |
1133 | 788, |
1134 | 787, |
1135 | 786, |
1136 | 785, |
1137 | 784, |
1138 | 783, |
1139 | 782, |
1140 | 781, |
1141 | 780, |
1142 | 779, |
1143 | 778, |
1144 | 777, |
1145 | 776, |
1146 | 775, |
1147 | 774, |
1148 | 773, |
1149 | 772, |
1150 | 771, |
1151 | 770, |
1152 | 769, |
1153 | 768, |
1154 | 767, |
1155 | 766, |
1156 | 765, |
1157 | 764, |
1158 | 763, |
1159 | 762, |
1160 | 761, |
1161 | 760, |
1162 | 759, |
1163 | 758, |
1164 | 757, |
1165 | 756, |
1166 | 755, |
1167 | 754, |
1168 | 753, |
1169 | 752, |
1170 | 751, |
1171 | 750, |
1172 | 749, |
1173 | 748, |
1174 | 747, |
1175 | 746, |
1176 | 745, |
1177 | 744, |
1178 | 743, |
1179 | 742, |
1180 | 741, |
1181 | 740, |
1182 | 739, |
1183 | 738, |
1184 | 737, |
1185 | 736, |
1186 | 735, |
1187 | 734, |
1188 | 733, |
1189 | 732, |
1190 | 731, |
1191 | 730, |
1192 | 729, |
1193 | 728, |
1194 | 727, |
1195 | 726, |
1196 | 725, |
1197 | 724, |
1198 | 723, |
1199 | 722, |
1200 | 721, |
1201 | 720, |
1202 | 719, |
1203 | 718, |
1204 | 717, |
1205 | 716, |
1206 | 715, |
1207 | 714, |
1208 | 713, |
1209 | 712, |
1210 | 711, |
1211 | 710, |
1212 | 709, |
1213 | 708, |
1214 | 707, |
1215 | 706, |
1216 | 705, |
1217 | 704, |
1218 | 703, |
1219 | 702, |
1220 | 701, |
1221 | 700, |
1222 | 699, |
1223 | 698, |
1224 | 697, |
1225 | 696, |
1226 | 695, |
1227 | 694, |
1228 | 693, |
1229 | 692, |
1230 | 691, |
1231 | 690, |
1232 | 689, |
1233 | 688, |
1234 | 687, |
1235 | 686, |
1236 | 685, |
1237 | 684, |
1238 | 683, |
1239 | 682, |
1240 | 681, |
1241 | 680, |
1242 | 679, |
1243 | 678, |
1244 | 677, |
1245 | 676, |
1246 | 675, |
1247 | 674, |
1248 | 673, |
1249 | 672, |
1250 | 671, |
1251 | 670, |
1252 | 669, |
1253 | 668, |
1254 | 667, |
1255 | 666, |
1256 | 665, |
1257 | 664, |
1258 | 663, |
1259 | 662, |
1260 | 661, |
1261 | 660, |
1262 | 659, |
1263 | 658, |
1264 | 657, |
1265 | 656, |
1266 | 655, |
1267 | 654, |
1268 | 653, |
1269 | 652, |
1270 | 651, |
1271 | 650, |
1272 | 649, |
1273 | 648, |
1274 | 647, |
1275 | 646, |
1276 | 645, |
1277 | 644, |
1278 | 643, |
1279 | 642, |
1280 | 641, |
1281 | 640, |
1282 | 639, |
1283 | 638, |
1284 | 637, |
1285 | 636, |
1286 | 635, |
1287 | 634, |
1288 | 633, |
1289 | 632, |
1290 | 631, |
1291 | 630, |
1292 | 629, |
1293 | 628, |
1294 | 627, |
1295 | 626, |
1296 | 625, |
1297 | 624, |
1298 | 623, |
1299 | 622, |
1300 | 621, |
1301 | 620, |
1302 | 619, |
1303 | 618, |
1304 | 617, |
1305 | 616, |
1306 | 615, |
1307 | 614, |
1308 | 613, |
1309 | 612, |
1310 | 611, |
1311 | 610, |
1312 | 609, |
1313 | 608, |
1314 | 607, |
1315 | 606, |
1316 | 605, |
1317 | 604, |
1318 | 603, |
1319 | 602, |
1320 | 601, |
1321 | 600, |
1322 | 599, |
1323 | 598, |
1324 | 597, |
1325 | 596, |
1326 | 595, |
1327 | 594, |
1328 | 593, |
1329 | 592, |
1330 | 591, |
1331 | 590, |
1332 | 589, |
1333 | 588, |
1334 | 587, |
1335 | 586, |
1336 | 585, |
1337 | 584, |
1338 | 583, |
1339 | 582, |
1340 | 581, |
1341 | 580, |
1342 | 579, |
1343 | 578, |
1344 | 577, |
1345 | 576, |
1346 | 575, |
1347 | 574, |
1348 | 573, |
1349 | 572, |
1350 | 571, |
1351 | 570, |
1352 | 569, |
1353 | 568, |
1354 | 567, |
1355 | 566, |
1356 | 565, |
1357 | 564, |
1358 | 563, |
1359 | 562, |
1360 | 561, |
1361 | 560, |
1362 | 559, |
1363 | 558, |
1364 | 557, |
1365 | 556, |
1366 | 555, |
1367 | 554, |
1368 | 553, |
1369 | 552, |
1370 | 551, |
1371 | 550, |
1372 | 549, |
1373 | 548, |
1374 | 547, |
1375 | 546, |
1376 | 545, |
1377 | 544, |
1378 | 543, |
1379 | 542, |
1380 | 541, |
1381 | 540, |
1382 | 539, |
1383 | 538, |
1384 | 537, |
1385 | 536, |
1386 | 535, |
1387 | 534, |
1388 | 533, |
1389 | 532, |
1390 | 531, |
1391 | 530, |
1392 | 529, |
1393 | 528, |
1394 | 527, |
1395 | 526, |
1396 | 525, |
1397 | 524, |
1398 | 523, |
1399 | 522, |
1400 | 521, |
1401 | 520, |
1402 | 519, |
1403 | 518, |
1404 | 517, |
1405 | 516, |
1406 | 515, |
1407 | 514, |
1408 | 513, |
1409 | 512, |
1410 | 511, |
1411 | 510, |
1412 | 509, |
1413 | 508, |
1414 | 507, |
1415 | 506, |
1416 | 505, |
1417 | 504, |
1418 | 503, |
1419 | 502, |
1420 | 501, |
1421 | 500, |
1422 | 499, |
1423 | 498, |
1424 | 497, |
1425 | 496, |
1426 | 495, |
1427 | 494, |
1428 | 493, |
1429 | 492, |
1430 | 491, |
1431 | 490, |
1432 | 489, |
1433 | 488, |
1434 | 487, |
1435 | 486, |
1436 | 485, |
1437 | 484, |
1438 | 483, |
1439 | 482, |
1440 | 481, |
1441 | 480, |
1442 | 479, |
1443 | 478, |
1444 | 477, |
1445 | 476, |
1446 | 475, |
1447 | 474, |
1448 | 473, |
1449 | 472, |
1450 | 471, |
1451 | 470, |
1452 | 469, |
1453 | 468, |
1454 | 467, |
1455 | 466, |
1456 | 465, |
1457 | 464, |
1458 | 463, |
1459 | 462, |
1460 | 461, |
1461 | 460, |
1462 | 459, |
1463 | 458, |
1464 | 457, |
1465 | 456, |
1466 | 455, |
1467 | 454, |
1468 | 453, |
1469 | 452, |
1470 | 451, |
1471 | 450, |
1472 | 449, |
1473 | 448, |
1474 | 447, |
1475 | 446, |
1476 | 445, |
1477 | 444, |
1478 | 443, |
1479 | 442, |
1480 | 441, |
1481 | 440, |
1482 | 439, |
1483 | 438, |
1484 | 437, |
1485 | 436, |
1486 | 435, |
1487 | 434, |
1488 | 433, |
1489 | 432, |
1490 | 431, |
1491 | 430, |
1492 | 429, |
1493 | 428, |
1494 | 427, |
1495 | 426, |
1496 | 425, |
1497 | 424, |
1498 | 423, |
1499 | 422, |
1500 | 421, |
1501 | 420, |
1502 | 419, |
1503 | 418, |
1504 | 417, |
1505 | 416, |
1506 | 415, |
1507 | 414, |
1508 | 413, |
1509 | 412, |
1510 | 411, |
1511 | 410, |
1512 | 409, |
1513 | 408, |
1514 | 407, |
1515 | 406, |
1516 | 405, |
1517 | 404, |
1518 | 403, |
1519 | 402, |
1520 | 401, |
1521 | 400, |
1522 | 399, |
1523 | 398, |
1524 | 397, |
1525 | 396, |
1526 | 395, |
1527 | 394, |
1528 | 393, |
1529 | 392, |
1530 | 391, |
1531 | 390, |
1532 | 389, |
1533 | 388, |
1534 | 387, |
1535 | 386, |
1536 | 385, |
1537 | 384, |
1538 | 383, |
1539 | 382, |
1540 | 381, |
1541 | 380, |
1542 | 379, |
1543 | 378, |
1544 | 377, |
1545 | 376, |
1546 | 375, |
1547 | 374, |
1548 | 373, |
1549 | 372, |
1550 | 371, |
1551 | 370, |
1552 | 369, |
1553 | 368, |
1554 | 367, |
1555 | 366, |
1556 | 365, |
1557 | 364, |
1558 | 363, |
1559 | 362, |
1560 | 361, |
1561 | 360, |
1562 | 359, |
1563 | 358, |
1564 | 357, |
1565 | 356, |
1566 | 355, |
1567 | 354, |
1568 | 353, |
1569 | 352, |
1570 | 351, |
1571 | 350, |
1572 | 349, |
1573 | 348, |
1574 | 347, |
1575 | 346, |
1576 | 345, |
1577 | 344, |
1578 | 343, |
1579 | 342, |
1580 | 341, |
1581 | 340, |
1582 | 339, |
1583 | 338, |
1584 | 337, |
1585 | 336, |
1586 | 335, |
1587 | 334, |
1588 | 333, |
1589 | 332, |
1590 | 331, |
1591 | 330, |
1592 | 329, |
1593 | 328, |
1594 | 327, |
1595 | 326, |
1596 | 325, |
1597 | 324, |
1598 | 323, |
1599 | 322, |
1600 | 321, |
1601 | 320, |
1602 | 319, |
1603 | 318, |
1604 | 317, |
1605 | 316, |
1606 | 315, |
1607 | 314, |
1608 | 313, |
1609 | 312, |
1610 | 311, |
1611 | 310, |
1612 | 309, |
1613 | 308, |
1614 | 307, |
1615 | 306, |
1616 | 305, |
1617 | 304, |
1618 | 303, |
1619 | 302, |
1620 | 301, |
1621 | 300, |
1622 | 299, |
1623 | 298, |
1624 | 297, |
1625 | 296, |
1626 | 295, |
1627 | 294, |
1628 | 293, |
1629 | 292, |
1630 | 291, |
1631 | 290, |
1632 | 289, |
1633 | 288, |
1634 | 287, |
1635 | 286, |
1636 | 285, |
1637 | 284, |
1638 | 283, |
1639 | 282, |
1640 | 281, |
1641 | 280, |
1642 | 279, |
1643 | 278, |
1644 | 277, |
1645 | 276, |
1646 | 275, |
1647 | 274, |
1648 | 273, |
1649 | 272, |
1650 | 271, |
1651 | 270, |
1652 | 269, |
1653 | 268, |
1654 | 267, |
1655 | 266, |
1656 | 265, |
1657 | 264, |
1658 | 263, |
1659 | 262, |
1660 | 261, |
1661 | 260, |
1662 | 259, |
1663 | 258, |
1664 | 257, |
1665 | 256, |
1666 | 255, |
1667 | 254, |
1668 | 253, |
1669 | 252, |
1670 | 251, |
1671 | 250, |
1672 | 249, |
1673 | 248, |
1674 | 247, |
1675 | 246, |
1676 | 245, |
1677 | 244, |
1678 | 243, |
1679 | 242, |
1680 | 241, |
1681 | 240, |
1682 | 239, |
1683 | 238, |
1684 | 237, |
1685 | 236, |
1686 | 235, |
1687 | 234, |
1688 | 233, |
1689 | 232, |
1690 | 231, |
1691 | 230, |
1692 | 229, |
1693 | 228, |
1694 | 227, |
1695 | 226, |
1696 | 225, |
1697 | 224, |
1698 | 223, |
1699 | 222, |
1700 | 221, |
1701 | 220, |
1702 | 219, |
1703 | 218, |
1704 | 217, |
1705 | 216, |
1706 | 215, |
1707 | 214, |
1708 | 213, |
1709 | 212, |
1710 | 211, |
1711 | 210, |
1712 | 209, |
1713 | 208, |
1714 | 207, |
1715 | 206, |
1716 | 205, |
1717 | 204, |
1718 | 203, |
1719 | 202, |
1720 | 201, |
1721 | 200, |
1722 | 199, |
1723 | 198, |
1724 | 197, |
1725 | 196, |
1726 | 195, |
1727 | 194, |
1728 | 193, |
1729 | 192, |
1730 | 191, |
1731 | 190, |
1732 | 189, |
1733 | 188, |
1734 | 187, |
1735 | 186, |
1736 | 185, |
1737 | 184, |
1738 | 183, |
1739 | 182, |
1740 | 181, |
1741 | 180, |
1742 | 179, |
1743 | 178, |
1744 | 177, |
1745 | 176, |
1746 | 175, |
1747 | 174, |
1748 | 173, |
1749 | 172, |
1750 | 171, |
1751 | 170, |
1752 | 169, |
1753 | 168, |
1754 | 167, |
1755 | 166, |
1756 | 165, |
1757 | 164, |
1758 | 163, |
1759 | 162, |
1760 | 161, |
1761 | 160, |
1762 | 159, |
1763 | 158, |
1764 | 157, |
1765 | 156, |
1766 | 155, |
1767 | 154, |
1768 | 153, |
1769 | 152, |
1770 | 151, |
1771 | 150, |
1772 | 149, |
1773 | 148, |
1774 | 147, |
1775 | 146, |
1776 | 145, |
1777 | 144, |
1778 | 143, |
1779 | 142, |
1780 | 141, |
1781 | 140, |
1782 | 139, |
1783 | 138, |
1784 | 137, |
1785 | 136, |
1786 | 135, |
1787 | 134, |
1788 | 133, |
1789 | 132, |
1790 | 131, |
1791 | 130, |
1792 | 129, |
1793 | 128, |
1794 | 127, |
1795 | 126, |
1796 | 125, |
1797 | 124, |
1798 | 123, |
1799 | 122, |
1800 | 121, |
1801 | 120, |
1802 | 119, |
1803 | 118, |
1804 | 117, |
1805 | 116, |
1806 | 115, |
1807 | 114, |
1808 | 113, |
1809 | 112, |
1810 | 111, |
1811 | 110, |
1812 | 109, |
1813 | 108, |
1814 | 107, |
1815 | 106, |
1816 | 105, |
1817 | 104, |
1818 | 103, |
1819 | 102, |
1820 | 101, |
1821 | 100, |
1822 | 99, |
1823 | 98, |
1824 | 97, |
1825 | 96, |
1826 | 95, |
1827 | 94, |
1828 | 93, |
1829 | 92, |
1830 | 91, |
1831 | 90, |
1832 | 89, |
1833 | 88, |
1834 | 87, |
1835 | 86, |
1836 | 85, |
1837 | 84, |
1838 | 83, |
1839 | 82, |
1840 | 81, |
1841 | 80, |
1842 | 79, |
1843 | 78, |
1844 | 77, |
1845 | 76, |
1846 | 75, |
1847 | 74, |
1848 | 73, |
1849 | 72, |
1850 | 71, |
1851 | 70, |
1852 | 69, |
1853 | 68, |
1854 | 67, |
1855 | 66, |
1856 | 65, |
1857 | 64, |
1858 | 63, |
1859 | 62, |
1860 | 61, |
1861 | 60, |
1862 | 59, |
1863 | 58, |
1864 | 57, |
1865 | 56, |
1866 | 55, |
1867 | 54, |
1868 | 53, |
1869 | 52, |
1870 | 51, |
1871 | 50, |
1872 | 49, |
1873 | 48, |
1874 | 47, |
1875 | 46, |
1876 | 45, |
1877 | 44, |
1878 | 43, |
1879 | 42, |
1880 | 41, |
1881 | 40, |
1882 | 39, |
1883 | 38, |
1884 | 37, |
1885 | 36, |
1886 | 35, |
1887 | 34, |
1888 | 33, |
1889 | 32, |
1890 | 31, |
1891 | 30, |
1892 | 29, |
1893 | 28, |
1894 | 27, |
1895 | 26, |
1896 | 25, |
1897 | 24, |
1898 | 23, |
1899 | 22, |
1900 | 21, |
1901 | 20, |
1902 | 19, |
1903 | 18, |
1904 | 17, |
1905 | 16, |
1906 | 15, |
1907 | 14, |
1908 | 13, |
1909 | 12, |
1910 | 11, |
1911 | 10, |
1912 | 9, |
1913 | 8, |
1914 | 7, |
1915 | 6, |
1916 | 5, |
1917 | 4, |
1918 | 3, |
1919 | 2, |
1920 | 1, |
1921 | 0, |
1922 | }; |
1923 | // clang-format on |
1924 | |
1925 | /// Compares a version string to the current Nvim version. |
1926 | /// |
1927 | /// @param version Version string like "1.3.42" |
1928 | /// |
1929 | /// @return true if Nvim is at or above the version. |
1930 | bool has_nvim_version(const char *const version_str) |
1931 | FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL |
1932 | { |
1933 | const char *p = version_str; |
1934 | int major = 0; |
1935 | int minor = 0; |
1936 | int patch = 0; |
1937 | |
1938 | if (!ascii_isdigit(*p)) { |
1939 | return false; |
1940 | } |
1941 | major = atoi(p); |
1942 | p = strchr(p, '.'); // Find the next dot. |
1943 | |
1944 | if (p) { |
1945 | p++; // Advance past the dot. |
1946 | if (!ascii_isdigit(*p)) { |
1947 | return false; |
1948 | } |
1949 | minor = atoi(p); |
1950 | p = strchr(p, '.'); |
1951 | if (p) { |
1952 | p++; |
1953 | if (!ascii_isdigit(*p)) { |
1954 | return false; |
1955 | } |
1956 | patch = atoi(p); |
1957 | } |
1958 | } |
1959 | |
1960 | return (major < NVIM_VERSION_MAJOR |
1961 | || (major == NVIM_VERSION_MAJOR |
1962 | && (minor < NVIM_VERSION_MINOR |
1963 | || (minor == NVIM_VERSION_MINOR |
1964 | && patch <= NVIM_VERSION_PATCH)))); |
1965 | } |
1966 | |
1967 | /// Checks whether a Vim patch has been included. |
1968 | /// |
1969 | /// @param n Patch number. |
1970 | /// |
1971 | /// @return true if patch `n` has been included. |
1972 | bool has_vim_patch(int n) |
1973 | { |
1974 | for (int i = 0; included_patches[i] != 0; i++) { |
1975 | if (included_patches[i] == n) { |
1976 | return true; |
1977 | } |
1978 | } |
1979 | return false; |
1980 | } |
1981 | |
1982 | Dictionary version_dict(void) { |
1983 | Dictionary d = ARRAY_DICT_INIT; |
1984 | PUT(d, "major" , INTEGER_OBJ(NVIM_VERSION_MAJOR)); |
1985 | PUT(d, "minor" , INTEGER_OBJ(NVIM_VERSION_MINOR)); |
1986 | PUT(d, "patch" , INTEGER_OBJ(NVIM_VERSION_PATCH)); |
1987 | PUT(d, "api_level" , INTEGER_OBJ(NVIM_API_LEVEL)); |
1988 | PUT(d, "api_compatible" , INTEGER_OBJ(NVIM_API_LEVEL_COMPAT)); |
1989 | PUT(d, "api_prerelease" , BOOLEAN_OBJ(NVIM_API_PRERELEASE)); |
1990 | return d; |
1991 | } |
1992 | |
1993 | void ex_version(exarg_T *eap) |
1994 | { |
1995 | // Ignore a ":version 9.99" command. |
1996 | if (*eap->arg == NUL) { |
1997 | msg_putchar('\n'); |
1998 | list_version(); |
1999 | } |
2000 | } |
2001 | |
2002 | /// Output a string for the version message. If it's going to wrap, output a |
2003 | /// newline, unless the message is too long to fit on the screen anyway. |
2004 | /// When "wrap" is TRUE wrap the string in []. |
2005 | /// @param s |
2006 | /// @param wrap |
2007 | static void version_msg_wrap(char_u *s, int wrap) |
2008 | { |
2009 | int len = (int)vim_strsize(s) + (wrap ? 2 : 0); |
2010 | |
2011 | if (!got_int |
2012 | && (len < Columns) |
2013 | && (msg_col + len >= Columns) |
2014 | && (*s != '\n')) { |
2015 | msg_putchar('\n'); |
2016 | } |
2017 | |
2018 | if (!got_int) { |
2019 | if (wrap) { |
2020 | msg_puts("[" ); |
2021 | } |
2022 | msg_puts((char *)s); |
2023 | if (wrap) { |
2024 | msg_puts("]" ); |
2025 | } |
2026 | } |
2027 | } |
2028 | |
2029 | static void version_msg(char *s) |
2030 | { |
2031 | version_msg_wrap((char_u *)s, false); |
2032 | } |
2033 | |
2034 | /// List all features. |
2035 | /// This does not use list_in_columns (as in Vim), because there are only a |
2036 | /// few, and we do not start at a new line. |
2037 | static void list_features(void) |
2038 | { |
2039 | version_msg(_("\n\nFeatures: " )); |
2040 | for (int i = 0; features[i] != NULL; i++) { |
2041 | version_msg(features[i]); |
2042 | if (features[i+1] != NULL) { |
2043 | version_msg(" " ); |
2044 | } |
2045 | } |
2046 | version_msg("\nSee \":help feature-compile\"\n\n" ); |
2047 | } |
2048 | |
2049 | /// List string items nicely aligned in columns. |
2050 | /// When "size" is < 0 then the last entry is marked with NULL. |
2051 | /// The entry with index "current" is inclosed in []. |
2052 | void list_in_columns(char_u **items, int size, int current) |
2053 | { |
2054 | int item_count = 0; |
2055 | int width = 0; |
2056 | |
2057 | // Find the length of the longest item, use that + 1 as the column width. |
2058 | int i; |
2059 | for (i = 0; size < 0 ? items[i] != NULL : i < size; i++) { |
2060 | int l = (int)vim_strsize(items[i]) + (i == current ? 2 : 0); |
2061 | |
2062 | if (l > width) { |
2063 | width = l; |
2064 | } |
2065 | item_count++; |
2066 | } |
2067 | width += 1; |
2068 | |
2069 | if (Columns < width) { |
2070 | // Not enough screen columns - show one per line |
2071 | for (i = 0; i < item_count; i++) { |
2072 | version_msg_wrap(items[i], i == current); |
2073 | if (msg_col > 0 && i < item_count - 1) { |
2074 | msg_putchar('\n'); |
2075 | } |
2076 | } |
2077 | return; |
2078 | } |
2079 | |
2080 | // The rightmost column doesn't need a separator. |
2081 | // Sacrifice it to fit in one more column if possible. |
2082 | int ncol = (int)(Columns + 1) / width; |
2083 | int nrow = item_count / ncol + (item_count % ncol ? 1 : 0); |
2084 | int cur_row = 1; |
2085 | |
2086 | // "i" counts columns then rows. "idx" counts rows then columns. |
2087 | for (i = 0; !got_int && i < nrow * ncol; i++) { |
2088 | int idx = (i / ncol) + (i % ncol) * nrow; |
2089 | if (idx < item_count) { |
2090 | int last_col = (i + 1) % ncol == 0; |
2091 | if (idx == current) { |
2092 | msg_putchar('['); |
2093 | } |
2094 | msg_puts((char *)items[idx]); |
2095 | if (idx == current) { |
2096 | msg_putchar(']'); |
2097 | } |
2098 | if (last_col) { |
2099 | if (msg_col > 0 && cur_row < nrow) { |
2100 | msg_putchar('\n'); |
2101 | } |
2102 | cur_row++; |
2103 | } else { |
2104 | while (msg_col % width) { |
2105 | msg_putchar(' '); |
2106 | } |
2107 | } |
2108 | } else { |
2109 | // this row is out of items, thus at the end of the row |
2110 | if (msg_col > 0) { |
2111 | if (cur_row < nrow) { |
2112 | msg_putchar('\n'); |
2113 | } |
2114 | cur_row++; |
2115 | } |
2116 | } |
2117 | } |
2118 | } |
2119 | |
2120 | void list_lua_version(void) |
2121 | { |
2122 | typval_T luaver_tv; |
2123 | typval_T arg = { .v_type = VAR_UNKNOWN }; // No args. |
2124 | char *luaver_expr = "((jit and jit.version) and jit.version or _VERSION)" ; |
2125 | executor_eval_lua(cstr_as_string(luaver_expr), &arg, &luaver_tv); |
2126 | assert(luaver_tv.v_type == VAR_STRING); |
2127 | MSG(luaver_tv.vval.v_string); |
2128 | xfree(luaver_tv.vval.v_string); |
2129 | } |
2130 | |
2131 | void list_version(void) |
2132 | { |
2133 | MSG(longVersion); |
2134 | MSG(version_buildtype); |
2135 | list_lua_version(); |
2136 | MSG(version_cflags); |
2137 | |
2138 | #ifdef HAVE_PATHDEF |
2139 | |
2140 | if ((*compiled_user != NUL) || (*compiled_sys != NUL)) { |
2141 | MSG_PUTS(_("\nCompiled " )); |
2142 | |
2143 | if (*compiled_user != NUL) { |
2144 | MSG_PUTS(_("by " )); |
2145 | MSG_PUTS(compiled_user); |
2146 | } |
2147 | |
2148 | if (*compiled_sys != NUL) { |
2149 | MSG_PUTS("@" ); |
2150 | MSG_PUTS(compiled_sys); |
2151 | } |
2152 | } |
2153 | #endif // ifdef HAVE_PATHDEF |
2154 | |
2155 | list_features(); |
2156 | |
2157 | #ifdef SYS_VIMRC_FILE |
2158 | version_msg(_(" system vimrc file: \"" )); |
2159 | version_msg(SYS_VIMRC_FILE); |
2160 | version_msg("\"\n" ); |
2161 | #endif // ifdef SYS_VIMRC_FILE |
2162 | #ifdef HAVE_PATHDEF |
2163 | |
2164 | if (*default_vim_dir != NUL) { |
2165 | version_msg(_(" fall-back for $VIM: \"" )); |
2166 | version_msg(default_vim_dir); |
2167 | version_msg("\"\n" ); |
2168 | } |
2169 | |
2170 | if (*default_vimruntime_dir != NUL) { |
2171 | version_msg(_(" f-b for $VIMRUNTIME: \"" )); |
2172 | version_msg(default_vimruntime_dir); |
2173 | version_msg("\"\n" ); |
2174 | } |
2175 | #endif // ifdef HAVE_PATHDEF |
2176 | |
2177 | version_msg("\nRun :checkhealth for more info" ); |
2178 | } |
2179 | |
2180 | |
2181 | /// Show the intro message when not editing a file. |
2182 | void maybe_intro_message(void) |
2183 | { |
2184 | if (BUFEMPTY() |
2185 | && (curbuf->b_fname == NULL) |
2186 | && (firstwin->w_next == NULL) |
2187 | && (vim_strchr(p_shm, SHM_INTRO) == NULL)) { |
2188 | intro_message(FALSE); |
2189 | } |
2190 | } |
2191 | |
2192 | /// Give an introductory message about Vim. |
2193 | /// Only used when starting Vim on an empty file, without a file name. |
2194 | /// Or with the ":intro" command (for Sven :-). |
2195 | /// |
2196 | /// @param colon TRUE for ":intro" |
2197 | void intro_message(int colon) |
2198 | { |
2199 | int i; |
2200 | long row; |
2201 | long blanklines; |
2202 | int ; |
2203 | char *p; |
2204 | static char *(lines[]) = { |
2205 | N_(NVIM_VERSION_LONG), |
2206 | "" , |
2207 | N_("Nvim is open source and freely distributable" ), |
2208 | N_("https://neovim.io/#chat" ), |
2209 | "" , |
2210 | N_("type :help nvim<Enter> if you are new! " ), |
2211 | N_("type :checkhealth<Enter> to optimize Nvim" ), |
2212 | N_("type :q<Enter> to exit " ), |
2213 | N_("type :help<Enter> for help " ), |
2214 | "" , |
2215 | N_("Help poor children in Uganda!" ), |
2216 | N_("type :help iccf<Enter> for information " ), |
2217 | }; |
2218 | |
2219 | // blanklines = screen height - # message lines |
2220 | size_t lines_size = ARRAY_SIZE(lines); |
2221 | assert(lines_size <= LONG_MAX); |
2222 | |
2223 | blanklines = Rows - ((long)lines_size - 1l); |
2224 | |
2225 | // Don't overwrite a statusline. Depends on 'cmdheight'. |
2226 | if (p_ls > 1) { |
2227 | blanklines -= Rows - topframe->fr_height; |
2228 | } |
2229 | |
2230 | if (blanklines < 0) { |
2231 | blanklines = 0; |
2232 | } |
2233 | |
2234 | // Show the sponsor and register message one out of four times, the Uganda |
2235 | // message two out of four times. |
2236 | sponsor = (int)time(NULL); |
2237 | sponsor = ((sponsor & 2) == 0) - ((sponsor & 4) == 0); |
2238 | |
2239 | // start displaying the message lines after half of the blank lines |
2240 | row = blanklines / 2; |
2241 | |
2242 | if (((row >= 2) && (Columns >= 50)) || colon) { |
2243 | for (i = 0; i < (int)ARRAY_SIZE(lines); ++i) { |
2244 | p = lines[i]; |
2245 | |
2246 | if (sponsor != 0) { |
2247 | if (strstr(p, "children" ) != NULL) { |
2248 | p = sponsor < 0 |
2249 | ? N_("Sponsor Vim development!" ) |
2250 | : N_("Become a registered Vim user!" ); |
2251 | } else if (strstr(p, "iccf" ) != NULL) { |
2252 | p = sponsor < 0 |
2253 | ? N_("type :help sponsor<Enter> for information " ) |
2254 | : N_("type :help register<Enter> for information " ); |
2255 | } else if (strstr(p, "Orphans" ) != NULL) { |
2256 | p = N_("menu Help->Sponsor/Register for information " ); |
2257 | } |
2258 | } |
2259 | |
2260 | if (*p != NUL) { |
2261 | do_intro_line(row, (char_u *)_(p), 0); |
2262 | } |
2263 | row++; |
2264 | } |
2265 | } |
2266 | |
2267 | // Make the wait-return message appear just below the text. |
2268 | if (colon) { |
2269 | assert(row <= INT_MAX); |
2270 | msg_row = (int)row; |
2271 | } |
2272 | } |
2273 | |
2274 | static void do_intro_line(long row, char_u *mesg, int attr) |
2275 | { |
2276 | long col; |
2277 | char_u *p; |
2278 | int l; |
2279 | int clen; |
2280 | |
2281 | // Center the message horizontally. |
2282 | col = vim_strsize(mesg); |
2283 | |
2284 | col = (Columns - col) / 2; |
2285 | |
2286 | if (col < 0) { |
2287 | col = 0; |
2288 | } |
2289 | |
2290 | // Split up in parts to highlight <> items differently. |
2291 | for (p = mesg; *p != NUL; p += l) { |
2292 | clen = 0; |
2293 | |
2294 | for (l = 0; p[l] != NUL |
2295 | && (l == 0 || (p[l] != '<' && p[l - 1] != '>')); ++l) { |
2296 | if (has_mbyte) { |
2297 | clen += ptr2cells(p + l); |
2298 | l += (*mb_ptr2len)(p + l) - 1; |
2299 | } else { |
2300 | clen += byte2cells(p[l]); |
2301 | } |
2302 | } |
2303 | assert(row <= INT_MAX && col <= INT_MAX); |
2304 | grid_puts_len(&default_grid, p, l, (int)row, (int)col, |
2305 | *p == '<' ? HL_ATTR(HLF_8) : attr); |
2306 | col += clen; |
2307 | } |
2308 | } |
2309 | |
2310 | /// ":intro": clear screen, display intro screen and wait for return. |
2311 | /// |
2312 | /// @param eap |
2313 | void ex_intro(exarg_T *eap) |
2314 | { |
2315 | screenclear(); |
2316 | intro_message(TRUE); |
2317 | wait_return(TRUE); |
2318 | } |
2319 | |
2320 | |