3 " Maintainer: Matt Neumann <mattneu@purpleturtle.com>
4 " (previously Allan Kelly <allan@fruitloaf.co.uk>)
5 " Original: Robin Becker <robin@jessikat.demon.co.uk>
6 " Version: 5.1(synched), 1998 June 29
8 " Keywords TODO: format clock click anchor
10 " For version 5.x: Clear all syntax items
11 " For version 6.x: Quit when a syntax file was already loaded
14 elseif exists("b:current_syntax")
18 " A bunch of useful keywords
19 syn keyword tclStatement proc global return lindex
20 syn keyword tclStatement llength lappend lreplace lrange list concat incr
21 syn keyword tclStatement upvar set
22 syn keyword tclLabel case default
23 syn keyword tclConditional if then else elseif switch
24 syn keyword tclRepeat while for foreach break continue
25 syn keyword tcltkSwitch contained insert create polygon fill outline tag
28 " commands associated with widgets
29 syn keyword tcltkWidgetSwitch contained background highlightbackground insertontime cget
30 syn keyword tcltkWidgetSwitch contained selectborderwidth borderwidth highlightcolor insertwidth
31 syn keyword tcltkWidgetSwitch contained selectforeground cursor highlightthickness padx setgrid
32 syn keyword tcltkWidgetSwitch contained exportselection insertbackground pady takefocus
33 syn keyword tcltkWidgetSwitch contained font insertborderwidth relief xscrollcommand
34 syn keyword tcltkWidgetSwitch contained foreground insertofftime selectbackground yscrollcommand
35 syn keyword tcltkWidgetSwitch contained height spacing1 spacing2 spacing3
36 syn keyword tcltkWidgetSwitch contained state tabs width wrap
38 syn keyword tcltkWidgetSwitch contained command default
40 syn keyword tcltkWidgetSwitch contained closeenough confine scrollregion xscrollincrement yscrollincrement orient
41 " checkbutton, radiobutton
42 syn keyword tcltkWidgetSwitch contained indicatoron offvalue onvalue selectcolor selectimage state variable
44 syn keyword tcltkWidgetSwitch contained show class colormap container visual
46 syn keyword tcltkWidgetSwitch contained selectmode postcommand selectcolor tearoff tearoffcommand title type
48 syn keyword tcltkWidgetSwitch contained direction aspect justify
50 syn keyword tcltkWidgetSwitch contained bigincrement digits from length resolution showvalue sliderlength sliderrelief tickinterval to
52 syn keyword tcltkWidgetSwitch contained activerelief elementborderwidth
54 syn keyword tcltkWidgetSwitch contained delete names types create
56 syn match tclVarRef "$\a[a-zA-Z0-9_.]*"
57 syn match tclVarRef "${\a[a-zA-Z0-9_.]*}"
59 syn keyword tcltkWidgetSwitch contained active end last none cascade checkbutton command radiobutton separator
60 syn keyword tcltkWidgetSwitch contained activebackground actveforeground accelerator background bitmap columnbreak
61 syn keyword tcltkWidgetSwitch contained font foreground hidemargin image indicatoron label menu offvalue onvalue
62 syn keyword tcltkWidgetSwitch contained selectcolor selectimage state underline value variable
63 syn keyword tcltkWidgetSwitch contained add clone configure delete entrycget entryconfigure index insert invoke
64 syn keyword tcltkWidgetSwitch contained post postcascade type unpost yposition activate
65 "syn keyword tcltkWidgetSwitch contained
66 "syn match tcltkWidgetSwitch contained
67 syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<button\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
68 syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<scale\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
70 syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<canvas\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
71 syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<checkbutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
72 syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<entry\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
73 syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<frame\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
74 syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<image\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
75 syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<listbox\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
76 syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<menubutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
77 syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<message\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
78 syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<radiobutton\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
79 syn region tcltkWidget matchgroup=tcltkWidgetColor start="\<scrollbar\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
80 " These words are dual purpose.
82 syn match tcltkWidgetSwitch contained "-text"hs=s+1
83 syn match tcltkWidgetSwitch contained "-menu"hs=s+1
84 syn match tcltkWidgetSwitch contained "-label"hs=s+1
85 " match commands - 2 lines for pretty match.
87 " Special case - If a number follows a variable region, it must be at the end of
88 " the pattern, by definition. Therefore, (1) either include a number as the region
89 " end and exclude tclNumber from the contains list, or (2) make variable
90 " keepend. As (1) would put variable out of step with everything else, use (2).
91 syn region tcltkCommand matchgroup=tcltkCommandColor start="^\<variable\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tclString,tclNumber,tclVarRef,tcltkCommand
92 syn region tcltkCommand matchgroup=tcltkCommandColor start="\s\<variable\>\|\[\<variable\>"hs=s+1 matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tclString,tclNumber,tclVarRef,tcltkCommand
94 syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<menu\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
95 syn region tcltkWidget matchgroup=tcltkWidgetColor start="\s\<menu\>\|\[\<menu\>"hs=s+1 matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
97 syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<label\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
98 syn region tcltkWidget matchgroup=tcltkWidgetColor start="\s\<label\>\|\[\<label\>"hs=s+1 matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
100 syn region tcltkWidget matchgroup=tcltkWidgetColor start="^\<text\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidget,tcltkWidgetSwitch,tcltkSwitch,tclNumber,tclVarRef,tclString
101 syn region tcltkWidget matchgroup=tcltkWidgetColor start="\s\<text\>\|\[\<text\>"hs=s+1 matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidget,tcltkWidgetSwitch,tclString,tcltkSwitch,tclNumber,tclVarRef
103 " This isn't contained (I don't think) so it's OK to just associate with the Color group.
104 " TODO: This could be wrong.
105 syn keyword tcltkWidgetColor toplevel
108 syn region tcltkPackConf matchgroup=tcltkPackConfColor start="\<configure\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tcltkPackConfSwitch,tclNumber,tclVarRef keepend
109 syn region tcltkPackConf matchgroup=tcltkPackConfColor start="\<cget\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"me=e-1 contains=tclLineContinue,tcltkWidgetSwitch,tclString,tcltkSwitch,tcltkPackConfSwitch,tclNumber,tclVarRef
113 " commands associated with namespace
114 syn keyword tcltkNamespaceSwitch contained children code current delete eval
115 syn keyword tcltkNamespaceSwitch contained export forget import inscope origin
116 syn keyword tcltkNamespaceSwitch contained parent qualifiers tail which command variable
117 syn region tcltkCommand matchgroup=tcltkCommandColor start="\<namespace\>" matchgroup=NONE skip="^\s*$" end="{\|}\|]\|\"\|[^\\]*\s*$"me=e-1 contains=tclLineContinue,tcltkNamespaceSwitch
120 " commands associated with expr
121 syn keyword tcltkMaths contained acos cos hypot sinh
122 syn keyword tcltkMaths contained asin cosh log sqrt
123 syn keyword tcltkMaths contained atan exp log10 tan
124 syn keyword tcltkMaths contained atan2 floor pow tanh
125 syn keyword tcltkMaths contained ceil fmod sin
126 syn region tcltkCommand matchgroup=tcltkCommandColor start="\<expr\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"me=e-1 contains=tclLineContinue,tcltkMaths,tclNumber,tclVarRef,tclString,tcltlWidgetSwitch,tcltkCommand,tcltkPackConf
129 syn region tcltkCommand matchgroup=tcltkCommandColor start="\<format\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"me=e-1 contains=tclLineContinue,tcltkMaths,tclNumber,tclVarRef,tclString,tcltlWidgetSwitch,tcltkCommand,tcltkPackConf
132 " commands associated with pack
133 syn keyword tcltkPackSwitch contained forget info propogate slaves
134 syn keyword tcltkPackConfSwitch contained after anchor before expand fill in ipadx ipady padx pady side
135 syn region tcltkCommand matchgroup=tcltkCommandColor start="\<pack\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkPackSwitch,tcltkPackConf,tcltkPackConfSwitch,tclNumber,tclVarRef,tclString,tcltkCommand keepend
138 " commands associated with string
139 syn keyword tcltkStringSwitch contained compare first index last length match range tolower toupper trim trimleft trimright wordstart wordend
140 syn region tcltkCommand matchgroup=tcltkCommandColor start="\<string\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkStringSwitch,tclNumber,tclVarRef,tclString,tcltkCommand
143 " commands associated with array
144 syn keyword tcltkArraySwitch contained anymore donesearch exists get names nextelement size startsearch set
145 " match from command name to ] or EOL
146 syn region tcltkCommand matchgroup=tcltkCommandColor start="\<array\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkArraySwitch,tclNumber,tclVarRef,tclString,tcltkCommand
150 syn keyword tcltkLsortSwitch contained ascii dictionary integer real command increasing decreasing index
151 " match from command name to ] or EOL
152 syn region tcltkCommand matchgroup=tcltkCommandColor start="\<lsort\>" matchgroup=NONE skip="^\s*$" end="]\|[^\\]*\s*$"he=e-1 contains=tclLineContinue,tcltkLsortSwitch,tclNumber,tclVarRef,tclString,tcltkCommand
154 syn keyword tclTodo contained TODO
157 " String and Character contstants
158 " Highlight special characters (those which have a backslash) differently
159 syn match tclSpecial contained "\\\d\d\d\=\|\\."
160 " A string needs the skip argument as it may legitimately contain \".
161 " Match at start of line
162 syn region tclString start=+^"+ end=+"+ contains=tclSpecial skip=+\\\\\|\\"+
163 "Match all other legal strings.
164 syn region tclString start=+[^\\]"+ms=s+1 end=+"+ contains=tclSpecial skip=+\\\\\|\\"+
166 syn match tclLineContinue "\\\s*$"
168 "integer number, or floating point number without a dot and with "f".
170 syn match tclNumber "\<\d\+\(u\=l\=\|lu\|f\)\>"
171 "floating point number, with dot, optional exponent
172 syn match tclNumber "\<\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\=\>"
173 "floating point number, starting with a dot, optional exponent
174 syn match tclNumber "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
175 "floating point number, without dot, with exponent
176 syn match tclNumber "\<\d\+e[-+]\=\d\+[fl]\=\>"
178 syn match tclNumber "0x[0-9a-f]\+\(u\=l\=\|lu\)\>"
179 "syn match tclIdentifier "\<[a-z_][a-z0-9_]*\>"
182 syn region tclComment start="^\s*\#" end="$" contains=tclTodo
183 syn region tclComment start=/;\s*\#/hs=s+1 end="$" contains=tclTodo
185 "syn sync ccomment tclComment
187 " Define the default highlighting.
188 " For version 5.7 and earlier: only when not done already
189 " For version 5.8 and later: only when an item doesn't have highlighting yet
190 if version >= 508 || !exists("did_tcl_syntax_inits")
192 let did_tcl_syntax_inits = 1
193 command -nargs=+ HiLink hi link <args>
195 command -nargs=+ HiLink hi def link <args>
198 HiLink tcltkSwitch Special
199 HiLink tclLabel Label
200 HiLink tclConditional Conditional
201 HiLink tclRepeat Repeat
202 HiLink tclNumber Number
203 HiLink tclError Error
204 HiLink tclStatement Statement
205 "HiLink tclStatementColor Statement
206 HiLink tclString String
207 HiLink tclComment Comment
208 HiLink tclSpecial Special
210 " Below here are the commands and their options.
211 HiLink tcltkCommandColor Statement
212 HiLink tcltkWidgetColor Structure
213 HiLink tclLineContinue WarningMsg
214 HiLink tcltkStringSwitch Special
215 HiLink tcltkArraySwitch Special
216 HiLink tcltkLsortSwitch Special
217 HiLink tcltkPackSwitch Special
218 HiLink tcltkPackConfSwitch Special
219 HiLink tcltkMaths Special
220 HiLink tcltkNamespaceSwitch Special
221 HiLink tcltkWidgetSwitch Special
222 HiLink tcltkPackConfColor Identifier
223 "HiLink tcltkLsort Statement
224 HiLink tclVarRef Identifier
229 let b:current_syntax = "tcl"