two_text(n) manual page
Back to the Index
Table of Contents
two_text - Extended Tk text widget with undo/redo
package require twoText ?1.0?
two_text pathName ?options?
two_text is a wrapper around
the Tk text widget with some different keyboard bindings (without emacs
bindings, better CTRL-Left/right handling etc.) and a (simple) auto indent
mode. It has unlimited undo/redo capability. The widget will send virtual
events on several state changes. Widget can be cloned; all clones will
present an independant view of the same text. All changes are made to all
clones.
The two_text widget command takes all of the text(n)
commands and additionally the following:
- pathName
undo
- Undo most recent
operation. Please note that the undo buffer handles subsequend entries
(key presses) as one action.
- pathName
redo
- Redo most recent undo.
- pathName
replace start end chars
- Replace the text betwenn the indices start and end with the text in chars.
- pathName
insertReplace index chars
- Insert (or replace) the chars at the
given index or replace a selection.
- pathName
paste index ?chars?
- Insert the
chars at the given index or replace a selection. If no chars are given,
paste the current selection. Won't overwrite text in overwrite mode.
- pathName
clone widgetPath
- Create a cloned widget. This new widget will present an independant view
of the same text. All changes are made to all clones. Returns the pathname
of the clone.
- pathName
indent direction
- Indent current selection or, if
there is none, the current line. A positive value of direction will add
4 (or whatever has been set as indentstep) space will be inserted. If direction
has a negative value, the respective number of spaces will be removed.
Nothing happens if there are no more spaces at the beginning of the lines,
with one exception: a leading tab character is removed.
- pathName
selState
- Returns 1 if there is a selection, 0 otherwise.
- pathName
modState
- Returns
1 if text has been modified since the last afterSave or afterLoad.
- pathName
undoState
- Returns 1 if undo is possible (i.e. there is anything to be undone).
- pathName
redoState
- Returns 1 if redo is possible.
- pathName
afterSave
- Call this command after
the buffer has been saved. This is to let the widget know that it is once
again in the unmodified state.
- pathName
afterLoad
- Call this method after
a new file has been loaded into the buffer. This will result in clearing
the undo and redo buffers and setting the unmodified state.
The
two_text command takes all options of the text(n)
widget plus to following
options:
-autoindent TCL_BOOLEAN
- Turn on/off the (some rather simple)
automatic indentation: if 1 then any Return will indent the new line just
like the previous one. Defaults to 0.
-indentstep step
- Set the number of
spaces that will be inserted or removed when pathName
indent is called.
Defaults to 4.
-hardtab TCL_BOOLEAN
- Sets how hardtabs (\t) are handled when
moving the cursor up or down one line (using cursor keys): if this option
is set to TRUE, then hardtabs will be treated as the number of whitespaces
that would be needed to replace them (hard tab width of 8). If FALSE, they
are just counted as a single char (default Tk behavior, but in an editor
you usually expect the former).
-overwrite TCL_BOOLEAN
- Switch the overwrite
modus.
The two_text widget generates the following events;
all events originate from all clones, only the PosChanges is generated
exclusively by the widget which is currently being used.
- <<PosChanged>>
- Insertion
cursor position has changed. New position is column %x and row %y.
- <<OverwriteOn>> and <<OverwriteOff>>
- Overwrite has been switched On or Off.
- <<ModOn>> and <<ModOff>>
- Text has been modified
for the first time (On) or all mods have been undone (no more mods; Off).
- <<SelOn>> and <<SelOff>>
- Selection is made (On) oder removed (Off).
- <<UndoOn>> and <<UndoOff>>
- Undo possible (On) or impossible (Off).
- <<RedoOn>> and <<RedoOff>>
- Redo possible
(On) or impossible (Off).
A two_text widget is realy a subclassed
Tcl/Tk text widget. Class for bindtags is TwoText.
Frank J. Leitner
frank@fjl.de
text(n)
.
Table of Contents
Back to the Index