From cb31a5025127f8e16c705c88f439a8f819952827 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, 25 Nov 2023 03:45:16 -0800 Subject: Moved everything out of dotfiles --- bimt | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100755 bimt (limited to 'bimt') diff --git a/bimt b/bimt new file mode 100755 index 0000000..4bef88f --- /dev/null +++ b/bimt @@ -0,0 +1,62 @@ +#!/bin/bash +#Janky ibus table boshiamy implementation for tmux, this variant prints +#characters using braille display + +#gets current window id of IME and puts it here +code="" +clear +while true; do + #need IFS="" so read reads spaces + OIFS=$IFS + export IFS=""; read -rsn1 i + export IFS=$OIFS + #echo ".$i." + if [[ "$i" = [abcdefghijklmnopqrstuvwxyz,.] ]]; then + clear + #escape periods + i=$(echo $i |sed 's/\./\\\./g') + code=$code$i + opt=$(grep "^$code\s" ~/lang/zh/boshiamy/ibus-boshiamy/boshiamy.txt |\ + #remove simplfied + grep -v 98|\ + awk '{print $3" "$2}' |\ + sort -nr|\ + awk '{print $2}') + echo $opt + echo $code + #because the braille font display is incredibly slow, truncate + # to first 5 options, this is unicode aware + opt=${opt:0:5} + #send options to textd for braille display, 8x8 bdf fonts + #assumed to be here + echo $opt | textd ~/lang/fonts/12 + elif [[ "$i" = [0123456789] ]]; then + if [ "$code" == "" ]; then + char=$i + else + clear + char=$(echo $opt | awk "{print \$$i}") + code="" + fi + tmux send-key -t "!" "$char" + #dirty hack for detecting space + elif [ "<$i>" == "< >" ]; then + if [ "$code" == "" ]; then + char=" " + else + clear + char=$(echo $opt | awk "{print \$1}") + code="" + fi + tmux send-key -t "!" "$char" + elif [[ "$i" = '`' ]]; then + clear + code="" + #if enter is pressed then I am done editing + elif [[ "$i" = "" ]]; then + #-r "!" means the previous window + tmux send-keys -t "!" Enter + else + tmux send-key -t "!" "$i" + fi +done -- cgit v1.1