diff options
-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); } |