codekingpro/portable-devtools
114k
1" Vim syntax file2" Language: printcap/termcap database3" Maintainer: Haakon Riiser <hakonrk@fys.uio.no>4" URL: http://folk.uio.no/hakonrk/vim/syntax/ptcap.vim5" Last Change: 2001 May 156 7" quit when a syntax file was already loaded8if exists("b:current_syntax")9 finish10endif11 12" Since I only highlight based on the structure of the databases, not13" specific keywords, case sensitivity isn't required14syn case ignore15 16" Since everything that is not caught by the syntax patterns is assumed17" to be an error, we start parsing 20 lines up, unless something else18" is specified19if exists("ptcap_minlines")20 exe "syn sync lines=".ptcap_minlines21else22 syn sync lines=2023endif24 25" Highlight everything that isn't caught by the rules as errors,26" except blank lines27syn match ptcapError "^.*\S.*$"28 29syn match ptcapLeadBlank "^\s\+" contained30 31" `:' and `|' are delimiters for fields and names, and should not be32" highlighted. Hence, they are linked to `NONE'33syn match ptcapDelimiter "[:|]" contained34 35" Escaped characters receive special highlighting36syn match ptcapEscapedChar "\\." contained37syn match ptcapEscapedChar "\^." contained38syn match ptcapEscapedChar "\\\o\{3}" contained39 40" A backslash at the end of a line will suppress the newline41syn match ptcapLineCont "\\$" contained42 43" A number follows the same rules as an integer in C44syn match ptcapNumber "#\(+\|-\)\=\d\+"lc=1 contained45syn match ptcapNumberError "#\d*[^[:digit:]:\\]"lc=1 contained46syn match ptcapNumber "#0x\x\{1,8}"lc=1 contained47syn match ptcapNumberError "#0x\X"me=e-1,lc=1 contained48syn match ptcapNumberError "#0x\x\{9}"lc=1 contained49syn match ptcapNumberError "#0x\x*[^[:xdigit:]:\\]"lc=1 contained50 51" The `@' operator clears a flag (i.e., sets it to zero)52" The `#' operator assigns a following number to the flag53" The `=' operator assigns a string to the preceding flag54syn match ptcapOperator "[@#=]" contained55 56" Some terminal capabilities have special names like `#5' and `@1', and we57" need special rules to match these properly58syn match ptcapSpecialCap "\W[#@]\d" contains=ptcapDelimiter contained59 60" If editing a termcap file, an entry in the database is terminated by61" a (non-escaped) newline. Otherwise, it is terminated by a line which62" does not start with a colon (:)63if exists("b:ptcap_type") && b:ptcap_type[0] == 't'64 syn region ptcapEntry start="^\s*[^[:space:]:]" end="[^\\]\(\\\\\)*$" end="^$" contains=ptcapNames,ptcapField,ptcapLeadBlank keepend65else66 syn region ptcapEntry start="^\s*[^[:space:]:]"me=e-1 end="^\s*[^[:space:]:#]"me=e-1 contains=ptcapNames,ptcapField,ptcapLeadBlank,ptcapComment67endif68syn region ptcapNames start="^\s*[^[:space:]:]" skip="[^\\]\(\\\\\)*\\:" end=":"me=e-1 contains=ptcapDelimiter,ptcapEscapedChar,ptcapLineCont,ptcapLeadBlank,ptcapComment keepend contained69syn region ptcapField start=":" skip="[^\\]\(\\\\\)*\\$" end="[^\\]\(\\\\\)*:"me=e-1 end="$" contains=ptcapDelimiter,ptcapString,ptcapNumber,ptcapNumberError,ptcapOperator,ptcapLineCont,ptcapSpecialCap,ptcapLeadBlank,ptcapComment keepend contained70syn region ptcapString matchgroup=ptcapOperator start="=" skip="[^\\]\(\\\\\)*\\:" matchgroup=ptcapDelimiter end=":"me=e-1 matchgroup=NONE end="[^\\]\(\\\\\)*[^\\]$" end="^$" contains=ptcapEscapedChar,ptcapLineCont keepend contained71syn region ptcapComment start="^\s*#" end="$" contains=ptcapLeadBlank72 73 74hi def link ptcapComment Comment75hi def link ptcapDelimiter Delimiter76" The highlighting of "ptcapEntry" should always be overridden by77" its contents, so I use Todo highlighting to indicate that there78" is work to be done with the syntax file if you can see it :-)79hi def link ptcapEntry Todo80hi def link ptcapError Error81hi def link ptcapEscapedChar SpecialChar82hi def link ptcapField Type83hi def link ptcapLeadBlank NONE84hi def link ptcapLineCont Special85hi def link ptcapNames Label86hi def link ptcapNumber NONE87hi def link ptcapNumberError Error88hi def link ptcapOperator Operator89hi def link ptcapSpecialCap Type90hi def link ptcapString NONE91 92 93let b:current_syntax = "ptcap"94 95" vim: sts=4 sw=4 ts=896 