c++11 updates.

git-svn-id: svn://qnap.local/TwoTerm/trunk@3114 5590a31f-7b70-45f8-8c82-aa3a8e5f4507
This commit is contained in:
Kelvin Sherlock 2016-07-11 02:25:39 +00:00
parent 291b16ff12
commit 64274d09c4
3 changed files with 29 additions and 35 deletions

View File

@ -99,9 +99,12 @@ void Screen::clearFlagBit(uint8_t bit)
void Screen::putc(TextPort *textPort, uint8_t c)
{
putc(textPort, c, _flag);
}
void Screen::putc(TextPort *textPort, uint8_t c, uint8_t flag)
{
/*
* textport must be valid.
@ -119,14 +122,14 @@ void Screen::putc(TextPort *textPort, uint8_t c)
if (textPort->rightMargin == TextPort::MarginOverwrite)
{
_updates.push_back(cursor);
_screen[cursor.y][cursor.x] = CharInfo(c, _flag);
_screen[cursor.y][cursor.x] = CharInfo(c, flag);
return;
}
//if (textPort->rightMargin == TextPort::MarginWrap)
}
_updates.push_back(cursor);
_screen[cursor.y][cursor.x] = CharInfo(c, _flag);
_screen[cursor.y][cursor.x] = CharInfo(c, flag);
if (textPort->advanceCursor)
{

View File

@ -19,11 +19,11 @@
typedef struct CharInfo {
CharInfo() : c(0), flag(0) {}
CharInfo() = default;
CharInfo(uint8_t cc, uint8_t ff) : c(cc), flag(ff) {}
uint8_t c;
uint8_t flag;
uint8_t c = 0;
uint8_t flag = 0;
} CharInfo;
@ -42,15 +42,15 @@ typedef struct TextPort {
iPoint cursor;
MarginBehavior leftMargin;
MarginBehavior rightMargin;
MarginBehavior leftMargin = MarginTruncate;
MarginBehavior rightMargin = MarginTruncate;
bool advanceCursor;
bool scroll;
bool advanceCursor = true;
bool scroll = true;
// clamp setCursor calls.
bool clampX;
bool clampY;
bool clampX = true;
bool clampY = true;
iPoint absoluteCursor() const;
@ -141,6 +141,7 @@ public:
void putc(uint8_t c, bool incrementX = true);
void putc(TextPort *textPort, uint8_t c);
void putc(TextPort *textPort, uint8_t c, uint8_t flags);
CharInfo getc(int x, int y) const;
@ -282,7 +283,7 @@ inline void Screen::unlock()
inline CharInfo Screen::getc(int x, int y) const
{
if (x < 0 || y < 0) return CharInfo(0,0);
if (x < 0 || y < 0) return CharInfo();
if (x >= width() || y >= height()) return CharInfo(0,0);
return _screen[y][x];

View File

@ -11,18 +11,12 @@
#define __IGEOMETRY_H__
#ifdef __cplusplus
#define equal_zero = 0
#else
#define equal_zero
#endif
typedef struct iSize {
int width equal_zero;
int height equal_zero;
int width = 0;
int height = 0;
#ifdef __cplusplus
iSize() = default;
iSize(const iSize &) = default;
iSize(int w, int h) : width(w), height(h) {}
@ -34,17 +28,15 @@ typedef struct iSize {
bool operator!=(const iSize& aSize)
{ return !(*this == aSize); }
#endif
} iSize;
typedef struct iPoint {
int x equal_zero;
int y equal_zero;
int x = 0;
int y = 0;
#ifdef __cplusplus
iPoint() = default;
iPoint(const iPoint &aPoint) = default;
iPoint(int xx, int yy) : x(xx), y(yy) {}
@ -62,9 +54,7 @@ typedef struct iPoint {
iPoint offset(iSize aSize) const
{ return iPoint(x + aSize.width, y + aSize.height); }
#endif
} iPoint;
@ -73,11 +63,15 @@ typedef struct iRect {
iPoint origin;
iSize size;
#ifdef __cplusplus
iRect() = default;
iRect(const iRect &aRect) = default;
iRect(const iPoint &aPoint, const iSize &aSize) : origin(aPoint), size(aSize) {}
iRect(int x, int y, int width, int height) : origin(iPoint(x, y)), size(iSize(width, height)) {}
iRect(int x, int y, int width, int height) : origin(x, y), size(width, height) {}
iRect(const iPoint &topLeft, const iPoint &bottomRight) :
origin(topLeft), size(bottomRight.x - topLeft.x, bottomRight.y - topLeft.y)
{}
iRect &operator=(const iRect &) = default;
@ -106,10 +100,6 @@ typedef struct iRect {
{ return minY() + height(); }
#endif
} iRect;
#undef equal_zero
#endif