mirror of
https://github.com/vapaamies/KolibriOS.git
synced 2025-09-23 23:53:50 +02:00
CRT unit with colored console example added
This commit is contained in:
@@ -1,53 +1,34 @@
|
||||
program DateTime;
|
||||
|
||||
uses
|
||||
KolibriOS;
|
||||
KolibriOS, CRT;
|
||||
|
||||
var
|
||||
hConsole: Pointer;
|
||||
ConsoleInit: procedure(WndWidth, WndHeight, ScrWidth, ScrHeight: LongWord; Caption: PKolibriChar); stdcall;
|
||||
ConsoleExit: procedure(bCloseWindow: Cardinal); stdcall;
|
||||
Printf: function(const Format: PKolibriChar): Integer; cdecl varargs;
|
||||
GetConsoleCursorPos: procedure(X, Y: PInteger); stdcall;
|
||||
SetConsoleCursorPos: procedure(X, Y: Integer); stdcall;
|
||||
kbhit: function: Boolean;
|
||||
SetConsoleCursorHeight: function(Height: Integer): Integer; stdcall;
|
||||
// ConsoleCls: procedure;
|
||||
|
||||
SystemDate: TSystemDate;
|
||||
SystemTime: TSystemTime;
|
||||
X, Y: Integer;
|
||||
CursorPos: TConsolePoint;
|
||||
|
||||
begin
|
||||
hConsole := LoadLibrary('/sys/lib/console.obj');
|
||||
ConsoleInit := GetProcAddress(hConsole, 'con_init');
|
||||
ConsoleExit := GetProcAddress(hConsole, 'con_exit');
|
||||
GetConsoleCursorPos := GetProcAddress(hConsole, 'con_get_cursor_pos');
|
||||
SetConsoleCursorPos := GetProcAddress(hConsole, 'con_set_cursor_pos');
|
||||
SetConsoleCursorHeight := GetProcAddress(hConsole, 'con_set_cursor_height');
|
||||
Printf := GetProcAddress(hConsole, 'con_printf');
|
||||
KBHit := GetProcAddress(hConsole, 'con_kbhit');
|
||||
ConsoleInit('Date/Time');
|
||||
|
||||
ConsoleInit($FFFFFFFF, $FFFFFFFF, $FFFFFFFF, $FFFFFFFF, 'Date/Time');
|
||||
|
||||
SetConsoleCursorHeight(0);
|
||||
SetConsoleCursorPos(27, 11);
|
||||
Printf(
|
||||
'SystemDate and SystemTime'#10 +
|
||||
' '
|
||||
SetCursorHeight(0);
|
||||
SetCursorPos(27, 11);
|
||||
Write(
|
||||
'System Date and System Time'#10 +
|
||||
' '
|
||||
);
|
||||
GetConsoleCursorPos(@X, @Y);
|
||||
CursorPos := GetCursorPos;
|
||||
repeat
|
||||
SystemDate := GetSystemDate;
|
||||
SystemTime := GetSystemTime;
|
||||
with SystemDate, SystemTime do
|
||||
begin
|
||||
Printf('%02x.%02x.%02x', Day, Month, Year);
|
||||
Printf(' - %02x:%02x:%02x', Hours, Minutes, Seconds);
|
||||
Write('%02x.%02x.%02x', Day, Month, Year);
|
||||
Write(' - %02x:%02x:%02x', Hours, Minutes, Seconds);
|
||||
end;
|
||||
SetConsoleCursorPos(X, Y);
|
||||
SetCursorPos(CursorPos);
|
||||
Sleep(50);
|
||||
until KBHit;
|
||||
until Escape;
|
||||
|
||||
ConsoleExit(1);
|
||||
ConsoleExit(True);
|
||||
end.
|
||||
|
Reference in New Issue
Block a user