{"id":30354416,"url":"https://github.com/rimeinn/pyrime","last_synced_at":"2026-02-28T10:32:35.642Z","repository":{"id":251153811,"uuid":"836327950","full_name":"rimeinn/pyrime","owner":"rimeinn","description":"ㄓ rime for python 🐍️","archived":false,"fork":false,"pushed_at":"2026-02-23T19:35:19.000Z","size":365,"stargazers_count":8,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-02-24T02:04:17.020Z","etag":null,"topics":["prompt-toolkit","ptpython","python","rime"],"latest_commit_sha":null,"homepage":"https://pyrime.readthedocs.io/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rimeinn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-07-31T16:01:11.000Z","updated_at":"2026-01-27T07:55:41.000Z","dependencies_parsed_at":"2024-08-01T07:19:11.863Z","dependency_job_id":"98fd8707-5441-4ab1-877c-ebf2fe6511b5","html_url":"https://github.com/rimeinn/pyrime","commit_stats":null,"previous_names":["freed-wu/pyrime","rimeinn/pyrime"],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/rimeinn/pyrime","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rimeinn%2Fpyrime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rimeinn%2Fpyrime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rimeinn%2Fpyrime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rimeinn%2Fpyrime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rimeinn","download_url":"https://codeload.github.com/rimeinn/pyrime/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rimeinn%2Fpyrime/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29930344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-28T09:58:13.507Z","status":"ssl_error","status_checked_at":"2026-02-28T09:57:57.047Z","response_time":90,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["prompt-toolkit","ptpython","python","rime"],"created_at":"2025-08-19T03:01:35.881Z","updated_at":"2026-02-28T10:32:35.634Z","avatar_url":"https://github.com/rimeinn.png","language":"Python","funding_links":[],"categories":["软件"],"sub_categories":["扩展或相关工具等"],"readme":"# pyrime\n\n[![readthedocs](https://shields.io/readthedocs/pyrime)](https://pyrime.readthedocs.io)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/rimeinn/pyrime/main.svg)](https://results.pre-commit.ci/latest/github/rimeinn/pyrime/main)\n[![github/workflow](https://github.com/rimeinn/pyrime/actions/workflows/main.yml/badge.svg)](https://github.com/rimeinn/pyrime/actions)\n[![codecov](https://codecov.io/gh/rimeinn/pyrime/branch/main/graph/badge.svg)](https://codecov.io/gh/rimeinn/pyrime)\n\n[![github/downloads](https://shields.io/github/downloads/rimeinn/pyrime/total)](https://github.com/rimeinn/pyrime/releases)\n[![github/downloads/latest](https://shields.io/github/downloads/rimeinn/pyrime/latest/total)](https://github.com/rimeinn/pyrime/releases/latest)\n[![github/issues](https://shields.io/github/issues/rimeinn/pyrime)](https://github.com/rimeinn/pyrime/issues)\n[![github/issues-closed](https://shields.io/github/issues-closed/rimeinn/pyrime)](https://github.com/rimeinn/pyrime/issues?q=is%3Aissue+is%3Aclosed)\n[![github/issues-pr](https://shields.io/github/issues-pr/rimeinn/pyrime)](https://github.com/rimeinn/pyrime/pulls)\n[![github/issues-pr-closed](https://shields.io/github/issues-pr-closed/rimeinn/pyrime)](https://github.com/rimeinn/pyrime/pulls?q=is%3Apr+is%3Aclosed)\n[![github/discussions](https://shields.io/github/discussions/rimeinn/pyrime)](https://github.com/rimeinn/pyrime/discussions)\n[![github/milestones](https://shields.io/github/milestones/all/rimeinn/pyrime)](https://github.com/rimeinn/pyrime/milestones)\n[![github/forks](https://shields.io/github/forks/rimeinn/pyrime)](https://github.com/rimeinn/pyrime/network/members)\n[![github/stars](https://shields.io/github/stars/rimeinn/pyrime)](https://github.com/rimeinn/pyrime/stargazers)\n[![github/watchers](https://shields.io/github/watchers/rimeinn/pyrime)](https://github.com/rimeinn/pyrime/watchers)\n[![github/contributors](https://shields.io/github/contributors/rimeinn/pyrime)](https://github.com/rimeinn/pyrime/graphs/contributors)\n[![github/commit-activity](https://shields.io/github/commit-activity/w/rimeinn/pyrime)](https://github.com/rimeinn/pyrime/graphs/commit-activity)\n[![github/last-commit](https://shields.io/github/last-commit/rimeinn/pyrime)](https://github.com/rimeinn/pyrime/commits)\n[![github/release-date](https://shields.io/github/release-date/rimeinn/pyrime)](https://github.com/rimeinn/pyrime/releases/latest)\n\n[![github/license](https://shields.io/github/license/rimeinn/pyrime)](https://github.com/rimeinn/pyrime/blob/main/LICENSE)\n[![github/languages](https://shields.io/github/languages/count/rimeinn/pyrime)](https://github.com/rimeinn/pyrime)\n[![github/languages/top](https://shields.io/github/languages/top/rimeinn/pyrime)](https://github.com/rimeinn/pyrime)\n[![github/directory-file-count](https://shields.io/github/directory-file-count/rimeinn/pyrime)](https://github.com/rimeinn/pyrime)\n[![github/code-size](https://shields.io/github/languages/code-size/rimeinn/pyrime)](https://github.com/rimeinn/pyrime)\n[![github/repo-size](https://shields.io/github/repo-size/rimeinn/pyrime)](https://github.com/rimeinn/pyrime)\n[![github/v](https://shields.io/github/v/release/rimeinn/pyrime)](https://github.com/rimeinn/pyrime)\n\n[![pypi/status](https://shields.io/pypi/status/pyrime)](https://pypi.org/project/pyrime/#description)\n[![pypi/v](https://shields.io/pypi/v/pyrime)](https://pypi.org/project/pyrime/#history)\n[![pypi/downloads](https://shields.io/pypi/dd/pyrime)](https://pypi.org/project/pyrime/#files)\n[![pypi/format](https://shields.io/pypi/format/pyrime)](https://pypi.org/project/pyrime/#files)\n[![pypi/implementation](https://shields.io/pypi/implementation/pyrime)](https://pypi.org/project/pyrime/#files)\n[![pypi/pyversions](https://shields.io/pypi/pyversions/pyrime)](https://pypi.org/project/pyrime/#files)\n\n[![aur/votes](https://img.shields.io/aur/votes/python-pyrime)](https://aur.archlinux.org/packages/python-pyrime)\n[![aur/popularity](https://img.shields.io/aur/popularity/python-pyrime)](https://aur.archlinux.org/packages/python-pyrime)\n[![aur/maintainer](https://img.shields.io/aur/maintainer/python-pyrime)](https://aur.archlinux.org/packages/python-pyrime)\n[![aur/last-modified](https://img.shields.io/aur/last-modified/python-pyrime)](https://aur.archlinux.org/packages/python-pyrime)\n[![aur/version](https://img.shields.io/aur/version/python-pyrime)](https://aur.archlinux.org/packages/python-pyrime)\n\n![screenshot](https://github.com/user-attachments/assets/5c79575c-79c5-4e4f-b6ab-b9cdaad352b2)\n\nrime for python, attached to prompt-toolkit keybindings for some prompt-toolkit\napplications such as ptpython.\n\nThis project is consist of two parts:\n\n- A python binding of librime\n- A librime frontend on ptpython\n- A librime frontend on neovim (TODO)\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 install librime pkg-config\n# Windows msys2\npacboy -S --noconfirm pkg-config librime gcc\n```\n\n## Usage\n\n### Binding\n\n```python\nfrom pyrime.ime.ui.vertical import UI\nfrom pyrime.key import Key\nfrom pyrime.session import Session\n\nsession = Session()\nkey = Key.new(\"n\")\nui = UI()\nif not session.process_key(key.code, key.mask):\n    raise Exception\ncontext = session.get_context()\nif context is None:\n    raise Exception\ncontent, _ = ui.draw(context)\nprint(\"\\n\".join(content))\n```\n\n```text\nn|\n[① 你]② 那 ③ 呢 ④ 能 ⑤ 年 ⑥ 您 ⑦ 内 ⑧ 拿 ⑨ 哪 ⓪ 弄 |\u003e\n```\n\nA simplest example can be found by:\n\n```sh\npip install pyrime[cli]\npython -m pyrime\n```\n\nBy default, pyrime search ibus/fcitx/trime's config paths. You can see where it\nfound:\n\n```python\nfrom pyrime.api import Traits\n\nprint(Traits.user_data_dir)\n```\n\n### Frontend\n\n#### Enable\n\n`~/.config/ptpython/config.py`:\n\n```python\nfrom ptpython.repl import PythonRepl\nfrom prompt_toolkit.key_binding.key_processor import KeyPressEvent\nfrom pyrime.ptpython.rime import Rime\n\n\ndef configure(repl: PythonRepl) -\u003e None:\n    rime = Rime(repl)\n\n    @repl.add_key_binding(\"c-^\", filter=rime.insert_mode)\n    def _(event: KeyPressEvent) -\u003e None:\n        rime.is_enabled = not rime.is_enabled\n```\n\nIf you have a special rime config path, you can:\n\n```python\nimport os\n\nfrom ptpython.repl import PythonRepl\nfrom pyrime.session import Session\nfrom pyrime.api import Traits\n\n\ndef configure(repl: PythonRepl) -\u003e None:\n\n    rime = Rime(\n        repl,\n        Session(Traits(user_config_dir=os.path.expanduser(\"~/.config/rime\"))),\n    )\n```\n\n#### Key Bindings\n\nIf you have defined some key bindings in `*_insert_mode`, they can disturb rime.\ntry:\n\n```python\n    # from prompt_toolkit.filters.app import emacs_insert_mode, vi_insert_mode\n\n    # @repl.add_key_binding(\"c-h\", filter=emacs_insert_mode | vi_insert_mode)\n    @repl.add_key_binding(\"c-h\", filter=rime.insert_mode)\n    def _(event: KeyPressEvent) -\u003e None:\n        pass\n```\n\nIf you want to exit rime in `vi_navigation_mode`, refer the following code of\n`pyrime.ptpython.bindings.viemacs`'s `load_viemacs_bindings()`:\n\n```python\n    from prompt_toolkit.filters.app import vi_navigation_mode\n\n    @repl.add_key_binding(\"escape\", filter=rime.insert_mode)\n    def _(event: KeyPressEvent) -\u003e None:\n        \"\"\"Switch insert mode to normal mode.\n\n        :param event:\n        :type event: KeyPressEvent\n        :rtype: None\n        \"\"\"\n        # store rime status\n        rime.iminsert = rime.is_enabled\n        # disable rime\n        rime.is_enabled = False\n        event.app.editing_mode = EditingMode.VI\n        event.app.vi_state.input_mode = InputMode.NAVIGATION\n\n    # and a, I, A, ...\n    @repl.add_key_binding(\"i\", filter=vi_navigation_mode)\n    def _(event: KeyPressEvent) -\u003e None:\n        \"\"\"Switch normal mode to insert mode.\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        # recovery rime status\n        rime.is_enabled = rime.iminsert\n```\n\nIt will remember rime status and enable it when reenter `vi_insert_mode` or\n`emacs_insert_mode`.\n\nSome predefined key bindings are\n[provided](https://github.com/rimeinn/pyrime/tree/main/src/pyrime/ptpython/bindings).\nYou can enable what you want:\n\n```python\nfrom prompt_toolkit.key_binding.key_bindings import merge_key_bindings\nfrom pyrime.ptpython.bindings.autopair import load_autopair_bindings\nfrom pyrime.ptpython.bindings.rime import load_rime_bindings\n\n# by default, last registry is:\n# from pyrime.ptpython.bindings import load_key_bindings\n# rime.app.key_bindings.registries[-1] = load_key_bindings(rime)\nrime.app.key_bindings.registries[-1] = merge_key_bindings([\n    load_rime_bindings(rime),\n    load_autopair_bindings(rime),\n])\n```\n\n## Related Projects\n\n- [A collection](https://github.com/rime/librime#frontends) of rime frontends\n- [A collection](https://github.com/rimeinn/ime.nvim/#librime) of rime frontends\n  for neovim\n- [A collection](https://github.com/rimeinn/rime.nvim#translators-and-filters)\n  of rime translators and filters\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frimeinn%2Fpyrime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frimeinn%2Fpyrime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frimeinn%2Fpyrime/lists"}