diff options
author | Haoran S. Diao (刁浩然) <0@hairydiode.xyz> | 2025-09-06 12:59:37 -0700 |
---|---|---|
committer | Haoran S. Diao (刁浩然) <0@hairydiode.xyz> | 2025-09-06 12:59:37 -0700 |
commit | 0353587069784fdf23a6412ab6edbbd9fc81eb0d (patch) | |
tree | 89a11c1e8401f01c9f43ce86119e9807c7cd1ef2 /ptyim.c | |
parent | 63b78eed2d0ec3a248ff7537fd7273102cf41e0a (diff) |
Cleaned up input method code, added preview function
Diffstat (limited to 'ptyim.c')
-rw-r--r-- | ptyim.c | 44 |
1 files changed, 2 insertions, 42 deletions
@@ -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); } } } |