annotate runtime/syntax/xpm.vim @ 11954:f88fa730ddb3

Added tag v8.0.0856 for changeset fd714bb0ae248376548cd3f81d9cad4f84ca7883
author Christian Brabandt <cb@256bit.org>
date Thu, 03 Aug 2017 21:00:06 +0200
parents c391bfbdb452
children 9c221ad9634a
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>
10895
c391bfbdb452 Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10051
diff changeset
4 " Last Change: 2017 Feb 01
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 " Version: 5.4n.1
10895
c391bfbdb452 Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10051
diff changeset
6 " Jemma Nelson added termguicolors support
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 1621
diff changeset
8 " quit when a syntax file was already loaded
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 1621
diff changeset
9 if exists("b:current_syntax")
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 finish
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 syn keyword xpmType char
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 syn keyword xpmStorageClass static
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 syn keyword xpmTodo TODO FIXME XXX contained
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 syn region xpmComment start="/\*" end="\*/" contains=xpmTodo
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 syn region xpmPixelString start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=@xpmColors
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18
10895
c391bfbdb452 Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10051
diff changeset
19 if has("gui_running") || has("termguicolors") && &termguicolors
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 let color = ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 let chars = ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 let colors = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 let cpp = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 let n = 0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 let i = 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 while i <= line("$") " scanning all lines
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 let s = matchstr(getline(i), '".\{-1,}"')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 if s != "" " does line contain a string?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 if n == 0 " first string is the Values string
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 " get the 3rd value: colors = number of colors
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 let colors = substitute(s, '"\s*\d\+\s\+\d\+\s\+\(\d\+\).*"', '\1', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 " get the 4th value: cpp = number of character per pixel
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 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
39 if cpp =~ '[^0-9]'
82b5078be2dd updated for version 7.2a
vimboss
parents: 7
diff changeset
40 break " if cpp is not made of digits there must be something wrong
82b5078be2dd updated for version 7.2a
vimboss
parents: 7
diff changeset
41 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 7
diff changeset
43 " Highlight the Values string as normal string (no pixel string).
82b5078be2dd updated for version 7.2a
vimboss
parents: 7
diff changeset
44 " Only when there is no slash, it would terminate the pattern.
82b5078be2dd updated for version 7.2a
vimboss
parents: 7
diff changeset
45 if s !~ '/'
82b5078be2dd updated for version 7.2a
vimboss
parents: 7
diff changeset
46 exe 'syn match xpmValues /' . s . '/'
82b5078be2dd updated for version 7.2a
vimboss
parents: 7
diff changeset
47 endif
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 hi link xpmValues String
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 let n = 1 " n = color index
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 elseif n <= colors " string is a color specification
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 " get chars = <cpp> length string representing the pixels
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 " (first incl. the following whitespace)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 let chars = substitute(s, '"\(.\{'.cpp.'}\s\).*"', '\1', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58 " now get color, first try 'c' key if any (color visual)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 let color = substitute(s, '".*\sc\s\+\(.\{-}\)\s*\(\(g4\=\|[ms]\)\s.*\)*\s*"', '\1', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 if color == s
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 " no 'c' key, try 'g' key (grayscale with more than 4 levels)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 let color = substitute(s, '".*\sg\s\+\(.\{-}\)\s*\(\(g4\|[ms]\)\s.*\)*\s*"', '\1', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 if color == s
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 " next try: 'g4' key (4-level grayscale)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 let color = substitute(s, '".*\sg4\s\+\(.\{-}\)\s*\([ms]\s.*\)*\s*"', '\1', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 if color == s
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 " finally try 'm' key (mono visual)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 let color = substitute(s, '".*\sm\s\+\(.\{-}\)\s*\(s\s.*\)*\s*"', '\1', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 if color == s
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 let color = ""
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 endif
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
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 " Vim cannot handle RGB codes with more than 6 hex digits
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 if color =~ '#\x\{10,}$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 let color = substitute(color, '\(\x\x\)\x\x', '\1', 'g')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 elseif color =~ '#\x\{7,}$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 let color = substitute(color, '\(\x\x\)\x', '\1', 'g')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 " nor with 3 digits
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 elseif color =~ '#\x\{3}$'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 let color = substitute(color, '\(\x\)\(\x\)\(\x\)', '0\10\20\3', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 " escape meta characters in patterns
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 let s = escape(s, '/\*^$.~[]')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 let chars = escape(chars, '/\*^$.~[]')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 " now create syntax items
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 " highlight the color string as normal string (no pixel string)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 exe 'syn match xpmCol'.n.'Def /'.s.'/ contains=xpmCol'.n.'inDef'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 exe 'hi link xpmCol'.n.'Def String'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 " but highlight the first whitespace after chars in its color
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 exe 'syn match xpmCol'.n.'inDef /"'.chars.'/hs=s+'.(cpp+1).' contained'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 exe 'hi link xpmCol'.n.'inDef xpmColor'.n
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 " remove the following whitespace from chars
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 let chars = substitute(chars, '.$', '', '')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 " and create the syntax item contained in the pixel strings
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 exe 'syn match xpmColor'.n.' /'.chars.'/ contained'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 exe 'syn cluster xpmColors add=xpmColor'.n
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 " if no color or color = "None" show background
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 if color == "" || substitute(color, '.*', '\L&', '') == 'none'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 exe 'hi xpmColor'.n.' guifg=bg'
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 exe 'hi xpmColor'.n.' guibg=NONE'
1621
82b5078be2dd updated for version 7.2a
vimboss
parents: 7
diff changeset
110 elseif color !~ "'"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 exe 'hi xpmColor'.n." guifg='".color."'"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 exe 'hi xpmColor'.n." guibg='".color."'"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 let n = n + 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 break " no more color string
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 let i = i + 1
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 endwhile
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 unlet color chars colors cpp n i s
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123
10895
c391bfbdb452 Updated runtime files.
Christian Brabandt <cb@256bit.org>
parents: 10051
diff changeset
124 endif " has("gui_running") || has("termguicolors") && &termguicolors
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126 " Define the default highlighting.
10048
43efa4f5a8ea commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents: 1621
diff changeset
127 " Only when an item doesn't have highlighting yet
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128
10051
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
129 hi def link xpmType Type
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
130 hi def link xpmStorageClass StorageClass
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
131 hi def link xpmTodo Todo
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
132 hi def link xpmComment Comment
46763b01cd9a commit https://github.com/vim/vim/commit/f37506f60f87d52a9e8850e30067645e2b13783c
Christian Brabandt <cb@256bit.org>
parents: 10048
diff changeset
133 hi def link xpmPixelString String
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136 let b:current_syntax = "xpm"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
138 " vim: ts=8:sw=3:noet: