Bộ gõ tiếng Việt không có chức năng gì ngoài gõ tiếng Việt...

Overview

This is my attempt to build an input method editor using only Rust. It's not the first, and definitely not the last.

The goal is to create an input method editor that allows the user to type Vietnamese text on the computer. Using either VNI or TELEX method. Other than that, no other feature are planned.

How to install

Currently, we're still in a very early stage, hence, no pre-built binaries are provided.

But you can get the source code and compile it yourself, it's very easy:

  1. Get the latest stable version of the Rust compiler (see here)
  2. Install the cargo-bundle extension, this is necessary for bundling macOS apps
  3. Checkout the source code of the gõkey project
    git clone https://github.com/huytd/goxkey && cd goxkey
    
  4. Run the bundle command:
    cargo bundle
    

After this, you'll find the Gõ Key.app file in the target/debug/bundle folder.

image

Dependencies

Development

Currently, only macOS is supported. Windows and Linux can be supported later but it's not in the roadmap. If you're on these OSes, any help would be greatly appreciated!

This project will only focus on the input handling logic, and provide a frontend for the input engine (vi-rs).

The following diagram explains how goxkey communicates with other components like OS's input source and vi-rs:

INPUT LAYER
+------------------+              FRONTEND                ENGINE
| macOS            | [d,d,a,a,y]  +---------+ "ddaay"     +-------+
|  +- CGEventTap   | -----------> | goxkey  | ----------> | vi-rs |
|                  |              +---------+             +-------+
| Linux   (TBD)    |               |  ^                    |
| Windows (TBD)    |               |  |              "đây" |
+------------------+               |  +--------------------+
                                   |
                                   | (send_key)
                                   v
                                Target
                                Application

On macOS, we run an instance of CGEventTap to listen for every keydown event. A callback function will be called on every keystroke. In this callback, we have a buffer (TYPING_BUF) to keep track of the word that the user is typing. This buffer will be reset whenever the user hit the SPACE or ENTER key.

The input engine (vi-rs) will receive this buffer and convert it to a correct word, for example: vieetj will be transformed into việt.

The result string will be sent back to goxkey, and from here, we will perform an edit on the target application. The edit is done using the BACKSPACE technique. It's unreliable but it has the benefit of not having the pre-edit line, worth it.

To get yourself familiar with IME, there are some good article on the topic:

Local development setup

To setup the project locally, first, checkout the code and run the install script to have all the Git hooks configured:

$ git clone https://github.com/huytd/goxkey && cd goxkey
$ make setup

After this step, you can use the make commands to run or bundle the code as needed:

$ make run

# or

$ make bundle
Comments
  • feat(UI): Implement the configuration UI

    feat(UI): Implement the configuration UI

    First step for the configuration dialog, there are still a lot todo.

    image

    Implementation steps:

    • [x] Build the basic UI for the configuration dialog
    • [x] Update the IME state from the UI
    • [x] Update the UI state for changes that are triggered from the IME
    • [ ] Implement a system tray icon
    • [ ] UI Functionalities
      • [ ] Config hotkey for toggling IME on/off
      • [ ] Config input method (VNI or Telex)
      • [x] Button to toggle IME on/off
    • [x] Add the ability to bundle the app on macOS
    opened by huytd 0
  • Docs: Translate the README.md into Vietnamese

    Docs: Translate the README.md into Vietnamese

    Lol. The target user is Vietnamese people. Not sure why I use English here in the first place...

    The plan for this ticket is as follows:

    • Write a proper introduction for gõkey, this is basically the "landing page" for the app
    • Move the technical notes into DEVELOPMENT.md file
    opened by huytd 2
  • UI: Detect when Secure Keyboard Input happen and tell the user

    UI: Detect when Secure Keyboard Input happen and tell the user

    Apps that deal with keyboard input, like IMEs or Hammerspoon, usually suffer from losing access to all keyboard input when Secure Keyboard Input happens. This makes the user unable to type in Vietnamese, as well as not able to toggle the input mode using the shortcut keys.

    Secure Keyboard Input is a macOS feature that will disable keyboard access for 3rd party apps when the user is in a private field like password input. See Apple's technical note on this topic for more details.

    Fig's documentation has some note on how to deal with Secure Keyboard Input, and we should have the same thing https://fig.io/docs/support/secure-keyboard-input

    opened by huytd 0
  • UI: Implement a dialog to notify user to enable Accessibilty Access

    UI: Implement a dialog to notify user to enable Accessibilty Access

    When the app started, it needed accessibility access to listen to mouse and keyboard events. The user needs to grant this access manually.

    To make it easier, implement a dialog that asks the user to do so and takes them to the correct screen in the System preferences.

    opened by huytd 0
  • UI: Implement system tray icon and menu

    UI: Implement system tray icon and menu

    The system tray should have the icon to show the current Vietnamese/English mode. As well as some menu item to display the control panel, quit the app, quickly toggle typing mode,...

    opened by huytd 0
Owner
Huy
Huy