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.
Version 0.40 of Tk::CodeText was re-written from scratch. This version and all later versions are 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
- autocomplete
- matching of nested {}, () and [] pairs
OPTIONS
- Name: acPopSize
- Class: AcPopSize
- Switch: -acpopsize
-
The length of the typed string to trigger autocomplete into making suggestions. Default value 5.
- Name: acScanSize
- Class: AcScanSize
- Switch: -acscansize
-
The minimal length of a word to be included in the autocomplete word database. Default value 5.
- Name: activeDelay
- Class: ActiveDelay
- Switch: -activedelay
-
The waiting time in miliseconds before an autocomplete pop up can occur. Default value 300.
- Name: autoComplete
- Class: AutoComplete
- Switch: -autocomplete
-
Boolean. Default value false. Enables or disables autocomplete.
- Name: autoIndent
- Class: AutoIndent
- 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.
- Switch: -findoptions
-
Default: [-background => '#C0FFC0', -foreground => '#000000'](light green and black). Specifies the options for the find tag.
- 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.
- Name: linesPerCycle
- Class: LinesPerCycle
- Switch: -linespercycle
-
Default value 10. It specifies how many lines Tk::CodeText will Highlight in one cycle. You can tone it down if the application responds sluggish.
- 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.
- Name: showSpaces
- Class: ShowSpaces
- Switch: -showspaces
-
Default value 0. If set the leading and trailing spaces on each line will be highlighted in their own back ground color. See also the -spacebackground and -tabbackground options.
- Name: spaceBackground
- Class: SpaceBackground
- Switch: -spacebackground
-
Default value #0098C2. The background color shown to leading and trailing spaces when the -showspaces option is set.
- 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.
- Name: tabBackground
- Class: TabBackground
- Switch: -tabbackground
-
Default value #B5C200. The background color shown to leading and trailing spaces when the -showspaces option is set.
- 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.
- 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
-
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.
- fixIndent
-
Works on the entire text unless a selection is set. In that case works only on the selection. Checks all lines in the working range for incorrect indentation and attempts to repair.
- 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.
- getRange
-
Checks for a selection and returns the line numbers of the begin and the end. If no selection is set it returns 1 and the line number of the last line.
- 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.
- replace$begin, $end, $string)
-
Replaces the text from index $begin to $end with the text in $string. Counts for one event in the undo stack.
- removeTrailingSpaces
-
Works on the entire text unless a selection is set. In that case works only on the selection. Checks all lines in the working range for trailing spaces or tabs and removes them.
- 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.
EXECUTABLES
This module packs an executable, codetext. It is a simple Notepad like editor but with all the features of Tk::CodeText. Type 'codetext -h' in the command line for options.
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.