Browse Source

* fixed writing of long strings when using the crt unit on win32, resolves #8843

git-svn-id: trunk@10449 -
florian 17 years ago
parent
commit
ff03c9569d
1 changed files with 19 additions and 9 deletions
  1. 19 9
      rtl/win/crt.pp

+ 19 - 9
rtl/win/crt.pp

@@ -645,19 +645,29 @@ var
   WinAttr : word;
   WinAttr : word;
   i: integer;
   i: integer;
 begin
 begin
-  WritePos.X := currX - 1;
-  WritePos.Y := currY - 1;
-
-  WriteConsoleOutputCharacter(GetStdhandle(STD_OUTPUT_HANDLE), @s[1], Length(s), writePos, numWritten);
+  WritePos.X:=currX-2;
+  WritePos.Y:=currY-1;
 
 
   WinAttr:=TextAttr;
   WinAttr:=TextAttr;
-  dec(WritePos.X);
-  for i:=0 to Length(s)-1 do
+  for i:=1 to Length(s) do
     begin
     begin
-      inc(WritePos.X);
+      Inc(WritePos.X);
+      WriteConsoleOutputCharacter(GetStdhandle(STD_OUTPUT_HANDLE), @s[i], 1, writePos, numWritten);
       WriteConsoleOutputAttribute(GetStdhandle(STD_OUTPUT_HANDLE),@WinAttr, 1, writePos, numWritten);
       WriteConsoleOutputAttribute(GetStdhandle(STD_OUTPUT_HANDLE),@WinAttr, 1, writePos, numWritten);
+      Inc(CurrX);
+      if CurrX>WindMaxX then
+        begin
+          CurrX:=WindMinX;
+          Inc(CurrY);
+          While CurrY>WindMaxY do
+            begin
+              RemoveLine(1);
+              Dec(CurrY);
+            end;
+          WritePos.X:=currX-2;
+          WritePos.Y:=currY-1;
+        end;
     end;
     end;
-  Inc(CurrX,Length(s));
 end;
 end;
 
 
 
 
@@ -678,7 +688,7 @@ begin
         if s<>'' then
         if s<>'' then
           begin
           begin
             WriteStr(s);
             WriteStr(s);
- 	          s:='';
+ 	    s:='';
           end;
           end;
         WriteChar(f.buffer[i]);
         WriteChar(f.buffer[i]);
       end
       end