Browse Source

+ some fv unicode fixes for supporting complex (multi-char) enhanced grapheme clusters

git-svn-id: branches/unicodekvm@48731 -
nickysn 4 years ago
parent
commit
89c7ae42af

+ 9 - 0
packages/fv/examples/testuapp.lpi

@@ -42,6 +42,15 @@
       <OtherUnitFiles Value="../src;../../rtl-console/src/unix;../../rtl-extra/src/inc;../../rtl-unicode/src/inc"/>
       <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
     </SearchPaths>
+    <CodeGeneration>
+      <Checks>
+        <IOChecks Value="True"/>
+        <RangeChecks Value="True"/>
+        <OverflowChecks Value="True"/>
+        <StackChecks Value="True"/>
+      </Checks>
+      <VerifyObjMethodCallValidity Value="True"/>
+    </CodeGeneration>
   </CompilerOptions>
   <Debugging>
     <Exceptions Count="3">

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

@@ -3,7 +3,7 @@ program testuapp;
 {$codepage UTF8}
 
 uses
-  Objects, UDrivers, UViews, UMenus, UApp;
+  Objects, UDrivers, UViews, UMenus, UApp, SysUtils;
 
 const
   cmOrderNew    = 200;
@@ -40,7 +40,7 @@ begin
   R.A.Y := R.B.Y - 1;
   new(StatusLine, Init(R,
       NewStatusDef(0, $EFFF,
-          NewStatusKey('~F1~ 打开', kbF1, cmHelp,
+          NewStatusKey({'~F1~ 打开'}'F1 По п' + 'ъ́' + 'тя', kbF1, cmHelp,
           NewStatusKey('~F3~ Отваряне', kbF3, cmOpen,
           NewStatusKey('~F4~ Νέος',  kbF4, cmNew,
           NewStatusKey('~Alt+F3~ Zavřít', kbAltF3, cmClose,

+ 1 - 1
packages/fv/src/menus.inc

@@ -1590,7 +1590,7 @@ BEGIN
 {$endif FV_UNICODE}
      Inc(I, 2);                                       { Move along }
      MoveStr(B[I], HintBuf, Byte(CNormal));           { Move hint to buffer }
-     I := I + Length(HintBuf);                        { Hint length }
+     I := I + StrWidth(HintBuf);                      { Hint length }
    End;
    WriteLine(0, 0, Size.X, 1, B);                          { Write the buffer }
 END;

+ 15 - 8
packages/fv/src/views.inc

@@ -60,7 +60,7 @@ USES
      Os2Def, DosCalls, PmWin,
    {$ENDIF}
 
-   Objects, {$ifdef FV_UNICODE}UFVCommon,UDrivers{$else}FVCommon,Drivers{$endif}, fvconsts, { GFV standard units }
+   Objects, {$ifdef FV_UNICODE}UFVCommon,UDrivers,GraphemeBreakProperty{$else}FVCommon,Drivers{$endif}, fvconsts, { GFV standard units }
    Video;
 
 
@@ -4525,23 +4525,30 @@ end;
 
 procedure TView.WriteStr(X, Y: Sw_Integer; Str: Sw_String; Color: Byte);
 var
+{$ifdef FV_UNICODE}
+  EGC: Sw_String;
+{$endif FV_UNICODE}
   l,i : Sw_word;
   B : TDrawBuffer;
   myColor : word;
 begin
-  l:=length(Str);
+  l:=StrWidth(Str);
   if l>0 then
    begin
      if l>maxViewWidth then
       l:=maxViewWidth;
      MyColor:=MapColor(Color);
 {$ifdef FV_UNICODE}
-     for i:=0 to l-1 do
-       with B[i] do
-         begin
-           Attribute:=MyColor;
-           ExtendedGraphemeCluster:=Str[i+1];
-         end;
+     i:=0;
+     for EGC in TUnicodeStringExtendedGraphemeClustersEnumerator.Create(Str) do
+       begin
+         with B[i] do
+           begin
+             Attribute:=MyColor;
+             ExtendedGraphemeCluster:=EGC;
+           end;
+         Inc(i, StrWidth(EGC));
+       end;
 {$else FV_UNICODE}
      MyColor:=MyColor shl 8;
      for i:=0 to l-1 do

+ 1 - 1
packages/rtl-console/src/inc/video.inc

@@ -80,7 +80,7 @@ end;
 class operator TEnhancedVideoCell.Copy(constref aSrc: TEnhancedVideoCell; var aDst: TEnhancedVideoCell);
 begin
   aDst.ExtendedGraphemeCluster := aSrc.ExtendedGraphemeCluster;
-  aDst.FAttributes := aSrc.FAttributes;
+  aDst.Attribute := aSrc.Attribute;
 end;
 
 Const

+ 6 - 4
packages/rtl-console/src/unix/video.pp

@@ -514,8 +514,8 @@ var
   LastX,LastY,
   SpaceAttr,
   LastAttr : longint;
-  p,pold   : penhancedvideocell;
   LastLineWidth : Longint;
+  p,pold   : penhancedvideocell;
 
   function transform_cp437_to_iso01(const st:string):string;
 
@@ -667,7 +667,9 @@ var
    Begin
     while (eol>0) do
      begin
-       hstr:=#13#10+hstr;
+       outbuf[outptr]:=#13;
+       outbuf[outptr+1]:=#10;
+       inc(outptr,2);
        dec(eol);
      end;
 {    if (convert=cv_vga_to_acs) and (ACSIn<>'') and (ACSOut<>'') then
@@ -797,7 +799,7 @@ begin
               LastX:=x+1;
               LastY:=y;
             end;
-           p^:=chattr;
+           //p^:=chattr;
          end;
         inc(p);
         inc(pold);
@@ -811,7 +813,7 @@ begin
    end;
   eol:=0;
  {if am in capabilities? Then}
-  if (Console=ttyFreeBSD) and (Plongint(p)^<>plongint(pold)^) Then
+  if (Console=ttyFreeBSD) and (p^<>pold^) Then
    begin
     OutData(XY2Ansi(ScreenWidth,ScreenHeight,LastX,LastY));
     OutData(#8);