Skip to content

Commit

Permalink
0.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
MacHu-GWU committed Oct 30, 2023
1 parent 0ca73d8 commit de97f7a
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 7 deletions.
13 changes: 12 additions & 1 deletion release-history.rst
Expand Up @@ -15,7 +15,18 @@ x.y.z (Backlog)
**Miscellaneous**


0.2.1 (2023-10-28)
0.2.2 (2023-10-30)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**Minor Improvements**

- Allow user to custom the following shortcut keys's behavior:
- ``Ctrl + T``
- ``Ctrl + G``
- ``Ctrl + B``
- ``Ctrl + N``


0.2.1 (2023-10-30)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
**Features and Improvements**

Expand Down
2 changes: 1 addition & 1 deletion zelfred/_version.py
@@ -1,4 +1,4 @@
__version__ = "0.2.1"
__version__ = "0.2.2"

if __name__ == "__main__": # pragma: no cover
print(__version__)
11 changes: 6 additions & 5 deletions zelfred/keyboard.py
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-

from sys import platform

from readchar import key

UP = key.UP # select the previous item in dropdown menu.
Expand All @@ -19,22 +21,21 @@
CTRL_W = key.CTRL_W # user action
CTRL_E = key.CTRL_E # select the previous item in dropdown menu.
CTRL_R = key.CTRL_R # scroll up
CTRL_T = key.CTRL_T
CTRL_T = key.CTRL_T # user custom shortcut
CTRL_U = key.CTRL_U # user action
CTRL_P = key.CTRL_P # user action
CTRL_A = key.CTRL_A # user action
CTRL_D = key.CTRL_D # select the next item in dropdown menu.
CTRL_F = key.CTRL_F # scroll down
CTRL_G = key.CTRL_G
CTRL_G = key.CTRL_G # user custom shortcut
CTRL_H = key.CTRL_H # DON'T USE THIS, IT DOESN'T WORK ON WINDOWS
CTRL_K = key.CTRL_K # delete previous word
CTRL_L = key.CTRL_L # delete next word
CTRL_X = key.CTRL_X # clear the user input.
CTRL_C = key.CTRL_C # keyboard interrupt
CTRL_B = key.CTRL_B
CTRL_N = key.CTRL_N
CTRL_B = key.CTRL_B # user custom shortcut
CTRL_N = key.CTRL_N # user custom shortcut

from sys import platform

if platform.startswith(("linux", "darwin", "freebsd")):
ALT_LEFT = "\x1bb" # move to previous word
Expand Down
37 changes: 37 additions & 0 deletions zelfred/ui_process_key_pressed.py
Expand Up @@ -281,6 +281,38 @@ def process_f1(self: "UI"):
"""
raise exc.JumpOutLoopError

def process_ctrl_t(self: "UI"):
"""
Default behavior:
Do nothing. This is reserved for user custom shortcut.
"""
self.wait_next_user_input()

def process_ctrl_g(self: "UI"):
"""
Default behavior:
Do nothing. This is reserved for user custom shortcut.
"""
self.wait_next_user_input()

def process_ctrl_b(self: "UI"):
"""
Default behavior:
Do nothing. This is reserved for user custom shortcut.
"""
self.wait_next_user_input()

def process_ctrl_n(self: "UI"):
"""
Default behavior:
Do nothing. This is reserved for user custom shortcut.
"""
self.wait_next_user_input()

def _create_key_processor_mapper(self):
self._key_processor_mapper = {
# dropdown menu
Expand Down Expand Up @@ -311,6 +343,11 @@ def _create_key_processor_mapper(self):
keyboard.CTRL_W: self.process_ctrl_w,
keyboard.CTRL_P: self.process_ctrl_p,
keyboard.F1: self.process_f1,
# user custom shortcut
keyboard.CTRL_T: self.process_ctrl_t,
keyboard.CTRL_G: self.process_ctrl_g,
keyboard.CTRL_B: self.process_ctrl_b,
keyboard.CTRL_N: self.process_ctrl_n,
}

def _process_key_pressed_input(self: "UI", key: str):
Expand Down

0 comments on commit de97f7a

Please sign in to comment.