texport additions.

git-svn-id: svn://qnap.local/TwoTerm/trunk@1985 5590a31f-7b70-45f8-8c82-aa3a8e5f4507
This commit is contained in:
Kelvin Sherlock 2011-01-12 03:43:41 +00:00
parent 6b9b1086f7
commit fbb90864c3
3 changed files with 153 additions and 4 deletions

View File

@ -420,7 +420,7 @@ void Screen::erase(EraseRegion region)
if (region == EraseLineBeforeCursor)
{
std::fill(_screen[y()].begin(), _screen[y()].begin() + x() + 1, CharInfo(0,0));
std::fill(_screen[y()].begin(), _screen[y()].begin() + x(), CharInfo(0,0));
_updates.push_back(iPoint(0, y()));
_updates.push_back(cursor());
@ -435,7 +435,144 @@ void Screen::erase(EraseRegion region)
_updates.push_back(cursor());
_updates.push_back(iPoint(width() - 1, y()));
return;
}
}
void Screen::erase(TextPort* textPort, EraseRegion region)
{
if (!textPort) textPort = &_port;
iRect frame = textPort->frame;
iPoint cursor = textPort->absoluteCursor();
if (region == EraseAll)
{
//erase the current screen
ScreenIterator begin = _screen.begin() + frame.minY();
ScreenIterator end = _screen.begin() + frame.maxY();
for (ScreenIterator iter = begin; iter != end; ++iter)
{
CharInfoIterator begin = iter->begin() + frame.minX();
CharInfoIterator end = iter->begin() + frame.maxX();
std::fill(begin, end, CharInfo(0, 0));
}
_updates.push_back(frame.origin);
_updates.push_back(iPoint(frame.maxX() - 1, frame.maxY() - 1));
return;
}
if (region == EraseLineAll)
{
// erase the current line.
ScreenIterator iter = _screen.begin() + cursor.y;
CharInfoIterator begin = iter->begin() + frame.minX();
CharInfoIterator end = iter->begin() + frame.maxX();
std::fill(begin, end, CharInfo(0, 0));
_updates.push_back(iPoint(frame.minX(), cursor.y));
_updates.push_back(iPoint(frame.maxX() - 1, cursor.y));
return;
}
if (region == EraseBeforeCursor)
{
// erase everything before the cursor
// part 1 -- erase all lines prior to the current line.
ScreenIterator begin = _screen.begin() + frame.minY();
ScreenIterator end = _screen.begin() + cursor.y;
for (ScreenIterator iter = begin; iter != end; ++iter)
{
CharInfoIterator begin = iter->begin() + frame.minX();
CharInfoIterator end = iter->begin() + frame.maxX();
std::fill(begin, end, CharInfo(0, 0));
}
_updates.push_back(frame.origin);
_updates.push_back(iPoint(frame.maxX() - 1, cursor.y - 1));
// handle rest below.
region = EraseLineBeforeCursor;
}
if (region == EraseAfterCursor)
{
// erase everything after the cursor
// part 1 -- erase all lines after the current line.
ScreenIterator begin = _screen.begin() + cursor.y + 1;
ScreenIterator end = _screen.begin() + frame.maxY();
if (begin < end)
{
for (ScreenIterator iter = begin; iter != end; ++iter)
{
CharInfoIterator begin = iter->begin() + frame.minX();
CharInfoIterator end = iter->begin() + frame.maxX();
std::fill(begin, end, CharInfo(0, 0));
}
_updates.push_back(iPoint(cursor.x, cursor.y + 1));
_updates.push_back(iPoint(frame.maxX() - 1, frame.maxY() - 1));
}
region = EraseLineAfterCursor;
}
if (region == EraseLineBeforeCursor)
{
// erase the current line, before the cursor.
ScreenIterator iter = _screen.begin() + cursor.y;
CharInfoIterator begin = iter->begin() + frame.minX();
CharInfoIterator end = iter->begin() + cursor.x;
std::fill(begin, end, CharInfo(0, 0));
_updates.push_back(iPoint(frame.minX(), cursor.y));
_updates.push_back(iPoint(cursor.x - 1, cursor.y));
return;
}
if (region == EraseLineAfterCursor)
{
// erase the current line, after the cursor.
ScreenIterator iter = _screen.begin() + cursor.y;
CharInfoIterator begin = iter->begin() + cursor.x;
CharInfoIterator end = iter->begin() + frame.maxX();
std::fill(begin, end, CharInfo(0, 0));
_updates.push_back(iPoint(cursor.x, cursor.y));
_updates.push_back(iPoint(frame.maxX() - 1, cursor.y));
return;
}
}

View File

@ -56,7 +56,7 @@ typedef struct TextPort {
iPoint absoluteCursor() const;
};
} TextPort;
class Screen {
@ -68,6 +68,8 @@ public:
static const unsigned FlagBold = 0x04;
static const unsigned FlagUnderscore = 0x08;
static const unsigned FlagBlink = 0x10;
static const unsigned FlagStrike = 0x20;
static const unsigned FlagSelected = 0x8000;
@ -119,9 +121,9 @@ public:
int incrementY(TextPort *textPort);
int decrementX(TextPort *textPort);
int decrementY(TextPort *textPort);
int decrementY(TextPort *textPort);
void setCursor(TextPort *textPort,iPoint point);
void setCursor(TextPort *textPort, iPoint point);
void setCursor(TextPort *textPort, int x, int y);
@ -145,6 +147,7 @@ public:
void erase(EraseRegion);
void erase(TextPort *, EraseRegion);
void eraseLine();
void eraseScreen();

9
Screen_Texport.cpp Normal file
View File

@ -0,0 +1,9 @@
//
// Screen_Texport.cpp
// 2Term
//
// Created by Kelvin Sherlock on 1/11/2011.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#include "Screen.h"