annotate runtime/syntax/xpm.vim @ 6224:0d2c821cdc25 v7.4.447

updated for version 7.4.447 Problem: Spell files from Hunspell may generate a lot of errors. Solution: Add the IGNOREEXTRA flag.
author Bram Moolenaar <bram@vim.org>
date Fri, 19 Sep 2014 16:04:11 +0200
parents 82b5078be2dd
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: X Pixmap
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 " Maintainer: Ronald Schild <rs@scutum.de>
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 7
diff changeset
4 " Last Change: 2008 May 28
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 " Version: 5.4n.1
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 syntax 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 syn keyword xpmType char
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 syn keyword xpmStorageClass static
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 syn keyword xpmTodo TODO FIXME XXX contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 syn region xpmComment start="/\*" end="\*/" contains=xpmTodo
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 syn region xpmPixelString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@xpmColors
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 if has("gui_running")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 let color = ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 let chars = ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 let colors = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 let cpp = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 let n = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 let i = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 while i <= line("$") " scanning all lines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 let s = matchstr(getline(i), '".\{-1,}"')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 if s != "" " does line contain a string?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 if n == 0 " first string is the Values string
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 " get the 3rd value: colors = number of colors
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 let colors = substitute(s, '"\s*\d\+\s\+\d\+\s\+\(\d\+\).*"', '\1', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 " get the 4th value: cpp = number of character per pixel
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 let cpp = substitute(s, '"\s*\d\+\s\+\d\+\s\+\d\+\s\+\(\d\+\).*"', '\1', '')
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 7
diff changeset
41 if cpp =~ '[^0-9]'
82b5078be2dd updated for version 7.2a
vimboss
parents: 7
diff changeset
42 break " if cpp is not made of digits there must be something wrong
82b5078be2dd updated for version 7.2a
vimboss
parents: 7
diff changeset
43 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 7
diff changeset
45 " Highlight the Values string as normal string (no pixel string).
82b5078be2dd updated for version 7.2a
vimboss
parents: 7
diff changeset
46 " Only when there is no slash, it would terminate the pattern.
82b5078be2dd updated for version 7.2a
vimboss
parents: 7
diff changeset
47 if s !~ '/'
82b5078be2dd updated for version 7.2a
vimboss
parents: 7
diff changeset
48 exe 'syn match xpmValues /' . s . '/'
82b5078be2dd updated for version 7.2a
vimboss
parents: 7
diff changeset
49 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 hi link xpmValues String
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 let n = 1 " n = color index
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 elseif n <= colors " string is a color specification
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 " get chars = <cpp> length string representing the pixels
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 " (first incl. the following whitespace)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 let chars = substitute(s, '"\(.\{'.cpp.'}\s\).*"', '\1', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 " now get color, first try 'c' key if any (color visual)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 let color = substitute(s, '".*\sc\s\+\(.\{-}\)\s*\(\(g4\=\|[ms]\)\s.*\)*\s*"', '\1', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 if color == s
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 " no 'c' key, try 'g' key (grayscale with more than 4 levels)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 let color = substitute(s, '".*\sg\s\+\(.\{-}\)\s*\(\(g4\|[ms]\)\s.*\)*\s*"', '\1', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 if color == s
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 " next try: 'g4' key (4-level grayscale)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 let color = substitute(s, '".*\sg4\s\+\(.\{-}\)\s*\([ms]\s.*\)*\s*"', '\1', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 if color == s
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 " finally try 'm' key (mono visual)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 let color = substitute(s, '".*\sm\s\+\(.\{-}\)\s*\(s\s.*\)*\s*"', '\1', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 if color == s
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 let color = ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 " Vim cannot handle RGB codes with more than 6 hex digits
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 if color =~ '#\x\{10,}$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 let color = substitute(color, '\(\x\x\)\x\x', '\1', 'g')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 elseif color =~ '#\x\{7,}$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 let color = substitute(color, '\(\x\x\)\x', '\1', 'g')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 " nor with 3 digits
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 elseif color =~ '#\x\{3}$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 let color = substitute(color, '\(\x\)\(\x\)\(\x\)', '0\10\20\3', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 " escape meta characters in patterns
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 let s = escape(s, '/\*^$.~[]')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 let chars = escape(chars, '/\*^$.~[]')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 " now create syntax items
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 " highlight the color string as normal string (no pixel string)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 exe 'syn match xpmCol'.n.'Def /'.s.'/ contains=xpmCol'.n.'inDef'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 exe 'hi link xpmCol'.n.'Def String'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 " but highlight the first whitespace after chars in its color
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 exe 'syn match xpmCol'.n.'inDef /"'.chars.'/hs=s+'.(cpp+1).' contained'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 exe 'hi link xpmCol'.n.'inDef xpmColor'.n
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 " remove the following whitespace from chars
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 let chars = substitute(chars, '.$', '', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 " and create the syntax item contained in the pixel strings
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 exe 'syn match xpmColor'.n.' /'.chars.'/ contained'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 exe 'syn cluster xpmColors add=xpmColor'.n
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 " if no color or color = "None" show background
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 if color == "" || substitute(color, '.*', '\L&', '') == 'none'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 exe 'hi xpmColor'.n.' guifg=bg'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 exe 'hi xpmColor'.n.' guibg=NONE'
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 7
diff changeset
112 elseif color !~ "'"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 exe 'hi xpmColor'.n." guifg='".color."'"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 exe 'hi xpmColor'.n." guibg='".color."'"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 let n = n + 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 break " no more color string
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 let i = i + 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 unlet color chars colors cpp n i s
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 endif " has("gui_running")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 " Define the default highlighting.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 " For version 5.7 and earlier: only when not done already
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 " For version 5.8 and later: only when an item doesn't have highlighting yet
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131 if version >= 508 || !exists("did_xpm_syntax_inits")
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 if version < 508
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 let did_xpm_syntax_inits = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 command -nargs=+ HiLink hi link <args>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 command -nargs=+ HiLink hi def link <args>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
139 HiLink xpmType Type
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
140 HiLink xpmStorageClass StorageClass
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
141 HiLink xpmTodo Todo
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
142 HiLink xpmComment Comment
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
143 HiLink xpmPixelString String
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
144
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
145 delcommand HiLink
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
146 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
147
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
148 let b:current_syntax = "xpm"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
149
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
150 " vim: ts=8:sw=3:noet: