diff -uNr embeddedkonsole.org/TECommon.h embeddedkonsole/TECommon.h --- embeddedkonsole.org/TECommon.h 2002-02-04 10:03:57.000000000 +0900 +++ embeddedkonsole/TECommon.h 2002-09-19 11:49:52.000000000 +0900 @@ -74,12 +74,13 @@ UINT8 _f = DEFAULT_FORE_COLOR, UINT8 _b = DEFAULT_BACK_COLOR, UINT8 _r = DEFAULT_RENDITION) - : c(_c), f(_f), b(_b), r(_r) {} + : c(_c), f(_f), b(_b), r(_r), right(false) {} public: UINT16 c; // character UINT8 f; // foreground color UINT8 b; // background color UINT8 r; // rendition + bool right; public: friend BOOL operator == (ca a, ca b); friend BOOL operator != (ca a, ca b); @@ -87,12 +88,12 @@ inline BOOL operator == (ca a, ca b) { - return a.c == b.c && a.f == b.f && a.b == b.b && a.r == b.r; + return a.c == b.c && a.f == b.f && a.b == b.b && a.r == b.r && a.right == b.right; } inline BOOL operator != (ca a, ca b) { - return a.c != b.c || a.f != b.f || a.b != b.b || a.r != b.r; + return a.c != b.c || a.f != b.f || a.b != b.b || a.r != b.r || a.right != b.right; } /*! diff -uNr embeddedkonsole.org/TEScreen.cpp embeddedkonsole/TEScreen.cpp --- embeddedkonsole.org/TEScreen.cpp 2001-01-15 12:43:37.000000000 +0900 +++ embeddedkonsole/TEScreen.cpp 2002-09-19 11:49:52.000000000 +0900 @@ -406,6 +406,7 @@ newimg[y*new_columns+x].f = DEFAULT_FORE_COLOR; newimg[y*new_columns+x].b = DEFAULT_BACK_COLOR; newimg[y*new_columns+x].r = DEFAULT_RENDITION; + newimg[y*new_columns+x].right = false; } int cpy_lines = QMIN(new_lines, lines); int cpy_columns = QMIN(new_columns,columns); @@ -413,10 +414,15 @@ for (int y = 0; y < cpy_lines; y++) for (int x = 0; x < cpy_columns; x++) { +#if 0 newimg[y*new_columns+x].c = image[loc(x,y)].c; newimg[y*new_columns+x].f = image[loc(x,y)].f; newimg[y*new_columns+x].b = image[loc(x,y)].b; newimg[y*new_columns+x].r = image[loc(x,y)].r; + newimg[y*new_columns+x].right = false; +#else + newimg[y*new_columns+x] = image[loc(x,y)]; +#endif } free(image); image = newimg; @@ -546,7 +552,21 @@ reverseRendition(&merged[i]); // for reverse display } if (getMode(MODE_Cursor) && (cuY+(hist.getLines()-histCursor) < lines)) // cursor visible - reverseRendition(&merged[loc(cuX,cuY+(hist.getLines()-histCursor))]); + { + int cy = cuY+(hist.getLines()-histCursor); + reverseRendition(&merged[loc(cuX,cy)]); + if (merged[loc(cuX,cy)].right) { + int i; + for (i = 1; merged[loc(cuX-i,cy)].right; i++) { + reverseRendition(&merged[loc(cuX-i,cy)]); + } + reverseRendition(&merged[loc(cuX-i,cy)]); + } + for (int i = 1; merged[loc(cuX+i,cy)].right; i++) { + reverseRendition(&merged[loc(cuX+i,cy)]); + } +// reverseRendition(&merged[loc(cuX,cuY+(hist.getLines()-histCursor))]); + } return merged; } @@ -587,7 +607,10 @@ void TEScreen::BackSpace() { cuX = QMAX(0,cuX-1); - if (BS_CLEARS) image[loc(cuX,cuY)].c = ' '; + if (BS_CLEARS) { + image[loc(cuX,cuY)].c = ' '; + image[loc(cuX,cuY)].right = false; + } } /*! @@ -667,12 +690,26 @@ checkSelection(i, i); // check if selection is still valid. +/* image[i].c = c; image[i].f = ef_fg; image[i].b = ef_bg; image[i].r = ef_re; cuX += 1; +*/ + int l = QString(QChar(c)).local8Bit().length(); +/*knok*/ if (l > 2) l = 2; + for (int j = 0; j < l; j++) { + image[i+j].c = c; + image[i+j].f = ef_fg; + image[i+j].b = ef_bg; + image[i+j].r = ef_re; + image[i+j].right = (j != 0); + cuX += 1; + // if (j > 0) { fprintf(stderr, "right: %d, %d %d\n", cuX, cuY, c); } + } + } // Region commands ------------------------------------------------------------- @@ -797,6 +834,7 @@ image[i].f = ef_fg; //DEFAULT_FORE_COLOR; //FIXME: xterm and linux/ansi image[i].b = ef_bg; //DEFAULT_BACK_COLOR; // many have different image[i].r = ef_re; //DEFAULT_RENDITION; // ideas here. + image[i].right = false; } } @@ -961,6 +999,34 @@ sel_begin = loc(x,y+histCursor) ; sel_BR = sel_begin; sel_TL = sel_begin; + + int hist_BR = loc(0, hist.getLines()); + if (sel_TL < hist_BR) { + int sx = sel_TL % columns; + int sy = sel_TL / columns; + while (sx < hist.getLineLen(sy) && hist.getCell(sy, sx).right) { + sel_TL--; + sx--; + } + } else { + while (image[sel_TL-hist_BR].right) { + sel_TL--; + } + } + if (sel_BR < hist_BR) { + int sx = sel_BR % columns; + int sy = sel_BR / columns; + while (sx+1 < hist.getLineLen(sy) && hist.getCell(sy, sx+1).right) { + sel_BR++; + sx++; + } + } else { + while (sel_BR-hist_BR+1 < loc(columns,lines) && image[sel_BR-hist_BR+1].right) { + sel_BR++; + } + } + // kdDebug() << "setSelBeginXY(): sel_TL = " << sel_TL << ", sel_BR = " << sel_BR << ", sel_begin = " << sel_begin << endl; + } void TEScreen::setSelExtentXY(const int x, const int y) @@ -981,6 +1047,34 @@ sel_TL = sel_begin; sel_BR = l; } + + int hist_BR = loc(0, hist.getLines()); + // kdDebug() << "setSelExtentXY(): hist_BR = " << hist_BR << endl; + if (sel_TL < hist_BR) { + int sx = sel_TL % columns; + int sy = sel_TL / columns; + while (sx < hist.getLineLen(sy) && hist.getCell(sy, sx).right) { + sel_TL--; + sx--; + } + } else { + while (image[sel_TL-hist_BR].right) { + sel_TL--; + } + } + if (sel_BR < hist_BR) { + int sx = sel_BR % columns; + int sy = sel_BR / columns; + while (sx+1 < hist.getLineLen(sy) && hist.getCell(sy, sx+1).right) { + sel_BR++; + sx++; + } + } else { + while (sel_BR-hist_BR+1 < loc(columns,lines) && image[sel_BR-hist_BR+1].right) { + sel_BR++; + } + } + // kdDebug() << "setSelExtentXY(): sel_TL = " << sel_TL << ", sel_BR = " << sel_BR << ", sel_begin = " << sel_begin << endl; } QString TEScreen::getSelText(const BOOL preserve_line_breaks) @@ -1018,7 +1112,11 @@ while (hX < eol) { - m[d++] = hist.getCell(hY, hX++).c; +// m[d++] = hist.getCell(hY, hX++).c; + if (!hist.getCell(hY, hX).right) { + m[d++] = hist.getCell(hY, hX).c; + } + hX++; s++; } @@ -1082,6 +1180,7 @@ while (s <= eol) { m[d++] = image[s++ - hist_BR].c; + if (image[s-1 - hist_BR].right) d--; } if (eol < sel_BR) diff -uNr embeddedkonsole.org/TEWidget.cpp embeddedkonsole/TEWidget.cpp --- embeddedkonsole.org/TEWidget.cpp 2002-02-04 10:03:57.000000000 +0900 +++ embeddedkonsole/TEWidget.cpp 2002-09-19 14:54:27.000000000 +0900 @@ -190,6 +190,7 @@ static QChar vt100extended(QChar c) { + QString s(c); switch (c.unicode()) { case 0x25c6 : return 1; @@ -236,13 +237,22 @@ { QFontMetrics fm(font()); font_h = fm.height(); - font_w = fm.maxWidth(); +// font_w = fm.maxWidth(); + // font_w = fm.maxWidth(); + font_w = 0; + int fw; + for (int i = 0; i < 128; i++) { + if (isprint(i) && font_w < (fw = fm.width(i))) { + font_w = fw; + } + } font_a = fm.ascent(); //printf("font_h: %d\n",font_h); //printf("font_w: %d\n",font_w); //printf("font_a: %d\n",font_a); //printf("charset: %s\n",QFont::encodingName(font().charSet()).ascii()); //printf("rawname: %s\n",font().rawName().ascii()); +/* fontMap = #if QT_VERSION < 300 strcmp(QFont::encodingName(font().charSet()).ascii(),"iso10646") @@ -250,6 +260,13 @@ : #endif identicalMap; +*/ + QString encoding = QFont::encodingName(font().charSet()); + if (encoding == "iso10646" || encoding == "Set_Ja") { + fontMap = identicalMap; + } else { + fontMap = vt100extended; + } propagateSize(); update(); } @@ -376,6 +393,19 @@ The size of the new image may or may not match the size of the widget. */ +void TEWidget::setCursorPos(const int curx, const int cury) +{ + QPoint tL = contentsRect().topLeft(); + int tLx = tL.x(); + int tLy = tL.y(); + + int xpos, ypos; + ypos = bY + tLy + font_h*(cury-1) + font_a; + xpos = blX + tLx + font_w*curx; + setMicroFocusHint(xpos, ypos, 0, font_h); + // fprintf(stderr, "x/y = %d/%d\txpos/ypos = %d/%d\n", curx, cury, xpos, ypos); +} + void TEWidget::setImage(const ca* const newimg, int lines, int columns) { int y,x,len; const QPixmap* pm = backgroundPixmap(); @@ -413,14 +443,21 @@ if (ext[x].f != cf) cf = ext[x].f; int lln = cols - x; disstrU[0] = fontMap(ext[x+0].c); + int rlen = 0; for (len = 1; len < lln; len++) { 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[len] = fontMap(ext[x+len].c); + if (ext[x+len].right) { + rlen++; + } else { + disstrU[len - rlen] = fontMap(ext[x+len].c); + } } - QString unistr(disstrU,len); +// QString unistr(disstrU,len); + QString unistr(disstrU,len-rlen); drawAttrStr(paint, QRect(blX+tLx+font_w*x,bY+tLy+font_h*y,font_w*len,font_h), unistr, ext[x], pm != NULL, true); @@ -485,6 +522,7 @@ // BL: I have no idea why we need this, and it breaks the refresh. QChar *disstrU = new QChar[columns]; +/* for (int y = luy; y <= rly; y++) for (int x = lux; x <= rlx; x++) { @@ -506,6 +544,38 @@ QRect(blX+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; +*/ + for (int y = luy; y <= rly; y++) { + int f = 0; + while (image[loc(lux - f, y)].right) { + f++; + } + for (int x = lux - f; x <= rlx; x++) + { + int len = 1; + int rlen = 0; + 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 ) + { + if (image[loc(x+len,y)].right) { + rlen++; + } else { + disstrU[len - rlen] = fontMap(image[loc(x+len,y)].c); + } + len += 1; + } + QString unistr(disstrU,len-rlen); + drawAttrStr(paint, + QRect(blX+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; + } } delete [] disstrU; drawFrame( &paint ); @@ -970,7 +1040,7 @@ return FALSE; // not us if ( e->type() == QEvent::Wheel) { - QApplication::sendEvent(scrollbar, e); + QApplication::sendEvent(scrollbar, e); } #ifdef FAKE_CTRL_AND_ALT @@ -1077,6 +1147,7 @@ image[loc(x,y)].f = 0xff; //DEFAULT_FORE_COLOR; image[loc(x,y)].b = 0xff; //DEFAULT_BACK_COLOR; image[loc(x,y)].r = 0xff; //DEFAULT_RENDITION; + image[loc(x,y)].right = false; //DEFAULT_IS_LEFT; } } diff -uNr embeddedkonsole.org/TEWidget.h embeddedkonsole/TEWidget.h --- embeddedkonsole.org/TEWidget.h 2002-02-04 10:03:57.000000000 +0900 +++ embeddedkonsole/TEWidget.h 2002-09-19 11:49:52.000000000 +0900 @@ -65,6 +65,7 @@ public: void setImage(const ca* const newimg, int lines, int columns); + void setCursorPos(const int curx, const int cury); int Lines() { return lines; } int Columns() { return columns; } diff -uNr embeddedkonsole.org/TEmulation.cpp embeddedkonsole/TEmulation.cpp --- embeddedkonsole.org/TEmulation.cpp 2001-09-27 12:54:32.000000000 +0900 +++ embeddedkonsole/TEmulation.cpp 2002-09-19 11:49:52.000000000 +0900 @@ -298,6 +298,7 @@ gui->setImage(image, scr->getLines(), scr->getColumns()); // actual refresh + gui->setCursorPos(scr->getCursorX(), scr->getCursorY()); free(image); //FIXME: check that we do not trigger other draw event here. gui->setScroll(scr->getHistCursor(),scr->getHistLines()); diff -uNr embeddedkonsole.org/embeddedkonsole.pro embeddedkonsole/embeddedkonsole.pro --- embeddedkonsole.org/embeddedkonsole.pro 2001-11-27 19:30:01.000000000 +0900 +++ embeddedkonsole/embeddedkonsole.pro 2002-09-19 15:06:16.000000000 +0900 @@ -13,7 +13,8 @@ session.h \ keytrans.h \ konsole.h \ - MyPty.h + MyPty.h \ + escqpeapp.h SOURCES = TEScreen.cpp \ TEWidget.cpp \ @@ -24,7 +25,8 @@ keytrans.cpp \ konsole.cpp \ main.cpp \ - MyPty.cpp + MyPty.cpp \ + escqpeapp.cpp TARGET = embeddedkonsole diff -uNr embeddedkonsole.org/escqpeapp.cpp embeddedkonsole/escqpeapp.cpp --- embeddedkonsole.org/escqpeapp.cpp 1970-01-01 09:00:00.000000000 +0900 +++ embeddedkonsole/escqpeapp.cpp 2002-09-19 15:30:15.000000000 +0900 @@ -0,0 +1,21 @@ +#include +#include +#include +#include "escqpeapp.h" + +EscQPEApplication::EscQPEApplication( int& argc, char **argv, Type t ) + : QPEApplication( argc, argv, t ) +{ +} + +bool EscQPEApplication::qwsEventFilter(QWSEvent *e) +{ + if (e->type == QWSEvent::Key) { + QWSKeyEvent *ke = (QWSKeyEvent *) e; + if (ke->simpleData.keycode == Qt::Key_Escape && + ke->simpleData.is_press) { + return QApplication::qwsEventFilter(e); + } + } + return QPEApplication::qwsEventFilter(e); +} diff -uNr embeddedkonsole.org/escqpeapp.h embeddedkonsole/escqpeapp.h --- embeddedkonsole.org/escqpeapp.h 1970-01-01 09:00:00.000000000 +0900 +++ embeddedkonsole/escqpeapp.h 2002-09-19 15:16:43.000000000 +0900 @@ -0,0 +1,17 @@ +#ifndef ESCQPEAPP_H + +#define ESCQPEAPP_H + +#include + +class EscQPEApplication : public QPEApplication +{ +Q_OBJECT +public: + EscQPEApplication( int& argc, char **argv, Type=GuiClient ); + +protected: + bool qwsEventFilter(QWSEvent *); +}; + +#endif /* ESCQPEAPP_H */ diff -uNr embeddedkonsole.org/konsole.cpp embeddedkonsole/konsole.cpp --- embeddedkonsole.org/konsole.cpp 2002-02-04 10:03:57.000000000 +0900 +++ embeddedkonsole/konsole.cpp 2002-09-19 15:40:53.000000000 +0900 @@ -43,6 +43,8 @@ #include #include #include +#include +#include #include #include @@ -198,6 +200,24 @@ f.setFixedPitch(TRUE); fonts.append(new VTFont(tr("Medium Fixed"), f)); + f = QFont("Unismall", 10, QFont::Normal); + f.setFixedPitch(TRUE); + fonts.append(new VTFont(tr("Unifont small"), f)); + + f = QFont("unifont", 16, QFont::Normal); + f.setFixedPitch(TRUE); + fonts.append(new VTFont(tr("Unifont"), f)); + + f = QFont("lcfont", 10, QFont::Normal); + f.setFixedPitch(TRUE); + fonts.append(new VTFont(tr("lcfont small"), f)); + f = QFont("lcfont", 12, QFont::Normal); + f.setFixedPitch(TRUE); + fonts.append(new VTFont(tr("lcfont medium"), f)); + f = QFont("lcfont", 16, QFont::Normal); + f.setFixedPitch(TRUE); + fonts.append(new VTFont(tr("lcfont large"), f)); + // create terminal emulation framework //////////////////////////////////// nsessions = 0; diff -uNr embeddedkonsole.org/main.cpp embeddedkonsole/main.cpp --- embeddedkonsole.org/main.cpp 2001-11-09 11:28:08.000000000 +0900 +++ embeddedkonsole/main.cpp 2002-09-19 15:06:52.000000000 +0900 @@ -20,6 +20,7 @@ /* -------------------------------------------------------------------------- */ #include "konsole.h" +#include "escqpeapp.h" #include @@ -35,7 +36,7 @@ { setuid(getuid()); setgid(getgid()); // drop privileges - QPEApplication a( argc, argv ); + EscQPEApplication a( argc, argv ); #ifdef FAKE_CTRL_AND_ALT QPEApplication::grabKeyboard(); // for CTRL and ALT