Fossil Forum

feature request: new setting "wrap mode" in "gdiff -tk"
Login

feature request: new setting "wrap mode" in "gdiff -tk"

feature request: new setting "wrap mode" in "gdiff -tk"

(1) By anonymous on 2021-07-08 07:19:15 [source]

The wrap mode "none" is fixed in the source code of Fossil. It would be nice to have a Fossil setting for this in order to change it to "word" or "char".

(2) By Stephan Beal (stephan) on 2021-07-08 07:54:16 in reply to 1 [link] [source]

The wrap mode "none" is fixed in the source code of Fossil

Those particular diffs are designed such that they can be saved as a tcl script and passed on independently of fossil. That argues for the toggle being built into the diff's UI, rather than a fossil setting. Whether or not that's feasible with the current implementation, i can't say off hand, though.

FWIW, i've use the tk diffs as my primary diff approach since years, daily, and the current default has never proven problematic for me. If it can't be toggled in the UI, adding a flag to the diff command would be my strong preference over adding an almost-never-needed config option for it.

In any case, i'll take a look at it later on.

(3) By Stephan Beal (stephan) on 2021-07-08 08:53:29 in reply to 2 [link] [source]

Those particular diffs are designed such that they can be saved as a tcl script and passed on independently of fossil. That argues for the toggle being built into the diff's UI, rather than a fossil setting. Whether or not that's feasible with the current implementation, i can't say off hand, though.

First the bad news:

The styling for the -tk diff is baked into the TCL part of the diff and the C code does not, without significant surgery, have a way to rewrite any of that script.

The good news:

My very-first-ever bit of tk code adds a "wrap" toggle button to the -tk window which can toggle between none/word wrap modes. It should arguably toggle between none/char mode, but let's start with this and see how it turns out:

src:132340e6f77a38e3

(4.1) By Stephan Beal (stephan) on 2021-07-08 12:42:53 edited from 4.0 in reply to 3 [link] [source]

The good news: My very-first-ever bit of tk code adds a "wrap" toggle button to the -tk window which can toggle between none/word wrap modes.

And back to the bad news: wrapping doesn't work properly with the line numbers. Each wrapped line adds new lines to the output and those lines get new numbers. Thus that feature was rolled back. Sorry about that.

Edit: those line numbers are in a different column than the diff text so cannot be told to wrap along with the diff lines. The only "fix" i see in for this is to move the line numbers into the same element as the diff text, but that would mean that the line numbers would be selected when one wants to copy text from the diff widget, which would be horrible.