Skip to main content

rime for python, attached to prompt-toolkit keybindings for some prompt-toolkit applications such as ptpython

Project description

pyrime

readthedocs pre-commit.ci status github/workflow codecov

github/downloads github/downloads/latest github/issues github/issues-closed github/issues-pr github/issues-pr-closed github/discussions github/milestones github/forks github/stars github/watchers github/contributors github/commit-activity github/last-commit github/release-date

github/license github/languages github/languages/top github/directory-file-count github/code-size github/repo-size github/v

pypi/status pypi/v pypi/downloads pypi/format pypi/implementation pypi/pyversions

aur/votes aur/popularity aur/maintainer aur/last-modified aur/version

screenshot

rime for python, attached to prompt-toolkit keybindings for some prompt-toolkit applications such as ptpython.

Dependence

# 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:

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.rime 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:

    @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:

    @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 to know more.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyrime-0.0.10.tar.gz (45.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyrime-0.0.10-pp311-pypy311_pp73-macosx_14_0_arm64.whl (1.2 MB view details)

Uploaded PyPymacOS 14.0+ ARM64

pyrime-0.0.10-cp313-cp313-win_amd64.whl (96.9 kB view details)

Uploaded CPython 3.13Windows x86-64

pyrime-0.0.10-cp313-cp313-musllinux_1_2_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

pyrime-0.0.10-cp313-cp313-musllinux_1_2_s390x.whl (2.6 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ s390x

pyrime-0.0.10-cp313-cp313-musllinux_1_2_ppc64le.whl (2.5 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ ppc64le

pyrime-0.0.10-cp313-cp313-musllinux_1_2_i686.whl (2.5 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ i686

pyrime-0.0.10-cp313-cp313-musllinux_1_2_armv7l.whl (2.0 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ ARMv7l

pyrime-0.0.10-cp313-cp313-musllinux_1_2_aarch64.whl (2.3 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ ARM64

pyrime-0.0.10-cp313-cp313-manylinux_2_17_x86_64.whl (69.1 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

pyrime-0.0.10-cp313-cp313-macosx_14_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.13macOS 14.0+ ARM64

pyrime-0.0.10-cp312-cp312-musllinux_1_2_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

pyrime-0.0.10-cp312-cp312-musllinux_1_2_s390x.whl (2.6 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ s390x

pyrime-0.0.10-cp312-cp312-musllinux_1_2_ppc64le.whl (2.5 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ ppc64le

pyrime-0.0.10-cp312-cp312-musllinux_1_2_i686.whl (2.5 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ i686

pyrime-0.0.10-cp312-cp312-musllinux_1_2_armv7l.whl (2.0 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ ARMv7l

pyrime-0.0.10-cp312-cp312-musllinux_1_2_aarch64.whl (2.3 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ ARM64

pyrime-0.0.10-cp312-cp312-macosx_14_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

pyrime-0.0.10-cp311-cp311-musllinux_1_2_x86_64.whl (2.3 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

pyrime-0.0.10-cp311-cp311-musllinux_1_2_s390x.whl (2.6 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ s390x

pyrime-0.0.10-cp311-cp311-musllinux_1_2_ppc64le.whl (2.5 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ ppc64le

pyrime-0.0.10-cp311-cp311-musllinux_1_2_i686.whl (2.5 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ i686

pyrime-0.0.10-cp311-cp311-musllinux_1_2_armv7l.whl (2.0 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ ARMv7l

pyrime-0.0.10-cp311-cp311-musllinux_1_2_aarch64.whl (2.3 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ ARM64

pyrime-0.0.10-cp311-cp311-macosx_14_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

File details

Details for the file pyrime-0.0.10.tar.gz.

File metadata

  • Download URL: pyrime-0.0.10.tar.gz
  • Upload date:
  • Size: 45.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyrime-0.0.10.tar.gz
Algorithm Hash digest
SHA256 e02d5cc0e0720a0a80f5dc6bd88fde7dfd952a35118b777d6918c5bdaccc188d
MD5 cb01e012631adc42d1388542ef553b37
BLAKE2b-256 cceea2603a254bd1b766aa0ab69fb35948cd0ad64c0e0108c358f6d0e9f610e6

See more details on using hashes here.

File details

Details for the file pyrime-0.0.10-pp311-pypy311_pp73-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyrime-0.0.10-pp311-pypy311_pp73-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 ceaf01dc7c6019e454bdee5f73be72fe12ac0d2e92275baf23998fe440133ee6
MD5 2305fb7d0dd814696eb6e04bc945d6a8
BLAKE2b-256 4834652dce3d9af497dd54c673802d506c0fc54509f8c868cef12ee70d214450

See more details on using hashes here.

File details

Details for the file pyrime-0.0.10-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: pyrime-0.0.10-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 96.9 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pyrime-0.0.10-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e838b2c646f8c020dfefbb8c9fffae934f49463e5b02ebeac052ad3acea087e3
MD5 f40ff3f329d0cdf17be395225f67f34b
BLAKE2b-256 877e0088045d3c6e20e4df45d6b2a507c3fecca7f50992435e291b893b9beb8a

See more details on using hashes here.

File details

Details for the file pyrime-0.0.10-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyrime-0.0.10-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 89b1a60373569feb667d66e8ebaa89bc2c9b3bb966f0ca8c3e104cde86fc5e0c
MD5 ea657ad20648be46dc822ffc3f26d144
BLAKE2b-256 0761cbfd6e1522b9580515b71ec90a6482bb4e2407bf809b712b47df0fc34c7d

See more details on using hashes here.

File details

Details for the file pyrime-0.0.10-cp313-cp313-musllinux_1_2_s390x.whl.

File metadata

File hashes

Hashes for pyrime-0.0.10-cp313-cp313-musllinux_1_2_s390x.whl
Algorithm Hash digest
SHA256 0b5c085daf9e9a2240fb1edc16a7e5a225ddb0d3b03ac5db901cbbc9e1becbfb
MD5 2592d0bd3a326b3460f188a127400a6a
BLAKE2b-256 d968b03721eea926ff59ea4f1306966725972b765efe39bf36cd02a5ba35e32e

See more details on using hashes here.

File details

Details for the file pyrime-0.0.10-cp313-cp313-musllinux_1_2_ppc64le.whl.

File metadata

File hashes

Hashes for pyrime-0.0.10-cp313-cp313-musllinux_1_2_ppc64le.whl
Algorithm Hash digest
SHA256 3e4a18ed1ec8dea2c1b430dce7b6fda8ea4301e1ee5cc86ec54c3460d6abf18c
MD5 d5c1498bbe5373988547b8b8449924ff
BLAKE2b-256 3e32e7d4dd6f44971062d7f70be694f9f782536642b30e94900824889516b740

See more details on using hashes here.

File details

Details for the file pyrime-0.0.10-cp313-cp313-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for pyrime-0.0.10-cp313-cp313-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 94864a6d4cc1a08cf63078b8148e43e97895e988ff5e3697904435a2727018bc
MD5 47a87cdd6dc028698520aac66a4b6a8a
BLAKE2b-256 1dcbecf952340d8013beb71d5419256ac8b86d59f67113e50154754fcafad19f

See more details on using hashes here.

File details

Details for the file pyrime-0.0.10-cp313-cp313-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for pyrime-0.0.10-cp313-cp313-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 ecb6c1140c0598464aba98798162e194a8b07ea9d10412a357302e5caa39fff9
MD5 f0f87e7dfd30ff065f135a55db6ae0f5
BLAKE2b-256 aff577e1603bb8cde25f4e12136160517c79094347108a7dc5c728348ba9ea32

See more details on using hashes here.

File details

Details for the file pyrime-0.0.10-cp313-cp313-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pyrime-0.0.10-cp313-cp313-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 7e243f5d1a420a4d6b074ffce0c8f4181ac7dbe614bee818c094d71f0cccb0f1
MD5 a26b44b68120e19f08a35509d5e069f5
BLAKE2b-256 b1eb979cb251a6630fc6b356dadfbdf7b82f972ffc2a8952545e72fe0bcd01ef

See more details on using hashes here.

File details

Details for the file pyrime-0.0.10-cp313-cp313-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for pyrime-0.0.10-cp313-cp313-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 9c956a4e346bde4d1d94a75559eb692439fae3b2fe0f5b797d6d8977d9535255
MD5 9fab062d9b83bb073c957450b25fb2bf
BLAKE2b-256 eb5a01ae24e9a12c2518bcb2cf09390b7d9d599fba237dff1abb4a5db05bb44f

See more details on using hashes here.

File details

Details for the file pyrime-0.0.10-cp313-cp313-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyrime-0.0.10-cp313-cp313-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 9ef9ffa620ebb360aa3b94bca404a4908ec551318f0ac58fd0721e725396ad06
MD5 889081965e86692aad74d4aaae69e17d
BLAKE2b-256 910e41e642fb3a8e2ab5037337dd470055540e8364935ea8ff57ea4375869c5d

See more details on using hashes here.

File details

Details for the file pyrime-0.0.10-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyrime-0.0.10-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2b2ded21c6932f9a07ca9bd08ad7eb0aed9392afc7bcf06f17d1bed3012b1726
MD5 cd83841f0b2087d4ce05c0f7be30b32c
BLAKE2b-256 801a0b15b6e9cd80da8676c630d103c0b637c2ac3b06c40053fb65c82423ad03

See more details on using hashes here.

File details

Details for the file pyrime-0.0.10-cp312-cp312-musllinux_1_2_s390x.whl.

File metadata

File hashes

Hashes for pyrime-0.0.10-cp312-cp312-musllinux_1_2_s390x.whl
Algorithm Hash digest
SHA256 e2826750300b2ecd59a280e4166a0dd335b43bc66994a9abe9a543eb409329e9
MD5 68fc9c03e1049465df339a4ca1c647be
BLAKE2b-256 085a588aa763eeba8f1f8adab69f4a0d4d9926de9dd6144573d5afe72b273e08

See more details on using hashes here.

File details

Details for the file pyrime-0.0.10-cp312-cp312-musllinux_1_2_ppc64le.whl.

File metadata

File hashes

Hashes for pyrime-0.0.10-cp312-cp312-musllinux_1_2_ppc64le.whl
Algorithm Hash digest
SHA256 947da8af539b9e9c318e267d1c9c6ffc6cec278bfa645f6ef4a69926c09f62dd
MD5 e3e107f78d27942d0319bcdaf55de330
BLAKE2b-256 2272c9d7dcdcea3bda999ae4e8e174ffecaf8780f2e46fe872cfee2949a105ba

See more details on using hashes here.

File details

Details for the file pyrime-0.0.10-cp312-cp312-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for pyrime-0.0.10-cp312-cp312-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 e44c689547ff7c80f1716df53cdc50e890a8fc85b0f28c4fa4d7873e7dd39e0f
MD5 4b9ee3b091fae17fa74871ea23ca0e68
BLAKE2b-256 9719e8396f32bf9799a5419d7d5645d57815cc0d857b826ef12367d206ccb65d

See more details on using hashes here.

File details

Details for the file pyrime-0.0.10-cp312-cp312-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for pyrime-0.0.10-cp312-cp312-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 364b296170921df328cf6fd640b83fd49b1a10a37c546e1c761cd63b95320d47
MD5 7a9f050988e19f60007c62fa8d100d5a
BLAKE2b-256 5ee465f03cdeb83027c9708e0332b3ad12ea6fd5c599c73b7e78a0795b1b0f90

See more details on using hashes here.

File details

Details for the file pyrime-0.0.10-cp312-cp312-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pyrime-0.0.10-cp312-cp312-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 ce9a5e2018dc0afba340dc8eec8b57eb6173a3524c0aa31e9893b337598cd1ab
MD5 3df850312c3d8372fa01f8e29e0d61df
BLAKE2b-256 b31b81879141d32ba5d7a02ebac63655798f57a2000adfa526422d5a07882e01

See more details on using hashes here.

File details

Details for the file pyrime-0.0.10-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyrime-0.0.10-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 8bad680e41dc5056b1a403a1a98968f703bb266b5e3afcda11fbf266272e538a
MD5 50366d34ccba10ae16bbcd230090345d
BLAKE2b-256 a487eb702f72e44ae80c0ef0f6ccec6e405af16a4fa4430cec992228aa9a5869

See more details on using hashes here.

File details

Details for the file pyrime-0.0.10-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for pyrime-0.0.10-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 a7aed381a746d64e6228a6a7fab8a1f946841c79b16e940d53d30fd3e2b4d5aa
MD5 1347c2b57ca4c06b8cbbc66355b3038d
BLAKE2b-256 7cd745aae8860f8bd6cbd378995f2c8f99e9c609228ca46990aeaf2b3b9ad52c

See more details on using hashes here.

File details

Details for the file pyrime-0.0.10-cp311-cp311-musllinux_1_2_s390x.whl.

File metadata

File hashes

Hashes for pyrime-0.0.10-cp311-cp311-musllinux_1_2_s390x.whl
Algorithm Hash digest
SHA256 0ab664a89462d859bb2a94447f06816318237ce80c6088f9caecbc8961c92454
MD5 6100624be8422035eb4fc033c83c8d68
BLAKE2b-256 a2bf7d92814efa7c37eedc09f3426477b554125f90655b8eab664d8cb388a47c

See more details on using hashes here.

File details

Details for the file pyrime-0.0.10-cp311-cp311-musllinux_1_2_ppc64le.whl.

File metadata

File hashes

Hashes for pyrime-0.0.10-cp311-cp311-musllinux_1_2_ppc64le.whl
Algorithm Hash digest
SHA256 5384de17e68d835c62a59ecb32cce00069248238c932bc312baaf23512194a85
MD5 177590f2a442cedf4122d81c88a423f5
BLAKE2b-256 02d4b05d5e49700a6a597e0d8ee6f85b8b06066cf9a231fca1837a8e2ae2b579

See more details on using hashes here.

File details

Details for the file pyrime-0.0.10-cp311-cp311-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for pyrime-0.0.10-cp311-cp311-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 b49ac075f539870070e16a7fb0855bdde77604520868315822aef303d2bed706
MD5 c637ad700398458e7f702e7b6e1516e4
BLAKE2b-256 b696ec7050daf6dbddfdaa78ffdaadd512c125edb76fddbd68379c2315bd0fbc

See more details on using hashes here.

File details

Details for the file pyrime-0.0.10-cp311-cp311-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for pyrime-0.0.10-cp311-cp311-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 097781e351b1b0528e185a4804276e929600bc0b8885c68da35973ffc90f862b
MD5 bffd08b1d3d0061f07048f5b8d6e4677
BLAKE2b-256 953caf3a83406778f70d87fa8c45fc27270a67916e9878a3affea403214d76cd

See more details on using hashes here.

File details

Details for the file pyrime-0.0.10-cp311-cp311-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for pyrime-0.0.10-cp311-cp311-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 7d992607cef3111f0981938a1bea57541ffdc7793cf7ce2be42cb0e8210ca694
MD5 ed5a780cb456a601960f7eb71a358a3a
BLAKE2b-256 7da4517efae313058a6d059e3892b1c18c74a21a415a16f17ff8551bf09048ed

See more details on using hashes here.

File details

Details for the file pyrime-0.0.10-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pyrime-0.0.10-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 e21e042e75cbbd2ab72b59f38a75185c7e40b396d75d426e7d872089a9eef872
MD5 abc697a9e58a415667939bc73220731f
BLAKE2b-256 90b7defc834443a44f62d24e65367e358d94cd402dd9876bd1768c74be4f36dd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page