Motivation
Currently, ttyper has no native support for IME-based languages (e.g., Chinese,
Japanese). In its current state, users have two choices when typing these languages:
- With an IME active: Users must type the phonetic keys (e.g., Pinyin), use the IME overlay to select the correct word, and then commit it to the terminal. This completely breaks the speed and actually is quite annoying.
- Without an IME: There is no way to map raw keystrokes directly to target characters. For instance, a user cannot type
nihao and have ttyper validate it against 你好.
Proposed Format
Language files would support a mixed format. Each line is either:
word — existing format, unchanged
key_to_type\tdisplay_text — new format, split on the first tab
Example (chinese_full_pinyin):
nihao 你好
zaijian 再见
hello ← existing format still works
This is compatible with previous language files.
Alignment
In a monospace terminal, CJK characters and some others unicode characters typically render as 2 columns wide. This means key_to_type and display_text may have different terminal widths:
| key |
display |
key width |
display width |
padding needed |
nihao |
你好 |
5 |
4 |
1 space after display |
zf |
字符 |
2 |
4 |
2 space after key (in input area) |
Each word slot should be padded to max(key_width, display_width) columns. The unicode-width crate (already a transitive dependency via ratatui) provides UnicodeWidthStr::width() for this calculation.
However, some weird terminal/font combinations render all characters as 1 column wide. Maybe there should be a config option (e.g., --cjk-width 1|2) to handle this?
Motivation
Currently, ttyper has no native support for IME-based languages (e.g., Chinese,
Japanese). In its current state, users have two choices when typing these languages:
nihaoand havettypervalidate it against你好.Proposed Format
Language files would support a mixed format. Each line is either:
word— existing format, unchangedkey_to_type\tdisplay_text— new format, split on the firsttabExample (
chinese_full_pinyin):nihao 你好
zaijian 再见
hello ← existing format still works
This is compatible with previous language files.
Alignment
In a monospace terminal, CJK characters and some others unicode characters typically render as 2 columns wide. This means key_to_type and display_text may have different terminal widths:
nihao你好zf字符Each word slot should be padded to max(key_width, display_width) columns. The unicode-width crate (already a transitive dependency via ratatui) provides UnicodeWidthStr::width() for this calculation.
However, some weird terminal/font combinations render all characters as 1 column wide. Maybe there should be a config option (e.g., --cjk-width 1|2) to handle this?