static void handle_newl(void) { XWindowAttributes wa; if(dzen.slave_win.max_lines && (dzen.slave_win.tcnt > last_cnt)) { do_action(onnewinput); if (XGetWindowAttributes(dzen.dpy, dzen.slave_win.win, &wa), wa.map_state != IsUnmapped /* autoscroll and redraw only if we're * currently viewing the last line of input */ && (dzen.slave_win.last_line_vis == last_cnt)) { dzen.slave_win.first_line_vis = 0; dzen.slave_win.last_line_vis = 0; x_draw_body(); } /* needed for a_scrollhome */ else if(wa.map_state != IsUnmapped && dzen.slave_win.last_line_vis == dzen.slave_win.max_lines) x_draw_body(); /* forget state if window was unmapped */ else if(wa.map_state == IsUnmapped || !dzen.slave_win.last_line_vis) { dzen.slave_win.first_line_vis = 0; dzen.slave_win.last_line_vis = 0; x_draw_body(); } last_cnt = dzen.slave_win.tcnt; } }
int a_scrollend(char * opt[]) { (void)opt; if(dzen.slave_win.max_lines) { dzen.slave_win.first_line_vis = dzen.slave_win.tcnt - dzen.slave_win.max_lines ; dzen.slave_win.last_line_vis = dzen.slave_win.tcnt; x_draw_body(); } return 0; }
static void scroll(int n) { if(dzen.slave_win.tcnt <= dzen.slave_win.max_lines) return; if(dzen.slave_win.first_line_vis + n < 0) { dzen.slave_win.first_line_vis = 0; dzen.slave_win.last_line_vis = dzen.slave_win.max_lines; } else if(dzen.slave_win.last_line_vis + n > dzen.slave_win.tcnt) { dzen.slave_win.first_line_vis = dzen.slave_win.tcnt - dzen.slave_win.max_lines; dzen.slave_win.last_line_vis = dzen.slave_win.tcnt; } else { dzen.slave_win.first_line_vis += n; dzen.slave_win.last_line_vis += n; } x_draw_body(); }
void drawbody(char * text) { char *ec; int i, write_buffer=1; if(dzen.slave_win.tcnt == -1) { dzen.slave_win.tcnt = 0; drawheader(text); return; } if((ec = strstr(text, "^tw()")) && (*(ec-1) != '^')) { drawheader(ec+5); return; } if(dzen.slave_win.tcnt == dzen.slave_win.tsize) free_buffer(); write_buffer = parse_non_drawing_commands(text); if(text[0] == '^' && text[1] == 'c' && text[2] == 's') { free_buffer(); for(i=0; i < dzen.slave_win.max_lines; i++) XFillRectangle(dzen.dpy, dzen.slave_win.drawable[i], dzen.rgc, 0, 0, dzen.slave_win.width, dzen.line_height); x_draw_body(); return; } if( write_buffer && (dzen.slave_win.tcnt < dzen.slave_win.tsize) ) { dzen.slave_win.tbuf[dzen.slave_win.tcnt] = estrdup(text); dzen.slave_win.tcnt++; } }