two_editor(n) manual page

Back to the Index
Table of Contents

Name

two_editor - Text editor widget

Synopsis

package require twoEditor ?1.0?
two_editor pathName ?options?

Description

two_editor is an ASCII text editor widget. It extends the two_text(n) widget (also part of this library). It provides methods to open/save files into the widget and can be split into two parts which show different parts of the same file.

Commands

The two_editor widget command takes all of the two_text(n) commands and additionally the following:
pathName open filename
Load file filename into buffer (equivalent to configure -file).
pathName close
Close the current buffer
pathName save ?filename?
Save the current buffer to file filename. If filename is omitteted then the name of the currently opened file will be used.
pathName filename
Returns the name of currently opened file or the name of the buffer.
pathName mtime
Returns the mtime of the opened file as of the time of last opening or saveing the file. Returns 0 on new files.
pathName mtimeReset
Reset the seaved mtime to the current mtime of the opened file.
pathName splitState
Returns 1 if editor is split (equivalent to cget -split).
pathName isNew
Returns 1 if editor holds a new file (or buffer), i.e. no name has been given to it.
pathName isFile
Returns 1 if editor holds a file (with a name, i.e. this is not a buffer, nor is it a new and unnamed file.
Returns
1 if editor holds a buffer (with a name, i.e. this is not a file, nor is it a new and unnamed buffer.
pathName setFocus
Set the focus on the proper subwidget.
pathName repaint
Recalculate the higlighting for this editor if highlighting is configured.

Options

The two_editor command takes all options of the two_text(n) widget plus to following options:
-file filename
Initially load file filename into the buffer. If omitted, a new name New # will be generated and no file opened.
-buffer buffername
Apply a new to an editor, but this is no real file, so no file will be opned. If omitted, a new name New # will be generated.
-closecmd command
Call command when a modified buffer (i.e. file not saved since last changes) is about to be destroyed. The widget is actually only destroyed if this command returns true (or no command has been set set).
-openerrcmd command
Call command when opening a file fails. Two parameters are appended: the name of the file and the error message. You should test if a file is readable prior to openeing it, but that alone would open up a race condition: the (short) time gap between the check and actually opening the file might be sufficient for changes (due to external influences). To not fire up an internal error in such a case use this option.
-saveerrcmd command
Call command when saveing a file fails. Two parameters are appended: the name of the file and the error message. You should test if a file is writable prior to saving it, but that alone would open up a race condition: the (short) time gap between the check and actually saving the file might be sufficient for changes (due to external influences). To not fire up an internal error in such a case use this option.
-split TCL_BOOLEAN
If set to TRUE, then editor is set to display two views of the same file. Defaults to FALSE.
-scrollx TCL_BOOLEAN
If TRUE, then the editor will do no line wrapping and use an automatic horizontal scrollbar. Defaults to TRUE.
-style
Set the style of the splitter used by the editor: unix for more UNIX-like or windows for a look and feel like on windows.
-match TCL_BOOLEAN
If TRUE, then the editor will highlight matching parens, braces, and brackets while typing. Defaults to TRUE.
-highlight TCL_BOOLEAN
If TRUE, then the editor will perform syntax highlighting based on the following options. Defaults to FALSE.
-comment list
List with even number of elements. Each pair is a description (Regular Expression without parantheses) of start and stop of comments.
-string list
List with even number of elements. Each pair is a description (Regular Expression without parantheses) of start and stop of strings.
-keywords list
List of keywords.
-keywordRE expression
A single Regular Expression (without parantheses) describing what keywords are. This is an alternative to the keywords option (can't use both).

Virtual Events

The two_editor forwards all virtual events of the two_text(n) widget, and additinally generates the following event:
<<SplitOn>> and <<SplitOff>>
The Editor has been split (On) or joined again (Off).

Elements

The two_editor is built from a surrounding frame (class TwoEditor) and to slave frames (no class). Those two frames each contain a two_text(n) widget and two automatic scrollbars autosb(n) . The horizontal autosb is not used if the -scrollx option is set to FALSE. Fonts used (and created if non-existant) by the editor widget are:
twoEditorS
Used for highlighting strings
twoEditorC
Used for highlighting comments
twoEditorK
Used for highlighting keywords

Both slave frames (with the two_text widgets) are managed by a splitter(n) . Only one frame is visible if the editor is not split.

Author

Frank J. Leitner
frank@fjl.de

See Also

two_text(n) , two_autosb(n) , two_splitter(n) .


Table of Contents


Back to the Index