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

Add Alt-U shortcut to clear search highlight #268

Closed
wants to merge 1 commit into from

Conversation

tiymat
Copy link

@tiymat tiymat commented Feb 16, 2025

Adds the Alt-U keybinding from less to clear highlights on searched text.

@walles
Copy link
Owner

walles commented Feb 20, 2025

How did you test this? You can run ./moar.sh with the same command line parameters as moar to try your changes locally.

Your PR did not work for me when I tested it.

Also, from less --help:

  ESC-u                Undo (toggle) search highlighting.
  ESC-U                Clear search highlighting.

An Alt-combination might have worked, but Esc (same as ESC, short for "Escape") is used for exiting moar (and a lot of other things on different systems), so that's not something I'll be supporting as a prefix.

@tiymat
Copy link
Author

tiymat commented Feb 21, 2025

How did you test this? [...] Your PR did not work for me when I tested it.

I tested it using the moar binary I built (with go build) after making my changes. I just tried with moar.sh and it also worked. My exact commands were

  1. ./moar.sh ./go.mod
  2. /req
  3. ENTER
  4. ALT-u

and the highlighted occurrences of req cease to be highlighted. The same keystrokes work in less for me. I don't have any config for moar or less. Maybe it's something keyboard related. Out of curiosity, I tried in a different shell and different terminal and it continued to work.

My reason for this PR is that when reading a large file I will commonly use a search to find a specific part of the file. However, after I've found the part of the file I want, I no longer need the text to be highlighted, and find it distracting.

@tiymat
Copy link
Author

tiymat commented Feb 21, 2025

If you'd prefer it to use a different Alt-combination I could certainly make that change. Otherwise, if you aren't interested in this shortcut being in moar, I can close the PR.

Either way, thanks for your work developing and maintaining moar :)

@walles
Copy link
Owner

walles commented Feb 22, 2025

I'm missing something here.

Adds the Alt-U keybinding from less to clear highlights on searched text.

In less, Alt-U does nothing.

Is this PR about adding less' ESC-U key combination to moar?

Or is this PR about adding Alt-U support to moar, which less does not have?

What am I missing here?

Alt key combos might work, but I'm skeptical about ESC.

@tiymat
Copy link
Author

tiymat commented Feb 25, 2025

I'm still very surprised that the key combination doesn't do anything for you. I've tried on both Arch and Ubuntu, and I've switched keyboard layouts from US English to a couple of European ones (German and Swedish) and it behaved the same every time.

I can see in less that pressing Alt-u results in the \033u command being processed, which it maps to ESC-u. I might try to dig further into the code that gets that command this weekend if I get a chance. I guess I'll close this PR though, as it seems my setup is behaving differently than others' so I can't properly test my PR.

@tiymat tiymat closed this Feb 25, 2025
@walles
Copy link
Owner

walles commented Feb 25, 2025

I'm still very surprised that the key combination doesn't do anything for you.

Which key combination? Alt-U or ESC-u?

There is no connection between the two.

pressing Alt-u results in the \033u command being processed, which it maps to ESC-u.

When you say that Alt-u "maps to ESC-u", can you clarify this?

Alt and ESC are completely unrelated.

When you say that one "maps to" the other, what exactly do you mean by that?

Sorry if I'm being dense here, but I'm super confused.

@walles
Copy link
Owner

walles commented Feb 25, 2025

Or put in another way, which of these two are you after?

  1. Press and release ESC, then press and release u
  2. Press and hold Alt, then press and release u, then release Alt

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

Successfully merging this pull request may close these issues.

2 participants