mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-12-03 22:01:55 +03:00
2f54c7de00
git-svn-id: svn://kolibrios.org@8097 a494cfbc-eb01-0410-851d-a64ba20cac60
86 lines
1.7 KiB
Plaintext
86 lines
1.7 KiB
Plaintext
(*
|
|
BSD 2-Clause License
|
|
|
|
Copyright (c) 2020, Anton Krotov
|
|
All rights reserved.
|
|
*)
|
|
|
|
MODULE Out;
|
|
|
|
IMPORT SYSTEM;
|
|
|
|
|
|
VAR
|
|
|
|
hConsoleOutput: INTEGER;
|
|
|
|
PROCEDURE [windows, "msvcrt.dll", "printf"] printf1 (fmt: INTEGER; x: INTEGER);
|
|
PROCEDURE [windows, "msvcrt.dll", "printf"] printf2 (fmt: INTEGER; width, x: INTEGER);
|
|
PROCEDURE [windows, "msvcrt.dll", "printf"] printf3 (fmt: INTEGER; width, precision, x: INTEGER);
|
|
|
|
PROCEDURE [windows, "kernel32.dll", ""]
|
|
WriteConsoleW (hConsoleOutput, lpBuffer, nNumberOfCharsToWrite, lpNumberOfCharsWritten, lpReserved: INTEGER);
|
|
|
|
PROCEDURE [windows, "kernel32.dll", ""]
|
|
GetStdHandle (nStdHandle: INTEGER): INTEGER;
|
|
|
|
|
|
PROCEDURE Char* (x: CHAR);
|
|
BEGIN
|
|
printf1(SYSTEM.SADR("%c"), ORD(x))
|
|
END Char;
|
|
|
|
|
|
PROCEDURE StringW* (s: ARRAY OF WCHAR);
|
|
BEGIN
|
|
WriteConsoleW(hConsoleOutput, SYSTEM.ADR(s[0]), LENGTH(s), 0, 0)
|
|
END StringW;
|
|
|
|
|
|
PROCEDURE String* (s: ARRAY OF CHAR);
|
|
BEGIN
|
|
printf2(SYSTEM.SADR("%.*s"), LENGTH(s), SYSTEM.ADR(s[0]))
|
|
END String;
|
|
|
|
|
|
PROCEDURE Ln*;
|
|
BEGIN
|
|
printf1(SYSTEM.SADR("%s"), SYSTEM.SADR(CHR(13) + CHR(10)))
|
|
END Ln;
|
|
|
|
|
|
PROCEDURE Int* (x, width: INTEGER);
|
|
BEGIN
|
|
printf2(SYSTEM.SADR("%*lld"), width, x)
|
|
END Int;
|
|
|
|
|
|
PROCEDURE intval (x: REAL): INTEGER;
|
|
VAR
|
|
i: INTEGER;
|
|
|
|
BEGIN
|
|
SYSTEM.GET(SYSTEM.ADR(x), i)
|
|
RETURN i
|
|
END intval;
|
|
|
|
|
|
PROCEDURE Real* (x: REAL; width: INTEGER);
|
|
BEGIN
|
|
printf3(SYSTEM.SADR("%*.*E"), width, MAX(MIN(width - 8, 15), 1), intval(x))
|
|
END Real;
|
|
|
|
|
|
PROCEDURE FixReal* (x: REAL; width, precision: INTEGER);
|
|
BEGIN
|
|
printf3(SYSTEM.SADR("%*.*f"), width, precision, intval(x))
|
|
END FixReal;
|
|
|
|
|
|
PROCEDURE Open*;
|
|
BEGIN
|
|
hConsoleOutput := GetStdHandle(-11)
|
|
END Open;
|
|
|
|
|
|
END Out. |