TIP 466: Revised Implementation of the Text Widget

Login
Author:         François Vogel <[email protected]>
Author:         Gregor Cramer <[email protected]>
State:          Draft
Type:           Project
Vote:           Pending
Created:        10-Mar-2017
Post-History:   
Keywords:       Tk,text widget
Tcl-Version:    9.1
Tk-Branch:      revised_text

Abstract

This TIP proposes the replacement of the current implementation of the text widget (the "legacy" text widget) by a revised implementation offering a large number of advantages.

Rationale

The Tk text widget has become increasingly complex as long as incremental improvements and features have been added from time to time. In that process, some known long-standing issues have become very difficult to tackle, for instance the long line problem regarding lack of performance.

Gregor Cramer, in the process of using the text widget in one of his applications, has analyzed the issues the current text widget is suffering from, and has come up with a new implementation having the following main advantages:

Proposal

The proposal is to replace the legacy code with the new implementation.

The author of the revised implementation has written a well documented website http://scidb.sourceforge.net/tk/revised-text-widget.html describing in details the issues with the legacy code, how he fixed these issues, and what features he has changed or improved.

It was not deemed feasible nor necessary to copy/paste/reformat all the information of the above website into the present TIP. Only the new features and incompatibilities are highlighted here, as opposed to detailed rationales about each change.

A version of the text man page, consistent with the changes and improvements proposed by the present TIP, can be seen at http://scidb.sourceforge.net/tk/text.html This version of the man page is colorized, with blue meaning "changed", and green meaning "new", so that it is easier to spot what's different from the legacy text widget.

Performance Improvements

Detailed performance comparison between legacy code and revised code can be found at http://scidb.sourceforge.net/tk/comparison.html but these are the key points:

New Features

Detailed explanations and rationales for each of the items below can be found at http://scidb.sourceforge.net/tk/revised-text-widget.html

Bug Fixes

Details on each of these bugs can be found in the "Bugs/Issues in Original Implementation" section at http://scidb.sourceforge.net/tk/revised-text-widget.html

Incompatibilities with Legacy Version

Based on the author's website, the following incompatibilities are currently known:

Deprecated Commands and Options

Drawbacks

Detailed memory comparison between legacy code and revised code can be found at http://scidb.sourceforge.net/tk/comparison.html

Miscellaneous

Target Release

Given the amount of changes, also because of our usual precautions regarding backwards compatibility, and despite the very high quality of the code and the fact it passes (almost all) the previously existing test suite, it is deemed reasonable to target Tcl/Tk 8.7 (or 9.0), but neither the 8.6 nor the 8.5 streams of releases, which will continue to implement the legacy text widget code.

Support of versions back to 8.5 is currently included in the revised code, but will be removed (because it's useless for use in trunk only) at the time the new code will get merged into trunk.

Implementation

Implementation of the revised text widget code has been placed in branch https://core.tcl-lang.org/tk/timeline?r=revised_text of the fossil repository.

This implementation compiles on Linux, Windows, and OS X. It respects the standards of Tk (C99 standard, and also the Tcl source code formatting described in [247]).

The man page for the text widget has been contributed by jima and is included in the revised_text branch.

The expected results of many tests were adjusted to take into account that the revised implementation is better optimizing, so some trace results of display line computation are different. Other adjustments were required because of bug fixes.

Known Issues in the Revised Implementation

Based on the author's website, currently only these issues are known:

Also, the following should be noted:

Known bugs

Two bugs, namely [a34b49f8c6] and [6a78781cc3], make the corresponding testcases fail but these are not the only known bugs. The complete list of known bugs can be requested from the Tk bug tracker: https://core.tcl-lang.org/tk/rptview?rn=27

Open Questions

Copyright

This document has been placed in the public domain.

The author of the revised text widget code has explicitly placed his code of the text widget under the same license as Tcl.