On Sun, Oct 02, 2022 at 09:22:03AM +0100, Chris Green wrote:
> On Sat, Oct 01, 2022 at 06:35:26PM -0400, Thomas Dickey wrote:
> > On Sat, Oct 01, 2022 at 10:01:00AM +0100, Chris Green wrote:
> > > Well it's not entirely off topic, it's about something that works as
> > > I'd expect it to in vile (and less) but doesn't work right in mutt (my
> > > E-Mail program of choice).
> > > 
> > > The issue is about how long chunks of text, with no spaces in them,
> > > are wrapped when they are too long to fit in the terminal width.  The
> > > typical case (and the one that is a particular problem in mutt) is
> > > that of long URLs.  This *isn't* about how these programs manage
> > > wrapping normal text made up of 'words' with spaces in between.
> > > 
> > > In less or vile when there is a long piece of text and you have told
> > > less/vile to wrap long lines then the long URL (or whatever) is
> > > displayed wrapped at the right margin but it is still a single string
> > > and you can select it in the terminal by right clicking on it.
> > > 
> > > In mutt (in mutt's internal pager specifically) however, although the
> > > URL is displayed the same (i.e. wrapped at the right margin) it's
> > > actually broken into one or more lines and you *can't* select it by
> > > right clicking on it, you just get the single line that you click on.
> > > 
> > > This has been discussed at length at various times on the mutt mailing
> > > list and hasn't been solved.
> > 
> > I'm subscribed to mutt-dev (don't recall it there).
> > Perhaps mutt-user...
> 
> Yes, it's mutt-users.
> 
> > 
> > (none of the mutt development gets very deep into this stuff)
> >  
> > > Is there some specific way of using/calling ncurses which does what we
> > > want?  ... and/or does ncurses default to breaking the string at the
> > > page margin and need some option to prevent it doing this?
> > 
> > It's a special case of xterm (imitated by more than one terminal emulator,
> > though probably not _all_).  xterm notices when a line is written and
> > wraps.  Screen updates that simply write to the end of a line (including
> > a previously "wrapped" line) make it forget about follow part of a line.
> > 
> I sort of understand. So you're saying that it's the xterm (or
> similar) that is inserting the LF after mutt has output a long string
> using ncurses.

When xterm is asked (by another client that wants to paste the selection)
for the selection, it copies from its window the characters for the
selected range of columns/lines.  As it does that, it checks at the end
of each line whether that was wrapped -- and adds a newline in that case.

Double-clicking on a line does the same thing -- extending the selection
to the entire (wrapped) line.

The "wrapped" term in a half-dozen places in xterm's manpage is talking
about this...
 
> > less and vile have an advantage over ncurses in deciding if a line is
> > wrapped -- ncurses can't tell if an application writes text (using one
> > of the wrapping calls such as waddch) intending to construct a long line.
> > 
> So vile and less manage the wrapping themselves whereas xterm does it
> for mutt - is that the difference?

no - vile and less just happen to work when they write a wrapped line.

If they were smarter and only wrote the parts of lines that changed,
then they wouldn't trigger the special handling in the terminal
emulator that tells _it_ that this is one long line.
 
> I thought vile used ncurses.

vile (in a terminal) could be termcap, terminfo or curses :-)

fwiw, it's terminfo in Debian, which makes vile doing the screen updates.

(ncurses provides terminfo, but that's a low-level feature which is
different from the higher-level stuff that mutt is using)
 
> > Actually, long lines in mutt for me have a "+" marking the beginning
> > of the following lines (which iirc is configurable).
> >  
> I have "set nomarkers" in my muttrc which turns the + off.  At least
> one can then manually select the long URL and paste it into a browser
> address bar (as long as the browser, correctly, inores the embedded
> LF). However right-clicking the URL would be much handier.

agreed, but without some planning in the code, curses will just update
the places on a screen which have changed, and one you add in scrolling,
it's hard to say whether the library should have tweaked its updates to
ensure that wrapped lines are pasted together again :-)
 
> > > I'm floundering a bit at understanding this as I'm not really sure
> > > it's an ncurses issue but it does seem to be pretty much the same
> > > regardless of other things.  I use /usr/bin/xfce4-terminal but the
> > > same happens to lots of other people and I have tried other terminal
> > > emulators and seen no change.
> > > 
> > > Can anyone throw any light on this?
> > > 
> > > -- 
> > > Chris Green
> > > 
> > 
> > -- 
> > Thomas E. Dickey <dic...@invisible-island.net>
> > https://invisible-island.net
> > ftp://ftp.invisible-island.net
> 
> 
> 
> -- 
> Chris Green
> 

-- 
Thomas E. Dickey <dic...@invisible-island.net>
https://invisible-island.net
ftp://ftp.invisible-island.net

Attachment: signature.asc
Description: PGP signature

Reply via email to