Some renaming and inlining of TerminalBuffer methods.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25892 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -330,8 +330,8 @@ TermParse::EscParse()
|
||||
int cs96 = 0;
|
||||
uchar curess = 0;
|
||||
|
||||
uchar cbuf[4], dstbuf[4];
|
||||
uchar *ptr;
|
||||
char cbuf[4], dstbuf[4];
|
||||
char *ptr;
|
||||
|
||||
int now_coding = -1;
|
||||
|
||||
@@ -393,9 +393,7 @@ TermParse::EscParse()
|
||||
//debug_printf("TermParse: char: '%c' (%d), parse state: %d\n", c, c, parsestate[c]);
|
||||
switch (parsestate[c]) {
|
||||
case CASE_PRINT:
|
||||
cbuf[0] = c;
|
||||
cbuf[1] = '\0';
|
||||
fBuffer->Insert(cbuf, attr);
|
||||
fBuffer->InsertChar((char)c, attr);
|
||||
break;
|
||||
|
||||
case CASE_PRINT_GR:
|
||||
@@ -414,14 +412,16 @@ TermParse::EscParse()
|
||||
case CASE_SS3: /* JIS X 0212 */
|
||||
*ptr++ = curess;
|
||||
*ptr++ = c;
|
||||
GetReaderBuf(*ptr++);
|
||||
GetReaderBuf(c);
|
||||
*ptr++ = c;
|
||||
*ptr = 0;
|
||||
curess = 0;
|
||||
break;
|
||||
|
||||
default: /* JIS X 0208 */
|
||||
*ptr++ = c;
|
||||
GetReaderBuf(*ptr++);
|
||||
GetReaderBuf(c);
|
||||
*ptr++ = c;
|
||||
*ptr = 0;
|
||||
break;
|
||||
}
|
||||
@@ -431,21 +431,23 @@ TermParse::EscParse()
|
||||
*ptr = 0;
|
||||
}
|
||||
|
||||
if (now_coding != B_JIS_CONVERSION)
|
||||
CodeConv::ConvertToInternal((char*)cbuf, -1, (char*)dstbuf, now_coding);
|
||||
else
|
||||
CodeConv::ConvertToInternal((char*)cbuf, -1, (char*)dstbuf, B_EUC_CONVERSION);
|
||||
if (now_coding != B_JIS_CONVERSION) {
|
||||
CodeConv::ConvertToInternal(cbuf, -1, dstbuf, now_coding);
|
||||
} else {
|
||||
CodeConv::ConvertToInternal(cbuf, -1, dstbuf,
|
||||
B_EUC_CONVERSION);
|
||||
}
|
||||
|
||||
fBuffer->Insert(dstbuf, attr);
|
||||
fBuffer->InsertChar(dstbuf, 4, attr);
|
||||
break;
|
||||
|
||||
case CASE_PRINT_CS96:
|
||||
cbuf[0] = c | 0x80;
|
||||
GetReaderBuf(cbuf[1]);
|
||||
cbuf[1] |= 0x80;
|
||||
GetReaderBuf(c);
|
||||
cbuf[1] = c | 0x80;
|
||||
cbuf[2] = 0;
|
||||
CodeConv::ConvertToInternal((char*)cbuf, 2, (char*)dstbuf, B_EUC_CONVERSION);
|
||||
fBuffer->Insert(dstbuf, attr);
|
||||
CodeConv::ConvertToInternal(cbuf, 2, dstbuf, B_EUC_CONVERSION);
|
||||
fBuffer->InsertChar(dstbuf, 4, attr);
|
||||
break;
|
||||
|
||||
case CASE_LF:
|
||||
@@ -457,29 +459,30 @@ TermParse::EscParse()
|
||||
break;
|
||||
|
||||
case CASE_SJIS_KANA:
|
||||
cbuf[0] = (uchar)c;
|
||||
cbuf[0] = c;
|
||||
cbuf[1] = '\0';
|
||||
CodeConv::ConvertToInternal((char*)cbuf, 1, (char*)dstbuf, now_coding);
|
||||
fBuffer->Insert(dstbuf, attr);
|
||||
CodeConv::ConvertToInternal(cbuf, 1, dstbuf, now_coding);
|
||||
fBuffer->InsertChar(dstbuf, 4, attr);
|
||||
break;
|
||||
|
||||
case CASE_SJIS_INSTRING:
|
||||
cbuf[0] = (uchar)c;
|
||||
GetReaderBuf(cbuf[1]);
|
||||
cbuf[0] = c;
|
||||
GetReaderBuf(c);
|
||||
cbuf[1] = c;
|
||||
cbuf[2] = '\0';
|
||||
CodeConv::ConvertToInternal((char*)cbuf, 2, (char*)dstbuf, now_coding);
|
||||
fBuffer->Insert(dstbuf, attr);
|
||||
CodeConv::ConvertToInternal(cbuf, 2, dstbuf, now_coding);
|
||||
fBuffer->InsertChar(dstbuf, 4, attr);
|
||||
break;
|
||||
|
||||
case CASE_UTF8_2BYTE:
|
||||
cbuf[0] = (uchar)c;
|
||||
cbuf[0] = c;
|
||||
GetReaderBuf(c);
|
||||
if (groundtable[c] != CASE_UTF8_INSTRING)
|
||||
break;
|
||||
cbuf[1] = (uchar)c;
|
||||
cbuf[1] = c;
|
||||
cbuf[2] = '\0';
|
||||
|
||||
fBuffer->Insert(cbuf, attr);
|
||||
fBuffer->InsertChar(cbuf, 2, attr);
|
||||
break;
|
||||
|
||||
case CASE_UTF8_3BYTE:
|
||||
@@ -494,7 +497,7 @@ TermParse::EscParse()
|
||||
break;
|
||||
cbuf[2] = c;
|
||||
cbuf[3] = '\0';
|
||||
fBuffer->Insert(cbuf, attr);
|
||||
fBuffer->InsertChar(cbuf, 3, attr);
|
||||
break;
|
||||
|
||||
case CASE_MBCS:
|
||||
@@ -526,13 +529,13 @@ TermParse::EscParse()
|
||||
break;
|
||||
|
||||
case CASE_BS:
|
||||
fBuffer->MoveCurLeft(1);
|
||||
fBuffer->MoveCursorLeft(1);
|
||||
break;
|
||||
|
||||
case CASE_TAB:
|
||||
tmp = fBuffer->GetCurX();
|
||||
tmp = fBuffer->Cursor().x;
|
||||
tmp %= 8;
|
||||
fBuffer->MoveCurRight(8 - tmp);
|
||||
fBuffer->MoveCursorRight(8 - tmp);
|
||||
break;
|
||||
|
||||
case CASE_ESC:
|
||||
@@ -600,7 +603,7 @@ TermParse::EscParse()
|
||||
/* CUU */
|
||||
if ((row = param[0]) < 1)
|
||||
row = 1;
|
||||
fBuffer->MoveCurUp(row);
|
||||
fBuffer->MoveCursorUp(row);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
@@ -608,7 +611,7 @@ TermParse::EscParse()
|
||||
/* CUD */
|
||||
if ((row = param[0]) < 1)
|
||||
row = 1;
|
||||
fBuffer->MoveCurDown(row);
|
||||
fBuffer->MoveCursorDown(row);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
@@ -616,7 +619,7 @@ TermParse::EscParse()
|
||||
/* CUF */
|
||||
if ((row = param[0]) < 1)
|
||||
row = 1;
|
||||
fBuffer->MoveCurRight(row);
|
||||
fBuffer->MoveCursorRight(row);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
@@ -624,7 +627,7 @@ TermParse::EscParse()
|
||||
/* CUB */
|
||||
if ((row = param[0]) < 1)
|
||||
row = 1;
|
||||
fBuffer->MoveCurLeft(row);
|
||||
fBuffer->MoveCursorLeft(row);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
@@ -635,7 +638,7 @@ TermParse::EscParse()
|
||||
if (nparam < 2 || (col = param[1]) < 1)
|
||||
col = 1;
|
||||
|
||||
fBuffer->SetCurPos(col - 1, row - 1 );
|
||||
fBuffer->SetCursor(col - 1, row - 1 );
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
@@ -651,7 +654,7 @@ TermParse::EscParse()
|
||||
break;
|
||||
|
||||
case 2:
|
||||
fBuffer->SetCurPos(0, 0);
|
||||
fBuffer->SetCursor(0, 0);
|
||||
fBuffer->EraseBelow();
|
||||
break;
|
||||
}
|
||||
@@ -668,7 +671,7 @@ TermParse::EscParse()
|
||||
/* IL */
|
||||
if ((row = param[0]) < 1)
|
||||
row = 1;
|
||||
fBuffer->InsertNewLine(row);
|
||||
fBuffer->InsertLines(row);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
@@ -676,7 +679,7 @@ TermParse::EscParse()
|
||||
/* DL */
|
||||
if ((row = param[0]) < 1)
|
||||
row = 1;
|
||||
fBuffer->DeleteLine(row);
|
||||
fBuffer->DeleteLines(row);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
@@ -684,7 +687,7 @@ TermParse::EscParse()
|
||||
/* DCH */
|
||||
if ((row = param[0]) < 1)
|
||||
row = 1;
|
||||
fBuffer->DeleteChar(row);
|
||||
fBuffer->DeleteChars(row);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
@@ -849,7 +852,7 @@ TermParse::EscParse()
|
||||
|
||||
case CASE_RI:
|
||||
/* RI */
|
||||
fBuffer->ScrollRegion(-1, -1, SCRDOWN, 1);
|
||||
fBuffer->ScrollBy(-1);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
@@ -948,7 +951,7 @@ TermParse::EscParse()
|
||||
row = 1;
|
||||
|
||||
// note beterm wants it 1-based unlike usual terminals
|
||||
fBuffer->SetCurY(row - 1);
|
||||
fBuffer->SetCursorY(row - 1);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
@@ -958,7 +961,7 @@ TermParse::EscParse()
|
||||
col = 1;
|
||||
|
||||
// note beterm wants it 1-based unlike usual terminals
|
||||
fBuffer->SetCurX(col - 1);
|
||||
fBuffer->SetCursorX(col - 1);
|
||||
parsestate = groundtable;
|
||||
break;
|
||||
|
||||
|
||||
@@ -680,15 +680,6 @@ TerminalBuffer::InsertChar(UTF8Char c, uint32 attributes)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TerminalBuffer::Insert(uchar* string, ushort attr)
|
||||
{
|
||||
// TODO: Remove! Use InsertChar instead!
|
||||
UTF8Char character((const char*)string, 4);
|
||||
InsertChar(character, attr);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TerminalBuffer::InsertCR()
|
||||
{
|
||||
@@ -713,7 +704,7 @@ TerminalBuffer::InsertLF()
|
||||
|
||||
|
||||
void
|
||||
TerminalBuffer::InsertNewLine(int numLines)
|
||||
TerminalBuffer::InsertLines(int32 numLines)
|
||||
{
|
||||
if (fCursor.y >= fScrollTop && fCursor.y < fScrollBottom)
|
||||
_Scroll(fCursor.y, fScrollBottom, -numLines);
|
||||
@@ -728,7 +719,7 @@ TerminalBuffer::SetInsertMode(int flag)
|
||||
|
||||
|
||||
void
|
||||
TerminalBuffer::InsertSpace(int num)
|
||||
TerminalBuffer::InsertSpace(int32 num)
|
||||
{
|
||||
// TODO: Deal with full-width chars!
|
||||
if (fCursor.x + num > fWidth)
|
||||
@@ -755,7 +746,7 @@ TerminalBuffer::EraseBelow()
|
||||
|
||||
|
||||
void
|
||||
TerminalBuffer::DeleteChar(int numChars)
|
||||
TerminalBuffer::DeleteChars(int32 numChars)
|
||||
{
|
||||
Line* line = _LineAt(fCursor.y);
|
||||
if (fCursor.x < line->length) {
|
||||
@@ -786,7 +777,7 @@ TerminalBuffer::DeleteColumns()
|
||||
|
||||
|
||||
void
|
||||
TerminalBuffer::DeleteLine(int numLines)
|
||||
TerminalBuffer::DeleteLines(int32 numLines)
|
||||
{
|
||||
if (fCursor.y >= fScrollTop && fCursor.y <= fScrollBottom)
|
||||
_Scroll(fCursor.y, fScrollBottom, numLines);
|
||||
@@ -794,9 +785,9 @@ TerminalBuffer::DeleteLine(int numLines)
|
||||
|
||||
|
||||
void
|
||||
TerminalBuffer::SetCurPos(int x, int y)
|
||||
TerminalBuffer::SetCursor(int32 x, int32 y)
|
||||
{
|
||||
//debug_printf("TerminalBuffer::SetCurPos(%d, %d)\n", x, y);
|
||||
//debug_printf("TerminalBuffer::SetCursor(%d, %d)\n", x, y);
|
||||
x = restrict_value(x, 0, fWidth - 1);
|
||||
y = restrict_value(y, fScrollTop, fScrollBottom);
|
||||
if (x != fCursor.x || y != fCursor.y) {
|
||||
@@ -807,27 +798,6 @@ TerminalBuffer::SetCurPos(int x, int y)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TerminalBuffer::SetCurX(int x)
|
||||
{
|
||||
SetCurPos(x, fCursor.y);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TerminalBuffer::SetCurY(int y)
|
||||
{
|
||||
SetCurPos(fCursor.x, y);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
TerminalBuffer::GetCurX()
|
||||
{
|
||||
return fCursor.x;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TerminalBuffer::SaveCursor()
|
||||
{
|
||||
@@ -838,54 +808,18 @@ TerminalBuffer::SaveCursor()
|
||||
void
|
||||
TerminalBuffer::RestoreCursor()
|
||||
{
|
||||
SetCurPos(fSavedCursor.x, fSavedCursor.y);
|
||||
SetCursor(fSavedCursor.x, fSavedCursor.y);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TerminalBuffer::MoveCurRight(int num)
|
||||
{
|
||||
SetCurPos(fCursor.x + num, fCursor.y);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TerminalBuffer::MoveCurLeft(int num)
|
||||
{
|
||||
SetCurPos(fCursor.x - num, fCursor.y);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TerminalBuffer::MoveCurUp(int num)
|
||||
{
|
||||
SetCurPos(fCursor.x, fCursor.y - num);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TerminalBuffer::MoveCurDown(int num)
|
||||
{
|
||||
SetCurPos(fCursor.x, fCursor.y + num);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TerminalBuffer::ScrollRegion(int top, int bot, int dir, int numLines)
|
||||
{
|
||||
// TODO: Is only invoked with SCRDOWN and numLines = 1
|
||||
_Scroll(fScrollTop, fScrollBottom, -1);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TerminalBuffer::SetScrollRegion(int top, int bottom)
|
||||
TerminalBuffer::SetScrollRegion(int32 top, int32 bottom)
|
||||
{
|
||||
fScrollTop = restrict_value(top, 0, fHeight - 1);
|
||||
fScrollBottom = restrict_value(bottom, fScrollTop, fHeight - 1);
|
||||
|
||||
// also sets the cursor position
|
||||
SetCurPos(0, 0);
|
||||
SetCursor(0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -54,7 +54,6 @@ public:
|
||||
|
||||
int32 Width() const { return fWidth; }
|
||||
int32 Height() const { return fHeight; }
|
||||
TermPos Cursor() const { return fCursor; }
|
||||
int32 HistorySize() const { return fHistorySize; }
|
||||
|
||||
TerminalBufferDirtyInfo& DirtyInfo() { return fDirtyInfo; }
|
||||
@@ -83,42 +82,41 @@ public:
|
||||
bool matchWord, TermPos& matchStart,
|
||||
TermPos& matchEnd) const;
|
||||
|
||||
// output character
|
||||
// insert chars/lines
|
||||
void InsertChar(UTF8Char c, uint32 attributes);
|
||||
void Insert(uchar* string, ushort attr);
|
||||
inline void InsertChar(const char* c, int32 length,
|
||||
uint32 attributes);
|
||||
void InsertCR();
|
||||
void InsertLF();
|
||||
void InsertNewLine(int numLines);
|
||||
void SetInsertMode(int flag);
|
||||
void InsertSpace(int num);
|
||||
void InsertSpace(int32 num);
|
||||
void InsertLines(int32 numLines);
|
||||
|
||||
// delete character
|
||||
// delete chars/lines
|
||||
void EraseBelow();
|
||||
void DeleteChar(int num);
|
||||
void DeleteChars(int32 numChars);
|
||||
void DeleteColumns();
|
||||
void DeleteLine(int num);
|
||||
void DeleteLines(int32 numLines);
|
||||
|
||||
// get and set cursor position
|
||||
// TODO: Inline most of these!
|
||||
void SetCurPos(int x, int y);
|
||||
void SetCurX(int x);
|
||||
void SetCurY(int y);
|
||||
int GetCurX();
|
||||
// get and set cursor position
|
||||
void SetCursor(int32 x, int32 y);
|
||||
inline void SetCursorX(int32 x);
|
||||
inline void SetCursorY(int32 y);
|
||||
inline TermPos Cursor() const { return fCursor; }
|
||||
void SaveCursor();
|
||||
void RestoreCursor();
|
||||
|
||||
// move cursor
|
||||
void MoveCurRight(int num);
|
||||
void MoveCurLeft(int num);
|
||||
void MoveCurUp(int num);
|
||||
void MoveCurDown(int num);
|
||||
// move cursor
|
||||
inline void MoveCursorRight(int32 num);
|
||||
inline void MoveCursorLeft(int32 num);
|
||||
inline void MoveCursorUp(int32 num);
|
||||
inline void MoveCursorDown(int32 num);
|
||||
|
||||
// scroll region
|
||||
void ScrollRegion(int top, int bot, int dir,
|
||||
int num);
|
||||
void SetScrollRegion(int top, int bot);
|
||||
// scroll region
|
||||
inline void ScrollBy(int32 numLines);
|
||||
void SetScrollRegion(int32 top, int32 bot);
|
||||
|
||||
// other
|
||||
// other
|
||||
void SetTitle(const char* title);
|
||||
void NotifyQuit(int32 reason);
|
||||
|
||||
@@ -190,4 +188,61 @@ private:
|
||||
TerminalBufferDirtyInfo fDirtyInfo;
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
TerminalBuffer::InsertChar(const char* c, int32 length, uint32 attributes)
|
||||
{
|
||||
return InsertChar(UTF8Char(c, length), attributes);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TerminalBuffer::SetCursorX(int32 x)
|
||||
{
|
||||
SetCursor(x, fCursor.y);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TerminalBuffer::SetCursorY(int32 y)
|
||||
{
|
||||
SetCursor(fCursor.x, y);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TerminalBuffer::MoveCursorRight(int32 num)
|
||||
{
|
||||
SetCursor(fCursor.x + num, fCursor.y);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TerminalBuffer::MoveCursorLeft(int32 num)
|
||||
{
|
||||
SetCursor(fCursor.x - num, fCursor.y);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TerminalBuffer::MoveCursorUp(int32 num)
|
||||
{
|
||||
SetCursor(fCursor.x, fCursor.y - num);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TerminalBuffer::MoveCursorDown(int32 num)
|
||||
{
|
||||
SetCursor(fCursor.x, fCursor.y + num);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TerminalBuffer::ScrollBy(int32 numLines)
|
||||
{
|
||||
_Scroll(fScrollTop, fScrollBottom, numLines);
|
||||
}
|
||||
|
||||
|
||||
#endif // TERMINAL_BUFFER_H
|
||||
|
||||
Reference in New Issue
Block a user