Documentation generated from fossil trunk
ctext -
Ctext a text widget with highlighting support
package require Tk package require ctext ? 3.3 ? ctext pathName ? options ? ::ctext::addHighlightClass pathName class color keywordlist ::ctext::addHighlightClassWithOnlyCharStart pathName class color char ::ctext::addHighlightClassForSpecialChars pathName class color charstring ::ctext::addHighlightClassForRegexp pathName class color pattern ::ctext::clearHighlightClasses pathName ::ctext::getHighlightClasses pathName ::ctext::deleteHighlightClass pathName class ::ctext::enableComments enable ::ctext::disableComments enable pathName highlight startIndex endIndex pathName fastdelete index1 ? index2 ? pathName fastinsert pathName copy pathName cut pathName paste pathName append pathName configure option value ? ... ?
Ctext overloads the text widget and provides new commands, named highlight, copy, paste,cut, append, and edit. It also provides several commands that allow you to define classes. Each class corresponds to a tag in the widget.
# highlight some tcl keywords ::ctext::addHighlightClass .t tclkeywords red [list set info interp uplevel upvar]]
::ctext::addHighlightClassWithOnlyCharStart .t vars blue \$
Name | Database name | Database class |
---|---|---|
-linemap | ||
Creates (-linemap 1) or deletes (-linemap 0) a line number list on the left of the widget. The default is to have a linemap displayed. | ||
-linemapfg | ||
Changes the foreground of the linemap. The default is the same color as the main text widget. | ||
-linemapbg | ||
Changes the background of the linemap. The default is the same color as the main text widget. | ||
-linemap_select_fg | ||
Changes the selected line foreground. The default is black. | ||
-linemap_select_bg | ||
Changes the selected line background. The default is yellow. | ||
-linemap_mark_command | ||
Calls a procedure or command
with the pathName of the ctext window, the type which is
either marked or unmarked, and finally the line
number selected.
The proc prototype is:
proc linemark_cmd {win type line}.See also ctext_test_interactive.tcl |
||
-highlight | ||
Takes a boolean value which defines whether or not to highlight text which is inserted or deleted. The default is 1. | ||
-linemap_markable | ||
Takes a boolean value which specifies whether or not lines in the linemap are markable with the mouse. The default is 1. |
package require Tk package require ctext proc main {} { pack [frame .f] -fill both -expand 1 pack [scrollbar .f.s -command {.f.t yview}] -side right -fill y pack [ctext .f.t -bg black -fg white -insertbackground yellow -yscrollcommand {.f.s set}] -fill both -expand 1 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] 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] ctext::addHighlightClass .f.t stackControl red {proc uplevel namespace while for foreach if else} ctext::addHighlightClassWithOnlyCharStart .f.t vars mediumspringgreen "\$" ctext::addHighlightClass .f.t variable_funcs gold {set global variable unset} ctext::addHighlightClassForSpecialChars .f.t brackets green {[]{}} ctext::addHighlightClassForRegexp .f.t paths lightblue {\.[a-zA-Z0-9\_\-]+} ctext::addHighlightClassForRegexp .f.t comments khaki {#[^\n\r]*} .f.t fastinsert end [info body main] pack [frame .f1] -fill x .f.t highlight 1.0 end pack [button .f1.exit -text Exit -command exit] -side left pack [entry .e] -side bottom -fill x .e insert end "ctext::deleteHighlightClass .f.t " bind .e <Return> {eval [.e get]} } mainFurther examples are in the source package for ctext.
text, re_syntax