remove old screen code

git-svn-id: svn://qnap.local/TwoTerm/branches/fix-gno-scrolling-region@3163 5590a31f-7b70-45f8-8c82-aa3a8e5f4507
This commit is contained in:
Kelvin Sherlock 2017-02-16 00:27:56 +00:00
parent 0291b21733
commit 2f0cd34e32
2 changed files with 0 additions and 307 deletions

View File

@ -1,124 +0,0 @@
//
// Screen_TextPort.cpp
// 2Term
//
// Created by Kelvin Sherlock on 1/11/2011.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#include "Screen.h"
void Screen::setTextPort(const TextPort& textPort)
{
TextPort tmp(textPort);
// call virtual method...
setSize(textPort.frame.width(), textPort.frame.height());
tmp.frame.origin = iPoint(0, 0);
_port = tmp;
}
/*
* Non-destructive tab.
* Sets the horizontal cursor position, may wrap and scroll
*
*
*/
void Screen::tabTo(TextPort *textPort, unsigned xPos)
{
if (!textPort) textPort = &_port;
iRect frame = textPort->frame;
// best case -- no wrapping needed.
if (xPos < frame.width())
{
textPort->cursor.x = xPos;
}
else if (textPort->rightMargin == TextPort::MarginWrap)
{
// worst case -- wrapping needed.
textPort->cursor.x = 0;
incrementY(textPort);
if (textPort != &_port) _port.cursor = textPort->absoluteCursor();
return;
}
else
{
// clamp to right margin.
textPort->cursor.x = frame.width() - 1;
}
if (textPort != &_port) _port.cursor = textPort->absoluteCursor();
return;
}
// insert a character at the current cursor position,
// moving all characters right 1.
// no wrapping is performed.
void Screen::insertc(TextPort *textPort, uint8_t c)
{
if (!textPort) textPort = &_port;
iRect frame = textPort->frame;
iPoint cursor = textPort->cursor;
iPoint absoluteCursor = textPort->absoluteCursor();
if (cursor.x >= frame.width()) return;
if (cursor.y >= frame.height()) return;
CharInfoIterator iter = _screen[absoluteCursor.y].begin();
CharInfoIterator begin = iter + absoluteCursor.x;
CharInfoIterator end = iter + frame.maxX();
CharInfo ci(c, _flag);
// move all chars forward 1.
for (iter = begin; iter < end; ++iter)
{
std::swap(ci, *iter);
}
_updates.push_back(absoluteCursor);
_updates.push_back(iPoint(frame.maxX(), absoluteCursor.y));
}
// delete the character at the current cursor position,
// moving any character to the right left 1 spot
// the final position is blank filled.
// no wrapping is performed.
void Screen::deletec(TextPort *textPort)
{
if (!textPort) textPort = &_port;
iRect frame = textPort->frame;
iPoint cursor = textPort->cursor;
iPoint absoluteCursor = textPort->absoluteCursor();
if (cursor.x >= frame.width()) return;
if (cursor.y >= frame.height()) return;
CharInfoIterator iter = _screen[absoluteCursor.y].begin();
CharInfoIterator begin = iter + absoluteCursor.x;
CharInfoIterator end = iter + frame.maxX() - 1;
for (iter = begin; iter < end; ++iter)
{
iter[0] = iter[1];
}
// not sure about the flag situation...
*iter = CharInfo(' ', _flag);
_updates.push_back(absoluteCursor);
_updates.push_back(iPoint(frame.maxX(), absoluteCursor.y));
}

View File

@ -1,183 +0,0 @@
//
// Screen_obsolete.cpp
// 2Term
//
// Created by Kelvin Sherlock on 1/11/2011.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#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 = ' ';
}
void Screen::eraseLine()
{
// erases everything to the right of, and including, the cursor
for (CharInfoIterator ciIter = _screen[y()].begin() + x(); ciIter < _screen[y()].end(); ++ciIter)
{
*ciIter = CharInfo(0, _flag);
}
_updates.push_back(cursor());
_updates.push_back(iPoint(width() - 1, y()));
}
void Screen::eraseScreen()
{
// returns everything to the right of, and including, the cursor as well as all subsequent lines.
eraseLine();
if (y() == height() -1) return;
for (ScreenIterator iter = _screen.begin() + y(); iter < _screen.end(); ++iter)
{
for (CharInfoIterator ciIter = iter->begin(); ciIter < iter->end(); ++ciIter)
{
*ciIter = CharInfo(0, _flag);
}
}
_updates.push_back(iPoint(0, y() + 1));
_updates.push_back(iPoint(width() - 1, height() - 1));
}