Additional Widget Option '-tagging'

Command-Line Name: -tagging
Database Name: tagging
Database Class: Tagging

Setting the mode how characters will be tagged when inserting text without explicit tagging information. The following modes are defined:

within

the new text will receive any tags that are present on both before and after the insertion point, regardless whether it's a character (including the invisible newline), an embedded window, or an embedded image; if a tag is present on only one of these characters (windows, or images) then it will not be applied to the new text. This is the default tagging mode (and the way how the older versions of the text widget worked).

gravity

The new text will receive any tags that are present at one side of the insertion point: if the insert cursor has right gravity then the text will receive the tags of the character after the insertion point (including the invisible newline), otherwise, if the insertion cursor has left gravity, it will receive the tags of the character before the insertion point (Arabian mode), but only if a preceding character exists in this line. This mode is commonly used in some text editors.

none

The new text will not receive any tags from surrounded text.

The effort for the implementation of this feature was minimal. The description of the insert command has to be changed a bit:

pathName insert index chars ?tagList chars tagList?

Inserts all of the chars arguments just before the character at index. If index refers to the end of the text (the character after the last newline) then the new text is inserted just before the last newline instead. If there is a single chars argument and no tagList, then the new text will receive any tags depending on the tagging mode (see option -tagging). If tagList is specified then it consists of a list of tag names; the new characters will receive all of the tags in this list and no others, regardless of the tagging mode. If multiple chars-tagList argument pairs are present, they produce the same effect as if a separate pathName insert widget command had been issued for each pair, in order. The last tagList argument may be omitted.