1ctext(n)         Ctext a text widget with highlighting support        ctext(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       ctext - Ctext a text widget with highlighting support
9

SYNOPSIS

11       package require Tk
12
13       package require ctext  ?3.2?
14
15       ctext pathName ?options?
16
17       ::ctext::addHighlightClass pathName class color keywordlist
18
19       ::ctext::addHighlightClassWithOnlyCharStart pathName class color char
20
21       ::ctext::addHighlightClassForSpecialChars    pathName    class    color
22       charstring
23
24       ::ctext::addHighlightClassForRegexp pathName class color pattern
25
26       ::ctext::clearHighlightClasses pathName
27
28       ::ctext::getHighlightClasses pathName
29
30       ::ctext::deleteHighlightClass pathName class
31
32       ::ctext::enableComments enable
33
34       ::ctext::disableComments enable
35
36       pathName highlight startIndex endIndex
37
38       pathName fastdelete index1 ?index2?
39
40       pathName fastinsert
41
42       pathName copy
43
44       pathName cut
45
46       pathName paste
47
48       pathName append
49
50       pathName configure option value ?...?
51
52______________________________________________________________________________
53

DESCRIPTION

55       The ctext package provides the ctext widget which is an  enhanced  text
56       widget with support for configurable syntax highlighting and some extra
57       commands.
58
59       Ctext overloads the text widget and provides new commands, named  high‐
60       light,  copy,  paste,cut,  append,  and edit.  It also provides several
61       commands that allow you to define classes.  Each class corresponds to a
62       tag in the widget.
63

COMMANDS

65       ctext pathName ?options?
66              Creates and configures a ctext widget.
67

HIGHLIGHTING

69       Highlighting is controlled with text widget tags, that are called high‐
70       light classes.  The class is a tag name and can be configured like  any
71       text  widget  tag.   Four types of highlight classes are supported. All
72       highlight classes are automatically used by the highlight method of the
73       widget.
74
75       ::ctext::addHighlightClass pathName class color keywordlist
76              Add  a  highlighting  class  class to the ctext widget pathName.
77              The highligthing will be done with the color color. All words in
78              the keywordlist will be highlighted.
79
80
81                # highlight some tcl keywords
82                ::ctext::addHighlightClass .t tclkeywords red [list set info interp uplevel upvar]]
83
84
85       ::ctext::addHighlightClassWithOnlyCharStart pathName class color char
86              Add  a  highlighting  class  class to the ctext widget pathName.
87              The highligthing will be done with the color  color.  All  words
88              starting with char will be highlighted.
89
90
91                ::ctext::addHighlightClassWithOnlyCharStart .t vars blue \$
92
93
94       ::ctext::addHighlightClassForSpecialChars    pathName    class    color
95       charstring
96              Add a highlighting class class to  the  ctext  widget  pathName.
97              The highligthing will be done with the color color. All chars in
98              charstring will be highlighted.
99
100       ::ctext::addHighlightClassForRegexp pathName class color pattern
101              Add a highlighting class class to  the  ctext  widget  pathName.
102              The  highligthing  will  be  done with the color color. All text
103              parts matching the regexp pattern will be highligthed.
104
105       ::ctext::clearHighlightClasses pathName
106              Remove all highlight classes from the widget pathName.
107
108       ::ctext::getHighlightClasses pathName
109              List all highlight classes for the widget pathName.
110
111       ::ctext::deleteHighlightClass pathName class
112              Delete the highlight class class from the widget pathName
113
114       ::ctext::enableComments enable
115              Enable C comment highlighting. The class for c-style comments is
116              _cComment.  The C comment highlighting is disabled by default.
117
118       ::ctext::disableComments enable
119              Disable C comment highlighting.
120

WIDGET COMMANDS

122       Each ctext widget created with the above command supports the following
123       commands and options in addition to the standard text  widget  commands
124       and options.
125
126       pathName highlight startIndex endIndex
127              Highlight the text between startIndex and endIndex.
128
129       pathName fastdelete index1 ?index2?
130              Delete  text  range without updating the highlighting. Arguments
131              are identical to the pathName delete command inherited from  the
132              standard text widget.
133
134       pathName fastinsert
135              Insert  text  without  updating  the highlighting. Arguments are
136              identical to the pathName  insert  command  inherited  from  the
137              standard text widget.
138
139       pathName copy
140              Call tk_textCopy for the ctext instance.
141
142       pathName cut
143              Call tk_textCut for the ctext instance.
144
145       pathName paste
146              Call tk_textPaste for the ctext instance.
147
148       pathName append
149              Append the current selection to the clipboard.
150
151       pathName configure option value ?...?
152              Set  the  options for the ctext widget. Each option name must be
153              followed the new value.
154

WIDGET OPTIONS

