annotate runtime/syntax/ptcap.vim @ 4444:ccecb03e5e8b v7.3.970

updated for version 7.3.970 Problem: Syntax highlighting can be slow. Solution: Include the NFA regexp engine. Add the 'regexpengine' option to select which one is used. (various authors, including Ken Takata, Andrei Aiordachioaie, Russ Cox, Xiaozhou Liua, Ian Young)
author Bram Moolenaar <bram@vim.org>
date Sun, 19 May 2013 19:40:29 +0200
parents 3fc0f57ecb91
children 43efa4f5a8ea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 " Vim syntax file
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 " Language: printcap/termcap database
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 " Maintainer: Haakon Riiser <hakonrk@fys.uio.no>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 " URL: http://folk.uio.no/hakonrk/vim/syntax/ptcap.vim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 " Last Change: 2001 May 15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 " For version 5.x: Clear all syntax items
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 " For version 6.x: Quit when a syntax file was already loaded
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 if version < 600
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 syn clear
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 elseif exists("b:current_syntax")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 " Since I only highlight based on the structure of the databases, not
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 " specific keywords, case sensitivity isn't required
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 syn case ignore
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 " Since everything that is not caught by the syntax patterns is assumed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 " to be an error, we start parsing 20 lines up, unless something else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 " is specified
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 if exists("ptcap_minlines")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 exe "syn sync lines=".ptcap_minlines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 syn sync lines=20
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 " Highlight everything that isn't caught by the rules as errors,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 " except blank lines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 syn match ptcapError "^.*\S.*$"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 syn match ptcapLeadBlank "^\s\+" contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 " `:' and `|' are delimiters for fields and names, and should not be
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 " highlighted. Hence, they are linked to `NONE'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 syn match ptcapDelimiter "[:|]" contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 " Escaped characters receive special highlighting
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 syn match ptcapEscapedChar "\\." contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 syn match ptcapEscapedChar "\^." contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 syn match ptcapEscapedChar "\\\o\{3}" contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 " A backslash at the end of a line will suppress the newline
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 syn match ptcapLineCont "\\$" contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 " A number follows the same rules as an integer in C
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 syn match ptcapNumber "#\(+\|-\)\=\d\+"lc=1 contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 syn match ptcapNumberError "#\d*[^[:digit:]:\\]"lc=1 contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 syn match ptcapNumber "#0x\x\{1,8}"lc=1 contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 syn match ptcapNumberError "#0x\X"me=e-1,lc=1 contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 syn match ptcapNumberError "#0x\x\{9}"lc=1 contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 syn match ptcapNumberError "#0x\x*[^[:xdigit:]:\\]"lc=1 contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 " The `@' operator clears a flag (i.e., sets it to zero)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 " The `#' operator assigns a following number to the flag
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 " The `=' operator assigns a string to the preceding flag
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 syn match ptcapOperator "[@#=]" contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 " Some terminal capabilites have special names like `#5' and `@1', and we
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 " need special rules to match these properly
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 syn match ptcapSpecialCap "\W[#@]\d" contains=ptcapDelimiter contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 " If editing a termcap file, an entry in the database is terminated by
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 " a (non-escaped) newline. Otherwise, it is terminated by a line which
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 " does not start with a colon (:)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 if exists("b:ptcap_type") && b:ptcap_type[0] == 't'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 syn region ptcapEntry start="^\s*[^[:space:]:]" end="[^\\]\(\\\\\)*$" end="^$" contains=ptcapNames,ptcapField,ptcapLeadBlank keepend
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 syn region ptcapEntry start="^\s*[^[:space:]:]"me=e-1 end="^\s*[^[:space:]:#]"me=e-1 contains=ptcapNames,ptcapField,ptcapLeadBlank,ptcapComment
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 syn region ptcapNames start="^\s*[^[:space:]:]" skip="[^\\]\(\\\\\)*\\:" end=":"me=e-1 contains=ptcapDelimiter,ptcapEscapedChar,ptcapLineCont,ptcapLeadBlank,ptcapComment keepend contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 syn region ptcapField start=":" skip="[^\\]\(\\\\\)*\\$" end="[^\\]\(\\\\\)*:"me=e-1 end="$" contains=ptcapDelimiter,ptcapString,ptcapNumber,ptcapNumberError,ptcapOperator,ptcapLineCont,ptcapSpecialCap,ptcapLeadBlank,ptcapComment keepend contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 syn region ptcapString matchgroup=ptcapOperator start="=" skip="[^\\]\(\\\\\)*\\:" matchgroup=ptcapDelimiter end=":"me=e-1 matchgroup=NONE end="[^\\]\(\\\\\)*[^\\]$" end="^$" contains=ptcapEscapedChar,ptcapLineCont keepend contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 syn region ptcapComment start="^\s*#" end="$" contains=ptcapLeadBlank
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 if version >= 508 || !exists("did_ptcap_syntax_inits")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 if version < 508
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 let did_ptcap_syntax_inits = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 command -nargs=+ HiLink hi link <args>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 command -nargs=+ HiLink hi def link <args>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 HiLink ptcapComment Comment
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 HiLink ptcapDelimiter Delimiter
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 " The highlighting of "ptcapEntry" should always be overridden by
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 " its contents, so I use Todo highlighting to indicate that there
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 " is work to be done with the syntax file if you can see it :-)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 HiLink ptcapEntry Todo
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 HiLink ptcapError Error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 HiLink ptcapEscapedChar SpecialChar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 HiLink ptcapField Type
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 HiLink ptcapLeadBlank NONE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 HiLink ptcapLineCont Special
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 HiLink ptcapNames Label
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 HiLink ptcapNumber NONE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 HiLink ptcapNumberError Error
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 HiLink ptcapOperator Operator
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 HiLink ptcapSpecialCap Type
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 HiLink ptcapString NONE
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 delcommand HiLink
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 let b:current_syntax = "ptcap"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 " vim: sts=4 sw=4 ts=8