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.app import (
    emacs_insert_mode,
    vi_insert_mode,
    vi_navigation_mode,
)
from prompt_toolkit.key_binding.key_processor import KeyPressEvent
from pyrime.ptpython.plugins import RIME


def configure(repl: PythonRepl) -> None:
    rime = RIME(repl)

    @repl.add_key_binding(
        "c-^",
        filter=(emacs_insert_mode | vi_insert_mode) & rime.filter(),
    )
    def _(event: KeyPressEvent) -> None:
        rime.toggle()

If you defined some key bindings which will disturb rime, try:

    @repl.add_key_binding("c-h", filter=emacs_insert_mode & rime.filter())
    def _(event: KeyPressEvent) -> None:
        rime.toggle()

If you want to exit rime in vi_navigation_mode, try:

    @repl.add_key_binding("escape", filter=emacs_insert_mode)
    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=vi_navigation_mode)
    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 vi_insert_mode or emacs_insert_mode.

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.14.tar.gz (46.1 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.14-pp311-pypy311_pp73-macosx_15_0_arm64.whl (1.2 MB view details)

Uploaded PyPymacOS 15.0+ ARM64

pyrime-0.0.14-cp313-cp313-win_amd64.whl (97.9 kB view details)

Uploaded CPython 3.13Windows x86-64

pyrime-0.0.14-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.14-cp313-cp313-musllinux_1_2_s390x.whl (2.6 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ s390x

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

Uploaded CPython 3.13musllinux: musl 1.2+ ppc64le

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

Uploaded CPython 3.13musllinux: musl 1.2+ i686

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

Uploaded CPython 3.13musllinux: musl 1.2+ ARMv7l

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

Uploaded CPython 3.13musllinux: musl 1.2+ ARM64

pyrime-0.0.14-cp313-cp313-manylinux_2_17_x86_64.whl (69.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

pyrime-0.0.14-cp313-cp313-macosx_15_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

pyrime-0.0.14-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.14-cp312-cp312-musllinux_1_2_s390x.whl (2.6 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ s390x

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

Uploaded CPython 3.12musllinux: musl 1.2+ ppc64le

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

Uploaded CPython 3.12musllinux: musl 1.2+ i686

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

Uploaded CPython 3.12musllinux: musl 1.2+ ARMv7l

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

Uploaded CPython 3.12musllinux: musl 1.2+ ARM64

pyrime-0.0.14-cp312-cp312-macosx_15_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

pyrime-0.0.14-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.14-cp311-cp311-musllinux_1_2_s390x.whl (2.6 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ s390x

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

Uploaded CPython 3.11musllinux: musl 1.2+ ppc64le

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

Uploaded CPython 3.11musllinux: musl 1.2+ i686

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

Uploaded CPython 3.11musllinux: musl 1.2+ ARMv7l

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

Uploaded CPython 3.11musllinux: musl 1.2+ ARM64

pyrime-0.0.14-cp311-cp311-macosx_15_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.11macOS 15.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for pyrime-0.0.14.tar.gz
Algorithm Hash digest
SHA256 5ff698f25c9dc6cbd36bdaf1e19dcb6aaa961efa6a184934f7124523d9f66b55
MD5 ca9bd18388947d524ce41681069e58da
BLAKE2b-256 f6213db6db4c2eb1b08dc3b883e81179ab1201a9db2a6d5d7376a1f50d3a7815

See more details on using hashes here.

File details

Details for the file pyrime-0.0.14-pp311-pypy311_pp73-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyrime-0.0.14-pp311-pypy311_pp73-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 6fa6a7e7ebd5cca009a9b2a91afc558b24b9fce6c67e0130064c38a9734ebb7c
MD5 103028b40820731d047984eb51087183
BLAKE2b-256 5c24a1a031c03f5fe63783f4c5254eb2839c51e8d59d63edd7a0d768b099ed18

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pyrime-0.0.14-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 186fc56521b0ab1d0651c2038a8f1d857c8db33c26c665ff68db0ca1d6f696f9
MD5 8b31ab64cbed8a65a9072cd5ac45f231
BLAKE2b-256 2199fb540f762350e413015d15dcb3a0a0cf20935b09b90315b5cbee7fcb4d4d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.14-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 150b43167fc39544664e84cc130ac2aacd61bb24fada8635bb799d56912e7bc0
MD5 7d79ff105110d62a2e3ed6e170aeedb3
BLAKE2b-256 905b367486e76b341836d122afd73b466b71cdda7b0a7c95fa1c52fbb808b535

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.14-cp313-cp313-musllinux_1_2_s390x.whl
Algorithm Hash digest
SHA256 1e01bc504d326c252e66b090375b8182cb3b49bb0c6a0adce20c0abed1dcbf23
MD5 5369bc4b28402e950d229088e028e85a
BLAKE2b-256 16cb840813d00e4eb788fee2c67a4a095493341d8bf2ea5cd4c43c68de8719fc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.14-cp313-cp313-musllinux_1_2_ppc64le.whl
Algorithm Hash digest
SHA256 e3dabbc303121e8f98ca5482a41d09cd8b40f288c60df6b75c964995d48ed5eb
MD5 fe67cacfffe4d4dea17beef5c4bedd04
BLAKE2b-256 dd8ff40a842e32a6b4f3d36e8d56135fb2a6d8c2a92a53dba3a68e21de8e6ede

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.14-cp313-cp313-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 44a34b465d140b2f9895c65874c28915779d8e3c98e4bea0eb0904bfd5fc96ca
MD5 85c00c04f26d5c185ac7f4fa95f6d2a0
BLAKE2b-256 1d371507ab0ab0f56f96e537af6f17400a3e5badc031bc28d1875ef2a243a1ad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.14-cp313-cp313-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 1d29daa6ca90100f6b25acf0781e8d444e0b2345f94998d530495f8c6fc58509
MD5 8481a4588720e83832a993f5018b3048
BLAKE2b-256 cdd0dc04d760ae7098aa18d76dac4a63c7cc5f2dbd835e50c719910769f0ea3a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.14-cp313-cp313-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 8bd1fc4cccc720baf5b88f4fed75a3f5e3f15d2493ceafe8cc7d712a7f6b501e
MD5 caa39726182a7055b2045c56807d9011
BLAKE2b-256 c07bba68d7e896aa7a27a69120f5a1d7f4feec4ef860f9c55d65fbbef40c0d7b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.14-cp313-cp313-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 8cbcba83c3670918b4b2d534a32666a2213d261d6f019c537992d288e1c0fa5e
MD5 5b655d636372eae49c243ef6047ca7f3
BLAKE2b-256 2017e564e87fd99b275c7c3b3ab15c2fbdd9f869a8157231f913be3a34efab8d

See more details on using hashes here.

File details

Details for the file pyrime-0.0.14-cp313-cp313-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyrime-0.0.14-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 14041fadf0a83d820942f77503c27d199e870bdba868f02efa1cf99dd8ea14c7
MD5 313f0aee05ce6be0adac6c694ef75501
BLAKE2b-256 041376d554274fa26db721bad1e6a55f1c4ca05b18f51ad5df00942b5be4212d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.14-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 980baeb75f56edc10ede30e238cb667e5c9e53b41b74bed166829a83e2c57f9d
MD5 1da613d9635db53ea939e49dccd5aa3d
BLAKE2b-256 59624ea92dd608c8b0e3ae5bd3fc506572706c51bd5f9485fbd87742b857eac3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.14-cp312-cp312-musllinux_1_2_s390x.whl
Algorithm Hash digest
SHA256 77893898660dfd001bda18a4c89b8cdef8ee64b3ae69d9c12093c2e79dc670b3
MD5 a49ecd94db560035a7eebaea439d5c01
BLAKE2b-256 08fb8df303b549e50524b9093db815b86b0cfa94ea95a42a9a2de71654a655e5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.14-cp312-cp312-musllinux_1_2_ppc64le.whl
Algorithm Hash digest
SHA256 7ccc04c21dd22abdefc9efba8fcc22d783406488476cab13396c92bf421a8ccf
MD5 e52df66d7607d8e6df111053895c646d
BLAKE2b-256 94a8d7d18b39ad3b78d3ee602bfa45fd99c66379706ff76a60595cde75851f2f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.14-cp312-cp312-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 3acccfa5971c467fa7d17ba15e1ddd74e9b1f30a7a28bcc3f04267d84c4510ee
MD5 b5b9072f516da87378eca437c6900ab7
BLAKE2b-256 377486f9af7f246d3a9c0bd2627e6d4c7bd1ecb09e77a3cc7fe3bbf05652f3a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.14-cp312-cp312-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 76103b543d6aad27bc58fb4b6c286105126aec0d94cff33bc8b308bb858cfe58
MD5 55d12e1ea965a4067bf0d50848e4c598
BLAKE2b-256 8585de256551282b3d30e8c64c5b125f73386f1d39f9ba30fd2dd3ed44f6d991

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.14-cp312-cp312-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 89fabaf30f1d85b629c2ae1f2ba6350b1f7da0817f34890781eadd6919adfd9a
MD5 c2eee385c08ee6eba086d0e7a186ed98
BLAKE2b-256 39d449989f9972633052be45f839174568e3ce2b08ab9da8a034f6bbbadaec2a

See more details on using hashes here.

File details

Details for the file pyrime-0.0.14-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyrime-0.0.14-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 e2e047c6ddc0fb68121e388681f15ba4d4d7f3f51b14532ccd277214e20497e5
MD5 ef412c8afe04775889389e55f9d4d731
BLAKE2b-256 99f863f1482d73b4d91974b70a2ccde5af2fd8a64b95ec5f7ba935db0994ae10

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.14-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 0a6883ff3cca0d2472cfb11d37eba286d7c3c3254237746d43b051c667cb98c4
MD5 2ec6656c3221fec43c7083180fbb3792
BLAKE2b-256 4dc9616b4cdc070f04f5d5891b3ca8b66aa1e56741c228231002bb3d4ba34b0f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.14-cp311-cp311-musllinux_1_2_s390x.whl
Algorithm Hash digest
SHA256 69c5479a431b804536eb871c19a4ed667742e98693e52cb485cd2898c1d1240f
MD5 371b3833b1d2d826ad30a72b3a4776be
BLAKE2b-256 b37d6ddde83029df953ba2f8ae2a50868396fe2bbe538b808a09cc4f72b4027e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.14-cp311-cp311-musllinux_1_2_ppc64le.whl
Algorithm Hash digest
SHA256 60a3619ee1e27f429da1ab70e8492165c34c4d30b6b83396030dd58ec3dd1d13
MD5 580a66bc3cbb50cd51d3ae082d218910
BLAKE2b-256 b1651d72aad9b3a3abdf4b6174cd27d5fefa77d7429a2be0c1ae9fed4d77f9f0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.14-cp311-cp311-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 47835c97648f6218f8f0bbce52158856a7021d13814261e4b5d86d8c757d066e
MD5 e90cb925f7a6add273c662409afa2329
BLAKE2b-256 c8995a7af187ff118e90cc8ae0754c137996bb50693cef2e81f8ee2fcd287c73

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.14-cp311-cp311-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 fdfbc804b50506479b84b6e4fe8e380e537a9e2594c53ba4d8272b2ccdb828de
MD5 452c9b8905acaf1fd4d373c1ca8a204c
BLAKE2b-256 f8a965242ffb187d3e696a551922206787190cdbdf3a42210b2d6bbe0249d57d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.14-cp311-cp311-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 87c9034517d7000f9173b79a8c38a3bdcd2b7deb0964fc2fe7eff458a80b8e2c
MD5 f8341e6c2c539aa533bcd8e8e551fb66
BLAKE2b-256 bdac29def4878eef03a8128d78a094d237b2f23a3266b5938bc6ec6031ed7253

See more details on using hashes here.

File details

Details for the file pyrime-0.0.14-cp311-cp311-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for pyrime-0.0.14-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 4d7b90e05829a3a3b864e275c3de3baaf8b877453b6c5f62aa129f5464c5551f
MD5 5b058342beaf4e2ff636e5cafa5cbe2c
BLAKE2b-256 b566d93666d81eff1809ce3106bd99d17c09167ee45f64d129f53e1120472535

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