diff options
author | Haoran S. Diao (刁浩然) <0@hairydiode.xyz> | 2025-09-06 16:17:24 -0700 |
---|---|---|
committer | Haoran S. Diao (刁浩然) <0@hairydiode.xyz> | 2025-09-06 16:17:24 -0700 |
commit | 416999e8b22ceb6265b3c31555b1ba72170773c1 (patch) | |
tree | 08b97a38aea914c21d2cec81fc0b4211fae6bd10 /cont/ptyim.html |
Rebasing everything into a new repo
Diffstat (limited to 'cont/ptyim.html')
-rw-r--r-- | cont/ptyim.html | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/cont/ptyim.html b/cont/ptyim.html new file mode 100644 index 0000000..6fff58b --- /dev/null +++ b/cont/ptyim.html @@ -0,0 +1,47 @@ +<!-- +123456789-223456789-323456789-423456789-523456789-623456789-723456789-8234567890 +一二三四--> +[TITLE] [DATE] +-------------------------------------------------------------------------------- +[SETTITLE]Non-Janky Input Method for the Linux Console (and other Terminals) +[SETDATE]09-06-2025 + +I've implemented boshiamy in a lot of convoluted ways so far. I've done it using +<a href="https://hairydiode.xyz/jankime">bash scripts</a> and using <a href="https://hairydiode.xyz/xkbabuse">xkb compose rules</a>. + +But the reason I've been trying to do this to be able to use an input method in +the Linux Console, and eventually a physical terminal. Back in the day they had +zhcon, which was a userspace virtual console with the input method built in, but +it's ugly and only supports dbcs encoding. + +I've also been building a real world physical serial terminal, and having the +input method implemented in software saves me the trouble of trying to fit it +inside of microcontroller ROM. + +One Idea I've had for a while is to simply write an input method that sits +between the terminal/console and whatever program is running. If tmux can do it +so can I, right? + +After digging through a LOT of manpages I finally made my idea true. It's a +program that creates a pseudoterminal with a shell (or your program of choice) +attached to it, and routes all input through an input method before it reaches +the pseudo terminal. + +I had to mess around with a bunch of stuff like low level POSIX termios +libraries, obscure linux system calls, session/process groups, and even terminal +escape codes. Luckily, almost everything I needed was in the manpages. + +The final implementation should be encoding agnostic, although it does make some +assumptions about the terminal you're using. All this can be changed by +modifying some macros. + +Testing so far it works on st, the linux console, kmscon and other terminal +emulators. It's compatible with pretty much every ncurses program I tried. + +Special Thanks to: + - 何震邦(jdh8) for this <a href="https://github.com/jdh8/ibus-boshiamy">ibus boshiamy implementation</a> I based my IM table + off of + - Linux Akesson for this <a href="https://www.linusakesson.net/programming/tty/">writeup</a> which explained a everything + about how ttys work on linux + +Code and further reading are in a git repo <a href="https://hairydiode.xyz/cgit/ptyim">here</a> |