NAME
Tk::CodeText - Programmer's Swiss army knife Text widget.
SYNOPSIS
require Tk::CodeText;
my $text= $window->CodeText(@options)->pack;
DESCRIPTION
Tk::CodeText aims to be a Scintilla like text widget for Perl/Tk.
This is a rewrite, almost from scratch and not backwards compatible with version 0.3.4 and earlier.
It leans heavily on Syntax::Kamelon.
It features:
- line numbers on display
- code folding
- status bar
-
The status bar has document info and tools for setting tab size, indent style and syntax
- advanced word based undo/redo stack
-
It keeps track of the last saving point and selections
- syntax highlighting in many languages and formats.
- commenting and uncommenting blocks and lines
- indenting and unindenting blocks and lines
- automatic indentation
- matching of nested {}, () and [] pairs
OPTIONS
- Switch: -autoindent
-
By default 0. If set the text will be indented to the level and style of the previous line.
- Name: bookmarkColor
- Class: BookmarkColor
- Switch: -bookmarkcolor
-
Default value #71D0CC. Background color for the line number label of a bookmarked line.
- Name: bookmarkSize
- Class: BookmarkSize
- Switch: -bookmarksize
-
Default value 20. length of the label for bookmark entries in the bookmarks menu.
- Name: configDir
- Class: ConfigDir
- Switch: -configdir
-
An empty string by default. If set to an existing folder that folder will be used for config files. Currently there is only one of those. The recent colors for the TagsEditor.
-
Reference to a Tk::Menu object that is used as context menu. If you do not specify it, the -menuitems option is checked.
-
By default 0. If set the right-click context menu is disabled.
- Name: highlightInterval
- Class: HighlightInterval
- Switch: -highlightinterval
-
By default 1 milisecond. Highlighting is done on a line by line basis. This is the time between lines.
- Name: indentStyle
- Class: IndentStyle
- Switch: -indentstyle
-
Default value 'tab'. You can also set it to a number. In that case an indent will be the number of spaces.
- Switch: -match
-
Default value '[]{}()'. Specifies which items to match against nested occurrences.
- Switch: -matchoptions
-
Default: [-background => 'blue', -foreground => 'yellow']. Specifies the options for the match tag.
-
Specify the menu items for the left-click popup menu. By default set to undef, meaning no popup menu.
- Switch: -minusimg
-
Image used for the collapse state of a folding point. By default it is a bitmap defined in this module.
- Switch: -mmodifiedcall
-
Callback called whenever text is modified. It gets the location index as parameter.
- Switch: -plusimg
-
Image used for the expand state of a folding point. By default it is a bitmap defined in this module.
- Switch: -readonly
-
Default value 0. If you set it to 1 the user will not be able to make modifications.
- Switch: -saveimage
-
The icon image used to indicate the text is modified on the status bar. By default it is an internally defined xpm.
- Switch: -scrollbars
-
Default value 'osoe'. Specifies if and how scrollbars are to be used. If you set it to an ampty string no scrollbars will be created. See also Tk::Scrolled.
Only available at create time.
- Switch: -statusinterval
-
By default 200 ms. Update interval for the status bar.
- Name: showFolds
- Class: ShowFolds
- Switch: -showfolds
-
Default value 1. If cleared the folding markers will be hidden.
- Name: showNumbers
- Class: ShowNumbers
- Switch: -shownumbers
-
Default value 1. If cleared the line numbers will be hidden.
- Name: showStatus
- Class: ShowStatus
- Switch: -showstatus
-
Default value 1. If cleared the status bar will be hidden.
- Name: syntax
- Class: Syntax
- Switch: -syntax
-
Default value 'None'. Sets and returns the currently used syntax definition.
- Switch: -themefile
-
Default value undef. Sets and loads a theme file with tags information for highlighting. A call to cget returns the name of the loaded theme file. See also Tk::CodeText::Theme.
- Name: updateLines
- Class: UpdateLines
- Switch: -updatelines
-
Default value 100. If is used during save and load operation. It specifies after how many lines an update on the progress bar on the status bar should occur.
- Switch: -xmlfolder
-
XML folder to use for Syntax::Kamelon
Only available at create time.
METHODS
- bookmarkAdd(?$line?)
-
Bookmarks line number $line?. If you do not specify $line?, the line that has the insert cursor is bookmarked.
- bookmarked($line)
-
Returns true if line number $line? is bookmarked.
- bookmarkList
-
Returns a list of all bookmarked line numbers in the text.
- bookmarkNew
-
Same as bookmarkAdd except it updates the visible bookmarks in the line number column.
- bookmarkNext(?$line?)
-
Jumps to the next bookmark relative to line number $line. If you do not specify $line?, the jump is made from the insert cursor position.
- bookmarkPrev(?$line?)
-
Jumps to the previous bookmark relative to line number $line?. If you do not specify $line?, the jump is made from the insert cursor position.
- bookmarkRemove(?$line?)
-
Removes the bookmark at $line?. If you do not specify $line?, the bookmark of the line that holds the insert cursor position is removed.
- bookmarkRemoveAll(?$line?)
-
Removes all bookmarks.
- canUndo
-
Returns true if the undo stack has content.
- canRedo
-
Returns true if the redo stack has content.
- clear
-
Delets all text. Clears the undo and redo stack. Clears the modified flag. Resets hightlighting to syntax 'None'
- comment
-
Comments the current line or selection.
- foldCollapseAll
-
Collapses all folding points.
- foldExpandAll
-
Expands all folding points.
- fontCompose($font, %options)
-
Returns a new font based on $font. The keys -family -size -weight -slant are supported
- getFontInfo
-
Returns info about the font used in the text widget. The info is a hash with keys -family -size -weight -slant -underline -overstrike.
- goTo($index)
-
Sets the insert cursor to $index.
- indent
-
Indents the current line or selection.
- isHidden($line)
-
Returns true if $line is hidden by a colde fold.
- linenumber($index)
-
Returns the line number of $index.
- lineVisible($line)
- load($file)
-
Clears the text widget and loads $file. Returns 1 if successfull.
- redo
-
Redoes the last undo.
- save($file)
-
Saves the text into $file. Returns 1 if successfull.
- saveExport($file)
-
Same as save, except it does not clear the modified flag.
- selectionExists
-
Returns true if a selection exists
-
Returns the Kamelon list of AvailableAttributes.
- theme
-
Returns a reference to the current theme object. See also Tk::CodeText::Theme
- themeDialog
-
Initiates a dialog for editing the colors and font information for highlighting.
- uncomment
-
Uncomments the current line or selection.
- undo
-
Undoes the last edit operation.
- unindent
-
Unintents the current line or selection
- visualBegin
-
Returns the line number of the first visible line.
- visualEnd
-
Returns the line number of the last visible line.
AUTHOR
Hans Jeuken (hanje at cpan dot org)
BUGS AND CAVEATS
Matching {}, [] and () does not take strings with matchable symbols into account.
If you find any, please contact the author.