Use a better way to store the attributes for end of line. This should also fix some other bugs, as there were occasionalaccess to out-of-range chars.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39669 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -240,6 +240,7 @@ BasicTerminalBuffer::SynchronizeWith(const BasicTerminalBuffer* other,
|
||||
if (sourceLine != NULL) {
|
||||
if (sourceLine != destLine) {
|
||||
destLine->length = sourceLine->length;
|
||||
destLine->attributes = sourceLine->attributes;
|
||||
destLine->softBreak = sourceLine->softBreak;
|
||||
if (destLine->length > 0) {
|
||||
memcpy(destLine->cells, sourceLine->cells,
|
||||
@@ -444,6 +445,14 @@ BasicTerminalBuffer::LineLength(int32 index) const
|
||||
}
|
||||
|
||||
|
||||
int32
|
||||
BasicTerminalBuffer::GetLineColor(int32 index) const
|
||||
{
|
||||
// TerminalLine* lineBuffer = ALLOC_LINE_ON_STACK(fWidth);
|
||||
TerminalLine* line = _LineAt(index);
|
||||
return line != NULL ? line->attributes : 0;
|
||||
}
|
||||
|
||||
bool
|
||||
BasicTerminalBuffer::Find(const char* _pattern, const TermPos& start,
|
||||
bool forward, bool caseSensitive, bool matchWord, TermPos& _matchStart,
|
||||
@@ -615,10 +624,8 @@ void
|
||||
BasicTerminalBuffer::InsertCR(uint32 attributes)
|
||||
{
|
||||
TerminalLine* line = _LineAt(fCursor.y);
|
||||
line->cells[fCursor.x].attributes = attributes;
|
||||
line->cells[fCursor.x].character = ' ';
|
||||
line->length ++;
|
||||
|
||||
line->attributes = attributes;
|
||||
line->softBreak = false;
|
||||
fSoftWrappedCursor = false;
|
||||
fCursor.x = 0;
|
||||
|
||||
@@ -92,6 +92,7 @@ public:
|
||||
bool findNonWords, TermPos& start,
|
||||
TermPos& end) const;
|
||||
int32 LineLength(int32 index) const;
|
||||
int32 GetLineColor(int32 index) const;
|
||||
|
||||
bool Find(const char* pattern, const TermPos& start,
|
||||
bool forward, bool caseSensitive,
|
||||
|
||||
@@ -118,6 +118,7 @@ HistoryBuffer::GetTerminalLineAt(int32 index, TerminalLine* buffer) const
|
||||
|
||||
buffer->length = charCount;
|
||||
buffer->softBreak = line->softBreak;
|
||||
buffer->attributes = line->attributes;
|
||||
|
||||
return buffer;
|
||||
}
|
||||
@@ -186,6 +187,7 @@ HistoryBuffer::AddLine(const TerminalLine* line)
|
||||
attributesRun->length = line->length - attributesRun->offset;
|
||||
|
||||
historyLine->softBreak = line->softBreak;
|
||||
historyLine->attributes = line->attributes;
|
||||
//debug_printf(" line: \"%.*s\", history size now: %ld\n", historyLine->byteLength, historyLine->Chars(), fSize);
|
||||
}
|
||||
|
||||
|
||||
@@ -1428,24 +1428,9 @@ TermView::Draw(BRect updateRect)
|
||||
SetHighColor(fSelectBackColor);
|
||||
FillRect(rect);
|
||||
} else {
|
||||
// We are not in the selection, so we have to try to
|
||||
// guess the color for this line from the last char
|
||||
// that was drawn in it.
|
||||
int t = 1;
|
||||
while (count == 0 && i - t >= 0) {
|
||||
count = fVisibleTextBuffer->GetString(
|
||||
j - firstVisible,
|
||||
i - t, lastColumn, buf, attr);
|
||||
t++;
|
||||
}
|
||||
|
||||
// If the line is completely empty, we use the default
|
||||
// back color.
|
||||
// TODO: It would be better to look at the line above,
|
||||
// or ensure each line is always initialized with an
|
||||
// attribute telling wat color to set.
|
||||
SetHighColor(count ? kTermColorTable[IS_BACKCOLOR(attr)]
|
||||
: kTermColorTable[0]);
|
||||
uint32 backcolor = IS_BACKCOLOR(fVisibleTextBuffer->GetLineColor(j));
|
||||
rgb_color rgb_back = kTermColorTable[backcolor];
|
||||
SetHighColor(rgb_back);
|
||||
FillRect(rect);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
#include "TermConst.h"
|
||||
|
||||
#include "UTF8Char.h"
|
||||
|
||||
|
||||
@@ -19,11 +21,13 @@ struct TerminalCell {
|
||||
struct TerminalLine {
|
||||
uint16 length;
|
||||
bool softBreak; // soft line break
|
||||
uint32 attributes;
|
||||
TerminalCell cells[1];
|
||||
|
||||
inline void Clear()
|
||||
{
|
||||
length = 0;
|
||||
attributes = 0;
|
||||
softBreak = false;
|
||||
}
|
||||
};
|
||||
@@ -41,6 +45,7 @@ struct HistoryLine {
|
||||
uint16 attributesRunCount; // number of attribute runs
|
||||
uint16 byteLength : 15; // number of bytes in the line
|
||||
bool softBreak : 1; // soft line break;
|
||||
uint32 attributes;
|
||||
|
||||
AttributesRun* AttributesRuns() const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user