Browse Source

* Fix new Caret position after insertion of a character

mazen 21 years ago
parent
commit
e49816e03a
1 changed files with 16 additions and 25 deletions
  1. 16 25
      rtl/objpas/freebidi.pp

+ 16 - 25
rtl/objpas/freebidi.pp

@@ -10,7 +10,7 @@ interface
 
 
 type
 type
   TCharacter = WideChar;
   TCharacter = WideChar;
-  TString = WideSTring;
+  TString = WideString;
   TDirection=(
   TDirection=(
     drNONE,
     drNONE,
     drRTL,
     drRTL,
@@ -276,16 +276,14 @@ end;
 function InsertChar(Src:TCharacter; var Dest:TString; vp:Integer; pDir:TDirection):Integer;
 function InsertChar(Src:TCharacter; var Dest:TString; vp:Integer; pDir:TDirection):Integer;
 var
 var
   v2l:TVisualToLogical;
   v2l:TVisualToLogical;
-  lp,rvp:Integer;
+  lp:Integer;
   c:TCharacter;
   c:TCharacter;
 begin
 begin
   v2l := VisualToLogical(Dest, pDir);
   v2l := VisualToLogical(Dest, pDir);
-  rvp := v2l[0];
-  if vp > rvp
+  Result := v2l[0];
+  if vp > Result
   then
   then
-    begin
-      lp := Length(Dest) + 1
-    end
+    lp := Length(Dest) + 1
   else
   else
     lp := v2l[vp];
     lp := v2l[vp];
   c := Dest[lp];
   c := Dest[lp];
@@ -293,26 +291,19 @@ begin
   then
   then
     begin
     begin
       lp := lp + Length(c);
       lp := lp + Length(c);
-      rvp := rvp + 1;
+      Result += 1;
     end;
     end;
-  case DirectionOf(Src) of
-    drRTL:
-      begin
-        Result := vp;
-        while (Result > 0) and (DirectionOf(Dest[v2l[Result]]) <> drLTR) do
-          Result := Result - 1;
-        while (Result < vp) and (DirectionOf(Dest[v2l[Result]]) <> drRTL) do
-          Result := Result + 1;
-      end;
-    drLTR:
-      begin
-        Result := rvp + 1;
-      end;
-  else
+  if DirectionOf(Src) = drRTL
+  then
     begin
     begin
-      Result := rvp + 1;
-    end;
-  end;
+      Result := vp;
+      while (Result > 0) and (DirectionOf(Dest[v2l[Result]]) <> drLTR) do
+        Result -= 1;
+      while (Result < vp) and (DirectionOf(Dest[v2l[Result]]) <> drRTL) do
+        Result += 1;
+    end
+  else
+     Result += 1;
   Insert(Src, Dest, lp);
   Insert(Src, Dest, lp);
 end;
 end;