Although the basic GtkTextView is a lightweight plain vanilla text editing widget, it can be spiced up to do more interesting things, operations that would normally be expected in a word processing application. It is possible to embed such larger editors into a Gtk window, and the legacy binding to the Abiwidget is an example of that. Using such objects comes with the caveat that the widget is effectively an app within an app, rather than a component.
The gnocl::text object has three options, -balanceQuotes, -swap and -corrections which pushes the uses of the widget towards creative writing rather than just editing a simple text file.
All three options work in connection with the widget's 'key-release-event' signal to analyse the text buffer contents adjacent to the insert cursor. Setting the -balanceQuotes option to 1 will result in the any " or ' becoming modified to single or double open quotes dependent upon leading or trailing characters. It also enables the correct insertion of apostrophe's in the creation of English possessives.
The -swap option accepts an even list of char mappings resulting in substitution taking place at the point of insertion. Although IBUS allows switching between input methods, and character map applications allow specific glyphs to be inserted, these can be cumbersome or inconvenient. Character mapping allows convenient changes to be made by the user, during runtime.
At a more targeted way -corrections options allows whole words to be swap whist typing. This is useful to ensure the correct application of cumbersome to remember diacritics or where an acronym or abbreviation can be fully expanded.
For example:
$txt configure -balanceQuotes 1
$txt configure -swap {
aa ā
ii ī
^o ô
;s ś
.h ḥ }
$txt configure -corrections {
maha māha
mudra mūdra
Avalokiteshvara Avalôkiteśvara
prajna prajñā
AAPP {astasahasrika prajanparamita sutra}
SDPS {sadharma pundarika sutra}
}
Other uses for this functionality includes user-defined active spelling checking.
Comments