Name | pyrime JSON |
Version |
0.0.7
JSON |
| download |
home_page | None |
Summary | rime for python, attached to prompt-toolkit keybindings for some prompt-toolkit applications such as ptpython |
upload_time | 2024-12-03 07:37:05 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | GPL v3 |
keywords |
rime
ptpython
prompt-toolkit
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# pyrime
[](https://pyrime.readthedocs.io)
[](https://results.pre-commit.ci/latest/github/Freed-Wu/pyrime/main)
[](https://github.com/Freed-Wu/pyrime/actions)
[](https://codecov.io/gh/Freed-Wu/pyrime)
[](https://github.com/Freed-Wu/pyrime/releases)
[](https://github.com/Freed-Wu/pyrime/releases/latest)
[](https://github.com/Freed-Wu/pyrime/issues)
[](https://github.com/Freed-Wu/pyrime/issues?q=is%3Aissue+is%3Aclosed)
[](https://github.com/Freed-Wu/pyrime/pulls)
[](https://github.com/Freed-Wu/pyrime/pulls?q=is%3Apr+is%3Aclosed)
[](https://github.com/Freed-Wu/pyrime/discussions)
[](https://github.com/Freed-Wu/pyrime/milestones)
[](https://github.com/Freed-Wu/pyrime/network/members)
[](https://github.com/Freed-Wu/pyrime/stargazers)
[](https://github.com/Freed-Wu/pyrime/watchers)
[](https://github.com/Freed-Wu/pyrime/graphs/contributors)
[](https://github.com/Freed-Wu/pyrime/graphs/commit-activity)
[](https://github.com/Freed-Wu/pyrime/commits)
[](https://github.com/Freed-Wu/pyrime/releases/latest)
[](https://github.com/Freed-Wu/pyrime/blob/main/LICENSE)
[](https://github.com/Freed-Wu/pyrime)
[](https://github.com/Freed-Wu/pyrime)
[](https://github.com/Freed-Wu/pyrime)
[](https://github.com/Freed-Wu/pyrime)
[](https://github.com/Freed-Wu/pyrime)
[](https://github.com/Freed-Wu/pyrime)
[](https://pypi.org/project/pyrime/#description)
[](https://pypi.org/project/pyrime/#history)
[](https://pypi.org/project/pyrime/#files)
[](https://pypi.org/project/pyrime/#files)
[](https://pypi.org/project/pyrime/#files)
[](https://pypi.org/project/pyrime/#files)
[](https://aur.archlinux.org/packages/python-pyrime)
[](https://aur.archlinux.org/packages/python-pyrime)
[](https://aur.archlinux.org/packages/python-pyrime)
[](https://aur.archlinux.org/packages/python-pyrime)
[](https://aur.archlinux.org/packages/python-pyrime)

rime for python, attached to prompt-toolkit keybindings for some prompt-toolkit
applications such as ptpython.
## Dependence
- [librime](https://github.com/rime/librime)
```sh
# 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 librime gcc
```
## Configure
`~/.config/ptpython/config.py`:
```python
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()
```
If you defined some key bindings which will disturb rime, try:
```python
@repl.add_key_binding("c-h", filter=rime.filter(EmacsInsertMode()))
def _(event: KeyPressEvent) -> None:
rime.toggle()
```
If you want to exit rime in `ViNavigationMode()`, try:
```python
@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()
```
It will remember rime status and enable it when reenter `ViInsertMode()` or
`EmacsInsertMode()`.
Some utility functions are defined in this project. Refer
[my ptpython config](https://github.com/Freed-Wu/Freed-Wu/blob/main/.config/ptpython/config.py)
to know more.
Raw data
{
"_id": null,
"home_page": null,
"name": "pyrime",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "rime, ptpython, prompt-toolkit",
"author": null,
"author_email": "\"Wu, Zhenyu\" <wuzhenyu@ustc.edu>",
"download_url": "https://files.pythonhosted.org/packages/21/8b/1314fe5c93ca3864a1ab230387ea4236aa67ec5f7f50c3bb2fbf8647c8b3/pyrime-0.0.7.tar.gz",
"platform": null,
"description": "# pyrime\n\n[](https://pyrime.readthedocs.io)\n[](https://results.pre-commit.ci/latest/github/Freed-Wu/pyrime/main)\n[](https://github.com/Freed-Wu/pyrime/actions)\n[](https://codecov.io/gh/Freed-Wu/pyrime)\n\n[](https://github.com/Freed-Wu/pyrime/releases)\n[](https://github.com/Freed-Wu/pyrime/releases/latest)\n[](https://github.com/Freed-Wu/pyrime/issues)\n[](https://github.com/Freed-Wu/pyrime/issues?q=is%3Aissue+is%3Aclosed)\n[](https://github.com/Freed-Wu/pyrime/pulls)\n[](https://github.com/Freed-Wu/pyrime/pulls?q=is%3Apr+is%3Aclosed)\n[](https://github.com/Freed-Wu/pyrime/discussions)\n[](https://github.com/Freed-Wu/pyrime/milestones)\n[](https://github.com/Freed-Wu/pyrime/network/members)\n[](https://github.com/Freed-Wu/pyrime/stargazers)\n[](https://github.com/Freed-Wu/pyrime/watchers)\n[](https://github.com/Freed-Wu/pyrime/graphs/contributors)\n[](https://github.com/Freed-Wu/pyrime/graphs/commit-activity)\n[](https://github.com/Freed-Wu/pyrime/commits)\n[](https://github.com/Freed-Wu/pyrime/releases/latest)\n\n[](https://github.com/Freed-Wu/pyrime/blob/main/LICENSE)\n[](https://github.com/Freed-Wu/pyrime)\n[](https://github.com/Freed-Wu/pyrime)\n[](https://github.com/Freed-Wu/pyrime)\n[](https://github.com/Freed-Wu/pyrime)\n[](https://github.com/Freed-Wu/pyrime)\n[](https://github.com/Freed-Wu/pyrime)\n\n[](https://pypi.org/project/pyrime/#description)\n[](https://pypi.org/project/pyrime/#history)\n[](https://pypi.org/project/pyrime/#files)\n[](https://pypi.org/project/pyrime/#files)\n[](https://pypi.org/project/pyrime/#files)\n[](https://pypi.org/project/pyrime/#files)\n\n[](https://aur.archlinux.org/packages/python-pyrime)\n[](https://aur.archlinux.org/packages/python-pyrime)\n[](https://aur.archlinux.org/packages/python-pyrime)\n[](https://aur.archlinux.org/packages/python-pyrime)\n[](https://aur.archlinux.org/packages/python-pyrime)\n\n\n\nrime for python, attached to prompt-toolkit keybindings for some prompt-toolkit\napplications such as ptpython.\n\n## Dependence\n\n- [librime](https://github.com/rime/librime)\n\n```sh\n# Ubuntu\nsudo apt-get -y install librime-dev librime1 pkg-config\nsudo apt-mark auto librime-dev pkg-config\n# ArchLinux\nsudo pacman -S --noconfirm librime pkg-config\n# Android Termux\napt-get -y install librime pkg-config\n# Nix\n# use nix-shell to create a virtual environment then build\n# homebrew\nbrew tap tonyfettes/homebrew-rime\nbrew install librime pkg-config\n# Windows msys2\npacboy -S --noconfirm pkg-config librime gcc\n```\n\n## Configure\n\n`~/.config/ptpython/config.py`:\n\n```python\nfrom ptpython.repl import PythonRepl\nfrom prompt_toolkit.filters import EmacsInsertMode, ViInsertMode\nfrom prompt_toolkit.key_binding.key_processor import KeyPressEvent\nfrom pyrime.prompt_toolkit import Rime\n\n\ndef configure(repl: PythonRepl) -> None:\n rime = Rime(repl)\n\n @repl.add_key_binding(\"c-^\", filter=ViInsertMode())\n @repl.add_key_binding(\"c-^\", filter=EmacsInsertMode())\n @repl.add_key_binding(\"c-^\", filter=rime.mode())\n def _(event: KeyPressEvent) -> None:\n rime.toggle()\n```\n\nIf you defined some key bindings which will disturb rime, try:\n\n```python\n @repl.add_key_binding(\"c-h\", filter=rime.filter(EmacsInsertMode()))\n def _(event: KeyPressEvent) -> None:\n rime.toggle()\n```\n\nIf you want to exit rime in `ViNavigationMode()`, try:\n\n```python\n @repl.add_key_binding(\"escape\", filter=EmacsInsertMode())\n def _(event: KeyPressEvent) -> None:\n \"\"\".\n\n :param event:\n :type event: KeyPressEvent\n :rtype: None\n \"\"\"\n event.app.editing_mode = EditingMode.VI\n event.app.vi_state.input_mode = InputMode.NAVIGATION\n rime.conditional_disable()\n\n # and a, I, A, ...\n @repl.add_key_binding(\"i\", filter=ViNavigationMode())\n def _(event: KeyPressEvent) -> None:\n \"\"\".\n\n :param event:\n :type event: KeyPressEvent\n :rtype: None\n \"\"\"\n event.app.editing_mode = EditingMode.EMACS\n event.app.vi_state.input_mode = InputMode.INSERT\n rime.conditional_enable()\n```\n\nIt will remember rime status and enable it when reenter `ViInsertMode()` or\n`EmacsInsertMode()`.\n\nSome utility functions are defined in this project. Refer\n[my ptpython config](https://github.com/Freed-Wu/Freed-Wu/blob/main/.config/ptpython/config.py)\nto know more.\n",
"bugtrack_url": null,
"license": "GPL v3",
"summary": "rime for python, attached to prompt-toolkit keybindings for some prompt-toolkit applications such as ptpython",
"version": "0.0.7",
"project_urls": {
"Bug Report": "https://github.com/Freed-Wu/pyrime/issues",
"Download": "https://github.com/Freed-Wu/pyrime/releases",
"Homepage": "https://pyrime.readthedocs.io",
"Source": "https://github.com/Freed-Wu/pyrime"
},
"split_keywords": [
"rime",
" ptpython",
" prompt-toolkit"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6f0104e19e52ec5c8e8bc9aa1f77c8871069863b287f100eb045e852b25b1f24",
"md5": "32e5fd3ff1f2a0385b9867eb5d51946f",
"sha256": "9f4ff41cc15945f9ffcc0a7c26cd320963538bad75c4c2136b5a6efd8e4620c5"
},
"downloads": -1,
"filename": "pyrime-0.0.7-cp312-cp312-manylinux_2_17_x86_64.whl",
"has_sig": false,
"md5_digest": "32e5fd3ff1f2a0385b9867eb5d51946f",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": ">=3.10",
"size": 73249,
"upload_time": "2024-12-03T07:37:02",
"upload_time_iso_8601": "2024-12-03T07:37:02.304837Z",
"url": "https://files.pythonhosted.org/packages/6f/01/04e19e52ec5c8e8bc9aa1f77c8871069863b287f100eb045e852b25b1f24/pyrime-0.0.7-cp312-cp312-manylinux_2_17_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3062dd2ae5c35e422ea377854a2087e608626538b301423304871f4bbda7609e",
"md5": "7d1ce6531b1c41b41f722b67dfe2212d",
"sha256": "78e13d33ec57490dd94d07395c0518c938f3c7d86dd69b36400951095dd4ff92"
},
"downloads": -1,
"filename": "pyrime-0.0.7-cp312-cp312-win_amd64.whl",
"has_sig": false,
"md5_digest": "7d1ce6531b1c41b41f722b67dfe2212d",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": ">=3.10",
"size": 101925,
"upload_time": "2024-12-03T07:37:03",
"upload_time_iso_8601": "2024-12-03T07:37:03.477784Z",
"url": "https://files.pythonhosted.org/packages/30/62/dd2ae5c35e422ea377854a2087e608626538b301423304871f4bbda7609e/pyrime-0.0.7-cp312-cp312-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9accc8a9a4610b0a66e4f2acd5c3b25427e04f42a369273dc16e262c984c9b33",
"md5": "4bcb48e991e3f13272fa17522fcd799c",
"sha256": "734517ebbb064da3666c9b65017eb61f2fa142fe5ea651699bff496c324ef5bc"
},
"downloads": -1,
"filename": "pyrime-0.0.7-cp313-cp313-macosx_14_0_arm64.whl",
"has_sig": false,
"md5_digest": "4bcb48e991e3f13272fa17522fcd799c",
"packagetype": "bdist_wheel",
"python_version": "cp313",
"requires_python": ">=3.10",
"size": 54895,
"upload_time": "2024-12-03T07:37:04",
"upload_time_iso_8601": "2024-12-03T07:37:04.578559Z",
"url": "https://files.pythonhosted.org/packages/9a/cc/c8a9a4610b0a66e4f2acd5c3b25427e04f42a369273dc16e262c984c9b33/pyrime-0.0.7-cp313-cp313-macosx_14_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "218b1314fe5c93ca3864a1ab230387ea4236aa67ec5f7f50c3bb2fbf8647c8b3",
"md5": "0a85e655ff59ea01adc6612df44c8376",
"sha256": "e0a9ecc4f405eebf3d998c6c7c9464da730e1b46a509cd3d64b3556f6cb797e3"
},
"downloads": -1,
"filename": "pyrime-0.0.7.tar.gz",
"has_sig": false,
"md5_digest": "0a85e655ff59ea01adc6612df44c8376",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 42660,
"upload_time": "2024-12-03T07:37:05",
"upload_time_iso_8601": "2024-12-03T07:37:05.570125Z",
"url": "https://files.pythonhosted.org/packages/21/8b/1314fe5c93ca3864a1ab230387ea4236aa67ec5f7f50c3bb2fbf8647c8b3/pyrime-0.0.7.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-03 07:37:05",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Freed-Wu",
"github_project": "pyrime",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pyrime"
}