rime for python,连接到某些prompt-toolkit应用程序(如ptpython)的prompt-toolkit快捷键
项目描述
pyrime
rime for python,连接到某些prompt-toolkit应用程序(如ptpython)的prompt-toolkit快捷键。
依赖关系
# Ubuntu
sudo apt-get -y install librime-dev librime1 pkg-config
sudo apt-mark auto librime-dev pkg-config
# ArchLinux
sudo pacman -S --noconfirm librime pkg-config
# Android Termux
apt-get -y install librime pkg-config
# Nix
# use nix-shell to create a virtual environment then build
# homebrew
brew tap tonyfettes/homebrew-rime
brew install librime pkg-config
# Windows msys2
pacboy -S --noconfirm pkg-config:x librime:x gcc:x
配置
~/.config/ptpython/config.py
:
from ptpython.repl import PythonRepl
from prompt_toolkit.filters import EmacsInsertMode, ViInsertMode
from prompt_toolkit.key_binding.key_processor import KeyPressEvent
from pyrime.prompt_toolkit import Rime
def configure(repl: PythonRepl) -> None:
rime = Rime(repl)
@repl.add_key_binding("c-^", filter=ViInsertMode())
@repl.add_key_binding("c-^", filter=EmacsInsertMode())
@repl.add_key_binding("c-^", filter=rime.mode())
def _(event: KeyPressEvent) -> None:
rime.toggle()
如果您定义了一些会干扰rime的快捷键,请尝试
@repl.add_key_binding("c-h", filter=rime.filter(EmacsInsertMode()))
def _(event: KeyPressEvent) -> None:
rime.toggle()
如果您想在ViNavigationMode()
中退出rime,请尝试
@repl.add_key_binding("escape", filter=EmacsInsertMode())
def _(event: KeyPressEvent) -> None:
""".
:param event:
:type event: KeyPressEvent
:rtype: None
"""
event.app.editing_mode = EditingMode.VI
event.app.vi_state.input_mode = InputMode.NAVIGATION
rime.conditional_disable()
# and a, I, A, ...
@repl.add_key_binding("i", filter=ViNavigationMode())
def _(event: KeyPressEvent) -> None:
""".
:param event:
:type event: KeyPressEvent
:rtype: None
"""
event.app.editing_mode = EditingMode.EMACS
event.app.vi_state.input_mode = InputMode.INSERT
rime.conditional_enable()
它将记住rime的状态,并在重新进入ViInsertMode()
或EmacsInsertMode()
时启用它。
此项目定义了一些实用函数。有关更多信息,请参考我的ptpython配置。
项目详情
下载文件
下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于安装软件包的信息。
源代码分发
pyrime-0.0.2.tar.gz (43.1 kB 查看哈希值)
构建的分发包
pyrime-0.0.2-cp311-cp311-win_amd64.whl (61.7 kB 查看哈希值)
关闭
pyrime-0.0.2.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 21d7df51deba61a13440b6f3ef31432a2e136f3126bb985f5341ed3c0fc4141e |
|
MD5 | 804b994052984bc94a504fe936e2ff3e |
|
BLAKE2b-256 | ce377f6712cbed050fe5a2ace7125af2bf20353f0c49e6c9e185d068dc6b473c |
关闭
pyrime-0.0.2-cp312-cp312-manylinux_2_17_x86_64.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 177926158c285c5ee76ea1f41146062f3567ff51b76b34a0c6109887f8603bfb |
|
MD5 | 62179ee3faaca7273ab9469b61ac62f0 |
|
BLAKE2b-256 | 44155e6914d584d770389d1bdff8f91c6a6f989e4317496c92b0c40bf98e1baf |
关闭
pyrime-0.0.2-cp312-cp312-macosx_14_0_arm64.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 80e271d0593372a7a1d32d3eff4f35dd3a48c37e36797dc27aafec4007f2d658 |
|
MD5 | 9437a897eef50fb1667664b0656e4a64 |
|
BLAKE2b-256 | 30ca8316c9c427b62fc82e57d3bc24f4140e1003e67a7d8da7b86976b454fa22 |
关闭
pyrime-0.0.2-cp311-cp311-win_amd64.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 87bd3d57d2b71977b95f5806f2124286f37c3281340b57255b4618dbc0271c98 |
|
MD5 | ee4106e400c319c8eef3965ca34b7a62 |
|
BLAKE2b-256 | d81952c4399e00d596334d8debfc11f85203b76dd4434663e5402b9945f800c3 |