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: 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.
-
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: -plusimg
-
Image used for the expand state of a folding point. By default it is a bitmap defined in this module.
- 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
- 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.
- 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.