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.ptpython.plugins import RIME
from pyrime.ptpython.utils.condition import (
    InsertMode,
    any_condition,
)


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

    @repl.add_key_binding(
        "c-^",
        filter=any_condition(InsertMode, rime.mode(["c-^"])),
    )
    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.12.tar.gz (46.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.12-pp311-pypy311_pp73-macosx_15_0_arm64.whl (1.2 MB view details)

Uploaded PyPymacOS 15.0+ ARM64

pyrime-0.0.12-cp313-cp313-win_amd64.whl (98.2 kB view details)

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13musllinux: musl 1.2+ s390x

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

Uploaded CPython 3.13musllinux: musl 1.2+ ppc64le

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

Uploaded CPython 3.13musllinux: musl 1.2+ i686

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

Uploaded CPython 3.13musllinux: musl 1.2+ ARMv7l

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

Uploaded CPython 3.13musllinux: musl 1.2+ ARM64

pyrime-0.0.12-cp313-cp313-manylinux_2_17_x86_64.whl (70.2 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

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

Uploaded CPython 3.13macOS 15.0+ ARM64

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

Uploaded CPython 3.12musllinux: musl 1.2+ s390x

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

Uploaded CPython 3.12musllinux: musl 1.2+ ppc64le

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

Uploaded CPython 3.12musllinux: musl 1.2+ i686

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

Uploaded CPython 3.12musllinux: musl 1.2+ ARMv7l

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

Uploaded CPython 3.12musllinux: musl 1.2+ ARM64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

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

Uploaded CPython 3.11musllinux: musl 1.2+ s390x

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

Uploaded CPython 3.11musllinux: musl 1.2+ ppc64le

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

Uploaded CPython 3.11musllinux: musl 1.2+ i686

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

Uploaded CPython 3.11musllinux: musl 1.2+ ARMv7l

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

Uploaded CPython 3.11musllinux: musl 1.2+ ARM64

pyrime-0.0.12-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.12.tar.gz.

File metadata

  • Download URL: pyrime-0.0.12.tar.gz
  • Upload date:
  • Size: 46.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.12.tar.gz
Algorithm Hash digest
SHA256 10f1c4a5141d653e5a874364a79d70fd6027312c15c66403188a75f7207075d0
MD5 b6ac669ea01523ba1807488dac98ba3a
BLAKE2b-256 99639be2f5af49a20770c07804fa0e06a250d2a97c52101a90cba403de80ef6c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.12-pp311-pypy311_pp73-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 c443839a36806318463ccf79f7868d7fa01757355b72af8cd901e73af9c8cb15
MD5 34eb974c977dc111e5368ab2decf5672
BLAKE2b-256 456b03eb576c8fa2d8a7a21d529ccc9ac17f606330305c3faf3323835525d30a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyrime-0.0.12-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 98.2 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.12-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 612b5334cbf064545340b360306e83948ce2b4ecd1f90fa3fe1a838f86f6b701
MD5 cbcb518a8e41116b5ef448a5f84e1cf6
BLAKE2b-256 17daeb9591abe91e283af4a677b6914f8f38610e103c499a554070808166275c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.12-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 5e037281e3aa58b20ec0c469fad490dc8691dc457f74b919e18f88c5198e44a3
MD5 08e19801e5ec31c726e95129b8d185da
BLAKE2b-256 2958d9e6688d2027f98ecd358f037360ea5838634b2f12acef19031c9f861f0e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.12-cp313-cp313-musllinux_1_2_s390x.whl
Algorithm Hash digest
SHA256 5cefc56c52b39fdcc7996190dac020e7ad3400722d4b44d580e86950758075db
MD5 c1582dcb9034f12216095c3cb47e2784
BLAKE2b-256 93d22e15ff83aa607f203f37498384958331c1f8be9d547881cf35a7511f457c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.12-cp313-cp313-musllinux_1_2_ppc64le.whl
Algorithm Hash digest
SHA256 e93582c88656df7aec5004253b30096c9f320c4e978d4613f2fc6512a843a98e
MD5 6afbfde3abd487f8b318ecfa4e51f61f
BLAKE2b-256 b54976d3cc506b7ec2128c212aba446aa53530907122ed893e4ee49631fe71fd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.12-cp313-cp313-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 0ebb024435cd28b3d64c89ac0011bdb3583d1c9cc7d65fadb8654b1b3271370e
MD5 38e4e281477fee3386fc0c36ba4380bf
BLAKE2b-256 4b02328105ec4dc679c94384a3e7d396abe36be7410c0dac8c73757d6a287dd9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.12-cp313-cp313-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 3b5417a93173211ad36563c0bc28191ef0939c739e2c7c2997643856f93923e5
MD5 98b8e320e5b415e4d4c2ace67e6d4325
BLAKE2b-256 d205dcba8ecfcc1a637a79f4e7f8182958ad5f9ff6875808fad78f6783c9ec91

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.12-cp313-cp313-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 e2851dfdf92f7b2cd474225196606bb9f0c17e0007984d0aef7710a45b25b6e9
MD5 d6b9201be5c85416cd792f89355bb0c8
BLAKE2b-256 2d4a1139222e4f8e01b154d36307deca9334d6f3576d16ca22c6f152adaab37b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.12-cp313-cp313-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 2a48ae3a4364104e4a5bc6080b78978b690c5db6f51cb1ed992fac3cfbc8edc2
MD5 f58eadcd6ee19d3d5de05290fed35285
BLAKE2b-256 e23bd974d8123153542ceb95a46e038e32253f9aa69b3e3ad9838d30a434009b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.12-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 04a180236814df6903e92b66655f3abfadee3b08dec1b183384f593c3956890c
MD5 0988cc0e54a3de0ec290b9598d2eafda
BLAKE2b-256 0844a09abb005f6346285d5e88b99ea02df6725fe9b048a097d5c0b8e5791238

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.12-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 72fdc5a6db810f4fb4ede92ef22c3fb2013a37d83a2fcdd58e8fea906df3149b
MD5 2aea822b597a7bf261bd3bb4a593a529
BLAKE2b-256 4a5e987a8d942f8e1ef56d790a8189b1685f5b9203b1b87a21edac7e291d8467

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.12-cp312-cp312-musllinux_1_2_s390x.whl
Algorithm Hash digest
SHA256 b6e32d0fd392b135d4691c8b1a28afb55fd2cca1e4cbf9925609c3dab89241d9
MD5 2f19f467b5479671dd15ffc70ce57544
BLAKE2b-256 da2d15ea3ff44001321cfc5cd0d2ccfdeaf70b517b8209f1d85ed3bb69f5feca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.12-cp312-cp312-musllinux_1_2_ppc64le.whl
Algorithm Hash digest
SHA256 e4b39b8271894d72db6124cbfaa19fe8f44eb8abe18166fadf78fb746a28b2c0
MD5 e7b83ca1eb9eed23c16609d64f7998fc
BLAKE2b-256 7d75853d0ddafe3d822bcaef74616586c9127a9575882305a8c9899bc116b877

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.12-cp312-cp312-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 f4e25d6785b6f5c9511fc7c352c7fec323eb8c72fe1b0094e4147a74bf7f3dea
MD5 68c87fdc28d7b9fef10c50569f63b08f
BLAKE2b-256 14cf2abbf55d3ff96cee361f2da7cff94967b43dc9b3a22abc58c09e765f103b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.12-cp312-cp312-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 a51ebc18ca6e7b32d3223452df7e67fd3ababfe4df27952d3a88ed923effcb06
MD5 bee3963b3c9540721ad865174bb4a112
BLAKE2b-256 0c6d6f311e901293bc92ed188c88130cc5bdd1a76d3cd923f6e38ad51f8610bb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.12-cp312-cp312-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 e6ed1dc0a2796f2f5e4c3a20215876606fb452cca0b2f0e793018a75045d70d7
MD5 914a117a56b4e2ca3c300d4fa6a8aaec
BLAKE2b-256 2675f287de25251ba4caae107e8f3e5d2a3706f61651d07a4964580aa8e2421a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.12-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 2bc8063a1d7baf18e7b33541062df412265e0f55b2a2e03068815537cd0711b1
MD5 5c8894bbf2506360643351d45faf57ed
BLAKE2b-256 c68f142435de5464eefdd6ec9e33279ec47132bb16e442a85a5a8abe022d42c4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.12-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 6121ca0e963d1d854fc170eda39c8a30c8731d287e6a7e14930a276cb29eb77e
MD5 08cb504faca80ba54e14e633de8bb34f
BLAKE2b-256 2ce132438df1041dd210f723952f0b8fb22a070580c2a86c696cf15f39b9f957

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.12-cp311-cp311-musllinux_1_2_s390x.whl
Algorithm Hash digest
SHA256 67e191f23bc73c996fab7378f7abed34d536bde60267a27ed8b0ecaedcd4b84a
MD5 9f30e0a8a1d655e3ba27aaa9e7d3631e
BLAKE2b-256 24c0a12bc6abb0a81522a786f73355d92aa99d53613a4e0ff82d81eb8d6c754b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.12-cp311-cp311-musllinux_1_2_ppc64le.whl
Algorithm Hash digest
SHA256 063338bedb59aed4b60fa32a9686d5bbb63741601e8672be8992e3f5d539ddca
MD5 b133bcacb8f51425b4c1512734d073bd
BLAKE2b-256 ceb5786fca3ee669cf25cd76e2c1e745fdda3abf1afefbd94fe4d69f4b1e0f25

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.12-cp311-cp311-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 16f6484c179a1eb891b4ea60ae86a2d017304491c74b0a94b4feb1a5d106ab2f
MD5 3a86bb59ed52c581143c1774a08e9dff
BLAKE2b-256 1a2cec4ff7d772b2e9f63c42c293422dd2aa59ad2e324b451a42be851f62b1cf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.12-cp311-cp311-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 145dfab1eef459bcc618685e81dbcb9ddc49f93f62ea9f5effa334e26f586e95
MD5 a0ecdb11fde253dceb8a19c022f2c9d7
BLAKE2b-256 d2c754394ca82e53d75f2dd69b4e82d43993b1797a95ba20baa7d347f9250f80

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.12-cp311-cp311-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 7fb4ba07d4393f4f945a398db96fb8689f6e7b1c304737aff10ed63be74c9adf
MD5 5aa0c8c1ec16c2a631c826be6224be8f
BLAKE2b-256 b20487ed0707e5c7464152e9852c4de6255bc1f1ca790e9b570032dbe8d80e86

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.12-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 b8ae28e135befbc7f8daf8ebd1492e53b3e1f226ea1ada70e397bd8bb462d436
MD5 ae4cd59a9bf6a02557c04518f8faa56f
BLAKE2b-256 0d81f41597293d8fefed379aac4d33f2632142893e92e70ce2843cadfb0cd543

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