From 4020395d9767c061112bdeb7e0cef43751ec51a3 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Sun, 16 Jan 2011 23:04:31 +0000 Subject: [PATCH] resize by deleting lines below cursor first. git-svn-id: svn://qnap.local/TwoTerm/trunk@1993 5590a31f-7b70-45f8-8c82-aa3a8e5f4507 --- cpp/Screen.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/cpp/Screen.cpp b/cpp/Screen.cpp index dcf944f..e6835d2 100644 --- a/cpp/Screen.cpp +++ b/cpp/Screen.cpp @@ -868,8 +868,24 @@ void Screen::setSize(unsigned w, unsigned h) else if (height() > h) { unsigned count = height() - h; + int y = _port.cursor.y; + int maxY = height() - 1; + + // 1. erase from the bottom, up to the cursor (if blank) + // 2. erase lines from the top. + + while (count && maxY > y) + { + // todo -- check if blank... + _screen.pop_back(); + --count; + --maxY; + } + + // erase lines from the top. - _screen.erase(_screen.begin(), _screen.begin() + count); + if (count) + _screen.erase(_screen.begin(), _screen.begin() + count); }