diff options
Diffstat (limited to 'ptyim.c')
-rw-r--r-- | ptyim.c | 26 |
1 files changed, 14 insertions, 12 deletions
@@ -49,8 +49,6 @@ pthread_t om_thread; pthread_t im_disp_thread; //stdout semaphore sem_t out_sem; -//tracks whether the screen has been updated by om -int om_updated = 1; //return 0 on success, -1 on error @@ -111,29 +109,33 @@ void * om_routine( void *arg) { // pty_master -> STDOUT int wchars_read = read(pty_master,write_buffer, WRITE_BUFFER_LEN); if (wchars_read >0) { - out_state = update_esc_state(write_buffer, wchars_read, out_state); - fprintf(stderr, "%c: %d\n", write_buffer[wchars_read-1], out_state); sem_wait(&out_sem); + out_state = update_esc_state(write_buffer, wchars_read, out_state, + &out_c_parity, &out_clr); + fprintf(stderr, "%c: %d\n", write_buffer[wchars_read-1], out_state); write(STDOUT_FILENO,write_buffer,wchars_read); sem_post(&out_sem); - //sets update flag, im_disp_routine will set it to 0 - om_updated = 1; } } } void * im_disp_routine (void *args) { while (running) { // Every run of this loop, it checks to see if im_buffer has - // updated, if it has, and no escape sequences have been written - // so far, it will display the im - if (im_updated |om_updated) { - fprintf(stderr, "printing im statusline\n"); + // updated, or if the screen has been cleared + + //then checks if the cursor save parity is right, and if the + //last output tot the terminal is safe to append to + if (im_updated | out_clr) { + if (out_c_parity != 0) { + continue; + } if (safe_state(out_state)) { + fprintf(stderr, "printing im statusline\n"); sem_wait(&out_sem); disp_im(STDIN_FILENO, trows, tcols); sem_post(&out_sem); im_updated = 0; - om_updated = 0; + out_clr = 0; } } } @@ -235,7 +237,7 @@ int main (int argc, char * argv[], char * envp[]) { if (rchars_read > 0) { //feeds input char into the escape state //machine - in_state = update_esc_state(read_buffer, 1, in_state); + in_state = update_esc_state(read_buffer, 1, in_state, NULL, NULL); //skips if the char was anything but //normal if (in_state == NORMAL || in_state ==DOUBLE_ESC) { |