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

Feature suggestion: Jump directly to next/previous URL #151

Merged
merged 3 commits into from
Jun 2, 2024

Conversation

ilekka
Copy link
Contributor

@ilekka ilekka commented May 30, 2024

When context view is enabled and the next URL is not visible on the screen, pressing j does not go directly to the next URL; instead, it seems to scroll down one line at a time until the URL is reached. The same applies to pressing k if the previous URL is off the screen.

Here I attempted to create the possibility to jump directly to the next/previous URL (bound to J and K by default.) This is done by creating a list of selectable item positions when the URLChooser class is initialized and adding functions which change focus to the next or previous position on the list according to the currently focused position.

Any comments are very welcome, especially if you see there is something wrong with my approach or the same outcome could have been achieved in some simpler way. This is very much possible as I am not experienced with urwid at all.

@firecat53
Copy link
Owner

Brilliant! That's been a long standing minor annoyance that I haven't fixed. Works perfectly...except when in compact mode where it fails pretty hard (crashes).

If you can fix that and update the README and man page with new keybindings I'll definitely merge this.

I'm not going to look and see if it can be simplified at this point. I'm no expert either and it works!

Thanks!!

@ilekka
Copy link
Contributor Author

ilekka commented May 31, 2024

Right - I forgot that the selectable positions must be updated if the items list itself is changed. This happens not only when context is switched on/off, but also after reversing the URLs and searching.

To fix this, I created a method in the URLChooser class which gets the selectable positions corresponding to the current list of items. In principle this seems slightly wasteful, since the selectable positions are now recalculated every time, even if there is no need to update them. However, in practice I couldn't actually see any visible difference in performance, not even on a very low-powered machine.

I have also added the new keybindings to the documentation.

@firecat53
Copy link
Owner

Awesome, works great! Thanks for the contribution and the interest!

@firecat53 firecat53 merged commit 0c2fb20 into firecat53:main Jun 2, 2024
@ilekka
Copy link
Contributor Author

ilekka commented Jun 2, 2024

Thank you for merging!

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