Commit 7b19861c authored by Waldo Bastian's avatar Waldo Bastian
Browse files

* Fix drawing of multi-column characters

* Fix selection of multi-column characters

svn path=/trunk/kdebase/konsole/; revision=137549
parent 2ff1414f
......@@ -1123,107 +1123,111 @@ QString TEScreen::getSelText(const BOOL preserve_line_breaks)
d = 0;
while (s <= sel_BR)
{
{
if (s < hist_BR)
{ // get lines from hist->history buffer.
eol = hist->getLineLen(hY);
if ((hY == (sel_BR / columns)) &&
(eol > (sel_BR % columns)))
{
eol = sel_BR % columns + 1;
}
while (hX < eol)
{
m[d++] = hist->getCell(hY, hX++).c;
s++;
}
if (s <= sel_BR)
{ // The line break handling
if (eol % columns == 0)
{ // That's either a full or empty line
if (eol == 0)
{ // empty line, not wrapped
m[d++] = preserve_line_breaks ? '\n' : ' ';
}
else
{ // We have a full line.
if (!hist->isWrappedLine(hY))
{ // line is not wrapped
m[d++] = preserve_line_breaks ? '\n' : ' ';
}
}
}
else if ((eol + 1) % columns == 0)
{
{ // get lines from hist->history buffer.
eol = hist->getLineLen(hY);
if ((hY == (sel_BR / columns)) &&
(eol > (sel_BR % columns)))
{
eol = sel_BR % columns + 1;
}
while (hX < eol)
{
Q_UINT16 c = hist->getCell(hY, hX++).c;
if (c)
m[d++] = c;
s++;
}
if (s <= sel_BR)
{ // The line break handling
if (eol % columns == 0)
{ // That's either a full or empty line
if (eol == 0)
{ // empty line, not wrapped
m[d++] = preserve_line_breaks ? '\n' : ' ';
}
else
{ // We have a full line.
if (!hist->isWrappedLine(hY))
{ // line is not wrapped
m[d++] = preserve_line_breaks ? '\n' : ' ';
}
}
}
else if ((eol + 1) % columns == 0)
{
if (!hist->isWrappedLine(hY))
{
m[d++] = preserve_line_breaks ? '\n' : ' ';
}
}
else
{ // We have a short line here.
m[d++] = preserve_line_breaks ? '\n' : ' ';
}
}
hY++;
hX = 0;
s = hY * columns;
}
else
{
m[d++] = preserve_line_breaks ? '\n' : ' ';
}
}
else
{ // We have a short line here.
m[d++] = preserve_line_breaks ? '\n' : ' ';
}
}
hY++;
hX = 0;
s = hY * columns;
}
else
{ // or from screen image.
eol = (s / columns + 1) * columns - 1;
eol = (s / columns + 1) * columns - 1;
bool addNewLine = false;
if (eol < sel_BR)
{
while ((eol > s) &&
isspace(image[eol - hist_BR].c) &&
if (eol < sel_BR)
{
while ((eol > s) &&
(!image[eol - hist_BR].c || isspace(image[eol - hist_BR].c)) &&
!line_wrapped[(eol-hist_BR)/columns])
{
eol--;
}
}
else if (eol == sel_BR)
{
{
eol--;
}
}
else if (eol == sel_BR)
{
addNewLine = true;
}
}
else
{
eol = sel_BR;
}
while (s <= eol)
{
m[d++] = image[s++ - hist_BR].c;
}
if (eol < sel_BR)
{ // eol processing
if ((eol + 1) % columns == 0)
{ // the whole line is filled
if (!line_wrapped[(eol - hist_BR)/columns])
{ // line is not wrapped
m[d++] = preserve_line_breaks ? '\n' : ' ';
}
}
else
{ // blank/partial line, not wrapped
m[d++] = preserve_line_breaks ? '\n' : ' ';
}
}
{
eol = sel_BR;
}
while (s <= eol)
{
Q_UINT16 c = image[s++ - hist_BR].c;
if (c)
m[d++] = c;
}
if (eol < sel_BR)
{ // eol processing
if ((eol + 1) % columns == 0)
{ // the whole line is filled
if (!line_wrapped[(eol - hist_BR)/columns])
{ // line is not wrapped
m[d++] = preserve_line_breaks ? '\n' : ' ';
}
}
else
{ // blank/partial line, not wrapped
m[d++] = preserve_line_breaks ? '\n' : ' ';
}
}
else if (addNewLine && preserve_line_breaks)
{
{
m[d++] = '\n';
}
}
s = (eol / columns + 1) * columns;
s = (eol / columns + 1) * columns;
}
}
}
QChar* qc = new QChar[d];
......
......@@ -451,19 +451,29 @@ HCNT("setImage");
hasBlinker |= (ext[x].r & RE_BLINK);
if (ext[x] != lcl[x])
{
Q_UINT16 c = ext[x+0].c;
if ( !c )
continue;
int p = 0;
disstrU[p++] = fontMap(c);
cr = ext[x].r;
cb = ext[x].b;
if (ext[x].f != cf) cf = ext[x].f;
int lln = cols - x;
disstrU[0] = fontMap(ext[x+0].c);
for (len = 1; len < lln; len++)
{
c = ext[x+len].c;
if (!c)
continue; // Skip trailing part of multi-col chars.
if (ext[x+len].f != cf || ext[x+len].b != cb || ext[x+len].r != cr ||
ext[x+len] == lcl[x+len] )
break;
disstrU[len] = fontMap(ext[x+len].c);
disstrU[p++] = fontMap(c);
}
QString unistr(disstrU,len);
QString unistr(disstrU, p);
drawAttrStr(paint,
QRect(bX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h),
unistr, ext[x], pm != NULL, true);
......@@ -564,26 +574,37 @@ HCNT("paintEvent");
QChar *disstrU = new QChar[columns];
for (int y = luy; y <= rly; y++)
for (int x = lux; x <= rlx; x++)
{
int len = 1;
disstrU[0] = fontMap(image[loc(x,y)].c);
int cf = image[loc(x,y)].f;
int cb = image[loc(x,y)].b;
int cr = image[loc(x,y)].r;
while (x+len <= rlx &&
image[loc(x+len,y)].f == cf &&
image[loc(x+len,y)].b == cb &&
image[loc(x+len,y)].r == cr )
Q_UINT16 c = image[loc(lux,y)].c;
int x = lux;
if(!c && x)
x--; // Search for start of multi-col char
for (; x <= rlx; x++)
{
disstrU[len] = fontMap(image[loc(x+len,y)].c);
len += 1;
}
QString unistr(disstrU,len);
drawAttrStr(paint,
int len = 1;
int p = 0;
c = image[loc(x,y)].c;
if (c)
disstrU[p++] = fontMap(c);
int cf = image[loc(x,y)].f;
int cb = image[loc(x,y)].b;
int cr = image[loc(x,y)].r;
while (x+len <= rlx &&
image[loc(x+len,y)].f == cf &&
image[loc(x+len,y)].b == cb &&
image[loc(x+len,y)].r == cr )
{
c = image[loc(x+len,y)].c;
if (c)
disstrU[p++] = fontMap(c);
len++;
}
QString unistr(disstrU,p);
drawAttrStr(paint,
QRect(bX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h),
unistr, image[loc(x,y)], pm != NULL, false);
x += len - 1;
x += len - 1;
}
}
delete [] disstrU;
drawFrame( &paint );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment