librime

repository·master·Indexed 26 days ago

https://github.com/rime/librime

A modular, extensible, cross-platform C++ input method engine supporting various Chinese input methods (shape-based and phonetic-based). It features a YAML-based DSL for input schemas, native support for regional standards like OpenCC, and a plugin system for extending functionality (e.g., Lua scripting, next-word prediction). librime serves as a core engine for various frontends including ibus-rime, Squirrel, and Weasel.

Tokens
3.1K
Snippets
15
Records
27
Agent score
89%

What's inside librime

  1. Explore librime Frontends

    master

    librime is an engine that requires a frontend to interact with users.

    Official Frontends

    • ibus-rime: IBus frontend for Linux
    • Squirrel: Frontend for macOS
    • Weasel: Frontend for Windows

    Community Frontends

    There are numerous community-maintained frontends for various platforms and editors, including:

    • Mobile: Hamster (iOS), Trime (Android), YuyanIme (Android), fcitx5-android (Android)
    • Desktop/Linux: fcitx-rime, fcitx5-rime, ibus-rime
    • Editors: coc-rime (Vim), emacs-rime (Emacs), rime.nvim (Vim), fcitx5-ui.nvim (Vim), fcitx5.nvim (Vim)
    • Terminal/Shell: ARIF (Readline), rl_custom_rime (Readline), tmux-rime (Tmux), zsh-rime (Zsh)
    • Other: My RIME (Web), PIME (Windows), XIME (macOS), rabbit (Windows), pyrime (Ptpython)
  2. Build the rime-sample plugin library

    master

    You can build the rime-sample plugin as either a built-in part of librime or as a separate shared library using the BUILD_MERGED_PLUGINS CMake option. To build it as a separate shared library, use the BUILD_SEPARATE_LIBS=ON option to speed up the build process by limiting dependencies to the core module.

    To build the shared library:

    cd librime
    cmake . -Bbuild -DBUILD_SAMPLE=ON -DBUILD_SEPARATE_LIBS=ON
    cmake --build build --target rime-sample
  3. Build a standard Rime plugin

    master

    Standard Rime plugins are separate projects that integrate into the librime build system without requiring modifications to the librime source code. To convert the sample into a standard plugin:

    1. Link or copy the plugin source code directory to plugins/sample.
    2. Set the CMake flag BUILD_SAMPLE=OFF.

    You can also use the install-plugins.sh script to fetch plugins from GitHub:

    cd librime
    bash install-plugins.sh rime/librime-sample
  4. Manually compile librime on macOS

    master

    To build librime from source on macOS, follow these steps:

    1. Install Prerequisites: Install Xcode with command line tools and build tools via Homebrew:

      brew install cmake git
    2. Get the Source: Clone the repository recursively to include submodules:

      git clone --recursive https://github.com/rime/librime.git
    3. Install Boost C++ libraries: Choose one of the following options:

      • Option 1 (Recommended for portability): Build from source using the provided script:
        cd librime
        bash install-boost.sh
        export BOOST_ROOT="$(pwd)/deps/boost-<version>"
      • Option 2 (Fastest): Use Homebrew. Note that binaries built this way may not be portable to machines without the same Homebrew formulae. If building with icu4c, update your LIBRARY_PATH:
        brew install boost
        export LIBRARY_PATH=${LIBRARY_PATH}:/opt/homebrew/opt/icu4c/lib:/usr/local/opt/icu4c/lib
      • Option 3 (For librime-charcode plugin compatibility): Install an older version of Boost that does not depend on icu4c:
        brew install boost@1.60
        brew link --force boost@1.60
    4. Build Third-party Dependencies: Build the libraries located in librime/deps/*:

      # Ensure submodules are initialized if not cloned recursively
      git submodule update --init
      make deps

      Note: You can build specific libraries individually, e.g., make deps/opencc.

    5. Build librime:

      • For a release build: make (outputs .dylib to build/lib/Release/ and tools to build/bin/Release/).
      • For a debug build: make debug.
    # Summary of manual build flow
    git clone --recursive https://github.com/rime/librime.git
    cd librime
    bash install-boost.sh
    export BOOST_ROOT="$(pwd)/deps/boost-1.89.0"
    make deps
    make