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                   # highlight some tcl keywords
81                   ::ctext::addHighlightClass .t tclkeywords red [list set info interp uplevel upvar]]
82
83
84       ::ctext::addHighlightClassWithOnlyCharStart pathName class color char
85              Add  a  highlighting  class  class to the ctext widget pathName.
86              The highligthing will be done with the color  color.  All  words
87              starting with char will be highlighted.
88
89                   ::ctext::addHighlightClassWithOnlyCharStart .t vars blue \$
90
91
92       ::ctext::addHighlightClassForSpecialChars    pathName    class    color
93       charstring
94              Add a highlighting class class to  the  ctext  widget  pathName.
95              The highligthing will be done with the color color. All chars in
96              charstring will be highlighted.
97
98       ::ctext::addHighlightClassForRegexp pathName class color pattern
99              Add a highlighting class class to  the  ctext  widget  pathName.
100              The  highligthing  will  be  done with the color color. All text
101              parts matching the regexp pattern will be highligthed.
102
103       ::ctext::clearHighlightClasses pathName
104              Remove all highlight classes from the widget pathName.
105
106       ::ctext::getHighlightClasses pathName
107              List all highlight classes for the widget pathName.
108
109       ::ctext::deleteHighlightClass pathName class
110              Delete the highlight class class from the widget pathName
111
112       ::ctext::enableComments enable
113              Enable C comment highlighting. The class for c-style comments is
114              _cComment.  The C comment highlighting is disabled by default.
115
116       ::ctext::disableComments enable
117              Disable C comment highlighting.
118

WIDGET COMMANDS

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

WIDGET OPTIONS

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

EXAMPLE

223                               package require Tk
224                               package require ctext
225
226                               proc main {} {
227                               pack [frame .f] -fill both -expand 1
228                               pack [scrollbar .f.s -command {.f.t yview}] -side right -fill y
229
230                               pack [ctext .f.t -bg black -fg white -insertbackground yellow  -yscrollcommand {.f.s set}] -fill both -expand 1
231
232                               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]
233
234                               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]
235
236                               ctext::addHighlightClass .f.t stackControl red  {proc uplevel namespace while for foreach if else}
237                               ctext::addHighlightClassWithOnlyCharStart .f.t vars mediumspringgreen "\$"
238                               ctext::addHighlightClass .f.t variable_funcs gold {set global variable unset}
239                               ctext::addHighlightClassForSpecialChars .f.t brackets green {[]{}}
240                               ctext::addHighlightClassForRegexp .f.t paths lightblue {\.[a-zA-Z0-9\_\-]+}
241                               ctext::addHighlightClassForRegexp .f.t comments khaki {#[^\n\r]*}
242                               .f.t fastinsert end [info body main]
243
244                               pack [frame .f1] -fill x
245
246                               .f.t highlight 1.0 end
247
248                               pack [button .f1.exit -text Exit -command exit] -side left
249
250                               pack [entry .e] -side bottom -fill x
251                               .e insert end "ctext::deleteHighlightClass .f.t "
252                               bind .e <Return> {eval [.e get]}
253                               }
254                               main
255
256
257       Further examples are in the source package for ctext.
258

THANKS

260       Kevin Kenny, Neil Madden, Jeffrey  Hobbs,  Richard  Suchenwirth,  Johan
261       Bengtsson, Mac Cody, Günther, Andreas Sievers, and Michael Schlenker.
262

SEE ALSO

264       re_syntax, text
265

KEYWORDS

267       syntax highlighting, text, widget
268
270       Copyright (c) George Peter Staplin <GeorgePS@XMission.com>
271
272
273
274
275ctext                                 3.2                             ctext(n)
Impressum