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.13.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.13-pp311-pypy311_pp73-macosx_15_0_arm64.whl (1.2 MB view details)

Uploaded PyPymacOS 15.0+ ARM64

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

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13musllinux: musl 1.2+ s390x

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

Uploaded CPython 3.13musllinux: musl 1.2+ ppc64le

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

Uploaded CPython 3.13musllinux: musl 1.2+ i686

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

Uploaded CPython 3.13musllinux: musl 1.2+ ARMv7l

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

Uploaded CPython 3.13musllinux: musl 1.2+ ARM64

pyrime-0.0.13-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.13-cp313-cp313-macosx_15_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.13macOS 15.0+ ARM64

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

Uploaded CPython 3.12musllinux: musl 1.2+ s390x

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

Uploaded CPython 3.12musllinux: musl 1.2+ ppc64le

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

Uploaded CPython 3.12musllinux: musl 1.2+ i686

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

Uploaded CPython 3.12musllinux: musl 1.2+ ARMv7l

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

Uploaded CPython 3.12musllinux: musl 1.2+ ARM64

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

Uploaded CPython 3.12macOS 15.0+ ARM64

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

Uploaded CPython 3.11musllinux: musl 1.2+ s390x

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

Uploaded CPython 3.11musllinux: musl 1.2+ ppc64le

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

Uploaded CPython 3.11musllinux: musl 1.2+ i686

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

Uploaded CPython 3.11musllinux: musl 1.2+ ARMv7l

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

Uploaded CPython 3.11musllinux: musl 1.2+ ARM64

pyrime-0.0.13-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.13.tar.gz.

File metadata

  • Download URL: pyrime-0.0.13.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.13.tar.gz
