2 " Language: printcap/termcap database
3 " Maintainer: Haakon Riiser <haakon@riiser.net>
4 " Last Change: 2001 Apr 25
6 " For version 5.x: Clear all syntax items
7 " For version 6.x: Quit when a syntax file was already loaded
10 elseif exists("b:current_syntax")
14 " Since I only highlight based on the structure of the databases, not
15 " specific keywords, case sensitivity isn't required
18 " Since everything that is not caught by the syntax patterns is assumed
19 " to be an error, we start parsing 20 lines up, unless something else
21 if exists("ptcap_minlines")
22 exe "syn sync lines=".ptcap_minlines
27 " Highlight everything that isn't caught by the rules as errors,
29 syn match ptcapError "^.*\S.*$"
31 syn match ptcapLeadBlank "^\s\+" contained
33 " `:' and `|' are delimiters for fields and names, and should not be
34 " highlighted. Hence, they are linked to `NONE'
35 syn match ptcapDelimiter "[:|]" contained
37 " Escaped characters receive special highlighting
38 syn match ptcapEscapedChar "\\." contained
39 syn match ptcapEscapedChar "\^." contained
40 syn match ptcapEscapedChar "\\\o\{3}" contained
42 " A backslash at the end of a line will suppress the newline
43 syn match ptcapLineCont "\\$" contained
45 " A number follows the same rules as an integer in C
46 syn match ptcapNumber "#\(+\|-\)\=\d\+"lc=1 contained
47 syn match ptcapNumberError "#\d*[^[:digit:]:\\]"lc=1 contained
48 syn match ptcapNumber "#0x\x\{1,8}"lc=1 contained
49 syn match ptcapNumberError "#0x\X"me=e-1,lc=1 contained
50 syn match ptcapNumberError "#0x\x\{9}"lc=1 contained
51 syn match ptcapNumberError "#0x\x*[^[:xdigit:]:\\]"lc=1 contained
53 " The `@' operator clears a flag (i.e., sets it to zero)
54 " The `#' operator assigns a following number to the flag
55 " The `=' operator assigns a string to the preceding flag
56 syn match ptcapOperator "[@#=]" contained
58 " Some terminal capabilites have special names like `#5' and `@1', and we
59 " need special rules to match these properly
60 syn match ptcapSpecialCap "\W[#@]\d" contains=ptcapDelimiter contained
62 " If editing a termcap file, an entry in the database is terminated by
63 " a (non-escaped) newline. Otherwise, it is terminated by a line which
64 " does not start with a colon (:)
65 if exists("b:ptcap_type") && b:ptcap_type[0] == 't'
66 syn region ptcapEntry start="^\s*[^[:space:]:]" end="[^\\]\(\\\\\)*$" end="^$" contains=ptcapNames,ptcapField,ptcapLeadBlank keepend
68 syn region ptcapEntry start="^\s*[^[:space:]:]"me=e-1 end="^\s*[^[:space:]:#]"me=e-1 contains=ptcapNames,ptcapField,ptcapLeadBlank,ptcapComment
70 syn region ptcapNames start="^\s*[^[:space:]:]" skip="[^\\]\(\\\\\)*\\:" end=":"me=e-1 contains=ptcapDelimiter,ptcapEscapedChar,ptcapLineCont,ptcapLeadBlank,ptcapComment keepend contained
71 syn region ptcapField start=":" skip="[^\\]\(\\\\\)*\\$" end="[^\\]\(\\\\\)*:"me=e-1 end="$" contains=ptcapDelimiter,ptcapString,ptcapNumber,ptcapNumberError,ptcapOperator,ptcapLineCont,ptcapSpecialCap,ptcapLeadBlank,ptcapComment keepend contained
72 syn region ptcapString matchgroup=ptcapOperator start="=" skip="[^\\]\(\\\\\)*\\:" matchgroup=ptcapDelimiter end=":"me=e-1 matchgroup=NONE end="[^\\]\(\\\\\)*[^\\]$" end="^$" contains=ptcapEscapedChar,ptcapLineCont keepend contained
73 syn region ptcapComment start="^\s*#" end="$" contains=ptcapLeadBlank
75 if version >= 508 || !exists("did_ptcap_syntax_inits")
77 let did_ptcap_syntax_inits = 1
78 command -nargs=+ HiLink hi link <args>
80 command -nargs=+ HiLink hi def link <args>
83 HiLink ptcapComment Comment
84 HiLink ptcapDelimiter Delimiter
85 " The highlighting of "ptcapEntry" should always be overridden by
86 " its contents, so I use Todo highlighting to indicate that there
87 " is work to be done with the syntax file if you can see it :-)
88 HiLink ptcapEntry Todo
89 HiLink ptcapError Error
90 HiLink ptcapEscapedChar SpecialChar
91 HiLink ptcapField Type
92 HiLink ptcapLeadBlank NONE
93 HiLink ptcapLineCont Special
94 HiLink ptcapNames Label
95 HiLink ptcapNumber NONE
96 HiLink ptcapNumberError Error
97 HiLink ptcapOperator Operator
98 HiLink ptcapSpecialCap Type
99 HiLink ptcapString NONE
104 let b:current_syntax = "ptcap"
106 " vim: sts=4 sw=4 ts=8