delphimvcframework/samples/consolesample/ConsoleSample.dpr

89 lines
2.1 KiB
ObjectPascal
Raw Normal View History

program ConsoleSample;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
System.TypInfo,
MVCFramework.Console;
var
F, B: Integer;
lFGColorName, lBGColorName: String;
lSize: TMVCConsoleSize;
begin
2023-10-03 13:01:59 +02:00
ShowCursor;
try
2023-10-03 13:01:59 +02:00
ClrScr;
GotoXY(0,0);
Write('Press ANY key (cusor is visible)');
GetCh;
GotoXY(0,0);
HideCursor;
Write('Press ANY key (cusor is now hidden)');
GetCh;
try
for F := 0 to 15 do
begin
2023-10-03 13:01:59 +02:00
TextBackground(Black);
ClrScr;
TextBackground(Black);
TextColor(TConsoleColor(F));
lFGColorName := ColorName(TConsoleColor(F));
WriteLn(''.PadLeft(GetConsoleSize.Columns));
WriteLn(('** TEST FOREGROUND COLOR: ' + lFGColorName + ' **').PadRight(GetConsoleSize.Columns));
WriteLn(StringOfChar('_', GetConsoleSize.Columns));
WriteLn(''.PadLeft(GetConsoleSize.Columns));
for B := 0 to 15 do
begin
lBGColorName := ColorName(TConsoleColor(B));
TextBackground(TConsoleColor(B));
WriteLn((lFGColorName + ' on ' + lBGColorName).PadLeft(GetConsoleSize.Columns));
end;
GetCh;
end;
2023-10-03 13:01:59 +02:00
ReadLn;
ResetConsole;
ClrScr;
lSize := GetConsoleSize;
WriteLn(Format('Console Size: %d columns x %d rows', [lSize.Columns, lSize.Rows]));
lSize := GetConsoleBufferSize;
WriteLn(Format('Console Buffer Size: %d columns x %d rows', [lSize.Columns, lSize.Rows]));
GetCh;
// limits
ClrScr;
TextColor(TConsoleColor.Red);
GotoXY(0, 0);
Write('X');
GotoXY(lSize.Columns - 1, 0);
Write('X');
GotoXY(lSize.Columns - 1, lSize.Rows - 2);
Write('X');
GotoXY(0, lSize.Rows - 2);
Write('X');
CenterInScreen('CONSOLE LIMITS');
GetCh;
2023-10-03 13:01:59 +02:00
ResetConsole;
ClrScr;
GotoXY(0,0);
except
on E: Exception do
WriteLn(E.ClassName, ': ', E.Message);
end;
2023-10-03 13:01:59 +02:00
finally
ShowCursor;
end;
if DebugHook <> 0 then
begin
ResetConsole;
TextColor(TConsoleColor.Red);
Write('Press ANY key to exit...');
ResetConsole;
GetCh;
ClrScr;
end;
end.