Add visited pages history back/forward keys (#204)

* Add keys for back and forward through history

Move through history of visited rooms without altering it.
Ctrl+H and Ctrl+Y by default.
Deviating from history while in the middle of it
causes a part of history to be discarded.

* Change default history binding to Ctrl+H and Ctrl+Shift+H

* Rename functions and settings

`earlier_page` and `later_page` is consistent naming with `last_page`

* Add option to wrap history

If you press `later_page` while at index 0 (newest), you loop to the end
of recorded history (oldest). If you press `earlier_page` while at at
the end of history (oldest), you loop back to the top (newest).
This can be disabled.

* Add showNthFromHistory

Grouped duplicated code into a new funcion.

* Minor formatting changes

* Move wrap_history setting from to General section

The Keys section is purely for keybindings; this setting should also be
able to control history navigation not done by keyboard such as extra
mouse button bindings.

* Change default bind for later_page and clear_all

Ctrl+H and Ctrl+L are a more intuitive pair than Ctrl+H and Ctrl+Shift+H.
Meanwhile, clear_all does not need the accessible binding Ctrl+L.

Co-authored-by: miruka <miruka@disroot.org>
This commit is contained in:
Maze
2021-04-06 00:57:19 +02:00
committed by miruka
parent f88ab45b94
commit c140d69138
2 changed files with 60 additions and 7 deletions

View File

@@ -17,6 +17,10 @@ class General:
# right room pane is visible at a time.
hide_side_panes_under: int = 450
# Whether to wrap around or do nothing when using the earlier_page or
# later_page keybinds and reaching the start or end of the history.
wrap_history: bool = True
# How many seconds the cursor must hover on buttons and other elements
# to show tooltips.
tooltips_delay: float = 0.5
@@ -253,6 +257,11 @@ class Keys:
# Switch to the last opened page/chat, similar to Alt+Tab on most desktops.
last_page = ["Ctrl+Tab"]
# Go throgh history of opened chats,
# similar to the "page back" and "page forward" keys in web browsers
earlier_page = ["Ctrl+H"]
later_page = ["Ctrl+L"]
# Toggle muting all notifications in the running client,
# except highlights (e.g. replies or keywords)
notifications_highlights_only = ["Ctrl+Alt+H"]
@@ -453,7 +462,7 @@ class Keys:
# Clear all messages from the chat.
# This does not remove anything for other users.
clear_all = ["Ctrl+L"]
clear_all = ["Ctrl+Shift+L"]
class ImageViewer:
# Close the image viewer. Escape can also be used.