tats / w3m

Debian's w3m: WWW browsable pager
https://tracker.debian.org/pkg/w3m
Other
872 stars 94 forks source link

Feature suggestion: "clickable" links using keyboard shortcuts #188

Open DanBiscotti opened 3 years ago

DanBiscotti commented 3 years ago

Hi there,

I noticed on other browsers (qutebrowser, chrome with vimium) that there is a feature which might be well suited to w3m as well. I'm not sure how you call it, but when you press the "f" key all hyperlinks visible in the window have a 1 or 2 key combination assigned to them. Then to follow that link you can type that combination.

Also capital F would produce the same combinations but opening in a new tab

I don't have much experience with C but would be happy to give it a try if the maintainers think it's possible/not too difficult!

rkta commented 3 years ago

On Tue, Jul 27, 2021 at 10:50:31AM -0700, Dan Scott wrote:

Hi there,

I noticed on other browsers (qutebrowser, chrome with vimium) that there is a feature which might be well suited to w3m as well. I'm not sure how you call it, but when you press the "f" key all hyperlinks visible in the window have a 1 or 2 key combination assigned to them. Then to follow that link you can type that combination.

Also capital F would produce the same combinations but opening in a new tab

I don't have much experience with C but would be happy to give it a try if the maintainers think it's possible/not too difficult!

There is MOVE_LIST_MENU, I have it mapped to f. I don't remember what the default is.

I'm not sure how to emulate F, though.

gotbletu commented 3 years ago

is usually refer to as Hinting mode/Hint mode and yes w3m already has it built-in, you just need to enable it. It uses numbers not characters but is the same idea.

in the options panel > Display Link Number [Yes] > OK usage: press 3[ to jump to link 3 example video: https://www.youtube.com/watch?v=8-11SkjJVdo

if you want to rebind the key to use f to jump instead e.g press 3f keymap f LINK_BEGIN e.g press 3F to open in new tab keymap F COMMAND "LINK_BEGIN; TAB_LINK" quick toggle hinting mode on/off keymap = COMMAND "SET_OPTION display_link_number=toggle ; RESHAPE"

Boruch-Baum commented 3 years ago

There is another way to invoke the feature, that has the advantage of being useful for other purposes:

Use default keybinding M-c to get a type of "command prompt" that accepts any w3m function defined in the documentation file README.func (usually /usr/share/doc/w3m/README.func).

From the prompt, enter LIST_MENU to raise a pop-up window of links and their shortcut keys.

The command prompt maintains a history, so in the future just press the up arrow key.

Use this for any w3m function, even if it has no keybinding.

-- hkp://keys.gnupg.net CA45 09B5 5351 7C11 A9D1 7286 0036 9E45 1595 8BC0

DanBiscotti commented 3 years ago

I tried both methods out and had some comments:

Would it be feasable to add a command which sort of combines these two methods? eg. similar to LIST_MENU which creates those key shortcuts, but instead of bringing up the menu, it places them in the square brackets next to the link (like in the display_link_number)? And then rather than 1a,1b,1c etc, prioritizes the home row for ease of typing

I think that would improve navigating experience/speed, but yeah just a suggestion!

gotbletu commented 3 years ago

that would be nice to toggle on hinting mode then press a-z hotkey then it auto toggle off again, like in gui browsers. think the reason why it uses 0-9 instead of a-z keys because most of those a-z keys are already binded (think vim normal mode). the list_menu popup menu has a different mode so any hotkeys in your keymap file does not work in there, thats why you can use a-z/0-9

rkta commented 2 days ago

Here is a proposed patch adding such a feature, feedback welcome:

https://lists.sr.ht/~rkta/w3m/%3CD5I83E14H3BV.1G1B36FRGFD8H@proton.me%3E

@DanBiscotti @gotbletu