Commits

Robert Lowry committed e2374a8

split redraw so that input doesn't refresh the whole screen

  • Participants
  • Parent commits 59a09cb

Comments (0)

Files changed (1)

 Watch *curwatch = NULL;
 Watch *lastwatch = NULL;
 int rows,cols;
-int screenupdate = 1;
+int updatescreen = 1;
+int updateinput = 1;
 char input[MAX_IN];
 int inpos = 0;
 
 	endwin();
 	refresh();
 	getmaxyx(stdscr,rows,cols);
-	screenupdate = 1;
+	updatescreen = 1;
 }
 
 int read_line(int fd, char *buf, size_t count)
 		}
 	} while(num > 0);
 	if (w == curwatch)
-		screenupdate = 1;
+		updatescreen = 1;
 }
 
 Watch *new_watch()
 
 	offset = strlen(input) - cols;
 	if (offset < 0) offset = 0;
-	for(i=0;i<cols;i++)
-		mvaddch(rows-1,i,' ');
+	if(!updatescreen)
+		for(i=0;i<cols;i++)
+			mvaddch(rows-1,i,' ');
 	mvprintw(rows-1,0,"%s",input+offset);
+	updateinput = 0;
 }
 
 void draw_screen()
 {
-	clear();
-	draw_lines();
-	draw_bar();
-	draw_input();
-	refresh();
-	screenupdate = 0;
+	if(updatescreen) clear();
+	if(updatescreen) draw_lines();
+	if(updatescreen) draw_bar();
+	if(updatescreen || updateinput) draw_input();
+	if(updatescreen || updateinput) refresh();
+	updatescreen = 0;
 }
 
 void input_addch(int ch)
 		input[inpos] = ch;
 		input[++inpos] = '\0';
 	}
+	updateinput = 1;
 }
 
 void input_rmch()
 {
 	if (inpos > 0)
 		input[--inpos] = '\0';
+	updateinput = 1;
 }
 
 void write_input()
 		input[0] = '\0';
 		inpos = 0;
 	}
+	updateinput = 1;
 }
 
 void handle_ncurses_input()
 	ch = getch();
 	if(ch == ERR)
 		return;
-	screenupdate = 1;
 	switch(ch) {
 		case KEY_ESCAPE:
 			deinit_ncurses();
 			break;
 		case KEY_CONTROL_N:
 			curwatch = next_active(curwatch);
+			updatescreen = 1;
 			break;
 		case KEY_CONTROL_P:
 			curwatch = prev_active(curwatch);
+			updatescreen = 1;
+			break;
 		case '\n':
 			write_input();
 			break;
 	curwatch = next_active(watch);
 	for (;;) {
 		CHECK_WATCHES(dir, WATCH_TIMEOUT);
-		if(screenupdate) draw_screen();
+		draw_screen();
 		handle_ncurses_input();
 	}
 	deinit_ncurses();