Triple-click to select logical line #23232

Closed
opened 2026-01-31 08:36:07 +00:00 by claunia · 8 comments
Owner

Originally created by @ebarzilay-godaddy on GitHub (May 5, 2025).

Description of the new feature

One very useful feature of xterm is that triple-clicking will (by default) select a whole logical line.

When is it useful?

Imagine sshing to some server and looking at a json-per-line log file with long lines. Looks like something is wrong in some area on the screen, so you want to look at that whole line -- how do you do that?

With xterm, I triple-click, and get the whole line. Winterm, OTOH, will select just the random physical line I clicked on.

I think that not only would it be good to have this functionality, it would also be better than the default in many cases.

Proposed technical implementation details

I don't know how it's implemented, but it looks like winterm does keep track of logical lines, so that information could be used instead of the physical line.

(I'm guessing the above because resizing the window shows that the logical lines are rewrapped; and also if I select a bunch of physical lines that come from a number of long lines, the resulting text has the proper logical newlines, rather than having them at the points where the text got wrapped.)

Originally created by @ebarzilay-godaddy on GitHub (May 5, 2025). ### Description of the new feature One very useful feature of xterm is that triple-clicking will (by default) select a whole ***logical*** line. ## When is it useful? Imagine sshing to some server and looking at a json-per-line log file with long lines. Looks like something is wrong in some area on the screen, so you want to look at that whole line -- how do you do that? With xterm, I triple-click, and get the whole line. Winterm, OTOH, will select just the random physical line I clicked on. I think that not only would it be good to have this functionality, it would also be better than the default in many cases. ### Proposed technical implementation details I don't know how it's implemented, but it looks like winterm *does* keep track of logical lines, so that information could be used instead of the physical line. (I'm guessing the above because resizing the window shows that the logical lines are rewrapped; and also if I select a bunch of physical lines that come from a number of long lines, the resulting text has the proper logical newlines, rather than having them at the points where the text got wrapped.)
Author
Owner

@ebarzilay-godaddy commented on GitHub (May 5, 2025):

Sorry, forgot to add that #9881 looks related, but the issue there is choosing just the user input, and nothing about what is the "line" that gets selected.

@ebarzilay-godaddy commented on GitHub (May 5, 2025): Sorry, forgot to add that #9881 looks related, but the issue there is choosing just the user input, and nothing about what is the "line" that gets selected.
Author
Owner

@j4james commented on GitHub (May 5, 2025):

See also #1553.

@j4james commented on GitHub (May 5, 2025): See also #1553.
Author
Owner

@DHowett commented on GitHub (May 7, 2025):

I think this is a good call! We should do this (and I don't necessarily think we should make it configurable.) It just makes sense.

@DHowett commented on GitHub (May 7, 2025): I think this is a good call! We should do this (and I don't necessarily think we should make it configurable.) It just makes sense.
Author
Owner

@albus-droid commented on GitHub (May 8, 2025):

06f736bebe/src/cascadia/TerminalControl/ControlCore.cpp (L2032-L2035)

06f736bebe/src/cascadia/TerminalCore/TerminalSelection.cpp (L299-L302)

06f736bebe/src/buffer/out/Row.cpp (L182)

I noticed that .WasWrapForced() marks wrapped rows in the buffer. Would using this in SelectionExpansion::Line for selection be the right approach to implement this?

@albus-droid commented on GitHub (May 8, 2025): https://github.com/microsoft/terminal/blob/06f736bebe84eda0c34b935a875eebe031a899b7/src/cascadia/TerminalControl/ControlCore.cpp#L2032-L2035 https://github.com/microsoft/terminal/blob/06f736bebe84eda0c34b935a875eebe031a899b7/src/cascadia/TerminalCore/TerminalSelection.cpp#L299-L302 https://github.com/microsoft/terminal/blob/06f736bebe84eda0c34b935a875eebe031a899b7/src/buffer/out/Row.cpp#L182 I noticed that `.WasWrapForced()` marks wrapped rows in the buffer. Would using this in `SelectionExpansion::Line` for selection be the right approach to implement this?
Author
Owner

@DHowett commented on GitHub (May 8, 2025):

I think so, yes!

@DHowett commented on GitHub (May 8, 2025): I think so, yes!
Author
Owner

@albus-droid commented on GitHub (May 8, 2025):

I'm interested to work on this

@albus-droid commented on GitHub (May 8, 2025): I'm interested to work on this
Author
Owner

@DHowett commented on GitHub (May 8, 2025):

Give it a shot! We would love to review a pull request for this. 😃

@DHowett commented on GitHub (May 8, 2025): Give it a shot! We would love to review a pull request for this. 😃
Author
Owner

@albus-droid commented on GitHub (May 8, 2025):

I have created a draft PR and would be happy to make any changes

@albus-droid commented on GitHub (May 8, 2025): I have created a draft PR and would be happy to make any changes
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#23232