Tk Source Code

View Ticket
Login
Ticket UUID: 5a670c16bae3da765a34bac149d99b64cdfa3775
Title: Revised [text]: -undo tag option default should be changed
Type: Bug Version: revised_text
Submitter: fvogel Created on: 2017-05-13 19:54:45
Subsystem: 18. [text] Assigned To: gcramer
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2019-01-01 15:07:21
Resolution: None Closed By: nobody
    Closed on:
Description:

Currently the man page for the revised text widget says:

-undo boolean
Specifies whether adding/removing this tag to/from text will be undone with undo operation. If this flag is false, then changes of tag associations will not be undone for this tag. The default is true, except for the special selection flag sel, the default for this tag is false. 

For compatibility reasons with the legacy widget I believe the default should be false for all tags.

I have application code that uses tags to colorize text. The undo/redo features are available to the user of the application. Text colorization (i.e. tagging) is launched by the app at each undo or redo operation. Having the text widget now saving tag changes on the undo stacks breaks this existing application code.

User Comments: gcramer added on 2019-01-01 15:07:21:

I agree, a widget-global option is quite useful here, I realized this with [1a6d99122a]. New text option -undotagging is available, this value will be used for the setup when creating tags. The default of -undotagging is "true". Now it will be possible to the restore the old (erroneous) behavior of undoing, with

option add *Text.undoTagging 0


kvutza added on 2018-12-23 13:09:02:
The case of structure/syntax highlighting really requires tags decoupled from undo/redo actions. And since it is quite common to have such features for texts, it would be good to have at least a widget-global option for setting it as a default for tags.

Notice please that many Tcl/Tk applications are scripts that work well over a range of Tcl/Tk versions. And having a necessity of putting an amount of catch commands (with the settings for individual tags) is somewhat unpleasant.

I am looking forward for the revised text widget, just wanna avoid bigger changes to current application codes.

gcramer added on 2017-05-14 08:11:58:
> For compatibility reasons with the legacy widget I believe the default should be false for all tags.

I know, this would be "compatible", but on other side I have shown that not undoing tag operations is in general erroneous. So including the tag operations into the undo mechanism is the natural way, excluding it is the unexpected way. I did take into account that some applications are using coloring after undo/redo operations, but normally this is not a problem, because normally the application is colorizing independently from current colors. So it's a bit unluckily that this application breaks. I suggest to invent an additional widget option -undotagging with default true, and tag option -undo will be initialized with this widget option (except "sel"). This would allow a quick "fix" for such applications.

I don't think it's a big problem with this incompatibility. Please consider that an application is dependent from the library version at release time. For instance some older (abandoned) Tk applications are linked with version 8.4, so they work as expected even if the most actual version is 8.6. The same applies to this application. If it is linked with 8.6, then nothing will happen with this application with the release of 8.7. And if this application is still living, then the developers will simply remove the colorizing after undo/redo when upgrading to 8.7, or they will use this quick fix with setting -undotagging to false. Preserving the compatibility is important for the developers, they don't like to change the whole code with an upgrade to a newer library version. But the compatibility is not a must, especially if an odd behavior has changed to a natural behavior, only in such a case some applications have to adjust the application to this special change in behavior. And the application is not breaking with the release of 8.7, because with an upgrade it is still dependent from 8.6.

You've found an application which does not work properly with undo/redo of tag operations. But normally an application will be "fixed" when upgrading to revised text widget (presumably version 8.7).