From 416999e8b22ceb6265b3c31555b1ba72170773c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Haoran=20S=2E=20Diao=20=28=E5=88=81=E6=B5=A9=E7=84=B6=29?= <0@hairydiode.xyz> Date: Sat, 6 Sep 2025 16:17:24 -0700 Subject: Rebasing everything into a new repo --- cont/ptyim.html | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 cont/ptyim.html (limited to 'cont/ptyim.html') 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 @@ + +[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 +bash scripts and using xkb compose rules. + +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 ibus boshiamy implementation I based my IM table + off of + - Linux Akesson for this writeup which explained a everything + about how ttys work on linux + +Code and further reading are in a git repo here -- cgit v1.1