Mercurial > vim
comparison src/syntax.c @ 7835:4d7ce6c03fda v7.4.1214
commit https://github.com/vim/vim/commit/764b23c8fd3369cb05ae9122abf3ca16fec539d7
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jan 30 21:10:09 2016 +0100
patch 7.4.1214
Problem: Using old style function declarations.
Solution: Change to new style function declarations. (script by Hirohito
Higashi)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sat, 30 Jan 2016 21:15:04 +0100 |
parents | 1a5d34492798 |
children | 05b88224cea1 |
comparison
equal
deleted
inserted
replaced
7834:2d1dc9ec41ce | 7835:4d7ce6c03fda |
---|---|
487 * The buffer is remembered in syn_buf, because get_syntax_attr() doesn't get | 487 * The buffer is remembered in syn_buf, because get_syntax_attr() doesn't get |
488 * it. Careful: curbuf and curwin are likely to point to another buffer and | 488 * it. Careful: curbuf and curwin are likely to point to another buffer and |
489 * window. | 489 * window. |
490 */ | 490 */ |
491 void | 491 void |
492 syntax_start(wp, lnum) | 492 syntax_start(win_T *wp, linenr_T lnum) |
493 win_T *wp; | |
494 linenr_T lnum; | |
495 { | 493 { |
496 synstate_T *p; | 494 synstate_T *p; |
497 synstate_T *last_valid = NULL; | 495 synstate_T *last_valid = NULL; |
498 synstate_T *last_min_valid = NULL; | 496 synstate_T *last_min_valid = NULL; |
499 synstate_T *sp, *prev = NULL; | 497 synstate_T *sp, *prev = NULL; |
666 /* | 664 /* |
667 * We cannot simply discard growarrays full of state_items or buf_states; we | 665 * We cannot simply discard growarrays full of state_items or buf_states; we |
668 * have to manually release their extmatch pointers first. | 666 * have to manually release their extmatch pointers first. |
669 */ | 667 */ |
670 static void | 668 static void |
671 clear_syn_state(p) | 669 clear_syn_state(synstate_T *p) |
672 synstate_T *p; | |
673 { | 670 { |
674 int i; | 671 int i; |
675 garray_T *gap; | 672 garray_T *gap; |
676 | 673 |
677 if (p->sst_stacksize > SST_FIX_STATES) | 674 if (p->sst_stacksize > SST_FIX_STATES) |
690 | 687 |
691 /* | 688 /* |
692 * Cleanup the current_state stack. | 689 * Cleanup the current_state stack. |
693 */ | 690 */ |
694 static void | 691 static void |
695 clear_current_state() | 692 clear_current_state(void) |
696 { | 693 { |
697 int i; | 694 int i; |
698 stateitem_T *sip; | 695 stateitem_T *sip; |
699 | 696 |
700 sip = (stateitem_T *)(current_state.ga_data); | 697 sip = (stateitem_T *)(current_state.ga_data); |
711 * 1. Search backwards for the end of a C-comment. | 708 * 1. Search backwards for the end of a C-comment. |
712 * 2. Search backwards for given sync patterns. | 709 * 2. Search backwards for given sync patterns. |
713 * 3. Simply start on a given number of lines above "lnum". | 710 * 3. Simply start on a given number of lines above "lnum". |
714 */ | 711 */ |
715 static void | 712 static void |
716 syn_sync(wp, start_lnum, last_valid) | 713 syn_sync( |
717 win_T *wp; | 714 win_T *wp, |
718 linenr_T start_lnum; | 715 linenr_T start_lnum, |
719 synstate_T *last_valid; | 716 synstate_T *last_valid) |
720 { | 717 { |
721 buf_T *curbuf_save; | 718 buf_T *curbuf_save; |
722 win_T *curwin_save; | 719 win_T *curwin_save; |
723 pos_T cursor_save; | 720 pos_T cursor_save; |
724 int idx; | 721 int idx; |
1007 | 1004 |
1008 /* | 1005 /* |
1009 * Return TRUE if the line-continuation pattern matches in line "lnum". | 1006 * Return TRUE if the line-continuation pattern matches in line "lnum". |
1010 */ | 1007 */ |
1011 static int | 1008 static int |
1012 syn_match_linecont(lnum) | 1009 syn_match_linecont(linenr_T lnum) |
1013 linenr_T lnum; | |
1014 { | 1010 { |
1015 regmmatch_T regmatch; | 1011 regmmatch_T regmatch; |
1016 int r; | 1012 int r; |
1017 char_u buf_chartab[32]; /* chartab array for syn iskyeyword */ | 1013 char_u buf_chartab[32]; /* chartab array for syn iskyeyword */ |
1018 | 1014 |
1033 | 1029 |
1034 /* | 1030 /* |
1035 * Prepare the current state for the start of a line. | 1031 * Prepare the current state for the start of a line. |
1036 */ | 1032 */ |
1037 static void | 1033 static void |
1038 syn_start_line() | 1034 syn_start_line(void) |
1039 { | 1035 { |
1040 current_finished = FALSE; | 1036 current_finished = FALSE; |
1041 current_col = 0; | 1037 current_col = 0; |
1042 | 1038 |
1043 /* | 1039 /* |
1058 * Check for items in the stack that need their end updated. | 1054 * Check for items in the stack that need their end updated. |
1059 * When "startofline" is TRUE the last item is always updated. | 1055 * When "startofline" is TRUE the last item is always updated. |
1060 * When "startofline" is FALSE the item with "keepend" is forcefully updated. | 1056 * When "startofline" is FALSE the item with "keepend" is forcefully updated. |
1061 */ | 1057 */ |
1062 static void | 1058 static void |
1063 syn_update_ends(startofline) | 1059 syn_update_ends(int startofline) |
1064 int startofline; | |
1065 { | 1060 { |
1066 stateitem_T *cur_si; | 1061 stateitem_T *cur_si; |
1067 int i; | 1062 int i; |
1068 int seen_keepend; | 1063 int seen_keepend; |
1069 | 1064 |
1159 * the distance is fixed at SST_DIST, for large buffers there is a fixed | 1154 * the distance is fixed at SST_DIST, for large buffers there is a fixed |
1160 * number of entries SST_MAX_ENTRIES, and the distance is computed. | 1155 * number of entries SST_MAX_ENTRIES, and the distance is computed. |
1161 */ | 1156 */ |
1162 | 1157 |
1163 static void | 1158 static void |
1164 syn_stack_free_block(block) | 1159 syn_stack_free_block(synblock_T *block) |
1165 synblock_T *block; | |
1166 { | 1160 { |
1167 synstate_T *p; | 1161 synstate_T *p; |
1168 | 1162 |
1169 if (block->b_sst_array != NULL) | 1163 if (block->b_sst_array != NULL) |
1170 { | 1164 { |
1178 /* | 1172 /* |
1179 * Free b_sst_array[] for buffer "buf". | 1173 * Free b_sst_array[] for buffer "buf". |
1180 * Used when syntax items changed to force resyncing everywhere. | 1174 * Used when syntax items changed to force resyncing everywhere. |
1181 */ | 1175 */ |
1182 void | 1176 void |
1183 syn_stack_free_all(block) | 1177 syn_stack_free_all(synblock_T *block) |
1184 synblock_T *block; | |
1185 { | 1178 { |
1186 win_T *wp; | 1179 win_T *wp; |
1187 | 1180 |
1188 syn_stack_free_block(block); | 1181 syn_stack_free_block(block); |
1189 | 1182 |
1203 * If the number of entries in b_sst_array[] is much too big or a bit too | 1196 * If the number of entries in b_sst_array[] is much too big or a bit too |
1204 * small, reallocate it. | 1197 * small, reallocate it. |
1205 * Also used to allocate b_sst_array[] for the first time. | 1198 * Also used to allocate b_sst_array[] for the first time. |
1206 */ | 1199 */ |
1207 static void | 1200 static void |
1208 syn_stack_alloc() | 1201 syn_stack_alloc(void) |
1209 { | 1202 { |
1210 long len; | 1203 long len; |
1211 synstate_T *to, *from; | 1204 synstate_T *to, *from; |
1212 synstate_T *sstp; | 1205 synstate_T *sstp; |
1213 | 1206 |
1282 * b_mod_* fields. | 1275 * b_mod_* fields. |
1283 * Called from update_screen(), before screen is being updated, once for each | 1276 * Called from update_screen(), before screen is being updated, once for each |
1284 * displayed buffer. | 1277 * displayed buffer. |
1285 */ | 1278 */ |
1286 void | 1279 void |
1287 syn_stack_apply_changes(buf) | 1280 syn_stack_apply_changes(buf_T *buf) |
1288 buf_T *buf; | |
1289 { | 1281 { |
1290 win_T *wp; | 1282 win_T *wp; |
1291 | 1283 |
1292 syn_stack_apply_changes_block(&buf->b_s, buf); | 1284 syn_stack_apply_changes_block(&buf->b_s, buf); |
1293 | 1285 |
1297 syn_stack_apply_changes_block(wp->w_s, buf); | 1289 syn_stack_apply_changes_block(wp->w_s, buf); |
1298 } | 1290 } |
1299 } | 1291 } |
1300 | 1292 |
1301 static void | 1293 static void |
1302 syn_stack_apply_changes_block(block, buf) | 1294 syn_stack_apply_changes_block(synblock_T *block, buf_T *buf) |
1303 synblock_T *block; | |
1304 buf_T *buf; | |
1305 { | 1295 { |
1306 synstate_T *p, *prev, *np; | 1296 synstate_T *p, *prev, *np; |
1307 linenr_T n; | 1297 linenr_T n; |
1308 | 1298 |
1309 if (block->b_sst_array == NULL) /* nothing to do */ | 1299 if (block->b_sst_array == NULL) /* nothing to do */ |
1351 /* | 1341 /* |
1352 * Reduce the number of entries in the state stack for syn_buf. | 1342 * Reduce the number of entries in the state stack for syn_buf. |
1353 * Returns TRUE if at least one entry was freed. | 1343 * Returns TRUE if at least one entry was freed. |
1354 */ | 1344 */ |
1355 static int | 1345 static int |
1356 syn_stack_cleanup() | 1346 syn_stack_cleanup(void) |
1357 { | 1347 { |
1358 synstate_T *p, *prev; | 1348 synstate_T *p, *prev; |
1359 disptick_T tick; | 1349 disptick_T tick; |
1360 int above; | 1350 int above; |
1361 int dist; | 1351 int dist; |
1415 /* | 1405 /* |
1416 * Free the allocated memory for a syn_state item. | 1406 * Free the allocated memory for a syn_state item. |
1417 * Move the entry into the free list. | 1407 * Move the entry into the free list. |
1418 */ | 1408 */ |
1419 static void | 1409 static void |
1420 syn_stack_free_entry(block, p) | 1410 syn_stack_free_entry(synblock_T *block, synstate_T *p) |
1421 synblock_T *block; | |
1422 synstate_T *p; | |
1423 { | 1411 { |
1424 clear_syn_state(p); | 1412 clear_syn_state(p); |
1425 p->sst_next = block->b_sst_firstfree; | 1413 p->sst_next = block->b_sst_firstfree; |
1426 block->b_sst_firstfree = p; | 1414 block->b_sst_firstfree = p; |
1427 ++block->b_sst_freecount; | 1415 ++block->b_sst_freecount; |
1430 /* | 1418 /* |
1431 * Find an entry in the list of state stacks at or before "lnum". | 1419 * Find an entry in the list of state stacks at or before "lnum". |
1432 * Returns NULL when there is no entry or the first entry is after "lnum". | 1420 * Returns NULL when there is no entry or the first entry is after "lnum". |
1433 */ | 1421 */ |
1434 static synstate_T * | 1422 static synstate_T * |
1435 syn_stack_find_entry(lnum) | 1423 syn_stack_find_entry(linenr_T lnum) |
1436 linenr_T lnum; | |
1437 { | 1424 { |
1438 synstate_T *p, *prev; | 1425 synstate_T *p, *prev; |
1439 | 1426 |
1440 prev = NULL; | 1427 prev = NULL; |
1441 for (p = syn_block->b_sst_first; p != NULL; prev = p, p = p->sst_next) | 1428 for (p = syn_block->b_sst_first; p != NULL; prev = p, p = p->sst_next) |
1451 /* | 1438 /* |
1452 * Try saving the current state in b_sst_array[]. | 1439 * Try saving the current state in b_sst_array[]. |
1453 * The current state must be valid for the start of the current_lnum line! | 1440 * The current state must be valid for the start of the current_lnum line! |
1454 */ | 1441 */ |
1455 static synstate_T * | 1442 static synstate_T * |
1456 store_current_state() | 1443 store_current_state(void) |
1457 { | 1444 { |
1458 int i; | 1445 int i; |
1459 synstate_T *p; | 1446 synstate_T *p; |
1460 bufstate_T *bp; | 1447 bufstate_T *bp; |
1461 stateitem_T *cur_si; | 1448 stateitem_T *cur_si; |
1574 | 1561 |
1575 /* | 1562 /* |
1576 * Copy a state stack from "from" in b_sst_array[] to current_state; | 1563 * Copy a state stack from "from" in b_sst_array[] to current_state; |
1577 */ | 1564 */ |
1578 static void | 1565 static void |
1579 load_current_state(from) | 1566 load_current_state(synstate_T *from) |
1580 synstate_T *from; | |
1581 { | 1567 { |
1582 int i; | 1568 int i; |
1583 bufstate_T *bp; | 1569 bufstate_T *bp; |
1584 | 1570 |
1585 clear_current_state(); | 1571 clear_current_state(); |
1622 /* | 1608 /* |
1623 * Compare saved state stack "*sp" with the current state. | 1609 * Compare saved state stack "*sp" with the current state. |
1624 * Return TRUE when they are equal. | 1610 * Return TRUE when they are equal. |
1625 */ | 1611 */ |
1626 static int | 1612 static int |
1627 syn_stack_equal(sp) | 1613 syn_stack_equal(synstate_T *sp) |
1628 synstate_T *sp; | |
1629 { | 1614 { |
1630 int i, j; | 1615 int i, j; |
1631 bufstate_T *bp; | 1616 bufstate_T *bp; |
1632 reg_extmatch_T *six, *bsx; | 1617 reg_extmatch_T *six, *bsx; |
1633 | 1618 |
1695 * displayed line | 1680 * displayed line |
1696 * displayed line | 1681 * displayed line |
1697 * lnum -> line below window | 1682 * lnum -> line below window |
1698 */ | 1683 */ |
1699 void | 1684 void |
1700 syntax_end_parsing(lnum) | 1685 syntax_end_parsing(linenr_T lnum) |
1701 linenr_T lnum; | |
1702 { | 1686 { |
1703 synstate_T *sp; | 1687 synstate_T *sp; |
1704 | 1688 |
1705 sp = syn_stack_find_entry(lnum); | 1689 sp = syn_stack_find_entry(lnum); |
1706 if (sp != NULL && sp->sst_lnum < lnum) | 1690 if (sp != NULL && sp->sst_lnum < lnum) |
1713 /* | 1697 /* |
1714 * End of handling of the state stack. | 1698 * End of handling of the state stack. |
1715 ****************************************/ | 1699 ****************************************/ |
1716 | 1700 |
1717 static void | 1701 static void |
1718 invalidate_current_state() | 1702 invalidate_current_state(void) |
1719 { | 1703 { |
1720 clear_current_state(); | 1704 clear_current_state(); |
1721 current_state.ga_itemsize = 0; /* mark current_state invalid */ | 1705 current_state.ga_itemsize = 0; /* mark current_state invalid */ |
1722 current_next_list = NULL; | 1706 current_next_list = NULL; |
1723 keepend_level = -1; | 1707 keepend_level = -1; |
1724 } | 1708 } |
1725 | 1709 |
1726 static void | 1710 static void |
1727 validate_current_state() | 1711 validate_current_state(void) |
1728 { | 1712 { |
1729 current_state.ga_itemsize = sizeof(stateitem_T); | 1713 current_state.ga_itemsize = sizeof(stateitem_T); |
1730 current_state.ga_growsize = 3; | 1714 current_state.ga_growsize = 3; |
1731 } | 1715 } |
1732 | 1716 |
1734 * Return TRUE if the syntax at start of lnum changed since last time. | 1718 * Return TRUE if the syntax at start of lnum changed since last time. |
1735 * This will only be called just after get_syntax_attr() for the previous | 1719 * This will only be called just after get_syntax_attr() for the previous |
1736 * line, to check if the next line needs to be redrawn too. | 1720 * line, to check if the next line needs to be redrawn too. |
1737 */ | 1721 */ |
1738 int | 1722 int |
1739 syntax_check_changed(lnum) | 1723 syntax_check_changed(linenr_T lnum) |
1740 linenr_T lnum; | |
1741 { | 1724 { |
1742 int retval = TRUE; | 1725 int retval = TRUE; |
1743 synstate_T *sp; | 1726 synstate_T *sp; |
1744 | 1727 |
1745 /* | 1728 /* |
1783 * This doesn't return any attributes, it only gets the state at the end of | 1766 * This doesn't return any attributes, it only gets the state at the end of |
1784 * the line. It can start anywhere in the line, as long as the current state | 1767 * the line. It can start anywhere in the line, as long as the current state |
1785 * is valid. | 1768 * is valid. |
1786 */ | 1769 */ |
1787 static int | 1770 static int |
1788 syn_finish_line(syncing) | 1771 syn_finish_line( |
1789 int syncing; /* called for syncing */ | 1772 int syncing) /* called for syncing */ |
1790 { | 1773 { |
1791 stateitem_T *cur_si; | 1774 stateitem_T *cur_si; |
1792 colnr_T prev_current_col; | 1775 colnr_T prev_current_col; |
1793 | 1776 |
1794 if (!current_finished) | 1777 if (!current_finished) |
1833 * line. But only a "col" after a previously used column is allowed. | 1816 * line. But only a "col" after a previously used column is allowed. |
1834 * When "can_spell" is not NULL set it to TRUE when spell-checking should be | 1817 * When "can_spell" is not NULL set it to TRUE when spell-checking should be |
1835 * done. | 1818 * done. |
1836 */ | 1819 */ |
1837 int | 1820 int |
1838 get_syntax_attr(col, can_spell, keep_state) | 1821 get_syntax_attr( |
1839 colnr_T col; | 1822 colnr_T col, |
1840 int *can_spell; | 1823 int *can_spell, |
1841 int keep_state; /* keep state of char at "col" */ | 1824 int keep_state) /* keep state of char at "col" */ |
1842 { | 1825 { |
1843 int attr = 0; | 1826 int attr = 0; |
1844 | 1827 |
1845 if (can_spell != NULL) | 1828 if (can_spell != NULL) |
1846 /* Default: Only do spelling when there is no @Spell cluster or when | 1829 /* Default: Only do spelling when there is no @Spell cluster or when |
1886 | 1869 |
1887 /* | 1870 /* |
1888 * Get syntax attributes for current_lnum, current_col. | 1871 * Get syntax attributes for current_lnum, current_col. |
1889 */ | 1872 */ |
1890 static int | 1873 static int |
1891 syn_current_attr(syncing, displaying, can_spell, keep_state) | 1874 syn_current_attr( |
1892 int syncing; /* When 1: called for syncing */ | 1875 int syncing, /* When 1: called for syncing */ |
1893 int displaying; /* result will be displayed */ | 1876 int displaying, /* result will be displayed */ |
1894 int *can_spell; /* return: do spell checking */ | 1877 int *can_spell, /* return: do spell checking */ |
1895 int keep_state; /* keep syntax stack afterwards */ | 1878 int keep_state) /* keep syntax stack afterwards */ |
1896 { | 1879 { |
1897 int syn_id; | 1880 int syn_id; |
1898 lpos_T endpos; /* was: char_u *endp; */ | 1881 lpos_T endpos; /* was: char_u *endp; */ |
1899 lpos_T hl_startpos; /* was: int hl_startcol; */ | 1882 lpos_T hl_startpos; /* was: int hl_startcol; */ |
1900 lpos_T hl_endpos; | 1883 lpos_T hl_endpos; |
2479 | 2462 |
2480 /* | 2463 /* |
2481 * Check if we already matched pattern "idx" at the current column. | 2464 * Check if we already matched pattern "idx" at the current column. |
2482 */ | 2465 */ |
2483 static int | 2466 static int |
2484 did_match_already(idx, gap) | 2467 did_match_already(int idx, garray_T *gap) |
2485 int idx; | |
2486 garray_T *gap; | |
2487 { | 2468 { |
2488 int i; | 2469 int i; |
2489 | 2470 |
2490 for (i = current_state.ga_len; --i >= 0; ) | 2471 for (i = current_state.ga_len; --i >= 0; ) |
2491 if (CUR_STATE(i).si_m_startcol == (int)current_col | 2472 if (CUR_STATE(i).si_m_startcol == (int)current_col |
2504 | 2485 |
2505 /* | 2486 /* |
2506 * Push the next match onto the stack. | 2487 * Push the next match onto the stack. |
2507 */ | 2488 */ |
2508 static stateitem_T * | 2489 static stateitem_T * |
2509 push_next_match(cur_si) | 2490 push_next_match(stateitem_T *cur_si) |
2510 stateitem_T *cur_si; | |
2511 { | 2491 { |
2512 synpat_T *spp; | 2492 synpat_T *spp; |
2513 #ifdef FEAT_CONCEAL | 2493 #ifdef FEAT_CONCEAL |
2514 int save_flags; | 2494 int save_flags; |
2515 #endif | 2495 #endif |
2598 | 2578 |
2599 /* | 2579 /* |
2600 * Check for end of current state (and the states before it). | 2580 * Check for end of current state (and the states before it). |
2601 */ | 2581 */ |
2602 static void | 2582 static void |
2603 check_state_ends() | 2583 check_state_ends(void) |
2604 { | 2584 { |
2605 stateitem_T *cur_si; | 2585 stateitem_T *cur_si; |
2606 int had_extend; | 2586 int had_extend; |
2607 | 2587 |
2608 cur_si = &CUR_STATE(current_state.ga_len - 1); | 2588 cur_si = &CUR_STATE(current_state.ga_len - 1); |
2703 /* | 2683 /* |
2704 * Update an entry in the current_state stack for a match or region. This | 2684 * Update an entry in the current_state stack for a match or region. This |
2705 * fills in si_attr, si_next_list and si_cont_list. | 2685 * fills in si_attr, si_next_list and si_cont_list. |
2706 */ | 2686 */ |
2707 static void | 2687 static void |
2708 update_si_attr(idx) | 2688 update_si_attr(int idx) |
2709 int idx; | |
2710 { | 2689 { |
2711 stateitem_T *sip = &CUR_STATE(idx); | 2690 stateitem_T *sip = &CUR_STATE(idx); |
2712 synpat_T *spp; | 2691 synpat_T *spp; |
2713 | 2692 |
2714 /* This should not happen... */ | 2693 /* This should not happen... */ |
2759 /* | 2738 /* |
2760 * Check the current stack for patterns with "keepend" flag. | 2739 * Check the current stack for patterns with "keepend" flag. |
2761 * Propagate the match-end to contained items, until a "skipend" item is found. | 2740 * Propagate the match-end to contained items, until a "skipend" item is found. |
2762 */ | 2741 */ |
2763 static void | 2742 static void |
2764 check_keepend() | 2743 check_keepend(void) |
2765 { | 2744 { |
2766 int i; | 2745 int i; |
2767 lpos_T maxpos; | 2746 lpos_T maxpos; |
2768 lpos_T maxpos_h; | 2747 lpos_T maxpos_h; |
2769 stateitem_T *sip; | 2748 stateitem_T *sip; |
2819 * This finds the end of the current item, if it's in the current line. | 2798 * This finds the end of the current item, if it's in the current line. |
2820 * | 2799 * |
2821 * Return the flags for the matched END. | 2800 * Return the flags for the matched END. |
2822 */ | 2801 */ |
2823 static void | 2802 static void |
2824 update_si_end(sip, startcol, force) | 2803 update_si_end( |
2825 stateitem_T *sip; | 2804 stateitem_T *sip, |
2826 int startcol; /* where to start searching for the end */ | 2805 int startcol, /* where to start searching for the end */ |
2827 int force; /* when TRUE overrule a previous end */ | 2806 int force) /* when TRUE overrule a previous end */ |
2828 { | 2807 { |
2829 lpos_T startpos; | 2808 lpos_T startpos; |
2830 lpos_T endpos; | 2809 lpos_T endpos; |
2831 lpos_T hl_endpos; | 2810 lpos_T hl_endpos; |
2832 lpos_T end_endpos; | 2811 lpos_T end_endpos; |
2885 * Add a new state to the current state stack. | 2864 * Add a new state to the current state stack. |
2886 * It is cleared and the index set to "idx". | 2865 * It is cleared and the index set to "idx". |
2887 * Return FAIL if it's not possible (out of memory). | 2866 * Return FAIL if it's not possible (out of memory). |
2888 */ | 2867 */ |
2889 static int | 2868 static int |
2890 push_current_state(idx) | 2869 push_current_state(int idx) |
2891 int idx; | |
2892 { | 2870 { |
2893 if (ga_grow(¤t_state, 1) == FAIL) | 2871 if (ga_grow(¤t_state, 1) == FAIL) |
2894 return FAIL; | 2872 return FAIL; |
2895 vim_memset(&CUR_STATE(current_state.ga_len), 0, sizeof(stateitem_T)); | 2873 vim_memset(&CUR_STATE(current_state.ga_len), 0, sizeof(stateitem_T)); |
2896 CUR_STATE(current_state.ga_len).si_idx = idx; | 2874 CUR_STATE(current_state.ga_len).si_idx = idx; |
2900 | 2878 |
2901 /* | 2879 /* |
2902 * Remove a state from the current_state stack. | 2880 * Remove a state from the current_state stack. |
2903 */ | 2881 */ |
2904 static void | 2882 static void |
2905 pop_current_state() | 2883 pop_current_state(void) |
2906 { | 2884 { |
2907 if (current_state.ga_len) | 2885 if (current_state.ga_len) |
2908 { | 2886 { |
2909 unref_extmatch(CUR_STATE(current_state.ga_len - 1).si_extmatch); | 2887 unref_extmatch(CUR_STATE(current_state.ga_len - 1).si_extmatch); |
2910 --current_state.ga_len; | 2888 --current_state.ga_len; |
2925 * will be 0. | 2903 * will be 0. |
2926 * If found, the end of the region and the end of the highlighting is | 2904 * If found, the end of the region and the end of the highlighting is |
2927 * computed. | 2905 * computed. |
2928 */ | 2906 */ |
2929 static void | 2907 static void |
2930 find_endpos(idx, startpos, m_endpos, hl_endpos, flagsp, end_endpos, | 2908 find_endpos( |
2931 end_idx, start_ext) | 2909 int idx, /* index of the pattern */ |
2932 int idx; /* index of the pattern */ | 2910 lpos_T *startpos, /* where to start looking for an END match */ |
2933 lpos_T *startpos; /* where to start looking for an END match */ | 2911 lpos_T *m_endpos, /* return: end of match */ |
2934 lpos_T *m_endpos; /* return: end of match */ | 2912 lpos_T *hl_endpos, /* return: end of highlighting */ |
2935 lpos_T *hl_endpos; /* return: end of highlighting */ | 2913 long *flagsp, /* return: flags of matching END */ |
2936 long *flagsp; /* return: flags of matching END */ | 2914 lpos_T *end_endpos, /* return: end of end pattern match */ |
2937 lpos_T *end_endpos; /* return: end of end pattern match */ | 2915 int *end_idx, /* return: group ID for end pat. match, or 0 */ |
2938 int *end_idx; /* return: group ID for end pat. match, or 0 */ | 2916 reg_extmatch_T *start_ext) /* submatches from the start pattern */ |
2939 reg_extmatch_T *start_ext; /* submatches from the start pattern */ | |
2940 { | 2917 { |
2941 colnr_T matchcol; | 2918 colnr_T matchcol; |
2942 synpat_T *spp, *spp_skip; | 2919 synpat_T *spp, *spp_skip; |
2943 int start_idx; | 2920 int start_idx; |
2944 int best_idx; | 2921 int best_idx; |
3163 | 3140 |
3164 /* | 3141 /* |
3165 * Limit "pos" not to be after "limit". | 3142 * Limit "pos" not to be after "limit". |
3166 */ | 3143 */ |
3167 static void | 3144 static void |
3168 limit_pos(pos, limit) | 3145 limit_pos(lpos_T *pos, lpos_T *limit) |
3169 lpos_T *pos; | |
3170 lpos_T *limit; | |
3171 { | 3146 { |
3172 if (pos->lnum > limit->lnum) | 3147 if (pos->lnum > limit->lnum) |
3173 *pos = *limit; | 3148 *pos = *limit; |
3174 else if (pos->lnum == limit->lnum && pos->col > limit->col) | 3149 else if (pos->lnum == limit->lnum && pos->col > limit->col) |
3175 pos->col = limit->col; | 3150 pos->col = limit->col; |
3177 | 3152 |
3178 /* | 3153 /* |
3179 * Limit "pos" not to be after "limit", unless pos->lnum is zero. | 3154 * Limit "pos" not to be after "limit", unless pos->lnum is zero. |
3180 */ | 3155 */ |
3181 static void | 3156 static void |
3182 limit_pos_zero(pos, limit) | 3157 limit_pos_zero( |
3183 lpos_T *pos; | 3158 lpos_T *pos, |
3184 lpos_T *limit; | 3159 lpos_T *limit) |
3185 { | 3160 { |
3186 if (pos->lnum == 0) | 3161 if (pos->lnum == 0) |
3187 *pos = *limit; | 3162 *pos = *limit; |
3188 else | 3163 else |
3189 limit_pos(pos, limit); | 3164 limit_pos(pos, limit); |
3191 | 3166 |
3192 /* | 3167 /* |
3193 * Add offset to matched text for end of match or highlight. | 3168 * Add offset to matched text for end of match or highlight. |
3194 */ | 3169 */ |
3195 static void | 3170 static void |
3196 syn_add_end_off(result, regmatch, spp, idx, extra) | 3171 syn_add_end_off( |
3197 lpos_T *result; /* returned position */ | 3172 lpos_T *result, /* returned position */ |
3198 regmmatch_T *regmatch; /* start/end of match */ | 3173 regmmatch_T *regmatch, /* start/end of match */ |
3199 synpat_T *spp; /* matched pattern */ | 3174 synpat_T *spp, /* matched pattern */ |
3200 int idx; /* index of offset */ | 3175 int idx, /* index of offset */ |
3201 int extra; /* extra chars for offset to start */ | 3176 int extra) /* extra chars for offset to start */ |
3202 { | 3177 { |
3203 int col; | 3178 int col; |
3204 int off; | 3179 int off; |
3205 char_u *base; | 3180 char_u *base; |
3206 char_u *p; | 3181 char_u *p; |
3243 /* | 3218 /* |
3244 * Add offset to matched text for start of match or highlight. | 3219 * Add offset to matched text for start of match or highlight. |
3245 * Avoid resulting column to become negative. | 3220 * Avoid resulting column to become negative. |
3246 */ | 3221 */ |
3247 static void | 3222 static void |
3248 syn_add_start_off(result, regmatch, spp, idx, extra) | 3223 syn_add_start_off( |
3249 lpos_T *result; /* returned position */ | 3224 lpos_T *result, /* returned position */ |
3250 regmmatch_T *regmatch; /* start/end of match */ | 3225 regmmatch_T *regmatch, /* start/end of match */ |
3251 synpat_T *spp; | 3226 synpat_T *spp, |
3252 int idx; | 3227 int idx, |
3253 int extra; /* extra chars for offset to end */ | 3228 int extra) /* extra chars for offset to end */ |
3254 { | 3229 { |
3255 int col; | 3230 int col; |
3256 int off; | 3231 int off; |
3257 char_u *base; | 3232 char_u *base; |
3258 char_u *p; | 3233 char_u *p; |
3296 | 3271 |
3297 /* | 3272 /* |
3298 * Get current line in syntax buffer. | 3273 * Get current line in syntax buffer. |
3299 */ | 3274 */ |
3300 static char_u * | 3275 static char_u * |
3301 syn_getcurline() | 3276 syn_getcurline(void) |
3302 { | 3277 { |
3303 return ml_get_buf(syn_buf, current_lnum, FALSE); | 3278 return ml_get_buf(syn_buf, current_lnum, FALSE); |
3304 } | 3279 } |
3305 | 3280 |
3306 /* | 3281 /* |
3307 * Call vim_regexec() to find a match with "rmp" in "syn_buf". | 3282 * Call vim_regexec() to find a match with "rmp" in "syn_buf". |
3308 * Returns TRUE when there is a match. | 3283 * Returns TRUE when there is a match. |
3309 */ | 3284 */ |
3310 static int | 3285 static int |
3311 syn_regexec(rmp, lnum, col, st) | 3286 syn_regexec( |
3312 regmmatch_T *rmp; | 3287 regmmatch_T *rmp, |
3313 linenr_T lnum; | 3288 linenr_T lnum, |
3314 colnr_T col; | 3289 colnr_T col, |
3315 syn_time_T *st UNUSED; | 3290 syn_time_T *st UNUSED) |
3316 { | 3291 { |
3317 int r; | 3292 int r; |
3318 #ifdef FEAT_PROFILE | 3293 #ifdef FEAT_PROFILE |
3319 proftime_T pt; | 3294 proftime_T pt; |
3320 | 3295 |
3351 * Check one position in a line for a matching keyword. | 3326 * Check one position in a line for a matching keyword. |
3352 * The caller must check if a keyword can start at startcol. | 3327 * The caller must check if a keyword can start at startcol. |
3353 * Return it's ID if found, 0 otherwise. | 3328 * Return it's ID if found, 0 otherwise. |
3354 */ | 3329 */ |
3355 static int | 3330 static int |
3356 check_keyword_id(line, startcol, endcolp, flagsp, next_listp, cur_si, ccharp) | 3331 check_keyword_id( |
3357 char_u *line; | 3332 char_u *line, |
3358 int startcol; /* position in line to check for keyword */ | 3333 int startcol, /* position in line to check for keyword */ |
3359 int *endcolp; /* return: character after found keyword */ | 3334 int *endcolp, /* return: character after found keyword */ |
3360 long *flagsp; /* return: flags of matching keyword */ | 3335 long *flagsp, /* return: flags of matching keyword */ |
3361 short **next_listp; /* return: next_list of matching keyword */ | 3336 short **next_listp, /* return: next_list of matching keyword */ |
3362 stateitem_T *cur_si; /* item at the top of the stack */ | 3337 stateitem_T *cur_si, /* item at the top of the stack */ |
3363 int *ccharp UNUSED; /* conceal substitution char */ | 3338 int *ccharp UNUSED) /* conceal substitution char */ |
3364 { | 3339 { |
3365 keyentry_T *kp; | 3340 keyentry_T *kp; |
3366 char_u *kwp; | 3341 char_u *kwp; |
3367 int round; | 3342 int round; |
3368 int kwlen; | 3343 int kwlen; |
3440 | 3415 |
3441 /* | 3416 /* |
3442 * Handle ":syntax conceal" command. | 3417 * Handle ":syntax conceal" command. |
3443 */ | 3418 */ |
3444 static void | 3419 static void |
3445 syn_cmd_conceal(eap, syncing) | 3420 syn_cmd_conceal(exarg_T *eap UNUSED, int syncing UNUSED) |
3446 exarg_T *eap UNUSED; | |
3447 int syncing UNUSED; | |
3448 { | 3421 { |
3449 #ifdef FEAT_CONCEAL | 3422 #ifdef FEAT_CONCEAL |
3450 char_u *arg = eap->arg; | 3423 char_u *arg = eap->arg; |
3451 char_u *next; | 3424 char_u *next; |
3452 | 3425 |
3466 | 3439 |
3467 /* | 3440 /* |
3468 * Handle ":syntax case" command. | 3441 * Handle ":syntax case" command. |
3469 */ | 3442 */ |
3470 static void | 3443 static void |
3471 syn_cmd_case(eap, syncing) | 3444 syn_cmd_case(exarg_T *eap, int syncing UNUSED) |
3472 exarg_T *eap; | |
3473 int syncing UNUSED; | |
3474 { | 3445 { |
3475 char_u *arg = eap->arg; | 3446 char_u *arg = eap->arg; |
3476 char_u *next; | 3447 char_u *next; |
3477 | 3448 |
3478 eap->nextcmd = find_nextcmd(arg); | 3449 eap->nextcmd = find_nextcmd(arg); |
3490 | 3461 |
3491 /* | 3462 /* |
3492 * Handle ":syntax spell" command. | 3463 * Handle ":syntax spell" command. |
3493 */ | 3464 */ |
3494 static void | 3465 static void |
3495 syn_cmd_spell(eap, syncing) | 3466 syn_cmd_spell(exarg_T *eap, int syncing UNUSED) |
3496 exarg_T *eap; | |
3497 int syncing UNUSED; | |
3498 { | 3467 { |
3499 char_u *arg = eap->arg; | 3468 char_u *arg = eap->arg; |
3500 char_u *next; | 3469 char_u *next; |
3501 | 3470 |
3502 eap->nextcmd = find_nextcmd(arg); | 3471 eap->nextcmd = find_nextcmd(arg); |
3522 | 3491 |
3523 /* | 3492 /* |
3524 * Handle ":syntax iskeyword" command. | 3493 * Handle ":syntax iskeyword" command. |
3525 */ | 3494 */ |
3526 static void | 3495 static void |
3527 syn_cmd_iskeyword(eap, syncing) | 3496 syn_cmd_iskeyword(exarg_T *eap, int syncing UNUSED) |
3528 exarg_T *eap; | |
3529 int syncing UNUSED; | |
3530 { | 3497 { |
3531 char_u *arg = eap->arg; | 3498 char_u *arg = eap->arg; |
3532 char_u save_chartab[32]; | 3499 char_u save_chartab[32]; |
3533 char_u *save_isk; | 3500 char_u *save_isk; |
3534 | 3501 |
3573 | 3540 |
3574 /* | 3541 /* |
3575 * Clear all syntax info for one buffer. | 3542 * Clear all syntax info for one buffer. |
3576 */ | 3543 */ |
3577 void | 3544 void |
3578 syntax_clear(block) | 3545 syntax_clear(synblock_T *block) |
3579 synblock_T *block; | |
3580 { | 3546 { |
3581 int i; | 3547 int i; |
3582 | 3548 |
3583 block->b_syn_error = FALSE; /* clear previous error */ | 3549 block->b_syn_error = FALSE; /* clear previous error */ |
3584 block->b_syn_ic = FALSE; /* Use case, by default */ | 3550 block->b_syn_ic = FALSE; /* Use case, by default */ |
3625 | 3591 |
3626 /* | 3592 /* |
3627 * Get rid of ownsyntax for window "wp". | 3593 * Get rid of ownsyntax for window "wp". |
3628 */ | 3594 */ |
3629 void | 3595 void |
3630 reset_synblock(wp) | 3596 reset_synblock(win_T *wp) |
3631 win_T *wp; | |
3632 { | 3597 { |
3633 if (wp->w_s != &wp->w_buffer->b_s) | 3598 if (wp->w_s != &wp->w_buffer->b_s) |
3634 { | 3599 { |
3635 syntax_clear(wp->w_s); | 3600 syntax_clear(wp->w_s); |
3636 vim_free(wp->w_s); | 3601 vim_free(wp->w_s); |
3640 | 3605 |
3641 /* | 3606 /* |
3642 * Clear syncing info for one buffer. | 3607 * Clear syncing info for one buffer. |
3643 */ | 3608 */ |
3644 static void | 3609 static void |
3645 syntax_sync_clear() | 3610 syntax_sync_clear(void) |
3646 { | 3611 { |
3647 int i; | 3612 int i; |
3648 | 3613 |
3649 /* free the syntax patterns */ | 3614 /* free the syntax patterns */ |
3650 for (i = curwin->w_s->b_syn_patterns.ga_len; --i >= 0; ) | 3615 for (i = curwin->w_s->b_syn_patterns.ga_len; --i >= 0; ) |
3667 | 3632 |
3668 /* | 3633 /* |
3669 * Remove one pattern from the buffer's pattern list. | 3634 * Remove one pattern from the buffer's pattern list. |
3670 */ | 3635 */ |
3671 static void | 3636 static void |
3672 syn_remove_pattern(block, idx) | 3637 syn_remove_pattern( |
3673 synblock_T *block; | 3638 synblock_T *block, |
3674 int idx; | 3639 int idx) |
3675 { | 3640 { |
3676 synpat_T *spp; | 3641 synpat_T *spp; |
3677 | 3642 |
3678 spp = &(SYN_ITEMS(block)[idx]); | 3643 spp = &(SYN_ITEMS(block)[idx]); |
3679 #ifdef FEAT_FOLDING | 3644 #ifdef FEAT_FOLDING |
3689 /* | 3654 /* |
3690 * Clear and free one syntax pattern. When clearing all, must be called from | 3655 * Clear and free one syntax pattern. When clearing all, must be called from |
3691 * last to first! | 3656 * last to first! |
3692 */ | 3657 */ |
3693 static void | 3658 static void |
3694 syn_clear_pattern(block, i) | 3659 syn_clear_pattern(synblock_T *block, int i) |
3695 synblock_T *block; | |
3696 int i; | |
3697 { | 3660 { |
3698 vim_free(SYN_ITEMS(block)[i].sp_pattern); | 3661 vim_free(SYN_ITEMS(block)[i].sp_pattern); |
3699 vim_regfree(SYN_ITEMS(block)[i].sp_prog); | 3662 vim_regfree(SYN_ITEMS(block)[i].sp_prog); |
3700 /* Only free sp_cont_list and sp_next_list of first start pattern */ | 3663 /* Only free sp_cont_list and sp_next_list of first start pattern */ |
3701 if (i == 0 || SYN_ITEMS(block)[i - 1].sp_type != SPTYPE_START) | 3664 if (i == 0 || SYN_ITEMS(block)[i - 1].sp_type != SPTYPE_START) |
3708 | 3671 |
3709 /* | 3672 /* |
3710 * Clear and free one syntax cluster. | 3673 * Clear and free one syntax cluster. |
3711 */ | 3674 */ |
3712 static void | 3675 static void |
3713 syn_clear_cluster(block, i) | 3676 syn_clear_cluster(synblock_T *block, int i) |
3714 synblock_T *block; | |
3715 int i; | |
3716 { | 3677 { |
3717 vim_free(SYN_CLSTR(block)[i].scl_name); | 3678 vim_free(SYN_CLSTR(block)[i].scl_name); |
3718 vim_free(SYN_CLSTR(block)[i].scl_name_u); | 3679 vim_free(SYN_CLSTR(block)[i].scl_name_u); |
3719 vim_free(SYN_CLSTR(block)[i].scl_list); | 3680 vim_free(SYN_CLSTR(block)[i].scl_list); |
3720 } | 3681 } |
3721 | 3682 |
3722 /* | 3683 /* |
3723 * Handle ":syntax clear" command. | 3684 * Handle ":syntax clear" command. |
3724 */ | 3685 */ |
3725 static void | 3686 static void |
3726 syn_cmd_clear(eap, syncing) | 3687 syn_cmd_clear(exarg_T *eap, int syncing) |
3727 exarg_T *eap; | |
3728 int syncing; | |
3729 { | 3688 { |
3730 char_u *arg = eap->arg; | 3689 char_u *arg = eap->arg; |
3731 char_u *arg_end; | 3690 char_u *arg_end; |
3732 int id; | 3691 int id; |
3733 | 3692 |
3808 | 3767 |
3809 /* | 3768 /* |
3810 * Clear one syntax group for the current buffer. | 3769 * Clear one syntax group for the current buffer. |
3811 */ | 3770 */ |
3812 static void | 3771 static void |
3813 syn_clear_one(id, syncing) | 3772 syn_clear_one(int id, int syncing) |
3814 int id; | |
3815 int syncing; | |
3816 { | 3773 { |
3817 synpat_T *spp; | 3774 synpat_T *spp; |
3818 int idx; | 3775 int idx; |
3819 | 3776 |
3820 /* Clear keywords only when not ":syn sync clear group-name" */ | 3777 /* Clear keywords only when not ":syn sync clear group-name" */ |
3836 | 3793 |
3837 /* | 3794 /* |
3838 * Handle ":syntax on" command. | 3795 * Handle ":syntax on" command. |
3839 */ | 3796 */ |
3840 static void | 3797 static void |
3841 syn_cmd_on(eap, syncing) | 3798 syn_cmd_on(exarg_T *eap, int syncing UNUSED) |
3842 exarg_T *eap; | |
3843 int syncing UNUSED; | |
3844 { | 3799 { |
3845 syn_cmd_onoff(eap, "syntax"); | 3800 syn_cmd_onoff(eap, "syntax"); |
3846 } | 3801 } |
3847 | 3802 |
3848 /* | 3803 /* |
3849 * Handle ":syntax enable" command. | 3804 * Handle ":syntax enable" command. |
3850 */ | 3805 */ |
3851 static void | 3806 static void |
3852 syn_cmd_enable(eap, syncing) | 3807 syn_cmd_enable(exarg_T *eap, int syncing UNUSED) |
3853 exarg_T *eap; | |
3854 int syncing UNUSED; | |
3855 { | 3808 { |
3856 set_internal_string_var((char_u *)"syntax_cmd", (char_u *)"enable"); | 3809 set_internal_string_var((char_u *)"syntax_cmd", (char_u *)"enable"); |
3857 syn_cmd_onoff(eap, "syntax"); | 3810 syn_cmd_onoff(eap, "syntax"); |
3858 do_unlet((char_u *)"g:syntax_cmd", TRUE); | 3811 do_unlet((char_u *)"g:syntax_cmd", TRUE); |
3859 } | 3812 } |
3860 | 3813 |
3861 /* | 3814 /* |
3862 * Handle ":syntax reset" command. | 3815 * Handle ":syntax reset" command. |
3863 */ | 3816 */ |
3864 static void | 3817 static void |
3865 syn_cmd_reset(eap, syncing) | 3818 syn_cmd_reset(exarg_T *eap, int syncing UNUSED) |
3866 exarg_T *eap; | |
3867 int syncing UNUSED; | |
3868 { | 3819 { |
3869 eap->nextcmd = check_nextcmd(eap->arg); | 3820 eap->nextcmd = check_nextcmd(eap->arg); |
3870 if (!eap->skip) | 3821 if (!eap->skip) |
3871 { | 3822 { |
3872 clear_string_option(&curwin->w_s->b_syn_isk); | 3823 clear_string_option(&curwin->w_s->b_syn_isk); |
3878 | 3829 |
3879 /* | 3830 /* |
3880 * Handle ":syntax manual" command. | 3831 * Handle ":syntax manual" command. |
3881 */ | 3832 */ |
3882 static void | 3833 static void |
3883 syn_cmd_manual(eap, syncing) | 3834 syn_cmd_manual(exarg_T *eap, int syncing UNUSED) |
3884 exarg_T *eap; | |
3885 int syncing UNUSED; | |
3886 { | 3835 { |
3887 syn_cmd_onoff(eap, "manual"); | 3836 syn_cmd_onoff(eap, "manual"); |
3888 } | 3837 } |
3889 | 3838 |
3890 /* | 3839 /* |
3891 * Handle ":syntax off" command. | 3840 * Handle ":syntax off" command. |
3892 */ | 3841 */ |
3893 static void | 3842 static void |
3894 syn_cmd_off(eap, syncing) | 3843 syn_cmd_off(exarg_T *eap, int syncing UNUSED) |
3895 exarg_T *eap; | |
3896 int syncing UNUSED; | |
3897 { | 3844 { |
3898 syn_cmd_onoff(eap, "nosyntax"); | 3845 syn_cmd_onoff(eap, "nosyntax"); |
3899 } | 3846 } |
3900 | 3847 |
3901 static void | 3848 static void |
3902 syn_cmd_onoff(eap, name) | 3849 syn_cmd_onoff(exarg_T *eap, char *name) |
3903 exarg_T *eap; | |
3904 char *name; | |
3905 { | 3850 { |
3906 char_u buf[100]; | 3851 char_u buf[100]; |
3907 | 3852 |
3908 eap->nextcmd = check_nextcmd(eap->arg); | 3853 eap->nextcmd = check_nextcmd(eap->arg); |
3909 if (!eap->skip) | 3854 if (!eap->skip) |
3916 | 3861 |
3917 /* | 3862 /* |
3918 * Handle ":syntax [list]" command: list current syntax words. | 3863 * Handle ":syntax [list]" command: list current syntax words. |
3919 */ | 3864 */ |
3920 static void | 3865 static void |
3921 syn_cmd_list(eap, syncing) | 3866 syn_cmd_list( |
3922 exarg_T *eap; | 3867 exarg_T *eap, |
3923 int syncing; /* when TRUE: list syncing items */ | 3868 int syncing) /* when TRUE: list syncing items */ |
3924 { | 3869 { |
3925 char_u *arg = eap->arg; | 3870 char_u *arg = eap->arg; |
3926 int id; | 3871 int id; |
3927 char_u *arg_end; | 3872 char_u *arg_end; |
3928 | 3873 |
4009 } | 3954 } |
4010 eap->nextcmd = check_nextcmd(arg); | 3955 eap->nextcmd = check_nextcmd(arg); |
4011 } | 3956 } |
4012 | 3957 |
4013 static void | 3958 static void |
4014 syn_lines_msg() | 3959 syn_lines_msg(void) |
4015 { | 3960 { |
4016 if (curwin->w_s->b_syn_sync_maxlines > 0 | 3961 if (curwin->w_s->b_syn_sync_maxlines > 0 |
4017 || curwin->w_s->b_syn_sync_minlines > 0) | 3962 || curwin->w_s->b_syn_sync_minlines > 0) |
4018 { | 3963 { |
4019 MSG_PUTS("; "); | 3964 MSG_PUTS("; "); |
4032 MSG_PUTS(_(" lines before top line")); | 3977 MSG_PUTS(_(" lines before top line")); |
4033 } | 3978 } |
4034 } | 3979 } |
4035 | 3980 |
4036 static void | 3981 static void |
4037 syn_match_msg() | 3982 syn_match_msg(void) |
4038 { | 3983 { |
4039 if (curwin->w_s->b_syn_sync_linebreaks > 0) | 3984 if (curwin->w_s->b_syn_sync_linebreaks > 0) |
4040 { | 3985 { |
4041 MSG_PUTS(_("; match ")); | 3986 MSG_PUTS(_("; match ")); |
4042 msg_outnum(curwin->w_s->b_syn_sync_linebreaks); | 3987 msg_outnum(curwin->w_s->b_syn_sync_linebreaks); |
4056 | 4001 |
4057 /* | 4002 /* |
4058 * List one syntax item, for ":syntax" or "syntax list syntax_name". | 4003 * List one syntax item, for ":syntax" or "syntax list syntax_name". |
4059 */ | 4004 */ |
4060 static void | 4005 static void |
4061 syn_list_one(id, syncing, link_only) | 4006 syn_list_one( |
4062 int id; | 4007 int id, |
4063 int syncing; /* when TRUE: list syncing items */ | 4008 int syncing, /* when TRUE: list syncing items */ |
4064 int link_only; /* when TRUE; list link-only too */ | 4009 int link_only) /* when TRUE; list link-only too */ |
4065 { | 4010 { |
4066 int attr; | 4011 int attr; |
4067 int idx; | 4012 int idx; |
4068 int did_header = FALSE; | 4013 int did_header = FALSE; |
4069 synpat_T *spp; | 4014 synpat_T *spp; |
4167 msg_outtrans(HL_TABLE()[HL_TABLE()[id - 1].sg_link - 1].sg_name); | 4112 msg_outtrans(HL_TABLE()[HL_TABLE()[id - 1].sg_link - 1].sg_name); |
4168 } | 4113 } |
4169 } | 4114 } |
4170 | 4115 |
4171 static void | 4116 static void |
4172 syn_list_flags(nlist, flags, attr) | 4117 syn_list_flags(struct name_list *nlist, int flags, int attr) |
4173 struct name_list *nlist; | |
4174 int flags; | |
4175 int attr; | |
4176 { | 4118 { |
4177 int i; | 4119 int i; |
4178 | 4120 |
4179 for (i = 0; nlist[i].flag != 0; ++i) | 4121 for (i = 0; nlist[i].flag != 0; ++i) |
4180 if (flags & nlist[i].flag) | 4122 if (flags & nlist[i].flag) |
4186 | 4128 |
4187 /* | 4129 /* |
4188 * List one syntax cluster, for ":syntax" or "syntax list syntax_name". | 4130 * List one syntax cluster, for ":syntax" or "syntax list syntax_name". |
4189 */ | 4131 */ |
4190 static void | 4132 static void |
4191 syn_list_cluster(id) | 4133 syn_list_cluster(int id) |
4192 int id; | |
4193 { | 4134 { |
4194 int endcol = 15; | 4135 int endcol = 15; |
4195 | 4136 |
4196 /* slight hack: roughly duplicate the guts of syn_list_header() */ | 4137 /* slight hack: roughly duplicate the guts of syn_list_header() */ |
4197 msg_putchar('\n'); | 4138 msg_putchar('\n'); |
4214 msg_puts((char_u *)"=NONE"); | 4155 msg_puts((char_u *)"=NONE"); |
4215 } | 4156 } |
4216 } | 4157 } |
4217 | 4158 |
4218 static void | 4159 static void |
4219 put_id_list(name, list, attr) | 4160 put_id_list(char_u *name, short *list, int attr) |
4220 char_u *name; | |
4221 short *list; | |
4222 int attr; | |
4223 { | 4161 { |
4224 short *p; | 4162 short *p; |
4225 | 4163 |
4226 msg_puts_attr(name, attr); | 4164 msg_puts_attr(name, attr); |
4227 msg_putchar('='); | 4165 msg_putchar('='); |
4256 } | 4194 } |
4257 msg_putchar(' '); | 4195 msg_putchar(' '); |
4258 } | 4196 } |
4259 | 4197 |
4260 static void | 4198 static void |
4261 put_pattern(s, c, spp, attr) | 4199 put_pattern( |
4262 char *s; | 4200 char *s, |
4263 int c; | 4201 int c, |
4264 synpat_T *spp; | 4202 synpat_T *spp, |
4265 int attr; | 4203 int attr) |
4266 { | 4204 { |
4267 long n; | 4205 long n; |
4268 int mask; | 4206 int mask; |
4269 int first; | 4207 int first; |
4270 static char *sepchars = "/+=-#@\"|'^&"; | 4208 static char *sepchars = "/+=-#@\"|'^&"; |
4329 /* | 4267 /* |
4330 * List or clear the keywords for one syntax group. | 4268 * List or clear the keywords for one syntax group. |
4331 * Return TRUE if the header has been printed. | 4269 * Return TRUE if the header has been printed. |
4332 */ | 4270 */ |
4333 static int | 4271 static int |
4334 syn_list_keywords(id, ht, did_header, attr) | 4272 syn_list_keywords( |
4335 int id; | 4273 int id, |
4336 hashtab_T *ht; | 4274 hashtab_T *ht, |
4337 int did_header; /* header has already been printed */ | 4275 int did_header, /* header has already been printed */ |
4338 int attr; | 4276 int attr) |
4339 { | 4277 { |
4340 int outlen; | 4278 int outlen; |
4341 hashitem_T *hi; | 4279 hashitem_T *hi; |
4342 keyentry_T *kp; | 4280 keyentry_T *kp; |
4343 int todo; | 4281 int todo; |
4427 | 4365 |
4428 return did_header; | 4366 return did_header; |
4429 } | 4367 } |
4430 | 4368 |
4431 static void | 4369 static void |
4432 syn_clear_keyword(id, ht) | 4370 syn_clear_keyword(int id, hashtab_T *ht) |
4433 int id; | |
4434 hashtab_T *ht; | |
4435 { | 4371 { |
4436 hashitem_T *hi; | 4372 hashitem_T *hi; |
4437 keyentry_T *kp; | 4373 keyentry_T *kp; |
4438 keyentry_T *kp_prev; | 4374 keyentry_T *kp_prev; |
4439 keyentry_T *kp_next; | 4375 keyentry_T *kp_next; |
4479 | 4415 |
4480 /* | 4416 /* |
4481 * Clear a whole keyword table. | 4417 * Clear a whole keyword table. |
4482 */ | 4418 */ |
4483 static void | 4419 static void |
4484 clear_keywtab(ht) | 4420 clear_keywtab(hashtab_T *ht) |
4485 hashtab_T *ht; | |
4486 { | 4421 { |
4487 hashitem_T *hi; | 4422 hashitem_T *hi; |
4488 int todo; | 4423 int todo; |
4489 keyentry_T *kp; | 4424 keyentry_T *kp; |
4490 keyentry_T *kp_next; | 4425 keyentry_T *kp_next; |
4510 | 4445 |
4511 /* | 4446 /* |
4512 * Add a keyword to the list of keywords. | 4447 * Add a keyword to the list of keywords. |
4513 */ | 4448 */ |
4514 static void | 4449 static void |
4515 add_keyword(name, id, flags, cont_in_list, next_list, conceal_char) | 4450 add_keyword( |
4516 char_u *name; /* name of keyword */ | 4451 char_u *name, /* name of keyword */ |
4517 int id; /* group ID for this keyword */ | 4452 int id, /* group ID for this keyword */ |
4518 int flags; /* flags for this keyword */ | 4453 int flags, /* flags for this keyword */ |
4519 short *cont_in_list; /* containedin for this keyword */ | 4454 short *cont_in_list, /* containedin for this keyword */ |
4520 short *next_list; /* nextgroup for this keyword */ | 4455 short *next_list, /* nextgroup for this keyword */ |
4521 int conceal_char; | 4456 int conceal_char) |
4522 { | 4457 { |
4523 keyentry_T *kp; | 4458 keyentry_T *kp; |
4524 hashtab_T *ht; | 4459 hashtab_T *ht; |
4525 hashitem_T *hi; | 4460 hashitem_T *hi; |
4526 char_u *name_ic; | 4461 char_u *name_ic; |
4570 * Get the start and end of the group name argument. | 4505 * Get the start and end of the group name argument. |
4571 * Return a pointer to the first argument. | 4506 * Return a pointer to the first argument. |
4572 * Return NULL if the end of the command was found instead of further args. | 4507 * Return NULL if the end of the command was found instead of further args. |
4573 */ | 4508 */ |
4574 static char_u * | 4509 static char_u * |
4575 get_group_name(arg, name_end) | 4510 get_group_name( |
4576 char_u *arg; /* start of the argument */ | 4511 char_u *arg, /* start of the argument */ |
4577 char_u **name_end; /* pointer to end of the name */ | 4512 char_u **name_end) /* pointer to end of the name */ |
4578 { | 4513 { |
4579 char_u *rest; | 4514 char_u *rest; |
4580 | 4515 |
4581 *name_end = skiptowhite(arg); | 4516 *name_end = skiptowhite(arg); |
4582 rest = skipwhite(*name_end); | 4517 rest = skipwhite(*name_end); |
4597 * collect all options in between other arguments. | 4532 * collect all options in between other arguments. |
4598 * Return a pointer to the next argument (which isn't an option). | 4533 * Return a pointer to the next argument (which isn't an option). |
4599 * Return NULL for any error; | 4534 * Return NULL for any error; |
4600 */ | 4535 */ |
4601 static char_u * | 4536 static char_u * |
4602 get_syn_options(arg, opt, conceal_char) | 4537 get_syn_options( |
4603 char_u *arg; /* next argument to be checked */ | 4538 char_u *arg, /* next argument to be checked */ |
4604 syn_opt_arg_T *opt; /* various things */ | 4539 syn_opt_arg_T *opt, /* various things */ |
4605 int *conceal_char UNUSED; | 4540 int *conceal_char UNUSED) |
4606 { | 4541 { |
4607 char_u *gname_start, *gname; | 4542 char_u *gname_start, *gname; |
4608 int syn_id; | 4543 int syn_id; |
4609 int len; | 4544 int len; |
4610 char *p; | 4545 char *p; |
4786 * Adjustments to syntax item when declared in a ":syn include"'d file. | 4721 * Adjustments to syntax item when declared in a ":syn include"'d file. |
4787 * Set the contained flag, and if the item is not already contained, add it | 4722 * Set the contained flag, and if the item is not already contained, add it |
4788 * to the specified top-level group, if any. | 4723 * to the specified top-level group, if any. |
4789 */ | 4724 */ |
4790 static void | 4725 static void |
4791 syn_incl_toplevel(id, flagsp) | 4726 syn_incl_toplevel(int id, int *flagsp) |
4792 int id; | |
4793 int *flagsp; | |
4794 { | 4727 { |
4795 if ((*flagsp & HL_CONTAINED) || curwin->w_s->b_syn_topgrp == 0) | 4728 if ((*flagsp & HL_CONTAINED) || curwin->w_s->b_syn_topgrp == 0) |
4796 return; | 4729 return; |
4797 *flagsp |= HL_CONTAINED; | 4730 *flagsp |= HL_CONTAINED; |
4798 if (curwin->w_s->b_syn_topgrp >= SYNID_CLUSTER) | 4731 if (curwin->w_s->b_syn_topgrp >= SYNID_CLUSTER) |
4813 | 4746 |
4814 /* | 4747 /* |
4815 * Handle ":syntax include [@{group-name}] filename" command. | 4748 * Handle ":syntax include [@{group-name}] filename" command. |
4816 */ | 4749 */ |
4817 static void | 4750 static void |
4818 syn_cmd_include(eap, syncing) | 4751 syn_cmd_include(exarg_T *eap, int syncing UNUSED) |
4819 exarg_T *eap; | |
4820 int syncing UNUSED; | |
4821 { | 4752 { |
4822 char_u *arg = eap->arg; | 4753 char_u *arg = eap->arg; |
4823 int sgl_id = 1; | 4754 int sgl_id = 1; |
4824 char_u *group_name_end; | 4755 char_u *group_name_end; |
4825 char_u *rest; | 4756 char_u *rest; |
4890 | 4821 |
4891 /* | 4822 /* |
4892 * Handle ":syntax keyword {group-name} [{option}] keyword .." command. | 4823 * Handle ":syntax keyword {group-name} [{option}] keyword .." command. |
4893 */ | 4824 */ |
4894 static void | 4825 static void |
4895 syn_cmd_keyword(eap, syncing) | 4826 syn_cmd_keyword(exarg_T *eap, int syncing UNUSED) |
4896 exarg_T *eap; | |
4897 int syncing UNUSED; | |
4898 { | 4827 { |
4899 char_u *arg = eap->arg; | 4828 char_u *arg = eap->arg; |
4900 char_u *group_name_end; | 4829 char_u *group_name_end; |
4901 int syn_id; | 4830 int syn_id; |
4902 char_u *rest; | 4831 char_u *rest; |
5019 * Handle ":syntax match {name} [{options}] {pattern} [{options}]". | 4948 * Handle ":syntax match {name} [{options}] {pattern} [{options}]". |
5020 * | 4949 * |
5021 * Also ":syntax sync match {name} [[grouphere | groupthere] {group-name}] .." | 4950 * Also ":syntax sync match {name} [[grouphere | groupthere] {group-name}] .." |
5022 */ | 4951 */ |
5023 static void | 4952 static void |
5024 syn_cmd_match(eap, syncing) | 4953 syn_cmd_match( |
5025 exarg_T *eap; | 4954 exarg_T *eap, |
5026 int syncing; /* TRUE for ":syntax sync match .. " */ | 4955 int syncing) /* TRUE for ":syntax sync match .. " */ |
5027 { | 4956 { |
5028 char_u *arg = eap->arg; | 4957 char_u *arg = eap->arg; |
5029 char_u *group_name_end; | 4958 char_u *group_name_end; |
5030 char_u *rest; | 4959 char_u *rest; |
5031 synpat_T item; /* the item found in the line */ | 4960 synpat_T item; /* the item found in the line */ |
5123 /* | 5052 /* |
5124 * Handle ":syntax region {group-name} [matchgroup={group-name}] | 5053 * Handle ":syntax region {group-name} [matchgroup={group-name}] |
5125 * start {start} .. [skip {skip}] end {end} .. [{options}]". | 5054 * start {start} .. [skip {skip}] end {end} .. [{options}]". |
5126 */ | 5055 */ |
5127 static void | 5056 static void |
5128 syn_cmd_region(eap, syncing) | 5057 syn_cmd_region( |
5129 exarg_T *eap; | 5058 exarg_T *eap, |
5130 int syncing; /* TRUE for ":syntax sync region .." */ | 5059 int syncing) /* TRUE for ":syntax sync region .." */ |
5131 { | 5060 { |
5132 char_u *arg = eap->arg; | 5061 char_u *arg = eap->arg; |
5133 char_u *group_name_end; | 5062 char_u *group_name_end; |
5134 char_u *rest; /* next arg, NULL on error */ | 5063 char_u *rest; /* next arg, NULL on error */ |
5135 char_u *key_end; | 5064 char_u *key_end; |
5392 */ | 5321 */ |
5393 static int | 5322 static int |
5394 #ifdef __BORLANDC__ | 5323 #ifdef __BORLANDC__ |
5395 _RTLENTRYF | 5324 _RTLENTRYF |
5396 #endif | 5325 #endif |
5397 syn_compare_stub(v1, v2) | 5326 syn_compare_stub(const void *v1, const void *v2) |
5398 const void *v1; | |
5399 const void *v2; | |
5400 { | 5327 { |
5401 const short *s1 = v1; | 5328 const short *s1 = v1; |
5402 const short *s2 = v2; | 5329 const short *s2 = v2; |
5403 | 5330 |
5404 return (*s1 > *s2 ? 1 : *s1 < *s2 ? -1 : 0); | 5331 return (*s1 > *s2 ? 1 : *s1 < *s2 ? -1 : 0); |
5407 /* | 5334 /* |
5408 * Combines lists of syntax clusters. | 5335 * Combines lists of syntax clusters. |
5409 * *clstr1 and *clstr2 must both be allocated memory; they will be consumed. | 5336 * *clstr1 and *clstr2 must both be allocated memory; they will be consumed. |
5410 */ | 5337 */ |
5411 static void | 5338 static void |
5412 syn_combine_list(clstr1, clstr2, list_op) | 5339 syn_combine_list(short **clstr1, short **clstr2, int list_op) |
5413 short **clstr1; | |
5414 short **clstr2; | |
5415 int list_op; | |
5416 { | 5340 { |
5417 int count1 = 0; | 5341 int count1 = 0; |
5418 int count2 = 0; | 5342 int count2 = 0; |
5419 short *g1; | 5343 short *g1; |
5420 short *g2; | 5344 short *g2; |
5534 /* | 5458 /* |
5535 * Lookup a syntax cluster name and return it's ID. | 5459 * Lookup a syntax cluster name and return it's ID. |
5536 * If it is not found, 0 is returned. | 5460 * If it is not found, 0 is returned. |
5537 */ | 5461 */ |
5538 static int | 5462 static int |
5539 syn_scl_name2id(name) | 5463 syn_scl_name2id(char_u *name) |
5540 char_u *name; | |
5541 { | 5464 { |
5542 int i; | 5465 int i; |
5543 char_u *name_u; | 5466 char_u *name_u; |
5544 | 5467 |
5545 /* Avoid using stricmp() too much, it's slow on some systems */ | 5468 /* Avoid using stricmp() too much, it's slow on some systems */ |
5556 | 5479 |
5557 /* | 5480 /* |
5558 * Like syn_scl_name2id(), but take a pointer + length argument. | 5481 * Like syn_scl_name2id(), but take a pointer + length argument. |
5559 */ | 5482 */ |
5560 static int | 5483 static int |
5561 syn_scl_namen2id(linep, len) | 5484 syn_scl_namen2id(char_u *linep, int len) |
5562 char_u *linep; | |
5563 int len; | |
5564 { | 5485 { |
5565 char_u *name; | 5486 char_u *name; |
5566 int id = 0; | 5487 int id = 0; |
5567 | 5488 |
5568 name = vim_strnsave(linep, len); | 5489 name = vim_strnsave(linep, len); |
5579 * The argument is a pointer to the name and the length of the name. | 5500 * The argument is a pointer to the name and the length of the name. |
5580 * If it doesn't exist yet, a new entry is created. | 5501 * If it doesn't exist yet, a new entry is created. |
5581 * Return 0 for failure. | 5502 * Return 0 for failure. |
5582 */ | 5503 */ |
5583 static int | 5504 static int |
5584 syn_check_cluster(pp, len) | 5505 syn_check_cluster(char_u *pp, int len) |
5585 char_u *pp; | |
5586 int len; | |
5587 { | 5506 { |
5588 int id; | 5507 int id; |
5589 char_u *name; | 5508 char_u *name; |
5590 | 5509 |
5591 name = vim_strnsave(pp, len); | 5510 name = vim_strnsave(pp, len); |
5604 * Add new syntax cluster and return it's ID. | 5523 * Add new syntax cluster and return it's ID. |
5605 * "name" must be an allocated string, it will be consumed. | 5524 * "name" must be an allocated string, it will be consumed. |
5606 * Return 0 for failure. | 5525 * Return 0 for failure. |
5607 */ | 5526 */ |
5608 static int | 5527 static int |
5609 syn_add_cluster(name) | 5528 syn_add_cluster(char_u *name) |
5610 char_u *name; | |
5611 { | 5529 { |
5612 int len; | 5530 int len; |
5613 | 5531 |
5614 /* | 5532 /* |
5615 * First call for this growarray: init growing array. | 5533 * First call for this growarray: init growing array. |
5654 /* | 5572 /* |
5655 * Handle ":syntax cluster {cluster-name} [contains={groupname},..] | 5573 * Handle ":syntax cluster {cluster-name} [contains={groupname},..] |
5656 * [add={groupname},..] [remove={groupname},..]". | 5574 * [add={groupname},..] [remove={groupname},..]". |
5657 */ | 5575 */ |
5658 static void | 5576 static void |
5659 syn_cmd_cluster(eap, syncing) | 5577 syn_cmd_cluster(exarg_T *eap, int syncing UNUSED) |
5660 exarg_T *eap; | |
5661 int syncing UNUSED; | |
5662 { | 5578 { |
5663 char_u *arg = eap->arg; | 5579 char_u *arg = eap->arg; |
5664 char_u *group_name_end; | 5580 char_u *group_name_end; |
5665 char_u *rest; | 5581 char_u *rest; |
5666 int scl_id; | 5582 int scl_id; |
5731 | 5647 |
5732 /* | 5648 /* |
5733 * On first call for current buffer: Init growing array. | 5649 * On first call for current buffer: Init growing array. |
5734 */ | 5650 */ |
5735 static void | 5651 static void |
5736 init_syn_patterns() | 5652 init_syn_patterns(void) |
5737 { | 5653 { |
5738 curwin->w_s->b_syn_patterns.ga_itemsize = sizeof(synpat_T); | 5654 curwin->w_s->b_syn_patterns.ga_itemsize = sizeof(synpat_T); |
5739 curwin->w_s->b_syn_patterns.ga_growsize = 10; | 5655 curwin->w_s->b_syn_patterns.ga_growsize = 10; |
5740 } | 5656 } |
5741 | 5657 |
5743 * Get one pattern for a ":syntax match" or ":syntax region" command. | 5659 * Get one pattern for a ":syntax match" or ":syntax region" command. |
5744 * Stores the pattern and program in a synpat_T. | 5660 * Stores the pattern and program in a synpat_T. |
5745 * Returns a pointer to the next argument, or NULL in case of an error. | 5661 * Returns a pointer to the next argument, or NULL in case of an error. |
5746 */ | 5662 */ |
5747 static char_u * | 5663 static char_u * |
5748 get_syn_pattern(arg, ci) | 5664 get_syn_pattern(char_u *arg, synpat_T *ci) |
5749 char_u *arg; | |
5750 synpat_T *ci; | |
5751 { | 5665 { |
5752 char_u *end; | 5666 char_u *end; |
5753 int *p; | 5667 int *p; |
5754 int idx; | 5668 int idx; |
5755 char_u *cpo_save; | 5669 char_u *cpo_save; |
5847 | 5761 |
5848 /* | 5762 /* |
5849 * Handle ":syntax sync .." command. | 5763 * Handle ":syntax sync .." command. |
5850 */ | 5764 */ |
5851 static void | 5765 static void |
5852 syn_cmd_sync(eap, syncing) | 5766 syn_cmd_sync(exarg_T *eap, int syncing UNUSED) |
5853 exarg_T *eap; | |
5854 int syncing UNUSED; | |
5855 { | 5767 { |
5856 char_u *arg_start = eap->arg; | 5768 char_u *arg_start = eap->arg; |
5857 char_u *arg_end; | 5769 char_u *arg_end; |
5858 char_u *key = NULL; | 5770 char_u *key = NULL; |
5859 char_u *next_arg; | 5771 char_u *next_arg; |
6008 * "arg" is advanced to after the last group name. | 5920 * "arg" is advanced to after the last group name. |
6009 * Careful: the argument is modified (NULs added). | 5921 * Careful: the argument is modified (NULs added). |
6010 * returns FAIL for some error, OK for success. | 5922 * returns FAIL for some error, OK for success. |
6011 */ | 5923 */ |
6012 static int | 5924 static int |
6013 get_id_list(arg, keylen, list) | 5925 get_id_list( |
6014 char_u **arg; | 5926 char_u **arg, |
6015 int keylen; /* length of keyword */ | 5927 int keylen, /* length of keyword */ |
6016 short **list; /* where to store the resulting list, if not | 5928 short **list) /* where to store the resulting list, if not |
6017 NULL, the list is silently skipped! */ | 5929 NULL, the list is silently skipped! */ |
6018 { | 5930 { |
6019 char_u *p = NULL; | 5931 char_u *p = NULL; |
6020 char_u *end; | 5932 char_u *end; |
6021 int round; | 5933 int round; |
6205 | 6117 |
6206 /* | 6118 /* |
6207 * Make a copy of an ID list. | 6119 * Make a copy of an ID list. |
6208 */ | 6120 */ |
6209 static short * | 6121 static short * |
6210 copy_id_list(list) | 6122 copy_id_list(short *list) |
6211 short *list; | |
6212 { | 6123 { |
6213 int len; | 6124 int len; |
6214 int count; | 6125 int count; |
6215 short *retval; | 6126 short *retval; |
6216 | 6127 |
6233 * Used to check if a syntax item is in the "contains" or "nextgroup" list of | 6144 * Used to check if a syntax item is in the "contains" or "nextgroup" list of |
6234 * the current item. | 6145 * the current item. |
6235 * This function is called very often, keep it fast!! | 6146 * This function is called very often, keep it fast!! |
6236 */ | 6147 */ |
6237 static int | 6148 static int |
6238 in_id_list(cur_si, list, ssp, contained) | 6149 in_id_list( |
6239 stateitem_T *cur_si; /* current item or NULL */ | 6150 stateitem_T *cur_si, /* current item or NULL */ |
6240 short *list; /* id list */ | 6151 short *list, /* id list */ |
6241 struct sp_syn *ssp; /* group id and ":syn include" tag of group */ | 6152 struct sp_syn *ssp, /* group id and ":syn include" tag of group */ |
6242 int contained; /* group id is contained */ | 6153 int contained) /* group id is contained */ |
6243 { | 6154 { |
6244 int retval; | 6155 int retval; |
6245 short *scl_list; | 6156 short *scl_list; |
6246 short item; | 6157 short item; |
6247 short id = ssp->id; | 6158 short id = ssp->id; |
6365 * ":syntax". | 6276 * ":syntax". |
6366 * This searches the subcommands[] table for the subcommand name, and calls a | 6277 * This searches the subcommands[] table for the subcommand name, and calls a |
6367 * syntax_subcommand() function to do the rest. | 6278 * syntax_subcommand() function to do the rest. |
6368 */ | 6279 */ |
6369 void | 6280 void |
6370 ex_syntax(eap) | 6281 ex_syntax(exarg_T *eap) |
6371 exarg_T *eap; | |
6372 { | 6282 { |
6373 char_u *arg = eap->arg; | 6283 char_u *arg = eap->arg; |
6374 char_u *subcmd_end; | 6284 char_u *subcmd_end; |
6375 char_u *subcmd_name; | 6285 char_u *subcmd_name; |
6376 int i; | 6286 int i; |
6404 --emsg_skip; | 6314 --emsg_skip; |
6405 } | 6315 } |
6406 } | 6316 } |
6407 | 6317 |
6408 void | 6318 void |
6409 ex_ownsyntax(eap) | 6319 ex_ownsyntax(exarg_T *eap) |
6410 exarg_T *eap; | |
6411 { | 6320 { |
6412 char_u *old_value; | 6321 char_u *old_value; |
6413 char_u *new_value; | 6322 char_u *new_value; |
6414 | 6323 |
6415 if (curwin->w_s == &curwin->w_buffer->b_s) | 6324 if (curwin->w_s == &curwin->w_buffer->b_s) |
6451 vim_free(old_value); | 6360 vim_free(old_value); |
6452 } | 6361 } |
6453 } | 6362 } |
6454 | 6363 |
6455 int | 6364 int |
6456 syntax_present(win) | 6365 syntax_present(win_T *win) |
6457 win_T *win; | |
6458 { | 6366 { |
6459 return (win->w_s->b_syn_patterns.ga_len != 0 | 6367 return (win->w_s->b_syn_patterns.ga_len != 0 |
6460 || win->w_s->b_syn_clusters.ga_len != 0 | 6368 || win->w_s->b_syn_clusters.ga_len != 0 |
6461 || win->w_s->b_keywtab.ht_used > 0 | 6369 || win->w_s->b_keywtab.ht_used > 0 |
6462 || win->w_s->b_keywtab_ic.ht_used > 0); | 6370 || win->w_s->b_keywtab_ic.ht_used > 0); |
6473 /* | 6381 /* |
6474 * Reset include_link, include_default, include_none to 0. | 6382 * Reset include_link, include_default, include_none to 0. |
6475 * Called when we are done expanding. | 6383 * Called when we are done expanding. |
6476 */ | 6384 */ |
6477 void | 6385 void |
6478 reset_expand_highlight() | 6386 reset_expand_highlight(void) |
6479 { | 6387 { |
6480 include_link = include_default = include_none = 0; | 6388 include_link = include_default = include_none = 0; |
6481 } | 6389 } |
6482 | 6390 |
6483 /* | 6391 /* |
6484 * Handle command line completion for :match and :echohl command: Add "None" | 6392 * Handle command line completion for :match and :echohl command: Add "None" |
6485 * as highlight group. | 6393 * as highlight group. |
6486 */ | 6394 */ |
6487 void | 6395 void |
6488 set_context_in_echohl_cmd(xp, arg) | 6396 set_context_in_echohl_cmd(expand_T *xp, char_u *arg) |
6489 expand_T *xp; | |
6490 char_u *arg; | |
6491 { | 6397 { |
6492 xp->xp_context = EXPAND_HIGHLIGHT; | 6398 xp->xp_context = EXPAND_HIGHLIGHT; |
6493 xp->xp_pattern = arg; | 6399 xp->xp_pattern = arg; |
6494 include_none = 1; | 6400 include_none = 1; |
6495 } | 6401 } |
6496 | 6402 |
6497 /* | 6403 /* |
6498 * Handle command line completion for :syntax command. | 6404 * Handle command line completion for :syntax command. |
6499 */ | 6405 */ |
6500 void | 6406 void |
6501 set_context_in_syntax_cmd(xp, arg) | 6407 set_context_in_syntax_cmd(expand_T *xp, char_u *arg) |
6502 expand_T *xp; | |
6503 char_u *arg; | |
6504 { | 6408 { |
6505 char_u *p; | 6409 char_u *p; |
6506 | 6410 |
6507 /* Default: expand subcommands */ | 6411 /* Default: expand subcommands */ |
6508 xp->xp_context = EXPAND_SYNTAX; | 6412 xp->xp_context = EXPAND_SYNTAX; |
6538 /* | 6442 /* |
6539 * Function given to ExpandGeneric() to obtain the list syntax names for | 6443 * Function given to ExpandGeneric() to obtain the list syntax names for |
6540 * expansion. | 6444 * expansion. |
6541 */ | 6445 */ |
6542 char_u * | 6446 char_u * |
6543 get_syntax_name(xp, idx) | 6447 get_syntax_name(expand_T *xp UNUSED, int idx) |
6544 expand_T *xp UNUSED; | |
6545 int idx; | |
6546 { | 6448 { |
6547 if (expand_what == EXP_SUBCMD) | 6449 if (expand_what == EXP_SUBCMD) |
6548 return (char_u *)subcommands[idx].name; | 6450 return (char_u *)subcommands[idx].name; |
6549 return (char_u *)case_args[idx]; | 6451 return (char_u *)case_args[idx]; |
6550 } | 6452 } |
6553 | 6455 |
6554 /* | 6456 /* |
6555 * Function called for expression evaluation: get syntax ID at file position. | 6457 * Function called for expression evaluation: get syntax ID at file position. |
6556 */ | 6458 */ |
6557 int | 6459 int |
6558 syn_get_id(wp, lnum, col, trans, spellp, keep_state) | 6460 syn_get_id( |
6559 win_T *wp; | 6461 win_T *wp, |
6560 long lnum; | 6462 long lnum, |
6561 colnr_T col; | 6463 colnr_T col, |
6562 int trans; /* remove transparency */ | 6464 int trans, /* remove transparency */ |
6563 int *spellp; /* return: can do spell checking */ | 6465 int *spellp, /* return: can do spell checking */ |
6564 int keep_state; /* keep state of char at "col" */ | 6466 int keep_state) /* keep state of char at "col" */ |
6565 { | 6467 { |
6566 /* When the position is not after the current position and in the same | 6468 /* When the position is not after the current position and in the same |
6567 * line of the same buffer, need to restart parsing. */ | 6469 * line of the same buffer, need to restart parsing. */ |
6568 if (wp->w_buffer != syn_buf | 6470 if (wp->w_buffer != syn_buf |
6569 || lnum != current_lnum | 6471 || lnum != current_lnum |
6587 * get_syntax_attr(). | 6489 * get_syntax_attr(). |
6588 * Stores the current item sequence nr in "*seqnrp". | 6490 * Stores the current item sequence nr in "*seqnrp". |
6589 * Returns the current flags. | 6491 * Returns the current flags. |
6590 */ | 6492 */ |
6591 int | 6493 int |
6592 get_syntax_info(seqnrp) | 6494 get_syntax_info(int *seqnrp) |
6593 int *seqnrp; | |
6594 { | 6495 { |
6595 *seqnrp = current_seqnr; | 6496 *seqnrp = current_seqnr; |
6596 return current_flags; | 6497 return current_flags; |
6597 } | 6498 } |
6598 | 6499 |
6599 /* | 6500 /* |
6600 * Return conceal substitution character | 6501 * Return conceal substitution character |
6601 */ | 6502 */ |
6602 int | 6503 int |
6603 syn_get_sub_char() | 6504 syn_get_sub_char(void) |
6604 { | 6505 { |
6605 return current_sub_char; | 6506 return current_sub_char; |
6606 } | 6507 } |
6607 #endif | 6508 #endif |
6608 | 6509 |
6611 * Return the syntax ID at position "i" in the current stack. | 6512 * Return the syntax ID at position "i" in the current stack. |
6612 * The caller must have called syn_get_id() before to fill the stack. | 6513 * The caller must have called syn_get_id() before to fill the stack. |
6613 * Returns -1 when "i" is out of range. | 6514 * Returns -1 when "i" is out of range. |
6614 */ | 6515 */ |
6615 int | 6516 int |
6616 syn_get_stack_item(i) | 6517 syn_get_stack_item(int i) |
6617 int i; | |
6618 { | 6518 { |
6619 if (i >= current_state.ga_len) | 6519 if (i >= current_state.ga_len) |
6620 { | 6520 { |
6621 /* Need to invalidate the state, because we didn't properly finish it | 6521 /* Need to invalidate the state, because we didn't properly finish it |
6622 * for the last character, "keep_state" was TRUE. */ | 6522 * for the last character, "keep_state" was TRUE. */ |
6631 #if defined(FEAT_FOLDING) || defined(PROTO) | 6531 #if defined(FEAT_FOLDING) || defined(PROTO) |
6632 /* | 6532 /* |
6633 * Function called to get folding level for line "lnum" in window "wp". | 6533 * Function called to get folding level for line "lnum" in window "wp". |
6634 */ | 6534 */ |
6635 int | 6535 int |
6636 syn_get_foldlevel(wp, lnum) | 6536 syn_get_foldlevel(win_T *wp, long lnum) |
6637 win_T *wp; | |
6638 long lnum; | |
6639 { | 6537 { |
6640 int level = 0; | 6538 int level = 0; |
6641 int i; | 6539 int i; |
6642 | 6540 |
6643 /* Return quickly when there are no fold items at all. */ | 6541 /* Return quickly when there are no fold items at all. */ |
6662 #if defined(FEAT_PROFILE) || defined(PROTO) | 6560 #if defined(FEAT_PROFILE) || defined(PROTO) |
6663 /* | 6561 /* |
6664 * ":syntime". | 6562 * ":syntime". |
6665 */ | 6563 */ |
6666 void | 6564 void |
6667 ex_syntime(eap) | 6565 ex_syntime(exarg_T *eap) |
6668 exarg_T *eap; | |
6669 { | 6566 { |
6670 if (STRCMP(eap->arg, "on") == 0) | 6567 if (STRCMP(eap->arg, "on") == 0) |
6671 syn_time_on = TRUE; | 6568 syn_time_on = TRUE; |
6672 else if (STRCMP(eap->arg, "off") == 0) | 6569 else if (STRCMP(eap->arg, "off") == 0) |
6673 syn_time_on = FALSE; | 6570 syn_time_on = FALSE; |
6678 else | 6575 else |
6679 EMSG2(_(e_invarg2), eap->arg); | 6576 EMSG2(_(e_invarg2), eap->arg); |
6680 } | 6577 } |
6681 | 6578 |
6682 static void | 6579 static void |
6683 syn_clear_time(st) | 6580 syn_clear_time(syn_time_T *st) |
6684 syn_time_T *st; | |
6685 { | 6581 { |
6686 profile_zero(&st->total); | 6582 profile_zero(&st->total); |
6687 profile_zero(&st->slowest); | 6583 profile_zero(&st->slowest); |
6688 st->count = 0; | 6584 st->count = 0; |
6689 st->match = 0; | 6585 st->match = 0; |
6691 | 6587 |
6692 /* | 6588 /* |
6693 * Clear the syntax timing for the current buffer. | 6589 * Clear the syntax timing for the current buffer. |
6694 */ | 6590 */ |
6695 static void | 6591 static void |
6696 syntime_clear() | 6592 syntime_clear(void) |
6697 { | 6593 { |
6698 int idx; | 6594 int idx; |
6699 synpat_T *spp; | 6595 synpat_T *spp; |
6700 | 6596 |
6701 if (!syntax_present(curwin)) | 6597 if (!syntax_present(curwin)) |
6714 /* | 6610 /* |
6715 * Function given to ExpandGeneric() to obtain the possible arguments of the | 6611 * Function given to ExpandGeneric() to obtain the possible arguments of the |
6716 * ":syntime {on,off,clear,report}" command. | 6612 * ":syntime {on,off,clear,report}" command. |
6717 */ | 6613 */ |
6718 char_u * | 6614 char_u * |
6719 get_syntime_arg(xp, idx) | 6615 get_syntime_arg(expand_T *xp UNUSED, int idx) |
6720 expand_T *xp UNUSED; | |
6721 int idx; | |
6722 { | 6616 { |
6723 switch (idx) | 6617 switch (idx) |
6724 { | 6618 { |
6725 case 0: return (char_u *)"on"; | 6619 case 0: return (char_u *)"on"; |
6726 case 1: return (char_u *)"off"; | 6620 case 1: return (char_u *)"off"; |
6744 | 6638 |
6745 static int | 6639 static int |
6746 #ifdef __BORLANDC__ | 6640 #ifdef __BORLANDC__ |
6747 _RTLENTRYF | 6641 _RTLENTRYF |
6748 #endif | 6642 #endif |
6749 syn_compare_syntime(v1, v2) | 6643 syn_compare_syntime(const void *v1, const void *v2) |
6750 const void *v1; | |
6751 const void *v2; | |
6752 { | 6644 { |
6753 const time_entry_T *s1 = v1; | 6645 const time_entry_T *s1 = v1; |
6754 const time_entry_T *s2 = v2; | 6646 const time_entry_T *s2 = v2; |
6755 | 6647 |
6756 return profile_cmp(&s1->total, &s2->total); | 6648 return profile_cmp(&s1->total, &s2->total); |
6758 | 6650 |
6759 /* | 6651 /* |
6760 * Clear the syntax timing for the current buffer. | 6652 * Clear the syntax timing for the current buffer. |
6761 */ | 6653 */ |
6762 static void | 6654 static void |
6763 syntime_report() | 6655 syntime_report(void) |
6764 { | 6656 { |
6765 int idx; | 6657 int idx; |
6766 synpat_T *spp; | 6658 synpat_T *spp; |
6767 # ifdef FEAT_FLOAT | 6659 # ifdef FEAT_FLOAT |
6768 proftime_T tm; | 6660 proftime_T tm; |
7093 #endif | 6985 #endif |
7094 NULL | 6986 NULL |
7095 }; | 6987 }; |
7096 | 6988 |
7097 void | 6989 void |
7098 init_highlight(both, reset) | 6990 init_highlight( |
7099 int both; /* include groups where 'bg' doesn't matter */ | 6991 int both, /* include groups where 'bg' doesn't matter */ |
7100 int reset; /* clear group first */ | 6992 int reset) /* clear group first */ |
7101 { | 6993 { |
7102 int i; | 6994 int i; |
7103 char **pp; | 6995 char **pp; |
7104 static int had_both = FALSE; | 6996 static int had_both = FALSE; |
7105 #ifdef FEAT_EVAL | 6997 #ifdef FEAT_EVAL |
7191 /* | 7083 /* |
7192 * Load color file "name". | 7084 * Load color file "name". |
7193 * Return OK for success, FAIL for failure. | 7085 * Return OK for success, FAIL for failure. |
7194 */ | 7086 */ |
7195 int | 7087 int |
7196 load_colors(name) | 7088 load_colors(char_u *name) |
7197 char_u *name; | |
7198 { | 7089 { |
7199 char_u *buf; | 7090 char_u *buf; |
7200 int retval = FAIL; | 7091 int retval = FAIL; |
7201 static int recursive = FALSE; | 7092 static int recursive = FALSE; |
7202 | 7093 |
7226 * Handle the ":highlight .." command. | 7117 * Handle the ":highlight .." command. |
7227 * When using ":hi clear" this is called recursively for each group with | 7118 * When using ":hi clear" this is called recursively for each group with |
7228 * "forceit" and "init" both TRUE. | 7119 * "forceit" and "init" both TRUE. |
7229 */ | 7120 */ |
7230 void | 7121 void |
7231 do_highlight(line, forceit, init) | 7122 do_highlight( |
7232 char_u *line; | 7123 char_u *line, |
7233 int forceit; | 7124 int forceit, |
7234 int init; /* TRUE when called for initializing */ | 7125 int init) /* TRUE when called for initializing */ |
7235 { | 7126 { |
7236 char_u *name_end; | 7127 char_u *name_end; |
7237 char_u *p; | 7128 char_u *p; |
7238 char_u *linep; | 7129 char_u *linep; |
7239 char_u *key_start; | 7130 char_u *key_start; |
8141 need_highlight_changed = TRUE; | 8032 need_highlight_changed = TRUE; |
8142 } | 8033 } |
8143 | 8034 |
8144 #if defined(EXITFREE) || defined(PROTO) | 8035 #if defined(EXITFREE) || defined(PROTO) |
8145 void | 8036 void |
8146 free_highlight() | 8037 free_highlight(void) |
8147 { | 8038 { |
8148 int i; | 8039 int i; |
8149 | 8040 |
8150 for (i = 0; i < highlight_ga.ga_len; ++i) | 8041 for (i = 0; i < highlight_ga.ga_len; ++i) |
8151 { | 8042 { |
8160 /* | 8051 /* |
8161 * Reset the cterm colors to what they were before Vim was started, if | 8052 * Reset the cterm colors to what they were before Vim was started, if |
8162 * possible. Otherwise reset them to zero. | 8053 * possible. Otherwise reset them to zero. |
8163 */ | 8054 */ |
8164 void | 8055 void |
8165 restore_cterm_colors() | 8056 restore_cterm_colors(void) |
8166 { | 8057 { |
8167 #if defined(MSDOS) || (defined(WIN3264) && !defined(FEAT_GUI_W32)) | 8058 #if defined(MSDOS) || (defined(WIN3264) && !defined(FEAT_GUI_W32)) |
8168 /* Since t_me has been set, this probably means that the user | 8059 /* Since t_me has been set, this probably means that the user |
8169 * wants to use this as default colors. Need to reset default | 8060 * wants to use this as default colors. Need to reset default |
8170 * background/foreground colors. */ | 8061 * background/foreground colors. */ |
8179 /* | 8070 /* |
8180 * Return TRUE if highlight group "idx" has any settings. | 8071 * Return TRUE if highlight group "idx" has any settings. |
8181 * When "check_link" is TRUE also check for an existing link. | 8072 * When "check_link" is TRUE also check for an existing link. |
8182 */ | 8073 */ |
8183 static int | 8074 static int |
8184 hl_has_settings(idx, check_link) | 8075 hl_has_settings(int idx, int check_link) |
8185 int idx; | |
8186 int check_link; | |
8187 { | 8076 { |
8188 return ( HL_TABLE()[idx].sg_term_attr != 0 | 8077 return ( HL_TABLE()[idx].sg_term_attr != 0 |
8189 || HL_TABLE()[idx].sg_cterm_attr != 0 | 8078 || HL_TABLE()[idx].sg_cterm_attr != 0 |
8190 || HL_TABLE()[idx].sg_cterm_fg != 0 | 8079 || HL_TABLE()[idx].sg_cterm_fg != 0 |
8191 || HL_TABLE()[idx].sg_cterm_bg != 0 | 8080 || HL_TABLE()[idx].sg_cterm_bg != 0 |
8201 | 8090 |
8202 /* | 8091 /* |
8203 * Clear highlighting for one group. | 8092 * Clear highlighting for one group. |
8204 */ | 8093 */ |
8205 static void | 8094 static void |
8206 highlight_clear(idx) | 8095 highlight_clear(int idx) |
8207 int idx; | |
8208 { | 8096 { |
8209 HL_TABLE()[idx].sg_term = 0; | 8097 HL_TABLE()[idx].sg_term = 0; |
8210 vim_free(HL_TABLE()[idx].sg_start); | 8098 vim_free(HL_TABLE()[idx].sg_start); |
8211 HL_TABLE()[idx].sg_start = NULL; | 8099 HL_TABLE()[idx].sg_start = NULL; |
8212 vim_free(HL_TABLE()[idx].sg_stop); | 8100 vim_free(HL_TABLE()[idx].sg_stop); |
8253 * Set the normal foreground and background colors according to the "Normal" | 8141 * Set the normal foreground and background colors according to the "Normal" |
8254 * highlighting group. For X11 also set "Menu", "Scrollbar", and | 8142 * highlighting group. For X11 also set "Menu", "Scrollbar", and |
8255 * "Tooltip" colors. | 8143 * "Tooltip" colors. |
8256 */ | 8144 */ |
8257 void | 8145 void |
8258 set_normal_colors() | 8146 set_normal_colors(void) |
8259 { | 8147 { |
8260 if (set_group_colors((char_u *)"Normal", | 8148 if (set_group_colors((char_u *)"Normal", |
8261 &gui.norm_pixel, &gui.back_pixel, | 8149 &gui.norm_pixel, &gui.back_pixel, |
8262 FALSE, TRUE, FALSE)) | 8150 FALSE, TRUE, FALSE)) |
8263 { | 8151 { |
8297 | 8185 |
8298 /* | 8186 /* |
8299 * Set the colors for "Normal", "Menu", "Tooltip" or "Scrollbar". | 8187 * Set the colors for "Normal", "Menu", "Tooltip" or "Scrollbar". |
8300 */ | 8188 */ |
8301 static int | 8189 static int |
8302 set_group_colors(name, fgp, bgp, do_menu, use_norm, do_tooltip) | 8190 set_group_colors( |
8303 char_u *name; | 8191 char_u *name, |
8304 guicolor_T *fgp; | 8192 guicolor_T *fgp, |
8305 guicolor_T *bgp; | 8193 guicolor_T *bgp, |
8306 int do_menu; | 8194 int do_menu, |
8307 int use_norm; | 8195 int use_norm, |
8308 int do_tooltip; | 8196 int do_tooltip) |
8309 { | 8197 { |
8310 int idx; | 8198 int idx; |
8311 | 8199 |
8312 idx = syn_name2id(name) - 1; | 8200 idx = syn_name2id(name) - 1; |
8313 if (idx >= 0) | 8201 if (idx >= 0) |
8330 /* | 8218 /* |
8331 * Get the font of the "Normal" group. | 8219 * Get the font of the "Normal" group. |
8332 * Returns "" when it's not found or not set. | 8220 * Returns "" when it's not found or not set. |
8333 */ | 8221 */ |
8334 char_u * | 8222 char_u * |
8335 hl_get_font_name() | 8223 hl_get_font_name(void) |
8336 { | 8224 { |
8337 int id; | 8225 int id; |
8338 char_u *s; | 8226 char_u *s; |
8339 | 8227 |
8340 id = syn_name2id((char_u *)"Normal"); | 8228 id = syn_name2id((char_u *)"Normal"); |
8350 /* | 8238 /* |
8351 * Set font for "Normal" group. Called by gui_mch_init_font() when a font has | 8239 * Set font for "Normal" group. Called by gui_mch_init_font() when a font has |
8352 * actually chosen to be used. | 8240 * actually chosen to be used. |
8353 */ | 8241 */ |
8354 void | 8242 void |
8355 hl_set_font_name(font_name) | 8243 hl_set_font_name(char_u *font_name) |
8356 char_u *font_name; | |
8357 { | 8244 { |
8358 int id; | 8245 int id; |
8359 | 8246 |
8360 id = syn_name2id((char_u *)"Normal"); | 8247 id = syn_name2id((char_u *)"Normal"); |
8361 if (id > 0) | 8248 if (id > 0) |
8368 /* | 8255 /* |
8369 * Set background color for "Normal" group. Called by gui_set_bg_color() | 8256 * Set background color for "Normal" group. Called by gui_set_bg_color() |
8370 * when the color is known. | 8257 * when the color is known. |
8371 */ | 8258 */ |
8372 void | 8259 void |
8373 hl_set_bg_color_name(name) | 8260 hl_set_bg_color_name( |
8374 char_u *name; /* must have been allocated */ | 8261 char_u *name) /* must have been allocated */ |
8375 { | 8262 { |
8376 int id; | 8263 int id; |
8377 | 8264 |
8378 if (name != NULL) | 8265 if (name != NULL) |
8379 { | 8266 { |
8389 /* | 8276 /* |
8390 * Set foreground color for "Normal" group. Called by gui_set_fg_color() | 8277 * Set foreground color for "Normal" group. Called by gui_set_fg_color() |
8391 * when the color is known. | 8278 * when the color is known. |
8392 */ | 8279 */ |
8393 void | 8280 void |
8394 hl_set_fg_color_name(name) | 8281 hl_set_fg_color_name( |
8395 char_u *name; /* must have been allocated */ | 8282 char_u *name) /* must have been allocated */ |
8396 { | 8283 { |
8397 int id; | 8284 int id; |
8398 | 8285 |
8399 if (name != NULL) | 8286 if (name != NULL) |
8400 { | 8287 { |
8410 /* | 8297 /* |
8411 * Return the handle for a color name. | 8298 * Return the handle for a color name. |
8412 * Returns INVALCOLOR when failed. | 8299 * Returns INVALCOLOR when failed. |
8413 */ | 8300 */ |
8414 static guicolor_T | 8301 static guicolor_T |
8415 color_name2handle(name) | 8302 color_name2handle(char_u *name) |
8416 char_u *name; | |
8417 { | 8303 { |
8418 if (STRCMP(name, "NONE") == 0) | 8304 if (STRCMP(name, "NONE") == 0) |
8419 return INVALCOLOR; | 8305 return INVALCOLOR; |
8420 | 8306 |
8421 if (STRICMP(name, "fg") == 0 || STRICMP(name, "foreground") == 0) | 8307 if (STRICMP(name, "fg") == 0 || STRICMP(name, "foreground") == 0) |
8429 /* | 8315 /* |
8430 * Return the handle for a font name. | 8316 * Return the handle for a font name. |
8431 * Returns NOFONT when failed. | 8317 * Returns NOFONT when failed. |
8432 */ | 8318 */ |
8433 static GuiFont | 8319 static GuiFont |
8434 font_name2handle(name) | 8320 font_name2handle(char_u *name) |
8435 char_u *name; | |
8436 { | 8321 { |
8437 if (STRCMP(name, "NONE") == 0) | 8322 if (STRCMP(name, "NONE") == 0) |
8438 return NOFONT; | 8323 return NOFONT; |
8439 | 8324 |
8440 return gui_mch_get_font(name, TRUE); | 8325 return gui_mch_get_font(name, TRUE); |
8444 /* | 8329 /* |
8445 * Return the handle for a fontset name. | 8330 * Return the handle for a fontset name. |
8446 * Returns NOFONTSET when failed. | 8331 * Returns NOFONTSET when failed. |
8447 */ | 8332 */ |
8448 static GuiFontset | 8333 static GuiFontset |
8449 fontset_name2handle(name, fixed_width) | 8334 fontset_name2handle(char_u *name, int fixed_width) |
8450 char_u *name; | |
8451 int fixed_width; | |
8452 { | 8335 { |
8453 if (STRCMP(name, "NONE") == 0) | 8336 if (STRCMP(name, "NONE") == 0) |
8454 return NOFONTSET; | 8337 return NOFONTSET; |
8455 | 8338 |
8456 return gui_mch_get_fontset(name, TRUE, fixed_width); | 8339 return gui_mch_get_fontset(name, TRUE, fixed_width); |
8459 | 8342 |
8460 /* | 8343 /* |
8461 * Get the font or fontset for one highlight group. | 8344 * Get the font or fontset for one highlight group. |
8462 */ | 8345 */ |
8463 static void | 8346 static void |
8464 hl_do_font(idx, arg, do_normal, do_menu, do_tooltip, free_font) | 8347 hl_do_font( |
8465 int idx; | 8348 int idx, |
8466 char_u *arg; | 8349 char_u *arg, |
8467 int do_normal; /* set normal font */ | 8350 int do_normal, /* set normal font */ |
8468 int do_menu UNUSED; /* set menu font */ | 8351 int do_menu UNUSED, /* set menu font */ |
8469 int do_tooltip UNUSED; /* set tooltip font */ | 8352 int do_tooltip UNUSED, /* set tooltip font */ |
8470 int free_font; /* free current font/fontset */ | 8353 int free_font) /* free current font/fontset */ |
8471 { | 8354 { |
8472 # ifdef FEAT_XFONTSET | 8355 # ifdef FEAT_XFONTSET |
8473 /* If 'guifontset' is not empty, first try using the name as a | 8356 /* If 'guifontset' is not empty, first try using the name as a |
8474 * fontset. If that doesn't work, use it as a font name. */ | 8357 * fontset. If that doesn't work, use it as a font name. */ |
8475 if (*p_guifontset != NUL | 8358 if (*p_guifontset != NUL |
8576 * Add a new entry to the term_attr_table, cterm_attr_table or gui_attr_table | 8459 * Add a new entry to the term_attr_table, cterm_attr_table or gui_attr_table |
8577 * if the combination is new. | 8460 * if the combination is new. |
8578 * Return 0 for error (no more room). | 8461 * Return 0 for error (no more room). |
8579 */ | 8462 */ |
8580 static int | 8463 static int |
8581 get_attr_entry(table, aep) | 8464 get_attr_entry(garray_T *table, attrentry_T *aep) |
8582 garray_T *table; | |
8583 attrentry_T *aep; | |
8584 { | 8465 { |
8585 int i; | 8466 int i; |
8586 attrentry_T *taep; | 8467 attrentry_T *taep; |
8587 static int recursive = FALSE; | 8468 static int recursive = FALSE; |
8588 | 8469 |
8702 | 8583 |
8703 /* | 8584 /* |
8704 * Clear all highlight tables. | 8585 * Clear all highlight tables. |
8705 */ | 8586 */ |
8706 void | 8587 void |
8707 clear_hl_tables() | 8588 clear_hl_tables(void) |
8708 { | 8589 { |
8709 int i; | 8590 int i; |
8710 attrentry_T *taep; | 8591 attrentry_T *taep; |
8711 | 8592 |
8712 #ifdef FEAT_GUI | 8593 #ifdef FEAT_GUI |
8731 * Since we expect there to be few spelling mistakes we don't cache the | 8612 * Since we expect there to be few spelling mistakes we don't cache the |
8732 * result. | 8613 * result. |
8733 * Return the resulting attributes. | 8614 * Return the resulting attributes. |
8734 */ | 8615 */ |
8735 int | 8616 int |
8736 hl_combine_attr(char_attr, prim_attr) | 8617 hl_combine_attr(int char_attr, int prim_attr) |
8737 int char_attr; | |
8738 int prim_attr; | |
8739 { | 8618 { |
8740 attrentry_T *char_aep = NULL; | 8619 attrentry_T *char_aep = NULL; |
8741 attrentry_T *spell_aep; | 8620 attrentry_T *spell_aep; |
8742 attrentry_T new_en; | 8621 attrentry_T new_en; |
8743 | 8622 |
8849 #endif | 8728 #endif |
8850 | 8729 |
8851 #ifdef FEAT_GUI | 8730 #ifdef FEAT_GUI |
8852 | 8731 |
8853 attrentry_T * | 8732 attrentry_T * |
8854 syn_gui_attr2entry(attr) | 8733 syn_gui_attr2entry(int attr) |
8855 int attr; | |
8856 { | 8734 { |
8857 attr -= ATTR_OFF; | 8735 attr -= ATTR_OFF; |
8858 if (attr >= gui_attr_table.ga_len) /* did ":syntax clear" */ | 8736 if (attr >= gui_attr_table.ga_len) /* did ":syntax clear" */ |
8859 return NULL; | 8737 return NULL; |
8860 return &(GUI_ATTR_ENTRY(attr)); | 8738 return &(GUI_ATTR_ENTRY(attr)); |
8864 /* | 8742 /* |
8865 * Get the highlight attributes (HL_BOLD etc.) from an attribute nr. | 8743 * Get the highlight attributes (HL_BOLD etc.) from an attribute nr. |
8866 * Only to be used when "attr" > HL_ALL. | 8744 * Only to be used when "attr" > HL_ALL. |
8867 */ | 8745 */ |
8868 int | 8746 int |
8869 syn_attr2attr(attr) | 8747 syn_attr2attr(int attr) |
8870 int attr; | |
8871 { | 8748 { |
8872 attrentry_T *aep; | 8749 attrentry_T *aep; |
8873 | 8750 |
8874 #ifdef FEAT_GUI | 8751 #ifdef FEAT_GUI |
8875 if (gui.in_use) | 8752 if (gui.in_use) |
8886 return aep->ae_attr; | 8763 return aep->ae_attr; |
8887 } | 8764 } |
8888 | 8765 |
8889 | 8766 |
8890 attrentry_T * | 8767 attrentry_T * |
8891 syn_term_attr2entry(attr) | 8768 syn_term_attr2entry(int attr) |
8892 int attr; | |
8893 { | 8769 { |
8894 attr -= ATTR_OFF; | 8770 attr -= ATTR_OFF; |
8895 if (attr >= term_attr_table.ga_len) /* did ":syntax clear" */ | 8771 if (attr >= term_attr_table.ga_len) /* did ":syntax clear" */ |
8896 return NULL; | 8772 return NULL; |
8897 return &(TERM_ATTR_ENTRY(attr)); | 8773 return &(TERM_ATTR_ENTRY(attr)); |
8898 } | 8774 } |
8899 | 8775 |
8900 attrentry_T * | 8776 attrentry_T * |
8901 syn_cterm_attr2entry(attr) | 8777 syn_cterm_attr2entry(int attr) |
8902 int attr; | |
8903 { | 8778 { |
8904 attr -= ATTR_OFF; | 8779 attr -= ATTR_OFF; |
8905 if (attr >= cterm_attr_table.ga_len) /* did ":syntax clear" */ | 8780 if (attr >= cterm_attr_table.ga_len) /* did ":syntax clear" */ |
8906 return NULL; | 8781 return NULL; |
8907 return &(CTERM_ATTR_ENTRY(attr)); | 8782 return &(CTERM_ATTR_ENTRY(attr)); |
8910 #define LIST_ATTR 1 | 8785 #define LIST_ATTR 1 |
8911 #define LIST_STRING 2 | 8786 #define LIST_STRING 2 |
8912 #define LIST_INT 3 | 8787 #define LIST_INT 3 |
8913 | 8788 |
8914 static void | 8789 static void |
8915 highlight_list_one(id) | 8790 highlight_list_one(int id) |
8916 int id; | |
8917 { | 8791 { |
8918 struct hl_group *sgp; | 8792 struct hl_group *sgp; |
8919 int didh = FALSE; | 8793 int didh = FALSE; |
8920 | 8794 |
8921 sgp = &HL_TABLE()[id - 1]; /* index is ID minus one */ | 8795 sgp = &HL_TABLE()[id - 1]; /* index is ID minus one */ |
8965 last_set_msg(sgp->sg_scriptID); | 8839 last_set_msg(sgp->sg_scriptID); |
8966 #endif | 8840 #endif |
8967 } | 8841 } |
8968 | 8842 |
8969 static int | 8843 static int |
8970 highlight_list_arg(id, didh, type, iarg, sarg, name) | 8844 highlight_list_arg( |
8971 int id; | 8845 int id, |
8972 int didh; | 8846 int didh, |
8973 int type; | 8847 int type, |
8974 int iarg; | 8848 int iarg, |
8975 char_u *sarg; | 8849 char_u *sarg, |
8976 char *name; | 8850 char *name) |
8977 { | 8851 { |
8978 char_u buf[100]; | 8852 char_u buf[100]; |
8979 char_u *ts; | 8853 char_u *ts; |
8980 int i; | 8854 int i; |
8981 | 8855 |
9023 /* | 8897 /* |
9024 * Return "1" if highlight group "id" has attribute "flag". | 8898 * Return "1" if highlight group "id" has attribute "flag". |
9025 * Return NULL otherwise. | 8899 * Return NULL otherwise. |
9026 */ | 8900 */ |
9027 char_u * | 8901 char_u * |
9028 highlight_has_attr(id, flag, modec) | 8902 highlight_has_attr( |
9029 int id; | 8903 int id, |
9030 int flag; | 8904 int flag, |
9031 int modec; /* 'g' for GUI, 'c' for cterm, 't' for term */ | 8905 int modec) /* 'g' for GUI, 'c' for cterm, 't' for term */ |
9032 { | 8906 { |
9033 int attr; | 8907 int attr; |
9034 | 8908 |
9035 if (id <= 0 || id > highlight_ga.ga_len) | 8909 if (id <= 0 || id > highlight_ga.ga_len) |
9036 return NULL; | 8910 return NULL; |
9054 #if (defined(FEAT_SYN_HL) && defined(FEAT_EVAL)) || defined(PROTO) | 8928 #if (defined(FEAT_SYN_HL) && defined(FEAT_EVAL)) || defined(PROTO) |
9055 /* | 8929 /* |
9056 * Return color name of highlight group "id". | 8930 * Return color name of highlight group "id". |
9057 */ | 8931 */ |
9058 char_u * | 8932 char_u * |
9059 highlight_color(id, what, modec) | 8933 highlight_color( |
9060 int id; | 8934 int id, |
9061 char_u *what; /* "font", "fg", "bg", "sp", "fg#", "bg#" or "sp#" */ | 8935 char_u *what, /* "font", "fg", "bg", "sp", "fg#", "bg#" or "sp#" */ |
9062 int modec; /* 'g' for GUI, 'c' for cterm, 't' for term */ | 8936 int modec) /* 'g' for GUI, 'c' for cterm, 't' for term */ |
9063 { | 8937 { |
9064 static char_u name[20]; | 8938 static char_u name[20]; |
9065 int n; | 8939 int n; |
9066 int fg = FALSE; | 8940 int fg = FALSE; |
9067 int sp = FALSE; | 8941 int sp = FALSE; |
9135 || defined(PROTO) | 9009 || defined(PROTO) |
9136 /* | 9010 /* |
9137 * Return color name of highlight group "id" as RGB value. | 9011 * Return color name of highlight group "id" as RGB value. |
9138 */ | 9012 */ |
9139 long_u | 9013 long_u |
9140 highlight_gui_color_rgb(id, fg) | 9014 highlight_gui_color_rgb( |
9141 int id; | 9015 int id, |
9142 int fg; /* TRUE = fg, FALSE = bg */ | 9016 int fg) /* TRUE = fg, FALSE = bg */ |
9143 { | 9017 { |
9144 guicolor_T color; | 9018 guicolor_T color; |
9145 | 9019 |
9146 if (id <= 0 || id > highlight_ga.ga_len) | 9020 if (id <= 0 || id > highlight_ga.ga_len) |
9147 return 0L; | 9021 return 0L; |
9161 /* | 9035 /* |
9162 * Output the syntax list header. | 9036 * Output the syntax list header. |
9163 * Return TRUE when started a new line. | 9037 * Return TRUE when started a new line. |
9164 */ | 9038 */ |
9165 static int | 9039 static int |
9166 syn_list_header(did_header, outlen, id) | 9040 syn_list_header( |
9167 int did_header; /* did header already */ | 9041 int did_header, /* did header already */ |
9168 int outlen; /* length of string that comes */ | 9042 int outlen, /* length of string that comes */ |
9169 int id; /* highlight group id */ | 9043 int id) /* highlight group id */ |
9170 { | 9044 { |
9171 int endcol = 19; | 9045 int endcol = 19; |
9172 int newline = TRUE; | 9046 int newline = TRUE; |
9173 | 9047 |
9174 if (!did_header) | 9048 if (!did_header) |
9211 /* | 9085 /* |
9212 * Set the attribute numbers for a highlight group. | 9086 * Set the attribute numbers for a highlight group. |
9213 * Called after one of the attributes has changed. | 9087 * Called after one of the attributes has changed. |
9214 */ | 9088 */ |
9215 static void | 9089 static void |
9216 set_hl_attr(idx) | 9090 set_hl_attr( |
9217 int idx; /* index in array */ | 9091 int idx) /* index in array */ |
9218 { | 9092 { |
9219 attrentry_T at_en; | 9093 attrentry_T at_en; |
9220 struct hl_group *sgp = HL_TABLE() + idx; | 9094 struct hl_group *sgp = HL_TABLE() + idx; |
9221 | 9095 |
9222 /* The "Normal" group doesn't need an attribute number */ | 9096 /* The "Normal" group doesn't need an attribute number */ |
9284 /* | 9158 /* |
9285 * Lookup a highlight group name and return it's ID. | 9159 * Lookup a highlight group name and return it's ID. |
9286 * If it is not found, 0 is returned. | 9160 * If it is not found, 0 is returned. |
9287 */ | 9161 */ |
9288 int | 9162 int |
9289 syn_name2id(name) | 9163 syn_name2id(char_u *name) |
9290 char_u *name; | |
9291 { | 9164 { |
9292 int i; | 9165 int i; |
9293 char_u name_u[200]; | 9166 char_u name_u[200]; |
9294 | 9167 |
9295 /* Avoid using stricmp() too much, it's slow on some systems */ | 9168 /* Avoid using stricmp() too much, it's slow on some systems */ |
9307 #if defined(FEAT_EVAL) || defined(PROTO) | 9180 #if defined(FEAT_EVAL) || defined(PROTO) |
9308 /* | 9181 /* |
9309 * Return TRUE if highlight group "name" exists. | 9182 * Return TRUE if highlight group "name" exists. |
9310 */ | 9183 */ |
9311 int | 9184 int |
9312 highlight_exists(name) | 9185 highlight_exists(char_u *name) |
9313 char_u *name; | |
9314 { | 9186 { |
9315 return (syn_name2id(name) > 0); | 9187 return (syn_name2id(name) > 0); |
9316 } | 9188 } |
9317 | 9189 |
9318 # if defined(FEAT_SEARCH_EXTRA) || defined(PROTO) | 9190 # if defined(FEAT_SEARCH_EXTRA) || defined(PROTO) |
9319 /* | 9191 /* |
9320 * Return the name of highlight group "id". | 9192 * Return the name of highlight group "id". |
9321 * When not a valid ID return an empty string. | 9193 * When not a valid ID return an empty string. |
9322 */ | 9194 */ |
9323 char_u * | 9195 char_u * |
9324 syn_id2name(id) | 9196 syn_id2name(int id) |
9325 int id; | |
9326 { | 9197 { |
9327 if (id <= 0 || id > highlight_ga.ga_len) | 9198 if (id <= 0 || id > highlight_ga.ga_len) |
9328 return (char_u *)""; | 9199 return (char_u *)""; |
9329 return HL_TABLE()[id - 1].sg_name; | 9200 return HL_TABLE()[id - 1].sg_name; |
9330 } | 9201 } |
9333 | 9204 |
9334 /* | 9205 /* |
9335 * Like syn_name2id(), but take a pointer + length argument. | 9206 * Like syn_name2id(), but take a pointer + length argument. |
9336 */ | 9207 */ |
9337 int | 9208 int |
9338 syn_namen2id(linep, len) | 9209 syn_namen2id(char_u *linep, int len) |
9339 char_u *linep; | |
9340 int len; | |
9341 { | 9210 { |
9342 char_u *name; | 9211 char_u *name; |
9343 int id = 0; | 9212 int id = 0; |
9344 | 9213 |
9345 name = vim_strnsave(linep, len); | 9214 name = vim_strnsave(linep, len); |
9356 * The argument is a pointer to the name and the length of the name. | 9225 * The argument is a pointer to the name and the length of the name. |
9357 * If it doesn't exist yet, a new entry is created. | 9226 * If it doesn't exist yet, a new entry is created. |
9358 * Return 0 for failure. | 9227 * Return 0 for failure. |
9359 */ | 9228 */ |
9360 int | 9229 int |
9361 syn_check_group(pp, len) | 9230 syn_check_group(char_u *pp, int len) |
9362 char_u *pp; | |
9363 int len; | |
9364 { | 9231 { |
9365 int id; | 9232 int id; |
9366 char_u *name; | 9233 char_u *name; |
9367 | 9234 |
9368 name = vim_strnsave(pp, len); | 9235 name = vim_strnsave(pp, len); |
9381 * Add new highlight group and return it's ID. | 9248 * Add new highlight group and return it's ID. |
9382 * "name" must be an allocated string, it will be consumed. | 9249 * "name" must be an allocated string, it will be consumed. |
9383 * Return 0 for failure. | 9250 * Return 0 for failure. |
9384 */ | 9251 */ |
9385 static int | 9252 static int |
9386 syn_add_group(name) | 9253 syn_add_group(char_u *name) |
9387 char_u *name; | |
9388 { | 9254 { |
9389 char_u *p; | 9255 char_u *p; |
9390 | 9256 |
9391 /* Check that the name is ASCII letters, digits and underscore. */ | 9257 /* Check that the name is ASCII letters, digits and underscore. */ |
9392 for (p = name; *p != NUL; ++p) | 9258 for (p = name; *p != NUL; ++p) |
9448 /* | 9314 /* |
9449 * When, just after calling syn_add_group(), an error is discovered, this | 9315 * When, just after calling syn_add_group(), an error is discovered, this |
9450 * function deletes the new name. | 9316 * function deletes the new name. |
9451 */ | 9317 */ |
9452 static void | 9318 static void |
9453 syn_unadd_group() | 9319 syn_unadd_group(void) |
9454 { | 9320 { |
9455 --highlight_ga.ga_len; | 9321 --highlight_ga.ga_len; |
9456 vim_free(HL_TABLE()[highlight_ga.ga_len].sg_name); | 9322 vim_free(HL_TABLE()[highlight_ga.ga_len].sg_name); |
9457 vim_free(HL_TABLE()[highlight_ga.ga_len].sg_name_u); | 9323 vim_free(HL_TABLE()[highlight_ga.ga_len].sg_name_u); |
9458 } | 9324 } |
9459 | 9325 |
9460 /* | 9326 /* |
9461 * Translate a group ID to highlight attributes. | 9327 * Translate a group ID to highlight attributes. |
9462 */ | 9328 */ |
9463 int | 9329 int |
9464 syn_id2attr(hl_id) | 9330 syn_id2attr(int hl_id) |
9465 int hl_id; | |
9466 { | 9331 { |
9467 int attr; | 9332 int attr; |
9468 struct hl_group *sgp; | 9333 struct hl_group *sgp; |
9469 | 9334 |
9470 hl_id = syn_get_final_id(hl_id); | 9335 hl_id = syn_get_final_id(hl_id); |
9490 /* | 9355 /* |
9491 * Get the GUI colors and attributes for a group ID. | 9356 * Get the GUI colors and attributes for a group ID. |
9492 * NOTE: the colors will be INVALCOLOR when not set, the color otherwise. | 9357 * NOTE: the colors will be INVALCOLOR when not set, the color otherwise. |
9493 */ | 9358 */ |
9494 int | 9359 int |
9495 syn_id2colors(hl_id, fgp, bgp) | 9360 syn_id2colors(int hl_id, guicolor_T *fgp, guicolor_T *bgp) |
9496 int hl_id; | |
9497 guicolor_T *fgp; | |
9498 guicolor_T *bgp; | |
9499 { | 9361 { |
9500 struct hl_group *sgp; | 9362 struct hl_group *sgp; |
9501 | 9363 |
9502 hl_id = syn_get_final_id(hl_id); | 9364 hl_id = syn_get_final_id(hl_id); |
9503 sgp = &HL_TABLE()[hl_id - 1]; /* index is ID minus one */ | 9365 sgp = &HL_TABLE()[hl_id - 1]; /* index is ID minus one */ |
9510 | 9372 |
9511 /* | 9373 /* |
9512 * Translate a group ID to the final group ID (following links). | 9374 * Translate a group ID to the final group ID (following links). |
9513 */ | 9375 */ |
9514 int | 9376 int |
9515 syn_get_final_id(hl_id) | 9377 syn_get_final_id(int hl_id) |
9516 int hl_id; | |
9517 { | 9378 { |
9518 int count; | 9379 int count; |
9519 struct hl_group *sgp; | 9380 struct hl_group *sgp; |
9520 | 9381 |
9521 if (hl_id > highlight_ga.ga_len || hl_id < 1) | 9382 if (hl_id > highlight_ga.ga_len || hl_id < 1) |
9540 /* | 9401 /* |
9541 * Call this function just after the GUI has started. | 9402 * Call this function just after the GUI has started. |
9542 * It finds the font and color handles for the highlighting groups. | 9403 * It finds the font and color handles for the highlighting groups. |
9543 */ | 9404 */ |
9544 void | 9405 void |
9545 highlight_gui_started() | 9406 highlight_gui_started(void) |
9546 { | 9407 { |
9547 int idx; | 9408 int idx; |
9548 | 9409 |
9549 /* First get the colors from the "Normal" and "Menu" group, if set */ | 9410 /* First get the colors from the "Normal" and "Menu" group, if set */ |
9550 set_normal_colors(); | 9411 set_normal_colors(); |
9554 | 9415 |
9555 highlight_changed(); | 9416 highlight_changed(); |
9556 } | 9417 } |
9557 | 9418 |
9558 static void | 9419 static void |
9559 gui_do_one_color(idx, do_menu, do_tooltip) | 9420 gui_do_one_color( |
9560 int idx; | 9421 int idx, |
9561 int do_menu; /* TRUE: might set the menu font */ | 9422 int do_menu, /* TRUE: might set the menu font */ |
9562 int do_tooltip; /* TRUE: might set the tooltip font */ | 9423 int do_tooltip) /* TRUE: might set the tooltip font */ |
9563 { | 9424 { |
9564 int didit = FALSE; | 9425 int didit = FALSE; |
9565 | 9426 |
9566 if (HL_TABLE()[idx].sg_font_name != NULL) | 9427 if (HL_TABLE()[idx].sg_font_name != NULL) |
9567 { | 9428 { |
9600 * Called only when the 'highlight' option has been changed and upon first | 9461 * Called only when the 'highlight' option has been changed and upon first |
9601 * screen redraw after any :highlight command. | 9462 * screen redraw after any :highlight command. |
9602 * Return FAIL when an invalid flag is found in 'highlight'. OK otherwise. | 9463 * Return FAIL when an invalid flag is found in 'highlight'. OK otherwise. |
9603 */ | 9464 */ |
9604 int | 9465 int |
9605 highlight_changed() | 9466 highlight_changed(void) |
9606 { | 9467 { |
9607 int hlf; | 9468 int hlf; |
9608 int i; | 9469 int i; |
9609 char_u *p; | 9470 char_u *p; |
9610 int attr; | 9471 int attr; |
9811 | 9672 |
9812 /* | 9673 /* |
9813 * Handle command line completion for :highlight command. | 9674 * Handle command line completion for :highlight command. |
9814 */ | 9675 */ |
9815 void | 9676 void |
9816 set_context_in_highlight_cmd(xp, arg) | 9677 set_context_in_highlight_cmd(expand_T *xp, char_u *arg) |
9817 expand_T *xp; | |
9818 char_u *arg; | |
9819 { | 9678 { |
9820 char_u *p; | 9679 char_u *p; |
9821 | 9680 |
9822 /* Default: expand group names */ | 9681 /* Default: expand group names */ |
9823 xp->xp_context = EXPAND_HIGHLIGHT; | 9682 xp->xp_context = EXPAND_HIGHLIGHT; |
9863 | 9722 |
9864 /* | 9723 /* |
9865 * List highlighting matches in a nice way. | 9724 * List highlighting matches in a nice way. |
9866 */ | 9725 */ |
9867 static void | 9726 static void |
9868 highlight_list() | 9727 highlight_list(void) |
9869 { | 9728 { |
9870 int i; | 9729 int i; |
9871 | 9730 |
9872 for (i = 10; --i >= 0; ) | 9731 for (i = 10; --i >= 0; ) |
9873 highlight_list_two(i, hl_attr(HLF_D)); | 9732 highlight_list_two(i, hl_attr(HLF_D)); |
9874 for (i = 40; --i >= 0; ) | 9733 for (i = 40; --i >= 0; ) |
9875 highlight_list_two(99, 0); | 9734 highlight_list_two(99, 0); |
9876 } | 9735 } |
9877 | 9736 |
9878 static void | 9737 static void |
9879 highlight_list_two(cnt, attr) | 9738 highlight_list_two(int cnt, int attr) |
9880 int cnt; | |
9881 int attr; | |
9882 { | 9739 { |
9883 msg_puts_attr((char_u *)&("N \bI \b! \b"[cnt / 11]), attr); | 9740 msg_puts_attr((char_u *)&("N \bI \b! \b"[cnt / 11]), attr); |
9884 msg_clr_eos(); | 9741 msg_clr_eos(); |
9885 out_flush(); | 9742 out_flush(); |
9886 ui_delay(cnt == 99 ? 40L : (long)cnt * 50L, FALSE); | 9743 ui_delay(cnt == 99 ? 40L : (long)cnt * 50L, FALSE); |
9893 /* | 9750 /* |
9894 * Function given to ExpandGeneric() to obtain the list of group names. | 9751 * Function given to ExpandGeneric() to obtain the list of group names. |
9895 * Also used for synIDattr() function. | 9752 * Also used for synIDattr() function. |
9896 */ | 9753 */ |
9897 char_u * | 9754 char_u * |
9898 get_highlight_name(xp, idx) | 9755 get_highlight_name(expand_T *xp UNUSED, int idx) |
9899 expand_T *xp UNUSED; | |
9900 int idx; | |
9901 { | 9756 { |
9902 #ifdef FEAT_CMDL_COMPL | 9757 #ifdef FEAT_CMDL_COMPL |
9903 if (idx == highlight_ga.ga_len && include_none != 0) | 9758 if (idx == highlight_ga.ga_len && include_none != 0) |
9904 return (char_u *)"none"; | 9759 return (char_u *)"none"; |
9905 if (idx == highlight_ga.ga_len + include_none && include_default != 0) | 9760 if (idx == highlight_ga.ga_len + include_none && include_default != 0) |
9921 /* | 9776 /* |
9922 * Free all the highlight group fonts. | 9777 * Free all the highlight group fonts. |
9923 * Used when quitting for systems which need it. | 9778 * Used when quitting for systems which need it. |
9924 */ | 9779 */ |
9925 void | 9780 void |
9926 free_highlight_fonts() | 9781 free_highlight_fonts(void) |
9927 { | 9782 { |
9928 int idx; | 9783 int idx; |
9929 | 9784 |
9930 for (idx = 0; idx < highlight_ga.ga_len; ++idx) | 9785 for (idx = 0; idx < highlight_ga.ga_len; ++idx) |
9931 { | 9786 { |