Browse Source

+ double width character support in the unix video unit

git-svn-id: branches/unicodekvm@48771 -
nickysn 4 years ago
parent
commit
4944e9296f
2 changed files with 18 additions and 4 deletions
  1. 3 2
      packages/fv/examples/testuapp.pas
  2. 15 2
      packages/rtl-console/src/unix/video.pp

+ 3 - 2
packages/fv/examples/testuapp.pas

@@ -40,12 +40,13 @@ begin
   R.A.Y := R.B.Y - 1;
   R.A.Y := R.B.Y - 1;
   new(StatusLine, Init(R,
   new(StatusLine, Init(R,
       NewStatusDef(0, $EFFF,
       NewStatusDef(0, $EFFF,
-          NewStatusKey({'~F1~ 打开'}'~F1~ По пъ́тя', kbF1, cmHelp,
+          NewStatusKey('~F1~ По пъ́тя', kbF1, cmHelp,
+          NewStatusKey('~F2~ 打开', kbF2, cmOpen,
           NewStatusKey('~F3~ Отваряне', kbF3, cmOpen,
           NewStatusKey('~F3~ Отваряне', kbF3, cmOpen,
           NewStatusKey('~F4~ Νέος',  kbF4, cmNew,
           NewStatusKey('~F4~ Νέος',  kbF4, cmNew,
           NewStatusKey('~Alt+F3~ Zavřít', kbAltF3, cmClose,
           NewStatusKey('~Alt+F3~ Zavřít', kbAltF3, cmClose,
           NewStatusKey('~Alt-X~ Exit', kbAltX, cmQuit,
           NewStatusKey('~Alt-X~ Exit', kbAltX, cmQuit,
-          nil))))),
+          nil)))))),
       NewStatusDef($F000, $FFFF,
       NewStatusDef($F000, $FFFF,
           NewStatusKey('~F6~ Next', kbF6, cmOrderNext,
           NewStatusKey('~F6~ Next', kbF6, cmOrderNext,
           NewStatusKey('~Shift+F6~ Pref', kbShiftF6, cmOrderPrev,
           NewStatusKey('~Shift+F6~ Pref', kbShiftF6, cmOrderPrev,

+ 15 - 2
packages/rtl-console/src/unix/video.pp

@@ -516,6 +516,7 @@ var
   LastAttr : longint;
   LastAttr : longint;
   LastLineWidth : Longint;
   LastLineWidth : Longint;
   p,pold   : penhancedvideocell;
   p,pold   : penhancedvideocell;
+  LastCharWasDoubleWidth: Boolean;
 
 
   function transform_cp437_to_iso01(const st:string):string;
   function transform_cp437_to_iso01(const st:string):string;
 
 
@@ -744,6 +745,7 @@ begin
   LastAttr:=7;
   LastAttr:=7;
   LastX:=-1;
   LastX:=-1;
   LastY:=-1;
   LastY:=-1;
+  LastCharWasDoubleWidth:=False;
   for y:=1 to ScreenHeight do
   for y:=1 to ScreenHeight do
    begin
    begin
      SpaceAttr:=0;
      SpaceAttr:=0;
@@ -753,7 +755,9 @@ begin
       LastLineWidth:=ScreenWidth-2;
       LastLineWidth:=ScreenWidth-2;
      for x:=1 to LastLineWidth do
      for x:=1 to LastLineWidth do
       begin
       begin
-        if (not force) and (p^=pold^) then
+        if LastCharWasDoubleWidth then
+         LastCharWasDoubleWidth:=false
+        else if (not force) and (p^=pold^) then
          begin
          begin
            if (Spaces>0) then
            if (Spaces>0) then
             OutSpaces;
             OutSpaces;
@@ -796,7 +800,16 @@ begin
               if LastAttr<>chattr.Attribute then
               if LastAttr<>chattr.Attribute then
                OutClr(chattr.Attribute);
                OutClr(chattr.Attribute);
               OutData(transform(chattr.ExtendedGraphemeCluster));
               OutData(transform(chattr.ExtendedGraphemeCluster));
-              LastX:=x+1;
+              if ExtendedGraphemeClusterDisplayWidth(chattr.ExtendedGraphemeCluster)=2 then
+               begin
+                LastX:=x+2;
+                LastCharWasDoubleWidth:=True;
+               end
+              else
+               begin
+                 LastX:=x+1;
+                 LastCharWasDoubleWidth:=False;
+               end;
               LastY:=y;
               LastY:=y;
             end;
             end;
            //p^:=chattr;
            //p^:=chattr;