From 513afcf4f8cd67275bad59251d1ee2a845d0ddca Mon Sep 17 00:00:00 2001 From: Marcus Brinkmann Date: Wed, 28 Aug 2002 17:28:36 +0000 Subject: hurd/ 2002-08-28 Marcus Brinkmann * console.h (struct cons_display): Fix comment on CUR_LINE. console/ 2002-08-28 Marcus Brinkmann * display.c (screen_fill): Take CUR_LINES modulo LINES. (screen_shift_left): Likewise. (screen_shift_right): Likewise. (linefeed): Don't take CUR_LINES modulo LINES here. libcons/ 2002-08-28 Marcus Brinkmann * file-changed.c (cons_S_file_changed): Take NEW_CUR_LINE modulo VCONS->state.screen.lines where appropriate. Adapt calculation of SCROLLING, and limit it to the screen size. Only scroll at all if there is something to scroll. Fix calculation of scrolled-in area. * vcons-refresh.c (cons_vcons_refresh): Take VCONS->state.screen.cur_line modulo VCONS->state.screen.lines. --- libcons/file-changed.c | 75 ++++++++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 33 deletions(-) (limited to 'libcons/file-changed.c') diff --git a/libcons/file-changed.c b/libcons/file-changed.c index ff51fa29..a681d626 100644 --- a/libcons/file-changed.c +++ b/libcons/file-changed.c @@ -87,41 +87,50 @@ cons_S_file_changed (cons_notify_t notify, natural_t tickno, } if (change.what.screen_cur_line) { - off_t size = vcons->state.screen.width - * vcons->state.screen.lines; - off_t vis_start; uint32_t new_cur_line; - int scrolling; - off_t start; - off_t end; new_cur_line = vcons->display->screen.cur_line; - scrolling = new_cur_line - vcons->state.screen.cur_line; - if (scrolling < 0) - scrolling += vcons->state.screen.lines; - cons_vcons_scroll (vcons, scrolling); - vis_start = vcons->state.screen.width * new_cur_line; - start = ((new_cur_line + vcons->state.screen.height - - scrolling) * vcons->state.screen.width) % size; - end = start + scrolling * vcons->state.screen.width - 1; - cons_vcons_write (vcons, vcons->state.screen.matrix + start, - end < size - ? end - start + 1 - : size - start, - (start - vis_start) - % vcons->state.screen.width, - (start - vis_start) - / vcons->state.screen.width); - if (end >= size) - cons_vcons_write (vcons, - vcons->state.screen.matrix, - end - size + 1, - (size - vis_start) - % vcons->state.screen.width, - (size - vis_start) - / vcons->state.screen.width); - cons_vcons_update (vcons); - vcons->state.screen.cur_line = new_cur_line; + if (new_cur_line != vcons->state.screen.cur_line) + { + off_t size = vcons->state.screen.width + * vcons->state.screen.lines; + off_t vis_start; + uint32_t scrolling; + off_t start; + off_t end; + + if (new_cur_line > vcons->state.screen.cur_line) + scrolling = new_cur_line + - vcons->state.screen.cur_line; + else + scrolling = UINT32_MAX - vcons->state.screen.cur_line + + 1 + new_cur_line; + if (scrolling > vcons->state.screen.height) + scrolling = vcons->state.screen.height; + if (scrolling < vcons->state.screen.height) + cons_vcons_scroll (vcons, scrolling); + vis_start = vcons->state.screen.width + * (new_cur_line % vcons->state.screen.lines); + start = (((new_cur_line % vcons->state.screen.lines) + + vcons->state.screen.height - scrolling) + * vcons->state.screen.width) % size; + end = start + scrolling * vcons->state.screen.width - 1; + cons_vcons_write (vcons, + vcons->state.screen.matrix + start, + end < size + ? end - start + 1 + : size - start, + 0, vcons->state.screen.height + - scrolling); + if (end >= size) + cons_vcons_write (vcons, + vcons->state.screen.matrix, + end - size + 1, + 0, (size - vis_start) + / vcons->state.screen.width); + cons_vcons_update (vcons); + vcons->state.screen.cur_line = new_cur_line; + } } if (change.what.screen_scr_lines) { @@ -152,7 +161,7 @@ cons_S_file_changed (cons_notify_t notify, natural_t tickno, /* For clipping. */ off_t size = vcons->state.screen.width*vcons->state.screen.lines; off_t rotate = vcons->state.screen.width - * vcons->state.screen.cur_line; + * (vcons->state.screen.cur_line % vcons->state.screen.lines); off_t vis_end = vcons->state.screen.height * vcons->state.screen.width - 1; off_t end2 = -1; -- cgit v1.2.3