Index: TECommon.h
===================================================================
RCS file: /cvsroot/qpe/qpe/embeddedkonsole/TECommon.h,v
retrieving revision 1.2
diff -u -r1.2 TECommon.h
--- TECommon.h	4 Feb 2002 01:03:57 -0000	1.2
+++ TECommon.h	2 May 2002 05:41:58 -0000
@@ -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;
 }
 
 /*!
Index: TEScreen.cpp
===================================================================
RCS file: /cvsroot/qpe/qpe/embeddedkonsole/TEScreen.cpp,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 TEScreen.cpp
--- TEScreen.cpp	15 Jan 2001 03:43:37 -0000	1.1.1.1
+++ TEScreen.cpp	2 May 2002 05:41:58 -0000
@@ -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,25 @@
 
   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();
+  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 +833,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 +998,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 +1046,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 +1111,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 +1179,7 @@
 	while (s <= eol)
 	  {
 	    m[d++] = image[s++ - hist_BR].c;
+            if (image[s-1 - hist_BR].right) d--;
 	  }
 
 	if (eol < sel_BR)
Index: TEWidget.cpp
===================================================================
RCS file: /cvsroot/qpe/qpe/embeddedkonsole/TEWidget.cpp,v
retrieving revision 1.7
diff -u -r1.7 TEWidget.cpp
--- TEWidget.cpp	4 Feb 2002 01:03:57 -0000	1.7
+++ TEWidget.cpp	2 May 2002 05:41:58 -0000
@@ -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 );
@@ -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;
   }
 }
 
Index: TEWidget.h
===================================================================
RCS file: /cvsroot/qpe/qpe/embeddedkonsole/TEWidget.h,v
retrieving revision 1.3
diff -u -r1.3 TEWidget.h
--- TEWidget.h	4 Feb 2002 01:03:57 -0000	1.3
+++ TEWidget.h	2 May 2002 05:41:58 -0000
@@ -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; }
Index: TEmulation.cpp
===================================================================
RCS file: /cvsroot/qpe/qpe/embeddedkonsole/TEmulation.cpp,v
retrieving revision 1.2
diff -u -r1.2 TEmulation.cpp
--- TEmulation.cpp	27 Sep 2001 03:54:32 -0000	1.2
+++ TEmulation.cpp	2 May 2002 05:41:58 -0000
@@ -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());
Index: konsole.cpp
===================================================================
RCS file: /cvsroot/qpe/qpe/embeddedkonsole/konsole.cpp,v
retrieving revision 1.23
diff -u -r1.23 konsole.cpp
--- konsole.cpp	4 Feb 2002 01:03:57 -0000	1.23
+++ konsole.cpp	2 May 2002 05:41:59 -0000
@@ -198,6 +198,14 @@
   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));
+
   // create terminal emulation framework ////////////////////////////////////
   nsessions = 0;
 
