TIP #466: Revised Implementation of the Text Widget


TIP:466
Title:Revised Implementation of the Text Widget
Version:$Revision: 1.10 $
Authors: François Vogel <fvogelnew1 at free dot fr>
Gregor Cramer <remarcg at gmx dot net>
State:Draft
Type:Project
Tcl-Version:8.7
Vote:Pending
Created:Friday, 10 March 2017
Keywords:Tk, text widget

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 [1] 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 [2] but these are the key points:

* Long line problem, especially with many tags, is eliminated

in general only O(N log N) in revised version, was a higher order polynomial time in legacy code.

* Display is faster

smoother scrolling, faster response time. [3]

* Undo/redo is much faster

a completely new implementation has been worked out, directly working on the text segments. [4]

New Features

Detailed explanations and rationales for each of the items below can be found at [5]

Bug Fixes

* Trimming spaces

Issue #1082213 is invalid, the fix put in trunk (8.7) has been reverted (but there is now the new option -spacemode that can be set to trim)

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

Known Issues in the Revised Implementation

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

Also, the following should be noted:

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 [6] 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 TIP #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.

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.


Powered by Tcl[Index] [History] [Edit] [HTML Format] [Source Format] [LaTeX Format] [Text Format] [XML Format] [*roff Format (experimental)] [RTF Format (experimental)]

TIP AutoGenerator - written by Donal K. Fellows