2020-05-25 15:12:46 +02:00
|
|
|
program ConsoleSample;
|
|
|
|
|
|
|
|
{$APPTYPE CONSOLE}
|
|
|
|
{$R *.res}
|
|
|
|
|
|
|
|
uses
|
|
|
|
System.SysUtils,
|
|
|
|
System.TypInfo,
|
|
|
|
MVCFramework.Console;
|
|
|
|
|
|
|
|
var
|
2022-10-20 17:29:04 +02:00
|
|
|
F, B: Integer;
|
2020-05-25 15:12:46 +02:00
|
|
|
lFGColorName, lBGColorName: String;
|
|
|
|
lSize: TMVCConsoleSize;
|
|
|
|
|
|
|
|
begin
|
2023-09-27 15:10:13 +02:00
|
|
|
Write('Press ANY key');
|
2020-05-25 15:12:46 +02:00
|
|
|
var c: Char := GetCh;
|
|
|
|
try
|
|
|
|
for F := 0 to 15 do
|
|
|
|
begin
|
|
|
|
TextBackground(Black);
|
|
|
|
TextColor(TConsoleColor(F));
|
|
|
|
lFGColorName := ColorName(TConsoleColor(F));
|
2023-09-27 15:10:13 +02:00
|
|
|
WriteLn(''.PadLeft(GetConsoleSize.Columns));
|
|
|
|
WriteLn(('** TEST FOREGROUND COLOR: ' + lFGColorName + ' **').PadRight(GetConsoleSize.Columns));
|
|
|
|
WriteLn(StringOfChar('_', GetConsoleSize.Columns));
|
|
|
|
WriteLn(''.PadLeft(GetConsoleSize.Columns));
|
2020-05-25 15:12:46 +02:00
|
|
|
for B := 0 to 15 do
|
|
|
|
begin
|
|
|
|
lBGColorName := ColorName(TConsoleColor(B));
|
|
|
|
TextBackground(TConsoleColor(B));
|
2023-09-27 15:10:13 +02:00
|
|
|
WriteLn((lFGColorName + ' on ' + lBGColorName).PadLeft(GetConsoleSize.Columns));
|
2020-05-25 15:12:46 +02:00
|
|
|
end;
|
2023-09-27 15:10:13 +02:00
|
|
|
GetCh;
|
2020-05-25 15:12:46 +02:00
|
|
|
end;
|
2023-09-27 15:10:13 +02:00
|
|
|
ReadLn;
|
2020-05-25 15:12:46 +02:00
|
|
|
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]));
|
|
|
|
readln;
|
|
|
|
GotoXY(0, 0);
|
2023-09-27 15:10:13 +02:00
|
|
|
TextColor(TConsoleColor.Red);
|
2020-05-25 15:12:46 +02:00
|
|
|
Write('X');
|
|
|
|
GotoXY(lSize.Columns - 1, lSize.Rows - 2);
|
|
|
|
Write('X');
|
2023-09-27 15:10:13 +02:00
|
|
|
ResetConsole;
|
|
|
|
GotoXY(0,0);
|
2020-05-25 15:12:46 +02:00
|
|
|
except
|
|
|
|
on E: Exception do
|
|
|
|
WriteLn(E.ClassName, ': ', E.Message);
|
|
|
|
end;
|
2023-09-27 15:10:13 +02:00
|
|
|
if DebugHook <> 0 then
|
|
|
|
begin
|
|
|
|
ResetConsole;
|
|
|
|
TextColor(TConsoleColor.Red);
|
|
|
|
Write('Press ANY key to exit...');
|
|
|
|
ResetConsole;
|
|
|
|
GetCh;
|
|
|
|
ClrScr;
|
|
|
|
end;
|
2020-05-25 15:12:46 +02:00
|
|
|
end.
|