Browse Source

minor fixes

Unknown 7 năm trước cách đây
mục cha
commit
106bba4f40
1 tập tin đã thay đổi với 15 bổ sung12 xóa
  1. 15 12
      Quick.Console.pas

+ 15 - 12
Quick.Console.pas

@@ -92,7 +92,8 @@ type
   procedure TextBackground(Color: Byte); overload;
   procedure TextBackground(Color: Byte); overload;
   procedure ResetColors;
   procedure ResetColors;
   function ClearScreen : Boolean;
   function ClearScreen : Boolean;
-  procedure ClearLine;
+  procedure ClearLine; overload;
+  procedure ClearLine(Y : Integer); overload;
   procedure ConsoleWaitForEnterKey;
   procedure ConsoleWaitForEnterKey;
   procedure InitConsole;
   procedure InitConsole;
 
 
@@ -221,7 +222,7 @@ begin
   LastCoord.Y := GetCursorY;
   LastCoord.Y := GetCursorY;
   NewCoord.X := x;
   NewCoord.X := x;
   NewCoord.Y := y;
   NewCoord.Y := y;
-  ClearLine;
+  ClearLine(Y);
   SetCursorPos(NewCoord);
   SetCursorPos(NewCoord);
   try
   try
     cout(s,cEventType);
     cout(s,cEventType);
@@ -234,10 +235,7 @@ procedure coutBL(const s : string; cEventType : TEventType);
 var
 var
   NewCoord : TCoord;
   NewCoord : TCoord;
 begin
 begin
-  coutXY(0,GetCurSorMaxBottom,s,cEventType);
-  NewCoord.X := GetCursorX;
-  NewCoord.Y := GetCurSorMaxBottom - 1;
-  SetCursorPos(NewCoord);
+  coutXY(0,GetCurSorMaxBottom - 1,s,cEventType);
 end;
 end;
 
 
 procedure coutFmt(const cMsg : string; params : array of const; cEventType : TEventType);
 procedure coutFmt(const cMsg : string; params : array of const; cEventType : TEventType);
@@ -304,16 +302,21 @@ begin
 end;
 end;
 
 
 procedure ClearLine;
 procedure ClearLine;
+begin
+  ClearLine(GetCursorY);
+end;
+
+procedure ClearLine(Y : Integer);
 var
 var
  dwWriteCoord: TCoord;
  dwWriteCoord: TCoord;
  dwCount, dwSize: DWord;
  dwCount, dwSize: DWord;
 begin
 begin
- if hStdOut = 0 then Exit;
- dwWriteCoord.X := ConsoleRect.Left;
- dwWriteCoord.Y := GetCursorY;
- dwSize := ConsoleRect.Right - ConsoleRect.Left + 1;
- FillConsoleOutputAttribute(hStdOut, TextAttr, dwSize, dwWriteCoord, dwCount);
- FillConsoleOutputCharacter(hStdOut, ' ', dwSize, dwWriteCoord, dwCount);
+  if hStdOut = 0 then Exit;
+  dwWriteCoord.X := 0;
+  dwWriteCoord.Y := Y;
+  dwSize := ConsoleRect.Right + 1;
+  FillConsoleOutputAttribute(hStdOut, TextAttr, dwSize, dwWriteCoord, dwCount);
+  FillConsoleOutputCharacter(hStdOut, ' ', dwSize, dwWriteCoord, dwCount);
 end;
 end;
 
 
 function ConsoleKeyPressed(ExpectedKey: Word): Boolean;
 function ConsoleKeyPressed(ExpectedKey: Word): Boolean;