From 565ba002e90dab150654a141bc305ca4f62776e2 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Mon, 27 Aug 2007 11:21:05 +0000 Subject: [PATCH] Don't scroll screen until trying to write beyond limits. --- screen.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/screen.c b/screen.c index bcd7f611..b78bc6c1 100644 --- a/screen.c +++ b/screen.c @@ -1,4 +1,4 @@ -/* $Id: screen.c,v 1.6 2007-08-27 10:08:44 nicm Exp $ */ +/* $Id: screen.c,v 1.7 2007-08-27 11:21:05 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -621,15 +621,16 @@ screen_sequence(struct screen *s, u_char *ptr) void screen_write_character(struct screen *s, u_char ch) { + if (s->cx > screen_last_x(s)) { + s->cx = 0; + screen_cursor_down_scroll(s, 1); + } + s->grid_data[s->cy][s->cx] = ch; s->grid_attr[s->cy][s->cx] = s->attr; s->grid_colr[s->cy][s->cx] = s->colr; s->cx++; - if (s->cx > screen_last_x(s)) { - s->cx = 0; - screen_cursor_down_scroll(s, 1); - } } /* Move cursor up and scroll if necessary. */ @@ -647,7 +648,7 @@ screen_cursor_up_scroll(struct screen *s, u_int ny) void screen_cursor_down_scroll(struct screen *s, u_int ny) { - if (screen_last_y(s) - s->cy < ny) { + if (s->cy + ny > screen_last_y(s)) { screen_scroll_up(s, ny - (screen_last_y(s) - s->cy)); s->cy = screen_last_y(s); } else