Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

distinguish q & Q, let latter exit without clearing screen #36

Closed
jimc opened this issue Nov 26, 2019 · 13 comments
Closed

distinguish q & Q, let latter exit without clearing screen #36

jimc opened this issue Nov 26, 2019 · 13 comments

Comments

@jimc
Copy link

jimc commented Nov 26, 2019

less has -XF options (iirc) that suppress clearing of screen on exit.
However, it is inconvenient to choose that before starting the browse.

ISTM it would be easy to assign different exit behavior (already possible)
to some of the :q command variations. My 1st try would prolly be to
assert those --options just before exit, but thats pure WAG.

@gwsw
Copy link
Owner

gwsw commented Dec 22, 2019

The -X flag doesn't specifically suppress clearing the screen, it suppresses (both) the terminal init and deinit sequences. Normally the init sequence is sent when less starts and the deinit is sent just before it exits. If you were to enter less without -X, it would send the init sequence, and if you later chose to exit without sending the deinit sequence, the terminal could be left in an inconsistent state (where arrow keys don't work correctly among other things). That's why -X is one of the few flags that can't be changed from within less.

@mcornella
Copy link

mcornella commented Dec 26, 2019

Could there be a mode where less always enters and exits the alternate screen, but upon doing so, the last printed page is also printed to the primary screen? Is something like that technically possible? This would fix the use case where a large file is scrolled through and its contents pollute the main screen, when what you really want preserved is what you last saw.

EDIT: I realize this is not technically on-topic. Let me know if I should open a new issue.

@gwsw
Copy link
Owner

gwsw commented Sep 5, 2021

Added --redraw-on-quit option in d081e3e to redraw the final screen after switching back from alternate screen. You can make Q invoke this behavior by adding this line to your .lesskey file.

Q toggle-option -!^Predraw-on-quit\nq

@mcornella
Copy link

@gwsw there's a bug when combined with -F when the input is smaller than a window, see:

Captura de pantalla de 2021-09-06 11-17-03

There are two bugs I see here:

  1. Both -F and --redraw-on-quit print the contents.
  2. --redraw-on-quit prints extra ~ characters.

@gwsw
Copy link
Owner

gwsw commented Sep 7, 2021

Should be fixed in dd9a11a.

@mcornella
Copy link

Works great now, thanks!

@gwsw gwsw closed this as completed Oct 19, 2021
@bew
Copy link

bew commented Oct 21, 2021

Added --redraw-on-quit option in d081e3e to redraw the final screen after switching back from alternate screen. You can make Q invoke this behavior by adding this line to your .lesskey file.

Q toggle-option -!^Predraw-on-quit\nq

Hello, I'm interested in this feature, when do you plan on making a release with it? (on https://greenwoodsoftware.com/)
Thank you

@gwsw
Copy link
Owner

gwsw commented Dec 10, 2021

@bew less-598 is now available for beta testing and includes this feature.

@bew
Copy link

bew commented Dec 10, 2021

Thank you @gwsw, I've noticed a few things(/bugs?) that prevent me from using that option just yet.
I've created #231 with my findings :)

@Chealer
Copy link

Chealer commented Jul 20, 2023

Thank you very much @jimc , @gwsw and @mcornella

Unfortunately this very useful option remains undocumented in the relevant FAQ entry.

@gwsw
Copy link
Owner

gwsw commented Jul 21, 2023

I've added a mention of --redraw-on-quit to the FAQ entry.

@Chealer
Copy link

Chealer commented Jul 21, 2023

Thank you @gwsw
But indicating the minimum version required for that option would be relevant at this time (no Red Hat Enterprise Linux release nor even Debian has it).

@gwsw
Copy link
Owner

gwsw commented Jul 21, 2023

Ok, done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants