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