From 613e8319b488d2cbeb4125193294d09174ddab18 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Sun, 16 Jan 2011 23:04:53 +0000 Subject: [PATCH] add back pre-textport methods. git-svn-id: svn://qnap.local/TwoTerm/trunk@1994 5590a31f-7b70-45f8-8c82-aa3a8e5f4507 --- cpp/Screen_obsolete.cpp | 141 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 140 insertions(+), 1 deletion(-) diff --git a/cpp/Screen_obsolete.cpp b/cpp/Screen_obsolete.cpp index 3967d18..d4dcf7d 100644 --- a/cpp/Screen_obsolete.cpp +++ b/cpp/Screen_obsolete.cpp @@ -1,5 +1,5 @@ // -// Screen_Texport.cpp +// Screen_obsolete.cpp // 2Term // // Created by Kelvin Sherlock on 1/11/2011. @@ -7,3 +7,142 @@ // #include "Screen.h" + +void Screen::setX(int x, bool clamp) +{ + if (x < 0) + { + if (clamp) _port.cursor.x = 0; + return; + } + if (x >= width()) + { + if (clamp) _port.cursor.x = width() - 1; + return; + } + + _port.cursor.x = x; +} + + +void Screen::setY(int y, bool clamp) +{ + if (y < 0) + { + if (clamp) _port.cursor.y = 0; + return; + } + if (y >= height()) + { + if (clamp) _port.cursor.y = height() - 1; + return; + } + + _port.cursor.y = y; +} + +int Screen::incrementX(bool clamp) +{ + setX(_port.cursor.x + 1, clamp); + return _port.cursor.x; +} + +int Screen::decrementX(bool clamp) +{ + setX(_port.cursor.x - 1, clamp); + return _port.cursor.x; +} + +int Screen::incrementY(bool clamp) +{ + setY(_port.cursor.y + 1, clamp); + return _port.cursor.y; +} + +int Screen::decrementY(bool clamp) +{ + setY(_port.cursor.y - 1, clamp); + return _port.cursor.y; +} + +void Screen::tabTo(unsigned xPos) +{ + CharInfo clear(' ', _flag); + CharInfoIterator iter; + + xPos = std::min((int)xPos, width() - 1); + + + _updates.push_back(_port.cursor); + _updates.push_back(iPoint(xPos, _port.cursor.y)); + + for (unsigned x = _port.cursor.x; x < xPos; ++x) + { + _screen[_port.cursor.y][x] = clear; + } + _port.cursor.x = xPos; +} + + + + +void Screen::putc(uint8_t c, bool incrementX) +{ + if (_port.cursor.x < width()) + { + _updates.push_back(_port.cursor); + + _screen[_port.cursor.y][_port.cursor.x] = CharInfo(c, _flag); + + if (incrementX && _port.cursor.x < width() - 1) ++_port.cursor.x; + } +} + + + +void Screen::deletec() +{ + // delete character at cursor. + // move following character up + // set final character to ' ' (retaining flags from previous char) + + if (_port.cursor.x >= width()) return; + + _updates.push_back(_port.cursor); + _updates.push_back(iPoint(width() - 1, _port.cursor.y)); + + + CharInfoIterator end = _screen[_port.cursor.y].end() - 1; + CharInfoIterator iter = _screen[_port.cursor.y].begin() + _port.cursor.x; + + + for ( ; iter != end; ++iter) + { + iter[0] = iter[1]; + + } + // retain the flags previously there. + end->c = ' '; +} + + +void Screen::insertc(uint8_t c) +{ + // insert character at cursor. + // move following characters up (retaining flags). + + if (_port.cursor.x >= width()) return; + + _updates.push_back(_port.cursor); + _updates.push_back(iPoint(width() - 1, _port.cursor.y)); + + CharInfoIterator end = _screen[_port.cursor.y].end() - 1; + CharInfoIterator iter = _screen[_port.cursor.y].begin() + _port.cursor.x; + + for ( ; iter != end; ++iter) + { + iter[1] = iter[0]; + } + + iter->c = ' '; +}