From 0353587069784fdf23a6412ab6edbbd9fc81eb0d 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 12:59:37 -0700 Subject: Cleaned up input method code, added preview function --- ptyim.c | 44 ++------------------------------------------ 1 file changed, 2 insertions(+), 42 deletions(-) (limited to 'ptyim.c') diff --git a/ptyim.c b/ptyim.c index 6fa6ac1..35f5563 100644 --- a/ptyim.c +++ b/ptyim.c @@ -34,47 +34,7 @@ void winchhook(int a) { ioctl(pty_slave, TIOCSWINSZ, &sz); } -void disp_im() { - //3 spaces for the im indicator +1 for automargin - int im_col = tcols - IM_TABLE_ENTRY_LEN - 4; - char pos_str[32] = ""; - int l = sprintf(pos_str, "\033[%d;%df",trows, im_col); - //printf("\0337"); - //printf("\033[%d;%df",trows,im_col); - //printf("\033[0;0f",trows,im_col); - //printf("\033[7m"); - //if (im_on) { - // printf("漢"); - //} else { - // printf("英"); - //} - //printf("%s",im_buffer); - //printf("\033[0m"); - //printf("\0338"); - write(STDOUT_FILENO,"\0337",2); - //also writes to top left the current im buffer - //write(STDOUT_FILENO,"\033[33;14f",8); - //write(STDOUT_FILENO,"\033[0;4f",6); - //write to the bottom left corner - write(STDOUT_FILENO, pos_str,l); - //invert video - write(STDOUT_FILENO,"\033[7m",4); - //overwrite what was there previously - write(STDOUT_FILENO," ", - IM_TABLE_ENTRY_LEN+4); - write(STDOUT_FILENO, pos_str,l); - //im mode indicator - if (im_on) { - write(STDOUT_FILENO,"漢:",4); - } else { - write(STDOUT_FILENO,"英:",4); - } - //actual buffer - write(STDOUT_FILENO,im_buffer,im_buffer_pos); - //restore cursor pos and attrbutes - write(STDOUT_FILENO,"\033[0m",4); - write(STDOUT_FILENO,"\0338",2); -} + int main (int argc, char * argv[], char * envp[]) { //creates the pty master int pty_master = posix_openpt(O_RDWR); @@ -187,7 +147,7 @@ int main (int argc, char * argv[], char * envp[]) { if (im_chars >0) { write(pty_master,input_buffer,im_chars); } - disp_im(); + disp_im(STDIN_FILENO, trows, tcols); } } } -- cgit v1.1