Algorithm Hash digest
SHA256 bb6db4783e5cb62d18d0685637e19f576b61632994461fa60d9f88c793c645c0
MD5 57bbcbcaf17bc65e9b410b4f02fdb587
BLAKE2b-256 a90b17494a3eeb7550f74450f6bce647b9ad1681b9fd098590b70d7d2b57b6b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.13-pp311-pypy311_pp73-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 dc8b105714443538ef283fb9e7ad6ad6b595de8b4b18d149cc45b96998e338ab
MD5 62d15347514810111936d87565953ae1
BLAKE2b-256 ba8bc82185e79eef2ef387d8d39712f7a040816b34a1e17aa34dbc7ef5fd4ab4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyrime-0.0.13-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.13-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 92424439bbcb1f9a85cfefad7b5db0c7c0a63a2d151c7e34451d5914a8cd5569
MD5 65e415d950d46e78d0794420f07c0758
BLAKE2b-256 43834a39600474d90b61d9c04db2f23c560273f55dc6692af52f9db2af90bce7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.13-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 3bbcb5409dce42294a80584bc2e34992326bf3cb66924a4a2f31250c013c4bd7
MD5 b4dcb40e889450cee7cdfbc8da95ab8f
BLAKE2b-256 2251fd2f483765b2cfad3844e8cc2981ba8a42ca62acdef444182bb8f7a6cc95

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.13-cp313-cp313-musllinux_1_2_s390x.whl
Algorithm Hash digest
SHA256 2a5b239bcae889218623de6774a4303c0f579caad46d09f48205baf0fceda465
MD5 863b26e6b0aef051eb28dfb665542f96
BLAKE2b-256 976750ace4fa8ef4e0c35fbb3d98986fa72983c62975f0c885e0b2854558dd80

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.13-cp313-cp313-musllinux_1_2_ppc64le.whl
Algorithm Hash digest
SHA256 7107256e2d6468c67e9830137e82196d41e9a435d2d88998f704d0f5268abff9
MD5 93ff77fa52666d39911fb539954927ee
BLAKE2b-256 e8d6520409a94e896127c330dd3fcdcbd37f9b164148db7c987e4962c759f36c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.13-cp313-cp313-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 77841be9cc5dcda92f03798e6b43886b98651b8042466de1332fdcb995478641
MD5 c5c586773ecf7ce2af4dc8c7fbfc3695
BLAKE2b-256 28e59d9d4578479eb5100e8e976c57d8ede851757817d57d2306adbeec237f67

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.13-cp313-cp313-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 5f87987fe3e3c033e75dec38cf168765bde21b7dcebc50e862a106d9c6f6029f
MD5 417699b2212ef93f103541f15a9e937d
BLAKE2b-256 068044fe1d6ef25b6b73db179a05f7d6e85f58335511353e6710e40ebd4192b4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.13-cp313-cp313-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 f4efdb4d2a143633045443ead4b246f868357e818fb19ed27671966f082f3354
MD5 9078daac33a41faf271c2e91600cabaf
BLAKE2b-256 008bef7199486de2d40fded613fc1a3aac04746f352294f48ff0b3c35d58383e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.13-cp313-cp313-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 0f56dfe50ff69fd9363af319d1961c39968f653773817d45edbfb46fe7ca76d8
MD5 be238c965afe26db977b77663896cbab
BLAKE2b-256 076012918b83a8dabfacb1a19f7a2965411bb39bb2a296876d54ed5b531fc936

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.13-cp313-cp313-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 8303ab932d09a5f0d1113e59e6d31ba8046970324b3bb781ba6bf14dee9572c8
MD5 2dcc03a7736534815a5a6c2577f350b0
BLAKE2b-256 47dcd6c1f73882a08d8fe0c7b7cf254340f84a8e874488380c850dbd01f187a9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.13-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 af5c5c4f3371e98535f6ca6193c3677c317f2ec79519b2e46bb25f6d6339187e
MD5 2f2beefa90e118532c5765842dd8b439
BLAKE2b-256 df145c40d0d00f569d47c8acfba2bed885e02028e2f12d31a0323fc36f285abf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.13-cp312-cp312-musllinux_1_2_s390x.whl
Algorithm Hash digest
SHA256 c622a3dd5a54396fbdbb071d60b249d7a594ab3211053e93a6fdc74f62180e01
MD5 ad8e609d21ac88766e8760cc93d1f959
BLAKE2b-256 79d43ec527bf414801fa6d9cc47748a57db224051668a04077efa7ee93089217

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.13-cp312-cp312-musllinux_1_2_ppc64le.whl
Algorithm Hash digest
SHA256 df363991cd3fa9217d48df4660adf4fc6cfbc38e718b4f8706308084670a1c99
MD5 6e791a3ad6a84fc5bc59f47804a69995
BLAKE2b-256 b28ca0ff1c781f935a25e00a9cbfb2ae0eaed6573f162abbfa8d16d8d57c554d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.13-cp312-cp312-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 402fd319ec7533211e4d2c23d11163a974a17f2de95fa25fbeb3c68a603f80ac
MD5 9f9506fae3ee08c4605be589ab70c28b
BLAKE2b-256 3f4a6961b0ded4fd1f55652eef8dd623a3066305047a337443cbc8f3435300ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.13-cp312-cp312-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 2932ac29d1f46333c4a4c7374692170cdb17242c472de0cf24b0da5f2b8fe7d4
MD5 20b24eed4562f92723e1641c51fb62b0
BLAKE2b-256 7c1ec3d6c5abbd5cab18dcbfd35d00cb27aff410cd207eb0660270b0bcd15b92

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.13-cp312-cp312-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 c53f51e97b9b0095e31fccfb3476430a87428d6018c77a39b8772ac389717c30
MD5 1408b699e0e9505a9716c37f6b4eecbc
BLAKE2b-256 4eb68e2055d84be0a3157ed6dee7cf523eca15abe8678f12cc88d7df6efae1cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.13-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 a2c13fa0d4a3294ebb9c4d4f56614c5fdda872db72183a481e808abfc046c1fe
MD5 438201e0c828338dca2a1847d1d4c947
BLAKE2b-256 2182dc4ab9bffc8f3b0fff6f5b3202b8733cf68c51b826940c657b820c7f4aa7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.13-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e167131b10fc7ec62c5151e98a3ee04140fed133a546d6881dd96d06892f6d11
MD5 973abac3b4b9de7cdf60db1bf211ac38
BLAKE2b-256 bd114f6712a6fc12092b7c0656e82cd5af863a9472ce013215b7318fa0a4c90c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.13-cp311-cp311-musllinux_1_2_s390x.whl
Algorithm Hash digest
SHA256 fb0cc65832ac70760dbd6e4f0827d75dd4d33abb573caf76ca93bb8733da1aea
MD5 1e8a8252175bba016f8af567193e899c
BLAKE2b-256 e5b7116ff5ee74491577b5e33ac999d1d7970046c96070256ba308769312d921

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.13-cp311-cp311-musllinux_1_2_ppc64le.whl
Algorithm Hash digest
SHA256 d9994176286da552e23ebb56436bc11bb1407ed4b534e2dfa9b1c9e510ecd2d6
MD5 291e5bc59a9280b1fe62d5ef355b0f73
BLAKE2b-256 6242c395125a17c6a84ad74ff87a37ca8419768344335d5756ba27e62b3f4720

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.13-cp311-cp311-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 eb0e68ce20d54ffd9b2bfb4216074b90a1fc642cc50195a11c3e02651ed80b08
MD5 667fa1d12744ada5b25a7bb1d0ee7d9b
BLAKE2b-256 aebbb2c01c4ee7e99ee9a8eee99ac7d3fb1049da0f68fc12cb4bf80090c9e427

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.13-cp311-cp311-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 a51e91c35ebf147e0cfd92c53792d4a73106389883b518182b308260c53b27b4
MD5 c3d1b33863f3d03d150703991b95d0ac
BLAKE2b-256 92a5b40d1f8a8ae75d0f0b25b064c90c044152b5154cf66656bc372624d48586

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.13-cp311-cp311-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 0b5adbc0325f518fd0efe3cd94033f0ab5bdfb36e130d52a0dfd2bdc4ba80dd6
MD5 ae46d4d4308c4b3c25222e97c8de5375
BLAKE2b-256 26a96625c204d2b97b51265612c304d674dad5a594bafc5b129f6e5c0a2e2395

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyrime-0.0.13-cp311-cp311-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 c6aa1cbdee2554af96ae08bc88c0c784493de5189b1164b1dddd406b6b6c86ee
MD5 eee978d2a6a6fc8b496d5d2a897b294b
BLAKE2b-256 e581b1041ec9ae670077009fa1b3a84297c328dc8d5e55239727cead8c320f66

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