Skip to content

Improve keybindings#191

Open
ymcx wants to merge 14 commits into
tarkah:masterfrom
ymcx:improve-keybindings
Open

Improve keybindings#191
ymcx wants to merge 14 commits into
tarkah:masterfrom
ymcx:improve-keybindings

Conversation

@ymcx

@ymcx ymcx commented May 20, 2026

Copy link
Copy Markdown
Contributor

This PR completely changes how keybinds are handled by dividing the actions into their own files, organized by the screen/state. Before we had a global function that handled all keybinds in all states. This approach, however, is quite prone to errors, since it's not exactly clear which actions will work and in which states, especially considering the state matching is dependend on the sorting of the keybinds in the match operation in the keybind function. This separation will mean that fewer actions are shared between states by default unless explicitly defined.

I've tried to compile a comprehensive list of the changed keybindings. Most keybindings should match the old behavior 1:1, but there might be small deviances. Most notably I added some alternative keybindings to already existing actions, like using the VIM keybindings for moving in all screens that support moving (Even though this was already partly addressed in #185). I've attached a table containing all of the changed keybindings to the bottom of this comment.

The second big change is how selection is handled. With this change we're now able to see the selected stock in the summary view as well. The title of the highlighted entry is colored orange and it can be changed using the exact same keybindings as in the stock screen. Scrolling the view using the mouse in place of the arrow keys doesn't control the selection, but the reverse doesn't apply. Selecting a stock that isn't on the screen will scroll the view as far back as is necessary to show the item on the screen. When adding a new stock, the view scrolls to the very bottom in order to show the newly added item.

The third and perhaps the most noticable change is that from now on stocks can be selected using the arrow right/down and up/left keys rather than the tab key. The tab key on the other hand now modifies the time frame. I would've liked to keep the shortcuts as unchanged as possible, but I decided to make this compromise in order to align stock switching with stock moving. Previously stock switching was done using the tab key, but stock moving was done with the arrow keys while holding down the control key. Now both utilize the arrow keys with the same modifiers.

Just like what was done in #185, the original stock removal key 'k' was once again changed, this time to 'r'. K can't be used since it's colliding with the VIM movement-keys. R is the initial character of the word 'remove' and as such it should be intuitive for new users.

[PLACE]			[OLD KEYBIND]		-> [NEW KEYBIND]						[DESCRIPTION]

stock search:	esc                 -> esc|/          						close menu

chart config:	any+esc|any+e|any+q -> esc|e|q								close menu
chart config:	down|tab            -> down|j								down
chart config:	up|shit+tab         -> up|k									up
chart config:	left                -> left|h								left
chart config:	right               -> right|l								right

options menu:	c                   -> none									change chart type
options menu:	down                -> down|j								down
options menu:	up                  -> up|k									up
options menu:	left                -> left|h								left
options menu:	right               -> right|l								right

summary:		down|j              -> none									scroll down
summary:		up|k                -> none									scroll up
summary:		none                -> o									open options menu
summary:		none                -> e									open chart configuration
summary:		none                -> r|del								remove stock
summary:		none                -> right|l|down|j						switch tab right/down
summary:		none                -> left|h|up|k							switch tab left/up
summary:		none                -> ctrl+right|ctrl+l|ctrl+down|ctrl+j	move tab right/down
summary:		none                -> ctrl+left|ctrl+h|ctrl+up|ctrl+k		move tab left/up

stock:			ctrl+w              -> r|del								remove stock
stock:			tab                 -> right|l|down|j						switch tab right/down
stock:			shift+tab           -> left|h|up|k							switch tab left/up
stock:			ctrl+left|ctrl+h    -> ctrl+right|ctrl+l|ctrl+down|ctrl+j	move tab right/down
stock:			ctrl+right|ctrl+l   -> ctrl+left|ctrl+h|ctrl+up|ctrl+k		move tab left/up

summary&stock:	q                   -> q|esc								exit
summary&stock:	right|l             -> tab									switch time frame right
summary&stock:	left|h              -> shift+tab							switch time frame left
summary&stock:	none                -> end									select tab last
summary&stock:	none                -> home									select tab first

@ymcx

ymcx commented May 20, 2026

Copy link
Copy Markdown
Contributor Author

Apparently this branch I was holding onto was based on the old fix of #190, so this contains some regressions I need to fix before this can be merged, sorry. I was certain I updated it to match the approach of the merged PR, but apparently not. I'll check this tomorrow, since I'm quite tired right now and have work the next morning.

@ymcx ymcx marked this pull request as draft May 20, 2026 19:09
@ymcx ymcx marked this pull request as ready for review May 21, 2026 16:38
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.

1 participant