[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Which Diff tool could I use for visually comparing two text files where Word Wrap is possible?



On 04/04/2023, davidson <davidson@freevolt.org> wrote:
    To: debian-user@lists.debian.org
    Subject: Re: Which Diff tool could I use for visually comparing
two text files where Word Wrap is possible?
    From: davidson <davidson@freevolt.org>
    Date: Tue, 4 Apr 2023 11:06:47 +0000 (UTC)
    Message-id: <[🔎] [🔎] alpine.DEB.2.21.2304041106390.12607@azone.org>
    In-reply-to: <[🔎]
[🔎] CAEG4cZUbT-mfzN4rn1OdMyemA0tmUFAUwZCH1S3PBC+z7w2aVw@mail.gmail.com>
    References:
<CAEG4cZU336q12B2DXH_O52=00up2fG+sd8Oz3WjKXou+Y1Menw@mail.gmail.com>
<CAEG4cZW5aXEVwx0dZrOhcD2q44S8g75OGgUH+hrVe23joqPz0A@mail.gmail.com>
<[🔎] [🔎] CAEG4cZUS4DYT02PVm5bYvrpxTxVDEYBTHFGWHRHi80uPoY962A@mail.gmail.com>
<[🔎] [🔎] CAEG4cZVrPz=aZN6C0V0J3EPYMrH=UGkWcbVCc8xY=31FF_PqQA@mail.gmail.com>
<[🔎] [🔎] CAEG4cZUXaUAxG=0zLWpXuY44X9RTf7TNEwvGfuDDMZQ7iLEfzA@mail.gmail.com>
<[🔎] [🔎] CAEG4cZVcE+49-MKWGW7Le3L1T6ztSak7JD3KchkEVFGH30366w@mail.gmail.com>
<[🔎] [🔎] CAEG4cZWKu1LVJY_Js+VtXA00tVEDPR_JuPaCJ=jrqeRAe4413w@mail.gmail.com>
<[🔎] [🔎] CAEG4cZU4ZCCbKC9FFF66nwWr2ubD_1p_z1BDNHRh_sjP3ikEYg@mail.gmail.com>
<[🔎] [🔎] CAEG4cZXvzBMjbsRRih6Ku1wSJN0oWP_=Y_TLFBUOObGPLiOKxg@mail.gmail.com>
<[🔎] [🔎] CAEG4cZUbT-mfzN4rn1OdMyemA0tmUFAUwZCH1S3PBC+z7w2aVw@mail.gmail.com>


[   ...   ]

> No mistakes means no learning. Learning how to make mistakes, to dare
> the facts to expose one's false beliefs, is a great art.

[   ...   ]

>     Would it be possible to increase the column length for the either of
>     the two files being compared,

I apologise for my yet another idiotic choice of word. It should have
been "width", not "length".

[   ...   ]
> I take this to mean that you would like to increase the length of
> lines displayed...
[   ...   ]
> ...in order to maximise the use of screen real estate.
>
> That is, you'd like to be shown as many characters on one screen as
> possible, without a lot of wastefully empty margins.
>
> (I expect I have overstated your intent here. Do correct me.)

There can absolutely be no need for correcting you. You have extracted
what I really meant from my poor choice of words. Yes, more "column
width" would reflect in "longer lines" without wasting empty margins.
PERFECT. Thank you indeed.


> It looks to me like icdiff tries to remain faithful to the source
> comparands, to the files you request it to compare.
>
> More concretely: Let's say the source files have newlines at a
> position no greater than column 55 (say). This means a side-by-side
> comparison will require about 113 columns.
>
> Since you have a giant display that can accomodate far more than that,
> icdiff displays sizeable righthand margins on each half of a maximised
> terminal window.
>
> So you would like icdiff to "flow" the text when it displays each
> source on its half of the terminal. You would like icdiff to replace
> newlines with spaces, and then wrap them (ie, inserting new newlines)
> as appropriate to fill up the right margins on each half.
>
> icdiff will not do that. icdiff is faithful to its sources. I have
> determined this by trying it out a little myself, and by examining the
> command line options documented in its manual page ("man icdiff").
>
> You could give it different sources:
>
>  $ icdiff <( tr '\n' ' ' <file1 ) <( tr '\n' ' ' <file2 )
>
> You can define a function to do the same thing, to save some typing at
> future invocations,
>
>  $ icdiff-flowed () { <( tr '\n' ' ' <file1 ) <( tr '\n' ' ' <file2 ) ; }
>
> and then use it like so
>
>  $ icdiff-flowed file1 file2 | less -R
>
> I imagine this is not quite what you want. But this seems like a good
> place to pause, to give you an opportunity to correct me, or to
> elaborate on the requirements.

Perfectly set to go.

>     If that is not possible
>
>
> I expect it is, but I may not yet fully understand what you are
> looking for.

Yes, you really did step into my shoes. Thank you indeed.

So the final steps should look like this:
Define a unique function:
icdiff-flowed () { icdiff <( tr '\n' ' ' <"$1" ) <( tr '\n' ' ' <"$2" ) ; }

Then use that function:
icdiff-flowed file1 file2 | less -R

Perfect.

But I received an error when the lxterminal screen was the default size:
RecursionError: maximum recursion depth exceeded while calling a Python object

When the screen was maximised, I received an output, but all
line-breaks, paragraph breaks, distinctions, separate colours, et al,
were made into two colours, one for the new file and one for the old.

May be the translation of '\n' into blank space ' ' is creating the
problem. Removing all formatting. Could the creators/maintainers be
contacted to amend the program to adjust column width? Is there a way
to set icdiff's column width?

Could you please change the html files you had used for
experimentation into text files and then run the experiment again? To
see if our objectives could be fulfilled?

Thanks once more.

Best wishes,
Rajib
Etc.


Reply to: