Additional States 'edit altered|irreversible'

See 'Edit modified' Gives Confusing Results about the problems with edit modified. So a new state has been introduced:

pathName edit altered

Returns whether changes have been done (eventual) affecting the text content, or the representation of the text content. Any of the following commands can set this flag to true:

  • delete
  • edit redo
  • insert
  • mark gravity|set|unset (but only if -steadymarks is enabled)
  • tag add|clear|lower|raise|remove (but not if -undo of affected tag is false)

This flag will be false before any of these operations have been done. It can never be false if edit irreversible reports true. It will be true after clear and load, and it will be true again if all changes have been undone (with edit undo). Also enabling the undo stack (via widget option -undo) will reset this state to false.

Any change of this state, if caused by an operation with (eventual) effects on the (representation of the) text content, will trigger the virtual event <<Altered>>.

The "old" state edit modified, related to the <<Modified>> event, will still reflect textual changes (as good as possible, see the problem with elided text). But the new state edit altered is reflecting any change which has an affect on text content, even if only the representation is affected (any change in tag associations will be seen as a change in the representation). If option -steadymarks is enabled, also the mark operations may have effects on the text content (although indirectly).

pathName edit irreversible

Returns a flag whether the content of the text widget is irreversible. The content is irreversible if the undo stack is not enabled when performing undoable edit operations, or the undo stack is enabled, but incomplete due to the limitation of stack depth and/or stack byte size. Also disabling widget option -undo will become an irreversible state if the undo stack was not empty at this time. A change of this state, if caused by an operation with (eventual) effects on the (representation of the) text content (see edit altered for details), will trigger the virtual event <<Irreversible>>. The state will be resetted to false if one of the following commands will be performed: clear, load, edit reset, or edit reset undo (but not edit reset redo). The state will also be resetted to false when widget option -undo will be enabled.

With the introduction of the 'irreversible' state, in conjunction with the new undo stack implementation, all the hacks in the original implementation – with dirty handling mode, and temporarily resetting the undo state –, are gone, now it's a solid implementation. Despite this it's an useful information for software developers whether the content is irreversible at a certain point, some GUI states can be set accordingly.