diff options
author | Haoran S. Diao (刁浩然) <0@hairydiode.xyz> | 2025-09-13 01:23:49 -0700 |
---|---|---|
committer | Haoran S. Diao (刁浩然) <0@hairydiode.xyz> | 2025-09-13 01:23:49 -0700 |
commit | e0d4fadb292d51cbeb4724bcb1abf61887db36b3 (patch) | |
tree | e73850e038259788a0f42dfdffda13ee65f0b3f9 | |
parent | 3f9b35631b0977dc2afc289cbff7702469153f77 (diff) |
Fixed order of attribute clearing for im display
-rw-r--r-- | im.h | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -56,11 +56,14 @@ int is_im_key(char input, unsigned int chars) { } char im_buffer[IM_BUFFER_LEN+1]; unsigned int im_buffer_pos = 0; +//set to 1 if the im buffer is changed, im_set_routine sets it back to zero +int im_updated = 1; int im_on = 1; //clears the im buffer void clear_im_buffer() { im_buffer[0] = 0; im_buffer_pos = 0; + im_updated = 1; } //recursive search, returns -1 on failure //searches from [start, end), @@ -109,6 +112,7 @@ int update_im_state(char input, char * output) { if (!im_on) { clear_im_buffer(); } + im_updated = 1; //do not passthrough the toggle return 0; } @@ -124,6 +128,7 @@ int update_im_state(char input, char * output) { im_buffer[im_buffer_pos] = input; im_buffer_pos++; im_buffer[im_buffer_pos] = 0; + im_updated = 1; } else { //passthrough output[0] = input; @@ -165,6 +170,7 @@ int update_im_state(char input, char * output) { if (im_buffer_pos > 0) { im_buffer_pos--; im_buffer[im_buffer_pos] = 0; + im_updated = 1; } return 0; break; @@ -234,6 +240,8 @@ void disp_im(int fd, int trows, int tcols) { write(fd,"\0337",2); //saves previous cursor position unrestrict_scroll(fd); //unrestricts the scrolling region + //undos any attributes that may have been set before + write(fd,"\033[0m",4); write(fd, pos_str,l); write(fd,"\033[7m",4); //invert video @@ -262,6 +270,5 @@ void disp_im(int fd, int trows, int tcols) { restrict_scroll(fd, trows, tcols); //resets scroll region //restore cursor pos and attrbutes - write(fd,"\033[0m",4); write(fd,"\0338",2); } |