Browse Source

+ unicode fixes for the window title

git-svn-id: branches/unicodekvm@48778 -
nickysn 4 years ago
parent
commit
d4be82e879
3 changed files with 35 additions and 6 deletions
  1. 1 1
      packages/fv/examples/testuapp.pas
  2. 32 3
      packages/fv/src/drivers.inc
  3. 2 2
      packages/fv/src/views.inc

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

@@ -103,7 +103,7 @@ begin
   { Create a basic dialog box. In it are buttons,  }
   { list boxes, scrollbars, inputlines, checkboxes }
   R.Assign(32, 2, 77, 18);                           { Assign screen area }
-  P := New(PDialog, Init(R, 'TEST DIALOG'));         { Create dialog }
+  P := New(PDialog, Init(R, '테스트 대화 상자'));         { Create dialog }
   If (P <> Nil) Then Begin                           { Dialog valid }
     R.Assign(5, 5, 20, 7);                          { Allocate area }
     //P^.Insert(New(PCheckBoxes, Init(R,

+ 32 - 3
packages/fv/src/drivers.inc

@@ -375,7 +375,8 @@ Sw_Words in Dest. The high bytes of the Sw_Words in Dest are set to Attr,
 or remain unchanged if Attr is zero.
 25May96 LdB
 ---------------------------------------------------------------------}
-PROCEDURE MoveBuf (Var Dest, Source; Attr: Byte; Count: Sw_Word);
+PROCEDURE MoveBuf (Var Dest, Source; Attr: Byte; Count: Sw_Word); deprecated;
+PROCEDURE MoveBuf (Var Dest, Source; Attr: Byte; DestWidth, SourceCount: SizeInt);
 
 {-MoveChar------------------------------------------------------------
 Moves characters into a buffer for use with a view's WriteBuf or
@@ -1054,7 +1055,7 @@ END;
 {  MoveBuf -> Platforms DOS/DPMI/WIN/NT/OS2 - Updated 10Jul99 LdB           }
 {---------------------------------------------------------------------------}
 {$ifdef FV_UNICODE}
-PROCEDURE MoveBuf (Var Dest, Source; Attr: Byte; Count: Sw_Word);
+PROCEDURE MoveBuf (Var Dest, Source; Attr: Byte; Count: Sw_Word); deprecated;
 VAR I: Word; P: PEnhancedVideoCell;
 BEGIN
    { todo: split string into extended grapheme clusters properly, handle non-BMP characters,
@@ -1065,8 +1066,32 @@ BEGIN
      P^.ExtendedGraphemeCluster := WideChar(TWordArray(Source)[I-1]); { Copy source data }
    End;
 END;
+PROCEDURE MoveBuf (Var Dest, Source; Attr: Byte; DestWidth, SourceCount: SizeInt);
+VAR
+  S, EGC: UnicodeString;
+  P: PEnhancedVideoCell;
+BEGIN
+  SetLength(S, SourceCount);
+  Move(Source, S[1], SourceCount * SizeOf(WideChar));
+  P := PEnhancedVideoCell(@Dest);                      { Pointer to TEnhancedVideoCell }
+  for EGC in TUnicodeStringExtendedGraphemeClustersEnumerator.Create(S) do
+    begin
+      if DestWidth <= 0 then
+        exit;
+      Dec(DestWidth, Video.ExtendedGraphemeClusterDisplayWidth(EGC));
+      if DestWidth < 0 then
+        begin
+          If (Attr <> 0) Then P^.Attribute := Attr;
+          P^.ExtendedGraphemeCluster := ' ';
+          exit;
+        end;
+      If (Attr <> 0) Then P^.Attribute := Attr;        { Copy attribute }
+      P^.ExtendedGraphemeCluster := EGC;               { Copy string char }
+      Inc(P, Video.ExtendedGraphemeClusterDisplayWidth(EGC));
+    end;
+END;
 {$else FV_UNICODE}
-PROCEDURE MoveBuf (Var Dest, Source; Attr: Byte; Count: Sw_Word);
+PROCEDURE MoveBuf (Var Dest, Source; Attr: Byte; Count: Sw_Word); deprecated;
 VAR I: Word; P: PWord;
 BEGIN
    For I := 1 To Count Do Begin
@@ -1075,6 +1100,10 @@ BEGIN
      WordRec(P^).Lo := TByteArray(Source)[I-1];       { Copy source data }
    End;
 END;
+PROCEDURE MoveBuf (Var Dest, Source; Attr: Byte; DestWidth, SourceCount: SizeInt);
+BEGIN
+  MoveBuf(Dest, Source, Attr, DestWidth);
+END;
 {$endif FV_UNICODE}
 
 {---------------------------------------------------------------------------}

+ 2 - 2
packages/fv/src/views.inc

@@ -2900,14 +2900,14 @@ begin
    Title := '';
   if Title <> '' then
    begin
-     L := Length(Title);
+     L := StrWidth(Title);
      if L > Width - 10 then
       L := Width - 10;
      if L < 0 then
       L := 0;
      I := (Width - L) shr 1;
      MoveChar(B[I - 1], ' ', CTitle, 1);
-     MoveBuf(B[I], Title[1], CTitle, L);
+     MoveBuf(B[I], Title[1], CTitle, L, Length(Title));
      MoveChar(B[I + L], ' ', CTitle, 1);
    end;
   if State and sfActive <> 0 then