156       Command-Line Switch:    -linemap
157       Database Name:
158       Database Class:
159
160
161              Creates (-linemap 1) or deletes (-linemap 0) a line number  list
162              on the left of the widget. The default is to have a linemap dis‐
163              played.
164
165       Command-Line Switch:    -linemapfg
166       Database Name:
167       Database Class:
168
169
170              Changes the foreground of the linemap.  The default is the  same
171              color as the main text widget.
172
173       Command-Line Switch:    -linemapbg
174       Database Name:
175       Database Class:
176
177
178              Changes  the background of the linemap.  The default is the same
179              color as the main text widget.
180
181       Command-Line Switch:    -linemap_select_fg
182       Database Name:
183       Database Class:
184
185
186              Changes the selected line foreground.  The default is black.
187
188       Command-Line Switch:    -linemap_select_bg
189       Database Name:
190       Database Class:
191
192
193              Changes the selected line background.  The default is yellow.
194
195       Command-Line Switch:    -linemap_mark_command
196       Database Name:
197       Database Class:
198
199
200              Calls a procedure or command with the pathName of the ctext win‐
201              dow,  the  type  which is either marked or unmarked, and finally
202              the line number selected.  The proc prototype is:
203
204
205              proc linemark_cmd {win type line}.
206
207
208              See also ctext_test_interactive.tcl
209
210       Command-Line Switch:    -highlight
211       Database Name:
212       Database Class:
213
214
215              Takes a boolean value which defines whether or not to  highlight
216              text which is inserted or deleted.  The default is 1.
217
218       Command-Line Switch:    -linemap_markable
219       Database Name:
220       Database Class:
221
222
223              Takes  a  boolean  value which specifies whether or not lines in
224              the linemap are markable with the mouse.  The default is 1.
225

EXAMPLE

227                package require Tk
228                package require ctext
229
230                proc main {} {
231                pack [frame .f] -fill both -expand 1
232                pack [scrollbar .f.s -command {.f.t yview}] -side right -fill y
233
234                pack [ctext .f.t -bg black -fg white -insertbackground yellow  -yscrollcommand {.f.s set}] -fill both -expand 1
235
236                ctext::addHighlightClass .f.t widgets purple  [list ctext button label text frame toplevel  scrollbar checkbutton canvas listbox menu menubar menubutton  radiobutton scale entry message tk_chooseDir tk_getSaveFile  tk_getOpenFile tk_chooseColor tk_optionMenu]
237
238                ctext::addHighlightClass .f.t flags orange  [list -text -command -yscrollcommand  -xscrollcommand -background -foreground -fg -bg  -highlightbackground -y -x -highlightcolor -relief -width  -height -wrap -font -fill -side -outline -style -insertwidth  -textvariable -activebackground -activeforeground -insertbackground  -anchor -orient -troughcolor -nonewline -expand -type -message  -title -offset -in -after -yscroll -xscroll -forward -regexp -count  -exact -padx -ipadx -filetypes -all -from -to -label -value -variable  -regexp -backwards -forwards -bd -pady -ipady -state -row -column  -cursor -highlightcolors -linemap -menu -tearoff -displayof -cursor  -underline -tags -tag]
239
240                ctext::addHighlightClass .f.t stackControl red  {proc uplevel namespace while for foreach if else}
241                ctext::addHighlightClassWithOnlyCharStart .f.t vars mediumspringgreen "\$"
242                ctext::addHighlightClass .f.t variable_funcs gold {set global variable unset}
243                ctext::addHighlightClassForSpecialChars .f.t brackets green {[]{}}
244                ctext::addHighlightClassForRegexp .f.t paths lightblue {\.[a-zA-Z0-9\_\-]+}
245                ctext::addHighlightClassForRegexp .f.t comments khaki {#[^\n\r]*}
246                .f.t fastinsert end [info body main]
247
248                pack [frame .f1] -fill x
249
250                .f.t highlight 1.0 end
251
252                pack [button .f1.exit -text Exit -command exit] -side left
253
254                pack [entry .e] -side bottom -fill x
255                .e insert end "ctext::deleteHighlightClass .f.t "
256                bind .e <Return> {eval [.e get]}
257                }
258                main
259
260
261       Further examples are in the source package for ctext.
262

THANKS

264       Kevin Kenny, Neil Madden, Jeffrey  Hobbs,  Richard  Suchenwirth,  Johan
265       Bengtsson, Mac Cody, Günther, Andreas Sievers, and Michael Schlenker.
266

SEE ALSO

268       re_syntax, text
269

KEYWORDS

271       syntax highlighting, text, widget
272
274       Copyright (c) George Peter Staplin <GeorgePS@XMission.com>
275
276
277
278
279ctext                                 3.2                             ctext(n)
Impressum