Re: [scintilla] Change history implementation

100 views
Skip to first unread message

Neil Hodgson

unread,
Jul 31, 2022, 10:49:24 PM7/31/22
to Scintilla mailing list, scite-i...@googlegroups.com
Change history is the common IDE feature of displaying a coloured bar in the margin to indicate which lines have been changed.

This has been committed to Scintilla and enabled in SciTE. The 'prehistory' aspect mentioned in the initial code isn't exposed although the underlying data structures still support it so there can be further experimentation to refine the design.

Original proposal:
https://scintilla.org/ChangeHistory.html

Applications may choose whether to enable change history and whether to show the history in the margin or inline or both. Change history depends on undo history so can only be enabled when the undo history is enabled and empty.

SciTE currently turns on both margin and inline history. This may be too much and it could be changed to just show in the margin before release.

Some new visual elements were added to better present change history: SC_MARK_BAR and INDIC_POINT_TOP. INDIC_POINT, INDIC_POINTCHARACTER, and INDIC_COMPOSITIONTHICK were tweaked. The default colours and shapes for change history were changed.

https://scintilla.org/ChangeHistory.png

SC_MARK_BAR is an outlined and filled rectangle that takes the full height of the line and 1/3 of the margin width. To give a connected appearance, it displays even on wrapped lines and draws end caps on the first and last line.

INDIC_POINT_TOP is the same as INDIC_POINT but draws at the top of the line instead of the bottom.

INDIC_POINT and INDIC_POINTCHARACTER were tweaked to be 1 pixel taller and 2 pixels wider in two-phase draw mode to be clearer.

The translucency of INDIC_COMPOSITIONTHICK can be changed with SCI_INDICSETOUTLINEALPHA.

Applications may override the default appearance and SciTE provides properties to do so.

To enable this feature in a basic way in an application, call SCI_SETCHANGEHISTORY(3) after enabling undo collection after loading files.

Available fro the Hg repositories and from
https://www.scintilla.org/scite.zip Source
https://www.scintilla.org/wscite.zip Windows executable (64-bit)

Neil

Neil Hodgson

unread,
Aug 8, 2022, 8:34:55 PM8/8/22
to Scintilla mailing list, scite-interest
An issue that has appeared with change markers is that SciTE's Revert command leads to the whole document getting a green change mark as revert just reloads each byte of the file. Since its useful to undo to before the revert, this point can't just be set as the start of change history to appear clear.

It may be possible to add a 'revert' state to the change history that could appear clear but its not obvious what the semantics of this state would be.

Running a diff between the on-disk file and in-memory document and only changing the ranges that differ would be possible and useful as the incoming changes would be visible. That is a bit complex so, for now, I've implemented a simpler version that finds the starting and ending ranges that are the same and replaces the range between them. This results in reasonable results in many circumstances.

This is implemented in SciTE and only works for moderate length (1MB) files in 8-bit encodings as it reads the whole file into a temporary buffer and then checks and modifies. A streaming version could be written that would handle larger files. Scintilla could also add an 'Update' API that could minimize change markers.
Reply all
Reply to author
Forward
0 new messages