KJN: This page defines a binding tag, modernText, as an alternative to the text widget's default binding tag, Text.
The purpose of modernText is to make the text widget behave more like a "modern" (Year 2005 CE) text editor. It makes the text widget more useful for implementing a text editor, and makes it behave in a way that is more familiar to many users.
modernText is implemented as a binding tag, and apart from these bindings its code is contained entirely in the ::modernText namespace, with no exports to the global or other namespaces, and no new widget commands. It uses modified copies of the Tk code, leaving the original code, and the Text binding tag, unchanged.
Vices of the default bindings:
The last two 'vices' are often useful features, so modernText gives you the option of retaining them, by setting variables defined in the ::modernText namespace to 1 (instead of their default 0). Explaining these vices/features in more detail:
I have worked on the bindings that I personally use a lot, but there are many others that I do not use - so I would appreciate feedback (on this Wiki page) on any features in modernText, particularly bindings or other features that may have been broken by these changes.
modernText is mainly intended for text widgets whose -wrap mode is "none" or "word". For a text widget that is wrapped in "char" mode, display line ends are much less meaningful, and so, for "-wrap char", modernText's rules on crossing line ends are relaxed for display lines (but not for logical lines).
Requirements
The code requires Tk 8.5; the latest development version (ActiveTcl 8.5 beta 4, 8.5a4) has a bug [L1 ] in the text widget. So I am using an earlier version, ActiveTcl 8.5 beta 3 (8.5a2). I recommend using this version for text widget work until a bugfixed version of 8.5 is released.
To use modernText, source the code in the first box below, and then use the bindtags command to specify the modernText binding tag (instead of the default Text) for your text widget, e.g.
bindtags .t {.t modernText . all}
The second box below has a simple demo program.
To Do