From 2c7bc9c1c2f9f8830114b67648ae913025d15c5f Mon Sep 17 00:00:00 2001 From: Andrew Borodin Date: Thu, 13 May 2010 17:21:49 +0400 Subject: [PATCH] Ticket #2157: fixed tty_fill_region() for ncurses-based TTY layer. If filled region is larger than screen, NCurses doesn't fill it unlike S-Lang. This patch fixes such behaviour: only visible part of region is filled. Signed-off-by: Andrew Borodin --- lib/tty/tty-ncurses.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/tty/tty-ncurses.c b/lib/tty/tty-ncurses.c index c59feacf3..b7a521385 100644 --- a/lib/tty/tty-ncurses.c +++ b/lib/tty/tty-ncurses.c @@ -295,6 +295,31 @@ tty_fill_region (int y, int x, int rows, int cols, unsigned char ch) { int i; + if (y < 0) + { + rows += y; + + if (rows <= 0) + return; + + y = 0; + } + + if (x < 0) + { + cols += x; + + if (cols <= 0) + return; + + x = 0; + } + + if (y + rows > LINES) + rows = LINES - y; + if (x + cols > COLS) + cols = COLS - x; + for (i = 0; i < rows; i++) { move (y + i, x);