mirror of
https://github.com/vapaamies/KolibriOS.git
synced 2025-09-21 02:30:07 +02:00
CRT unit with colored console example added
This commit is contained in:
34
Examples/Console/DateTime/DateTime.dpr
Normal file
34
Examples/Console/DateTime/DateTime.dpr
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
program DateTime;
|
||||||
|
|
||||||
|
uses
|
||||||
|
KolibriOS, CRT;
|
||||||
|
|
||||||
|
var
|
||||||
|
SystemDate: TSystemDate;
|
||||||
|
SystemTime: TSystemTime;
|
||||||
|
CursorPos: TConsolePoint;
|
||||||
|
|
||||||
|
begin
|
||||||
|
ConsoleInit('Date/Time');
|
||||||
|
|
||||||
|
SetCursorHeight(0);
|
||||||
|
SetCursorPos(27, 11);
|
||||||
|
Write(
|
||||||
|
'System Date and System Time'#10 +
|
||||||
|
' '
|
||||||
|
);
|
||||||
|
CursorPos := GetCursorPos;
|
||||||
|
repeat
|
||||||
|
SystemDate := GetSystemDate;
|
||||||
|
SystemTime := GetSystemTime;
|
||||||
|
with SystemDate, SystemTime do
|
||||||
|
begin
|
||||||
|
Write('%02x.%02x.%02x', Day, Month, Year);
|
||||||
|
Write(' - %02x:%02x:%02x', Hours, Minutes, Seconds);
|
||||||
|
end;
|
||||||
|
SetCursorPos(CursorPos);
|
||||||
|
Sleep(50);
|
||||||
|
until KeyPressed;
|
||||||
|
|
||||||
|
ConsoleExit(True);
|
||||||
|
end.
|
80
Examples/ConsoleColors/ConsoleColors.dpr
Normal file
80
Examples/ConsoleColors/ConsoleColors.dpr
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
program ConsoleColors;
|
||||||
|
|
||||||
|
uses
|
||||||
|
CRT;
|
||||||
|
|
||||||
|
begin
|
||||||
|
ConsoleInit('Console Colors');
|
||||||
|
|
||||||
|
TextBackground(Black);
|
||||||
|
WriteLn('Black');
|
||||||
|
TextBackground(Blue);
|
||||||
|
WriteLn('Blue');
|
||||||
|
TextBackground(Green);
|
||||||
|
WriteLn('Green');
|
||||||
|
TextBackground(Cyan);
|
||||||
|
WriteLn('Cyan');
|
||||||
|
TextBackground(Red);
|
||||||
|
WriteLn('Red');
|
||||||
|
TextBackground(Magenta);
|
||||||
|
WriteLn('Magenta');
|
||||||
|
TextBackground(Brown);
|
||||||
|
WriteLn('Brown');
|
||||||
|
TextBackground(LightGray);
|
||||||
|
WriteLn('LightGray');
|
||||||
|
TextBackground(DarkGray);
|
||||||
|
WriteLn('DarkGray');
|
||||||
|
TextBackground(LightBlue);
|
||||||
|
WriteLn('LightBlue');
|
||||||
|
TextBackground(LightGreen);
|
||||||
|
WriteLn('LightGreen');
|
||||||
|
TextBackground(LightCyan);
|
||||||
|
WriteLn('LightCyan');
|
||||||
|
TextBackground(LightRed);
|
||||||
|
WriteLn('LightRed');
|
||||||
|
TextBackground(LightMagenta);
|
||||||
|
WriteLn('LightMagenta');
|
||||||
|
TextBackground(Yellow);
|
||||||
|
WriteLn('Yellow');
|
||||||
|
TextBackground(White);
|
||||||
|
WriteLn('White');
|
||||||
|
|
||||||
|
ResetAttributes;
|
||||||
|
|
||||||
|
TextColor(Black);
|
||||||
|
WriteLn('Black');
|
||||||
|
TextColor(Blue);
|
||||||
|
WriteLn('Blue');
|
||||||
|
TextColor(Green);
|
||||||
|
WriteLn('Green');
|
||||||
|
TextColor(Cyan);
|
||||||
|
WriteLn('Cyan');
|
||||||
|
TextColor(Red);
|
||||||
|
WriteLn('Red');
|
||||||
|
TextColor(Magenta);
|
||||||
|
WriteLn('Magenta');
|
||||||
|
TextColor(Brown);
|
||||||
|
WriteLn('Brown');
|
||||||
|
TextColor(LightGray);
|
||||||
|
WriteLn('LightGray');
|
||||||
|
TextColor(DarkGray);
|
||||||
|
WriteLn('DarkGray');
|
||||||
|
TextColor(LightBlue);
|
||||||
|
WriteLn('LightBlue');
|
||||||
|
TextColor(LightGreen);
|
||||||
|
WriteLn('LightGreen');
|
||||||
|
TextColor(LightCyan);
|
||||||
|
WriteLn('LightCyan');
|
||||||
|
TextColor(LightRed);
|
||||||
|
WriteLn('LightRed');
|
||||||
|
TextColor(LightMagenta);
|
||||||
|
WriteLn('LightMagenta');
|
||||||
|
TextColor(Yellow);
|
||||||
|
WriteLn('Yellow');
|
||||||
|
TextColor(White);
|
||||||
|
WriteLn('White');
|
||||||
|
|
||||||
|
ReadKey;
|
||||||
|
|
||||||
|
ConsoleExit(True);
|
||||||
|
end.
|
1
Examples/ConsoleColors/build.bat
Normal file
1
Examples/ConsoleColors/build.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
@call "%~dp0..\..\Lib\build.bat" "%~dp0ConsoleColors"
|
@@ -1,53 +1,34 @@
|
|||||||
program DateTime;
|
program DateTime;
|
||||||
|
|
||||||
uses
|
uses
|
||||||
KolibriOS;
|
KolibriOS, CRT;
|
||||||
|
|
||||||
var
|
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;
|
SystemDate: TSystemDate;
|
||||||
SystemTime: TSystemTime;
|
SystemTime: TSystemTime;
|
||||||
X, Y: Integer;
|
CursorPos: TConsolePoint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
hConsole := LoadLibrary('/sys/lib/console.obj');
|
ConsoleInit('Date/Time');
|
||||||
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($FFFFFFFF, $FFFFFFFF, $FFFFFFFF, $FFFFFFFF, 'Date/Time');
|
SetCursorHeight(0);
|
||||||
|
SetCursorPos(27, 11);
|
||||||
SetConsoleCursorHeight(0);
|
Write(
|
||||||
SetConsoleCursorPos(27, 11);
|
'System Date and System Time'#10 +
|
||||||
Printf(
|
|
||||||
'SystemDate and SystemTime'#10 +
|
|
||||||
' '
|
' '
|
||||||
);
|
);
|
||||||
GetConsoleCursorPos(@X, @Y);
|
CursorPos := GetCursorPos;
|
||||||
repeat
|
repeat
|
||||||
SystemDate := GetSystemDate;
|
SystemDate := GetSystemDate;
|
||||||
SystemTime := GetSystemTime;
|
SystemTime := GetSystemTime;
|
||||||
with SystemDate, SystemTime do
|
with SystemDate, SystemTime do
|
||||||
begin
|
begin
|
||||||
Printf('%02x.%02x.%02x', Day, Month, Year);
|
Write('%02x.%02x.%02x', Day, Month, Year);
|
||||||
Printf(' - %02x:%02x:%02x', Hours, Minutes, Seconds);
|
Write(' - %02x:%02x:%02x', Hours, Minutes, Seconds);
|
||||||
end;
|
end;
|
||||||
SetConsoleCursorPos(X, Y);
|
SetCursorPos(CursorPos);
|
||||||
Sleep(50);
|
Sleep(50);
|
||||||
until KBHit;
|
until Escape;
|
||||||
|
|
||||||
ConsoleExit(1);
|
ConsoleExit(True);
|
||||||
end.
|
end.
|
||||||
|
@@ -9,8 +9,8 @@ MAKE = $(ROOT)\bin\make.exe -$(MAKEFLAGS) -f$**
|
|||||||
DCC = $(ROOT)\bin\dcc32.exe $**
|
DCC = $(ROOT)\bin\dcc32.exe $**
|
||||||
BRCC = $(ROOT)\bin\brcc32.exe $**
|
BRCC = $(ROOT)\bin\brcc32.exe $**
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
PROJECTS = ColorButtons.exe DateTime.exe DrawImage.exe DrawImageEx.exe DrawText.exe GetCurrentDirectory.exe GetPixel.exe \
|
PROJECTS = ColorButtons.exe ConsoleColors.exe DateTime.exe DrawImage.exe DrawImageEx.exe DrawText.exe GetCurrentDirectory.exe \
|
||||||
GetPointOwner.exe Hello.exe LoadFile.exe ReadFolder.exe Screenshot.exe SetCursor.exe SetPixel.exe SetWindowPos.exe
|
GetPixel.exe GetPointOwner.exe Hello.exe HelloGUI.exe LoadFile.exe ReadFolder.exe Screenshot.exe SetCursor.exe SetPixel.exe SetWindowPos.exe
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
default: $(PROJECTS)
|
default: $(PROJECTS)
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
@@ -18,6 +18,9 @@ default: $(PROJECTS)
|
|||||||
ColorButtons.exe: ColorButtons\ColorButtons.dpr
|
ColorButtons.exe: ColorButtons\ColorButtons.dpr
|
||||||
$(DCC)
|
$(DCC)
|
||||||
|
|
||||||
|
ConsoleColors.exe: ConsoleColors\ConsoleColors.dpr
|
||||||
|
$(DCC)
|
||||||
|
|
||||||
DateTime.exe: DateTime\DateTime.dpr
|
DateTime.exe: DateTime\DateTime.dpr
|
||||||
$(DCC)
|
$(DCC)
|
||||||
|
|
||||||
@@ -42,6 +45,9 @@ GetPointOwner.exe: GetPointOwner\GetPointOwner.dpr
|
|||||||
Hello.exe: Hello\Hello.dpr
|
Hello.exe: Hello\Hello.dpr
|
||||||
$(DCC)
|
$(DCC)
|
||||||
|
|
||||||
|
HelloGUI.exe: Hello\HelloGUI.dpr
|
||||||
|
$(DCC)
|
||||||
|
|
||||||
LoadFile.exe: LoadFile\LoadFile.dpr
|
LoadFile.exe: LoadFile\LoadFile.dpr
|
||||||
$(DCC)
|
$(DCC)
|
||||||
|
|
||||||
@@ -59,5 +65,3 @@ SetPixel.exe: SetPixel\SetPixel.dpr
|
|||||||
|
|
||||||
SetWindowPos.exe: SetWindowPos\SetWindowPos.dpr
|
SetWindowPos.exe: SetWindowPos\SetWindowPos.dpr
|
||||||
$(DCC)
|
$(DCC)
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
program GetCurrentDir;
|
program GetCurrentDir;
|
||||||
|
|
||||||
uses
|
uses
|
||||||
KolibriOS;
|
KolibriOS, CRT;
|
||||||
|
|
||||||
const
|
const
|
||||||
AppPath = PPKolibriChar(32);
|
AppPath = PPKolibriChar(32);
|
||||||
@@ -10,26 +10,16 @@ const
|
|||||||
BUFFER_SIZE = 256;
|
BUFFER_SIZE = 256;
|
||||||
|
|
||||||
var
|
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;
|
|
||||||
|
|
||||||
Buffer: array[0..BUFFER_SIZE - 1] of Char;
|
Buffer: array[0..BUFFER_SIZE - 1] of Char;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
hConsole := LoadLibrary('/sys/lib/console.obj');
|
ConsoleInit('Get Current Directory');
|
||||||
ConsoleInit := GetProcAddress(hConsole, 'con_init');
|
|
||||||
ConsoleExit := GetProcAddress(hConsole, 'con_exit');
|
|
||||||
printf := GetProcAddress(hConsole, 'con_printf');
|
|
||||||
|
|
||||||
ConsoleInit($FFFFFFFF, $FFFFFFFF, $FFFFFFFF, $FFFFFFFF, 'Get Current Directory');
|
|
||||||
|
|
||||||
GetCurrentDirectory(Buffer, BUFFER_SIZE);
|
GetCurrentDirectory(Buffer, BUFFER_SIZE);
|
||||||
|
|
||||||
printf('AppPath is "%s"'#10, AppPath^);
|
Write('AppPath is "%s"'#10, AppPath^);
|
||||||
printf('CmdLine is "%s"'#10, CmdLine^);
|
Write('CmdLine is "%s"'#10, CmdLine^);
|
||||||
printf('CurrentDirectory is "%s"'#10, Buffer);
|
Write('Current Directory is "%s"'#10, Buffer);
|
||||||
|
|
||||||
ConsoleExit(0);
|
ConsoleExit(False);
|
||||||
end.
|
end.
|
||||||
|
@@ -1,33 +1,13 @@
|
|||||||
program Hello;
|
program Hello;
|
||||||
|
|
||||||
uses
|
uses
|
||||||
KolibriOS;
|
CRT;
|
||||||
|
|
||||||
var
|
|
||||||
WndLeft, WndTop, WndWidth, WndHeight: Integer;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
with GetScreenSize do
|
ConsoleInit('Hello');
|
||||||
begin
|
|
||||||
WndWidth := Width div 4;
|
|
||||||
WndHeight := Height div 4;
|
|
||||||
WndLeft := (Width - WndWidth) div 2;
|
|
||||||
WndTop := (Height - WndHeight) div 2;
|
|
||||||
end;
|
|
||||||
|
|
||||||
while True do
|
WriteLn('Hello, world!');
|
||||||
case WaitEvent of
|
|
||||||
REDRAW_EVENT:
|
ReadKey;
|
||||||
begin
|
ConsoleExit(True);
|
||||||
BeginDraw;
|
|
||||||
DrawWindow(WndLeft, WndTop, WndWidth, WndHeight, 'Hello!', $00FFFFFF,
|
|
||||||
WS_SKINNED_FIXED + WS_CLIENT_COORDS + WS_CAPTION, CAPTION_MOVABLE);
|
|
||||||
EndDraw;
|
|
||||||
end;
|
|
||||||
KEY_EVENT:
|
|
||||||
GetKey;
|
|
||||||
BUTTON_EVENT:
|
|
||||||
if GetButton.ID = 1 then
|
|
||||||
TerminateThread;
|
|
||||||
end;
|
|
||||||
end.
|
end.
|
||||||
|
33
Examples/Hello/HelloGUI.dpr
Normal file
33
Examples/Hello/HelloGUI.dpr
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
program HelloGUI;
|
||||||
|
|
||||||
|
uses
|
||||||
|
KolibriOS;
|
||||||
|
|
||||||
|
var
|
||||||
|
WndLeft, WndTop, WndWidth, WndHeight: Integer;
|
||||||
|
|
||||||
|
begin
|
||||||
|
with GetScreenSize do
|
||||||
|
begin
|
||||||
|
WndWidth := Width div 4;
|
||||||
|
WndHeight := Height div 4;
|
||||||
|
WndLeft := (Width - WndWidth) div 2;
|
||||||
|
WndTop := (Height - WndHeight) div 2;
|
||||||
|
end;
|
||||||
|
|
||||||
|
while True do
|
||||||
|
case WaitEvent of
|
||||||
|
REDRAW_EVENT:
|
||||||
|
begin
|
||||||
|
BeginDraw;
|
||||||
|
DrawWindow(WndLeft, WndTop, WndWidth, WndHeight, 'Hello!', $00FFFFFF,
|
||||||
|
WS_SKINNED_FIXED + WS_CLIENT_COORDS + WS_CAPTION, CAPTION_MOVABLE);
|
||||||
|
EndDraw;
|
||||||
|
end;
|
||||||
|
KEY_EVENT:
|
||||||
|
GetKey;
|
||||||
|
BUTTON_EVENT:
|
||||||
|
if GetButton.ID = 1 then
|
||||||
|
TerminateThread;
|
||||||
|
end;
|
||||||
|
end.
|
@@ -1 +1,3 @@
|
|||||||
@call "%~dp0..\..\Lib\build.bat" "%~dp0Hello"
|
@echo off
|
||||||
|
call "%~dp0..\..\Lib\build.bat" "%~dp0Hello"
|
||||||
|
call "%~dp0..\..\Lib\build.bat" "%~dp0HelloGUI"
|
@@ -1,27 +1,17 @@
|
|||||||
program LoadFileApp;
|
program LoadFileApp;
|
||||||
|
|
||||||
uses
|
uses
|
||||||
KolibriOS;
|
KolibriOS, CRT;
|
||||||
|
|
||||||
var
|
var
|
||||||
hConsole: Pointer;
|
|
||||||
ConsoleInit: procedure(WndWidth, WndHeight, ScrWidth, ScrHeight: LongWord; Caption: PKolibriChar); stdcall;
|
|
||||||
ConsoleExit: procedure(bCloseWindow: Cardinal); stdcall;
|
|
||||||
WriteN: procedure(Str: PKolibriChar; Count: LongWord); stdcall;
|
|
||||||
|
|
||||||
FileSize: LongWord;
|
FileSize: LongWord;
|
||||||
Buffer: Pointer;
|
Buffer: Pointer;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
hConsole := LoadLibrary('/sys/lib/console.obj');
|
ConsoleInit('Load File');
|
||||||
ConsoleInit := GetProcAddress(hConsole, 'con_init');
|
|
||||||
ConsoleExit := GetProcAddress(hConsole, 'con_exit');
|
|
||||||
WriteN := GetProcAddress(hConsole, 'con_write_string');
|
|
||||||
|
|
||||||
ConsoleInit($FFFFFFFF, $FFFFFFFF, $FFFFFFFF, $FFFFFFFF, 'Load File');
|
|
||||||
|
|
||||||
Buffer := LoadFile('/sys/example.asm', FileSize);
|
Buffer := LoadFile('/sys/example.asm', FileSize);
|
||||||
WriteN(Buffer, FileSize);
|
WriteText(Buffer, FileSize);
|
||||||
|
|
||||||
ConsoleExit(0);
|
ConsoleExit(False);
|
||||||
end.
|
end.
|
||||||
|
@@ -1,19 +1,13 @@
|
|||||||
program ReadFolderApp;
|
program ReadFolderApp;
|
||||||
|
|
||||||
uses
|
uses
|
||||||
KolibriOS;
|
KolibriOS, CRT;
|
||||||
|
|
||||||
type
|
type
|
||||||
TInt64Rec = packed record
|
TInt64Rec = packed record
|
||||||
Lo, Hi: LongWord;
|
Lo, Hi: LongWord;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
const
|
const
|
||||||
FolderPath = '/sys';
|
FolderPath = '/sys';
|
||||||
|
|
||||||
@@ -23,46 +17,42 @@ var
|
|||||||
Pos: LongWord;
|
Pos: LongWord;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
hConsole := LoadLibrary('/sys/lib/console.obj');
|
ConsoleInit('Read Folder');
|
||||||
ConsoleInit := GetProcAddress(hConsole, 'con_init');
|
|
||||||
ConsoleExit := GetProcAddress(hConsole, 'con_exit');
|
|
||||||
printf := GetProcAddress(hConsole, 'con_printf');
|
|
||||||
|
|
||||||
if ReadFolder(FolderPath, FolderInformation, 0, 0, 0, BlocksRead) = 0 then
|
if ReadFolder(FolderPath, FolderInformation, 0, 0, 0, BlocksRead) = 0 then
|
||||||
with FolderInformation do
|
with FolderInformation do
|
||||||
begin
|
Write('Folder "%s" contains %u files and/or folders.'#10#10, FolderPath, FileCount)
|
||||||
ConsoleInit($FFFFFFFF, $FFFFFFFF, $FFFFFFFF, {11 printf In Loop}11 * FileCount + {2 printf below}2 + 1, 'ReadFolder');
|
|
||||||
printf('Folder "%s" contains %u files and/or folders.'#10, FolderPath, FileCount);
|
|
||||||
printf(#10);
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
begin
|
Write('Folder "%s" can not be read.'#10, FolderPath);
|
||||||
ConsoleInit($FFFFFFFF, $FFFFFFFF, $FFFFFFFF, $FFFFFFFF, 'Read Folder');
|
|
||||||
printf('Folder "%s" can not be read.'#10, FolderPath);
|
|
||||||
end;
|
|
||||||
|
|
||||||
Pos := 0;
|
Pos := 0;
|
||||||
while ReadFolder(FolderPath, FolderInformation, 1, Pos, 0, BlocksRead) = 0 do
|
while ReadFolder(FolderPath, FolderInformation, 1, Pos, 0, BlocksRead) = 0 do
|
||||||
begin
|
begin
|
||||||
with FolderInformation, FileInformation[0] do
|
with FolderInformation, FileInformation[0] do
|
||||||
begin
|
begin
|
||||||
printf('FileName = %s'#10, Name);
|
Write('FileName = %s'#10, Name);
|
||||||
with Attributes do
|
with Attributes do
|
||||||
begin
|
begin
|
||||||
printf('SizeLo = %u'#10, TInt64Rec(Size).Lo);
|
Write( 'SizeLo = %u'#10, TInt64Rec(Size).Lo);
|
||||||
printf('SizeHi = %u'#10, TInt64Rec(Size).Hi);
|
Write( 'SizeHi = %u'#10, TInt64Rec(Size).Hi);
|
||||||
with Modify.Date do printf('modifyDate = %02d.%02d.%02d'#10, Day, Month, Year);
|
with Modify.Date do
|
||||||
with Modify.Time do printf('modifyTime = %02d:%02d:%02d'#10, Hours, Minutes, Seconds);
|
Write('Modify Date = %02d.%02d.%02d'#10, Day, Month, Year);
|
||||||
with Access.Date do printf('AccessDate = %02d.%02d.%02d'#10, Day, Month, Year);
|
with Modify.Time do
|
||||||
with Access.Time do printf('AccessTime = %02d:%02d:%02d'#10, Hours, Minutes, Seconds);
|
Write('Modify Time = %02d:%02d:%02d'#10, Hours, Minutes, Seconds);
|
||||||
with Creation.Date do printf('CreationDate = %02d.%02d.%02d'#10, Day, Month, Year);
|
with Access.Date do
|
||||||
with Creation.Time do printf('CreationTime = %02d:%02d:%02d'#10, Hours, Minutes, Seconds);
|
Write('Access Date = %02d.%02d.%02d'#10, Day, Month, Year);
|
||||||
printf('Attributes = 0x%08x'#10, Attributes);
|
with Access.Time do
|
||||||
|
Write('Access Time = %02d:%02d:%02d'#10, Hours, Minutes, Seconds);
|
||||||
|
with Creation.Date do
|
||||||
|
Write('Creation Date = %02d.%02d.%02d'#10, Day, Month, Year);
|
||||||
|
with Creation.Time do
|
||||||
|
Write('Creation Time = %02d:%02d:%02d'#10, Hours, Minutes, Seconds);
|
||||||
|
Write( 'Attributes = 0x%08x'#10, Attributes);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
printf(#10);
|
Write(#10);
|
||||||
Inc(Pos);
|
Inc(Pos);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ConsoleExit(0);
|
ConsoleExit(False);
|
||||||
end.
|
end.
|
||||||
|
168
Lib/CRT.pas
Normal file
168
Lib/CRT.pas
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
unit CRT;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
KolibriOS;
|
||||||
|
|
||||||
|
type
|
||||||
|
TConsolePoint = record
|
||||||
|
X, Y: Integer;
|
||||||
|
end;
|
||||||
|
|
||||||
|
const
|
||||||
|
Black = 0;
|
||||||
|
Blue = 1;
|
||||||
|
Green = 2;
|
||||||
|
Cyan = 3;
|
||||||
|
Red = 4;
|
||||||
|
Magenta = 5;
|
||||||
|
Brown = 6; // none in KolibriOS?
|
||||||
|
LightGray = 7;
|
||||||
|
DarkGray = 8; // none in KolibriOS?
|
||||||
|
LightBlue = 9;
|
||||||
|
LightGreen = 10;
|
||||||
|
LightCyan = 11;
|
||||||
|
LightRed = 12;
|
||||||
|
LightMagenta = 13;
|
||||||
|
Yellow = 14;
|
||||||
|
White = 15;
|
||||||
|
|
||||||
|
procedure ConsoleInit(Title: PKolibriChar);
|
||||||
|
|
||||||
|
function GetCursorPos: TConsolePoint;
|
||||||
|
procedure SetCursorPos(X, Y: Integer); overload;
|
||||||
|
procedure SetCursorPos(const Point: TConsolePoint); overload;
|
||||||
|
|
||||||
|
procedure ResetAttributes;
|
||||||
|
procedure TextAttribute(Color, Background: Integer);
|
||||||
|
procedure TextBackground(Color: Integer);
|
||||||
|
procedure TextColor(Color: Integer);
|
||||||
|
|
||||||
|
function WriteLn(LineBreaks: Integer = 1): LongInt; overload;
|
||||||
|
function WriteLn(Text: PKolibriChar; LineBreaks: Integer = 1): LongInt; overload;
|
||||||
|
|
||||||
|
var
|
||||||
|
ConsoleExit: procedure(CloseWindow: Boolean); stdcall;
|
||||||
|
KeyPressed: function: Boolean;
|
||||||
|
ReadKey: function: KolibriChar; stdcall;
|
||||||
|
SetCursorHeight: function(Height: Integer): Integer; stdcall;
|
||||||
|
Write: function(const Text: PKolibriChar): LongInt; cdecl varargs;
|
||||||
|
WriteText: procedure(Text: PKolibriChar; Length: LongWord); stdcall;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
procedure ResetAttributes;
|
||||||
|
begin
|
||||||
|
Write(#27'[0m');
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TextAttribute(Color, Background: Integer);
|
||||||
|
begin
|
||||||
|
TextColor(Color);
|
||||||
|
TextBackground(Background);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TextBackground(Color: Integer);
|
||||||
|
const
|
||||||
|
Light = #27'[1m';
|
||||||
|
Colors: array[Black..LightGray] of PKolibriChar = (
|
||||||
|
#27'[40m', // Black
|
||||||
|
#27'[44m', // Blue
|
||||||
|
#27'[42m', // Green
|
||||||
|
#27'[46m', // Cyan
|
||||||
|
#27'[41m', // Red
|
||||||
|
#27'[45m', // Magenta
|
||||||
|
#27'[43m', // Brown
|
||||||
|
#27'[37m' // LightGray
|
||||||
|
);
|
||||||
|
begin
|
||||||
|
case Color of
|
||||||
|
Black..LightGray:
|
||||||
|
Write(Colors[Color]);
|
||||||
|
DarkGray..White:
|
||||||
|
begin
|
||||||
|
Write(Colors[Color]);
|
||||||
|
Write(Light);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TextColor(Color: Integer);
|
||||||
|
const
|
||||||
|
Light = #27'[5m';
|
||||||
|
Colors: array[Black..LightGray] of PKolibriChar = (
|
||||||
|
#27'[30m', // Black
|
||||||
|
#27'[34m', // Blue
|
||||||
|
#27'[32m', // Green
|
||||||
|
#27'[36m', // Cyan
|
||||||
|
#27'[31m', // Red
|
||||||
|
#27'[35m', // Magenta
|
||||||
|
#27'[33m', // Brown
|
||||||
|
#27'[37m' // LightGray
|
||||||
|
);
|
||||||
|
begin
|
||||||
|
case Color of
|
||||||
|
Black..LightGray:
|
||||||
|
Write(Colors[Color]);
|
||||||
|
DarkGray..White:
|
||||||
|
begin
|
||||||
|
Write(Colors[Color]);
|
||||||
|
Write(Light);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function WriteLn(LineBreaks: Integer): LongInt;
|
||||||
|
var
|
||||||
|
I: Integer;
|
||||||
|
begin
|
||||||
|
Result := 0;
|
||||||
|
for I := 0 to LineBreaks - 1 do
|
||||||
|
Inc(Result, Write(#10));
|
||||||
|
end;
|
||||||
|
|
||||||
|
function WriteLn(Text: PKolibriChar; LineBreaks: Integer): LongInt;
|
||||||
|
begin
|
||||||
|
Result := Write(Text) + WriteLn(LineBreaks);
|
||||||
|
end;
|
||||||
|
|
||||||
|
var
|
||||||
|
hConsole: Pointer;
|
||||||
|
ConsoleInitProc: procedure(WndWidth, WndHeight, ScrWidth, ScrHeight: LongInt; Caption: PKolibriChar); stdcall;
|
||||||
|
GetCursorPosProc: procedure(var X, Y: Integer); stdcall;
|
||||||
|
SetCursorPosProc: procedure(X, Y: Integer); stdcall;
|
||||||
|
|
||||||
|
procedure ConsoleInit(Title: PKolibriChar);
|
||||||
|
begin
|
||||||
|
hConsole := LoadLibrary('/sys/lib/console.obj');
|
||||||
|
ConsoleInitProc := GetProcAddress(hConsole, 'con_init');
|
||||||
|
ConsoleExit := GetProcAddress(hConsole, 'con_exit');
|
||||||
|
GetCursorPosProc := GetProcAddress(hConsole, 'con_get_cursor_pos');
|
||||||
|
KeyPressed := GetProcAddress(hConsole, 'con_kbhit');
|
||||||
|
ReadKey := GetProcAddress(hConsole, 'con_getch');
|
||||||
|
SetCursorHeight := GetProcAddress(hConsole, 'con_set_cursor_height');
|
||||||
|
SetCursorPosProc := GetProcAddress(hConsole, 'con_set_cursor_pos');
|
||||||
|
Write := GetProcAddress(hConsole, 'con_printf');
|
||||||
|
WriteText := GetProcAddress(hConsole, 'con_write_string');
|
||||||
|
|
||||||
|
ConsoleInitProc(-1, -1, -1, -1, Title);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function GetCursorPos: TConsolePoint;
|
||||||
|
begin
|
||||||
|
GetCursorPosProc(Result.X, Result.Y);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure SetCursorPos(X, Y: Integer);
|
||||||
|
begin
|
||||||
|
SetCursorPosProc(X, Y);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure SetCursorPos(const Point: TConsolePoint);
|
||||||
|
begin
|
||||||
|
with Point do
|
||||||
|
SetCursorPosProc(X, Y);
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
@@ -1,5 +1,5 @@
|
|||||||
Copyright © 2017-2019 0CodErr
|
Copyright © 2017-2019 0CodErr
|
||||||
Copyright © 2020 Vladislav Javadov (aka Freeman)
|
Copyright © 2020 0CodErr, Nikolay Burshtyn (aka amber8706), Vladislav Javadov (aka Freeman)
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||||
|
Reference in New Issue
Block a user