Standard library
The units every Adam program can import, each read here from its own documentation.
Using a unit
The standard library sits beside the compiler in res/libs/std: one folder of units named System.<Area>. Every build searches it, so a program imports a unit by name and reaches its public names bare (Modules):
module exe stdlib_collections;
import System.Collections;
var
GWords: List<string>;
GCounts: Map<string, int64>;
GI: int64;
GSeen: int64;
begin
GWords.Add("pear");
GWords.Add("apple");
GWords.Add("apple");
for GI := 0 to GWords.Count - 1 do
if not GCounts.TryGet(GWords[GI], GSeen) then
GSeen := 0;
end;
GCounts[GWords[GI]] := GSeen + 1;
end;
println("{} words, {} kinds", GWords.Count, GCounts.Count);
println("apple {}", GCounts["apple"]);
println("pear {}", GCounts["pear"]);
GWords.Sort();
println("sorted: {} {} {}", GWords[0], GWords[1], GWords[2]);
end.
3 words, 2 kinds
apple 2
pear 1
sorted: apple apple pear
List<T>, Map<K, V> and Set<T> are plain values: declared, then used, with no create. A map's index reads through Get, which raises for a key the map does not hold, and writes through Put; TryGet asks without raising.
One import for both targets
A target-neutral unit names no OS. It hands each job to the platform part the build's triple picks, imported under @ifdef TARGET_<triple> (Directives): System.IO.Win64 on x86_64-windows-gnu, System.IO.Linux64 on x86_64-linux-gnu. A program imports System.IO and is the same program on both. The platform parts are in the reference below too.
C libraries: .C and .Ext
A C library Adam ships (Vendored libraries) comes as a <Name>.C unit, written by adam cimport under the C header's own names, and most also as <Name>.Ext, the Adam API over it (SDL3, mojoAL, minizip, pl_mpeg and the C library have a .C unit only). A program imports the unit whose names it uses.
Every public routine of an Adam API unit links by its C++ name (clink and cpplink), so a C library's routine of the same spelling never meets it; a .C unit's routines keep C linkage.
The reference
Each entry is read from the unit's /// docs: a summary, the parameters, the result and an example. The editor's hover shows the same text.
System.Base64
Base64 (RFC 4648 sec 4, the standard alphabet with '=' padding), written in Adam: bytes or text to Base64 text and back.
Import it with import System.Base64;.
Routines
Base64Encode
func cpplink Base64Encode(const ABytes: ByteArray): string
ABytes as Base64 text (the standard alphabet, padded with =, one line).
Parameters
ABytes: the bytes (empty gives "")
Returns: the Base64 text
Example: Base64Encode(LPNG) for a data:image/png;base64, URL
func cpplink Base64Encode(const AText: string): string
The UTF-8 bytes of AText as Base64 text.
Parameters
AText: the text ("" gives "")
Returns: the Base64 text
Example: Base64Encode("Adam") is "QWRhbQ=="
Base64Decode
func cpplink Base64Decode(const AText: string; var ABytes: ByteArray): bool
Base64 text decoded to bytes: whitespace skipped, padding optional; anything else outside the standard alphabet, a = before the end or a lone last character fails.
Parameters
AText: the Base64 text ("" decodes to no bytes)ABytes: the bytes it holds (empty on a failure)
Returns: true when AText is Base64
Example: if Base64Decode(LField, LBytes) then WriteAllBytes("icon.png", LBytes); end;
func cpplink Base64Decode(const AText: string; var ADecoded: string): bool
Base64 text decoded to text: its bytes taken as they are (UTF-8 when they were text).
Parameters
AText: the Base64 textADecoded: the text it holds ("" on a failure)
Returns: true when AText is Base64
Example: Base64Decode("QWRhbQ==", LName) gives "Adam"
System.Bench
micro-benchmarks: time a kernel on the high-resolution clock, keep the best of several runs, and carry the kernel's checksum so the work can be checked and never optimized away.
Import it with import System.Bench;.
Types
BenchKernel
type BenchKernel = ref func(): int64
A benchmark kernel: does the work once and returns a checksum of what it computed.
BenchResult
type BenchResult = record
What BenchRun measured for one kernel.
Members
Name: string: The kernel's name, as given toBenchRun.BestNs: int64: The fastest timed run, in nanoseconds.Check: int64: The kernel's checksum (the warmup run's).Runs: int64: How many runs were timed.Stable: bool: True when every run returned the same checksum.
Routines
BenchRun
func cpplink BenchRun(const AName: string; const AKernel: BenchKernel; const ARuns: int64): BenchResult
Times AKernel: one untimed warmup run, then ARuns timed runs; the fastest is kept. A run count below 1 times one run.
Parameters
AName: the kernel's name (the result line's first word)AKernel: the work; returns a checksum of what it computedARuns: how many timed runs
Returns: the best time, the checksum, and whether every run agreed on it
Example: LResult := BenchRun("fib", func(): int64 begin return Fib(32); end, 5);
BenchLine
func cpplink BenchLine(const AResult: BenchResult): string
AResult as one line: <name> us=<best microseconds> check=<checksum>, with unstable added when the runs disagreed on the checksum.
Parameters
AResult: whatBenchRunmeasured
Returns: the line
Example: println(BenchLine(BenchRun("sieve", KernelSieve, 5)));
System.Collections
the generic containers (BNF sec 10, PLAN-ADAM M10g)
Import it with import System.Collections;.
Types
List
type List<T> = object
A growable list of T, in the order added.
Members
property Count: int64 read FCount: How many items the list holds.property Items[AIndex: int64]: T read; write: The item at an index (0-based), read and written; raises code 14 outside 0 .. Count - 1.method Add(const AItem: T): Adds an item at the end. Parameters:AItemthe item.method Insert(const AIndex: int64; const AItem: T): Puts an item at an index, the items from there on one place up; raises code 14 outside 0 .. Count. Parameters:AIndexwhere it goes (Count adds it at the end);AItemthe item.method Delete(const AIndex: int64): Takes the item at an index out, the items after it one place down; raises code 14 outside 0 .. Count - 1. Parameters:AIndexthe item's index.method RemoveLast(): T: Takes the last item off the list; raises code 14 when it is empty. Returns: the item taken offmethod Clear(): Empties the list (its storage kept for the items added next).const method IndexOf(const AItem: T): int64: Finds an item. Parameters:AItemthe item looked for (compared with =). Returns: the index of the first equal item; -1 when there is noneconst method Contains(const AItem: T): bool: Whether the list holds an item. Parameters:AItemthe item looked for (compared with =). Returns: true when an item equals itmethod Remove(const AItem: T): bool: Takes the first item equal to one out. Parameters:AItemthe item looked for (compared with =). Returns: false when there is nonemethod Reverse(): Puts the items in the opposite order.method Sort(): Sorts the items ascending by T's<, equal items kept in their order (a stable merge sort, n log n).const method ToArray(): array of T: The items as a new array. Returns: the array, in list order
Example: LNames.Add("Ada"); LNames.Sort(); println("{}", LNames[0]);
Map
type Map<K, V> = object
A map from K to V, its keys in the order first put; K takes any type with hash.
Members
property Count: int64 read FCount: How many keys the map holds.property Items[const AKey: K]: V read; write: The value of a key: read, it is Get's (raises code 1 for a key the map does not hold); written, it is Put's.method Put(const AKey: K; const AValue: V): Maps a key to a value: a key the map holds gets its value replaced, a new key is added last. Parameters:AKeythe key;AValueits value.const method Get(const AKey: K): V: The value of a key; raises code 1 when the map does not hold it. Parameters:AKeythe key. Returns: its valueconst method TryGet(const AKey: K; var AValue: V): bool: The value of a key, when the map holds it. Parameters:AKeythe key;AValueits value (left as it was when the map does not hold the key). Returns: true when the map holds the keyconst method Has(const AKey: K): bool: Whether the map holds a key. Parameters:AKeythe key. Returns: true when it doesmethod Remove(const AKey: K): bool: Takes a key and its value out; the last key out empties the map. Parameters:AKeythe key. Returns: false when the map does not hold itmethod Clear(): Empties the map (its storage kept for the keys put next).const method Keys(): array of K: The keys as a new array. Returns: the keys, in the order first putconst method Values(): array of V: The values as a new array. Returns: the values, in their keys' order (Keys)
Example: LAges.Put("Ada", 36); if LAges.Has("Ada") then println("{}", LAges["Ada"]); end;
Set
type Set<T> = object
A set of T, the items in the order added; T takes any type with hash.
Members
property Count: int64 read: How many items the set holds.method Add(const AItem: T): bool: Adds an item (last). Parameters:AItemthe item. Returns: false when the set held it already (nothing changes)const method Has(const AItem: T): bool: Whether the set holds an item. Parameters:AItemthe item. Returns: true when it doesmethod Remove(const AItem: T): bool: Takes an item out. Parameters:AItemthe item. Returns: false when the set did not hold itmethod Clear(): Empties the set.const method Items(): array of T: The items as a new array. Returns: the items, in the order added
Example: if LSeen.Add(LName) then println("new: {}", LName); end;
Constants
| Name | Declaration | Description |
|---|---|---|
ADAM_COLLECTIONS_EXC_INDEX | const ADAM_COLLECTIONS_EXC_INDEX: int32 = 14 | The code an index outside a container raises with: the runtime's own index check's (System.Runtime's ADAM_RUNTIME_EXC_INDEX), so a list reads as an array does. |
ADAM_COLLECTIONS_FIRST_CAPACITY | const ADAM_COLLECTIONS_FIRST_CAPACITY: int64 = 4 | A list's first storage, doubled each time it is full. |
ADAM_COLLECTIONS_EXC_KEY | const ADAM_COLLECTIONS_EXC_KEY: int32 = 1 | The code a map's Get of a key it does not hold raises with. |
ADAM_COLLECTIONS_FIRST_INDEX | const ADAM_COLLECTIONS_FIRST_INDEX: int64 = 8 | A map index's first size (a power of two, doubled while it is more than half used after a rebuild). |
ADAM_COLLECTIONS_SLOT_EMPTY | const ADAM_COLLECTIONS_SLOT_EMPTY: int64 = 0 | A map index slot no entry has used (any other slot holds its entry's position + 1). |
ADAM_COLLECTIONS_SLOT_REMOVED | const ADAM_COLLECTIONS_SLOT_REMOVED: int64 = -1 | A map index slot whose entry was removed (a tombstone: a search goes on past it). |
System.Console
the program's console: import System.Console; adds text and VT escape sequences on standard output and the keyboard on standard input.
Import it with import System.Console;.
Types
TextColor
type TextColor = choices(
The 16 standard terminal colours, in their SGR order (int32(TextColor.Red) is 1): foreground 30-37 / 90-97, background 40-47 / 100-107.
Members
TextColor.Black: SGR 30 / 40.TextColor.Red: SGR 31 / 41.TextColor.Green: SGR 32 / 42.TextColor.Yellow: SGR 33 / 43.TextColor.Blue: SGR 34 / 44.TextColor.Magenta: SGR 35 / 45.TextColor.Cyan: SGR 36 / 46.TextColor.White: SGR 37 / 47.TextColor.BrightBlack: Grey: SGR 90 / 100.TextColor.BrightRed: SGR 91 / 101.TextColor.BrightGreen: SGR 92 / 102.TextColor.BrightYellow: SGR 93 / 103.TextColor.BrightBlue: SGR 94 / 104.TextColor.BrightMagenta: SGR 95 / 105.TextColor.BrightCyan: SGR 96 / 106.TextColor.BrightWhite: SGR 97 / 107.
Example: SetForegroundColor(TextColor.BrightGreen); println("ok"); ResetFormat();
EscapeMode
type EscapeMode = choices(
When escape sequences are written.
Members
EscapeMode.Auto: While standard output is a terminal (the default).EscapeMode.On: Always, even into a pipe or a file.EscapeMode.Off: Never: the text alone.
TextAlign
type TextAlign = choices(
Where a text sits inside a padded width.
Members
TextAlign.Left: The text first, the padding after it.TextAlign.Center: The padding split around the text (the extra one after it).TextAlign.Right: The padding first, the text after it.
RGB
type RGB = object
A 24-bit colour (SGR 38;2 / 48;2): red, green and blue, 0-255 each.
Members
R: uint8: The red component, 0 .. 255G: uint8: The green component, 0 .. 255B: uint8: The blue component, 0 .. 255init(): Black (0, 0, 0).init(const AR: uint8; const AG: uint8; const AB: uint8): The colour (AR, AG, AB). Parameters:ARred, 0-255;AGgreen, 0-255;ABblue, 0-255.
Example: LGold: RGB(255, 215, 0);
Constants
| Name | Declaration | Description |
|---|---|---|
CsiEsc | const CsiEsc: string = "\x1b" | The escape character (ESC, 0x1B), the start of every sequence. |
CsiCr | const CsiCr: string = "\r" | A carriage return: the cursor to the start of its line. |
CsiLf | const CsiLf: string = "\n" | A line feed, the line break WriteLn writes. |
CsiCrLf | const CsiCrLf: string = "\r\n" | A carriage return and a line feed. |
CsiSaveCursorPosition | const CsiSaveCursorPosition: string = "\x1b[s"; CsiRestoreCursorPosition: string = "\x1b[u"; CsiShowCursor: string = "\x1b[?25h"; CsiHideCursor: string = "\x1b[?25l"; CsiBlinkCursor: string = "\x1b[?12h"; CsiSteadyCursor: string = "\x1b[?12l"; CsiClearScreen: string = "\x1b[2J"; CsiClearScrollback: string = "\x1b[3J"; CsiClearLine: string = "\x1b[2K"; CsiClearToEndOfLine: string = "\x1b[0K"; CsiBold: string = "\x1b[1m"; CsiDim: string = "\x1b[2m"; CsiItalic: string = "\x1b[3m"; CsiUnderline: string = "\x1b[4m"; CsiBlink: string = "\x1b[5m"; CsiInvertColors: string = "\x1b[7m"; CsiStrike: string = "\x1b[9m"; CsiNormalColors: string = "\x1b[27m"; CsiFramed: string = "\x1b[51m"; CsiEncircled: string = "\x1b[52m"; CsiResetFormat: string = "\x1b[0m"; CsiResetForeground: string = "\x1b[39m"; CsiResetBackground: string = "\x1b[49m"; CsiFgBlack: string = "\x1b[30m"; CsiFgRed: string = "\x1b[31m"; CsiFgGreen: string = "\x1b[32m"; CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Saves the cursor's position (CSI s). |
CsiRestoreCursorPosition | const CsiRestoreCursorPosition: string = "\x1b[u"; CsiShowCursor: string = "\x1b[?25h"; CsiHideCursor: string = "\x1b[?25l"; CsiBlinkCursor: string = "\x1b[?12h"; CsiSteadyCursor: string = "\x1b[?12l"; CsiClearScreen: string = "\x1b[2J"; CsiClearScrollback: string = "\x1b[3J"; CsiClearLine: string = "\x1b[2K"; CsiClearToEndOfLine: string = "\x1b[0K"; CsiBold: string = "\x1b[1m"; CsiDim: string = "\x1b[2m"; CsiItalic: string = "\x1b[3m"; CsiUnderline: string = "\x1b[4m"; CsiBlink: string = "\x1b[5m"; CsiInvertColors: string = "\x1b[7m"; CsiStrike: string = "\x1b[9m"; CsiNormalColors: string = "\x1b[27m"; CsiFramed: string = "\x1b[51m"; CsiEncircled: string = "\x1b[52m"; CsiResetFormat: string = "\x1b[0m"; CsiResetForeground: string = "\x1b[39m"; CsiResetBackground: string = "\x1b[49m"; CsiFgBlack: string = "\x1b[30m"; CsiFgRed: string = "\x1b[31m"; CsiFgGreen: string = "\x1b[32m"; CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Puts the cursor back where CsiSaveCursorPosition saved it (CSI u). |
CsiShowCursor | const CsiShowCursor: string = "\x1b[?25h"; CsiHideCursor: string = "\x1b[?25l"; CsiBlinkCursor: string = "\x1b[?12h"; CsiSteadyCursor: string = "\x1b[?12l"; CsiClearScreen: string = "\x1b[2J"; CsiClearScrollback: string = "\x1b[3J"; CsiClearLine: string = "\x1b[2K"; CsiClearToEndOfLine: string = "\x1b[0K"; CsiBold: string = "\x1b[1m"; CsiDim: string = "\x1b[2m"; CsiItalic: string = "\x1b[3m"; CsiUnderline: string = "\x1b[4m"; CsiBlink: string = "\x1b[5m"; CsiInvertColors: string = "\x1b[7m"; CsiStrike: string = "\x1b[9m"; CsiNormalColors: string = "\x1b[27m"; CsiFramed: string = "\x1b[51m"; CsiEncircled: string = "\x1b[52m"; CsiResetFormat: string = "\x1b[0m"; CsiResetForeground: string = "\x1b[39m"; CsiResetBackground: string = "\x1b[49m"; CsiFgBlack: string = "\x1b[30m"; CsiFgRed: string = "\x1b[31m"; CsiFgGreen: string = "\x1b[32m"; CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Shows the cursor. |
CsiHideCursor | const CsiHideCursor: string = "\x1b[?25l"; CsiBlinkCursor: string = "\x1b[?12h"; CsiSteadyCursor: string = "\x1b[?12l"; CsiClearScreen: string = "\x1b[2J"; CsiClearScrollback: string = "\x1b[3J"; CsiClearLine: string = "\x1b[2K"; CsiClearToEndOfLine: string = "\x1b[0K"; CsiBold: string = "\x1b[1m"; CsiDim: string = "\x1b[2m"; CsiItalic: string = "\x1b[3m"; CsiUnderline: string = "\x1b[4m"; CsiBlink: string = "\x1b[5m"; CsiInvertColors: string = "\x1b[7m"; CsiStrike: string = "\x1b[9m"; CsiNormalColors: string = "\x1b[27m"; CsiFramed: string = "\x1b[51m"; CsiEncircled: string = "\x1b[52m"; CsiResetFormat: string = "\x1b[0m"; CsiResetForeground: string = "\x1b[39m"; CsiResetBackground: string = "\x1b[49m"; CsiFgBlack: string = "\x1b[30m"; CsiFgRed: string = "\x1b[31m"; CsiFgGreen: string = "\x1b[32m"; CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Hides the cursor. |
CsiBlinkCursor | const CsiBlinkCursor: string = "\x1b[?12h"; CsiSteadyCursor: string = "\x1b[?12l"; CsiClearScreen: string = "\x1b[2J"; CsiClearScrollback: string = "\x1b[3J"; CsiClearLine: string = "\x1b[2K"; CsiClearToEndOfLine: string = "\x1b[0K"; CsiBold: string = "\x1b[1m"; CsiDim: string = "\x1b[2m"; CsiItalic: string = "\x1b[3m"; CsiUnderline: string = "\x1b[4m"; CsiBlink: string = "\x1b[5m"; CsiInvertColors: string = "\x1b[7m"; CsiStrike: string = "\x1b[9m"; CsiNormalColors: string = "\x1b[27m"; CsiFramed: string = "\x1b[51m"; CsiEncircled: string = "\x1b[52m"; CsiResetFormat: string = "\x1b[0m"; CsiResetForeground: string = "\x1b[39m"; CsiResetBackground: string = "\x1b[49m"; CsiFgBlack: string = "\x1b[30m"; CsiFgRed: string = "\x1b[31m"; CsiFgGreen: string = "\x1b[32m"; CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | A blinking cursor. |
CsiSteadyCursor | const CsiSteadyCursor: string = "\x1b[?12l"; CsiClearScreen: string = "\x1b[2J"; CsiClearScrollback: string = "\x1b[3J"; CsiClearLine: string = "\x1b[2K"; CsiClearToEndOfLine: string = "\x1b[0K"; CsiBold: string = "\x1b[1m"; CsiDim: string = "\x1b[2m"; CsiItalic: string = "\x1b[3m"; CsiUnderline: string = "\x1b[4m"; CsiBlink: string = "\x1b[5m"; CsiInvertColors: string = "\x1b[7m"; CsiStrike: string = "\x1b[9m"; CsiNormalColors: string = "\x1b[27m"; CsiFramed: string = "\x1b[51m"; CsiEncircled: string = "\x1b[52m"; CsiResetFormat: string = "\x1b[0m"; CsiResetForeground: string = "\x1b[39m"; CsiResetBackground: string = "\x1b[49m"; CsiFgBlack: string = "\x1b[30m"; CsiFgRed: string = "\x1b[31m"; CsiFgGreen: string = "\x1b[32m"; CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | A steady (not blinking) cursor. |
CsiClearScreen | const CsiClearScreen: string = "\x1b[2J"; CsiClearScrollback: string = "\x1b[3J"; CsiClearLine: string = "\x1b[2K"; CsiClearToEndOfLine: string = "\x1b[0K"; CsiBold: string = "\x1b[1m"; CsiDim: string = "\x1b[2m"; CsiItalic: string = "\x1b[3m"; CsiUnderline: string = "\x1b[4m"; CsiBlink: string = "\x1b[5m"; CsiInvertColors: string = "\x1b[7m"; CsiStrike: string = "\x1b[9m"; CsiNormalColors: string = "\x1b[27m"; CsiFramed: string = "\x1b[51m"; CsiEncircled: string = "\x1b[52m"; CsiResetFormat: string = "\x1b[0m"; CsiResetForeground: string = "\x1b[39m"; CsiResetBackground: string = "\x1b[49m"; CsiFgBlack: string = "\x1b[30m"; CsiFgRed: string = "\x1b[31m"; CsiFgGreen: string = "\x1b[32m"; CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Clears the visible screen (the cursor stays). |
CsiClearScrollback | const CsiClearScrollback: string = "\x1b[3J"; CsiClearLine: string = "\x1b[2K"; CsiClearToEndOfLine: string = "\x1b[0K"; CsiBold: string = "\x1b[1m"; CsiDim: string = "\x1b[2m"; CsiItalic: string = "\x1b[3m"; CsiUnderline: string = "\x1b[4m"; CsiBlink: string = "\x1b[5m"; CsiInvertColors: string = "\x1b[7m"; CsiStrike: string = "\x1b[9m"; CsiNormalColors: string = "\x1b[27m"; CsiFramed: string = "\x1b[51m"; CsiEncircled: string = "\x1b[52m"; CsiResetFormat: string = "\x1b[0m"; CsiResetForeground: string = "\x1b[39m"; CsiResetBackground: string = "\x1b[49m"; CsiFgBlack: string = "\x1b[30m"; CsiFgRed: string = "\x1b[31m"; CsiFgGreen: string = "\x1b[32m"; CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Clears the scrollback above the screen. |
CsiClearLine | const CsiClearLine: string = "\x1b[2K"; CsiClearToEndOfLine: string = "\x1b[0K"; CsiBold: string = "\x1b[1m"; CsiDim: string = "\x1b[2m"; CsiItalic: string = "\x1b[3m"; CsiUnderline: string = "\x1b[4m"; CsiBlink: string = "\x1b[5m"; CsiInvertColors: string = "\x1b[7m"; CsiStrike: string = "\x1b[9m"; CsiNormalColors: string = "\x1b[27m"; CsiFramed: string = "\x1b[51m"; CsiEncircled: string = "\x1b[52m"; CsiResetFormat: string = "\x1b[0m"; CsiResetForeground: string = "\x1b[39m"; CsiResetBackground: string = "\x1b[49m"; CsiFgBlack: string = "\x1b[30m"; CsiFgRed: string = "\x1b[31m"; CsiFgGreen: string = "\x1b[32m"; CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Clears the cursor's line (the cursor stays). |
CsiClearToEndOfLine | const CsiClearToEndOfLine: string = "\x1b[0K"; CsiBold: string = "\x1b[1m"; CsiDim: string = "\x1b[2m"; CsiItalic: string = "\x1b[3m"; CsiUnderline: string = "\x1b[4m"; CsiBlink: string = "\x1b[5m"; CsiInvertColors: string = "\x1b[7m"; CsiStrike: string = "\x1b[9m"; CsiNormalColors: string = "\x1b[27m"; CsiFramed: string = "\x1b[51m"; CsiEncircled: string = "\x1b[52m"; CsiResetFormat: string = "\x1b[0m"; CsiResetForeground: string = "\x1b[39m"; CsiResetBackground: string = "\x1b[49m"; CsiFgBlack: string = "\x1b[30m"; CsiFgRed: string = "\x1b[31m"; CsiFgGreen: string = "\x1b[32m"; CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Clears from the cursor to the end of its line. |
CsiBold | const CsiBold: string = "\x1b[1m"; CsiDim: string = "\x1b[2m"; CsiItalic: string = "\x1b[3m"; CsiUnderline: string = "\x1b[4m"; CsiBlink: string = "\x1b[5m"; CsiInvertColors: string = "\x1b[7m"; CsiStrike: string = "\x1b[9m"; CsiNormalColors: string = "\x1b[27m"; CsiFramed: string = "\x1b[51m"; CsiEncircled: string = "\x1b[52m"; CsiResetFormat: string = "\x1b[0m"; CsiResetForeground: string = "\x1b[39m"; CsiResetBackground: string = "\x1b[49m"; CsiFgBlack: string = "\x1b[30m"; CsiFgRed: string = "\x1b[31m"; CsiFgGreen: string = "\x1b[32m"; CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Bold text. |
CsiDim | const CsiDim: string = "\x1b[2m"; CsiItalic: string = "\x1b[3m"; CsiUnderline: string = "\x1b[4m"; CsiBlink: string = "\x1b[5m"; CsiInvertColors: string = "\x1b[7m"; CsiStrike: string = "\x1b[9m"; CsiNormalColors: string = "\x1b[27m"; CsiFramed: string = "\x1b[51m"; CsiEncircled: string = "\x1b[52m"; CsiResetFormat: string = "\x1b[0m"; CsiResetForeground: string = "\x1b[39m"; CsiResetBackground: string = "\x1b[49m"; CsiFgBlack: string = "\x1b[30m"; CsiFgRed: string = "\x1b[31m"; CsiFgGreen: string = "\x1b[32m"; CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Dim text. |
CsiItalic | const CsiItalic: string = "\x1b[3m"; CsiUnderline: string = "\x1b[4m"; CsiBlink: string = "\x1b[5m"; CsiInvertColors: string = "\x1b[7m"; CsiStrike: string = "\x1b[9m"; CsiNormalColors: string = "\x1b[27m"; CsiFramed: string = "\x1b[51m"; CsiEncircled: string = "\x1b[52m"; CsiResetFormat: string = "\x1b[0m"; CsiResetForeground: string = "\x1b[39m"; CsiResetBackground: string = "\x1b[49m"; CsiFgBlack: string = "\x1b[30m"; CsiFgRed: string = "\x1b[31m"; CsiFgGreen: string = "\x1b[32m"; CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Italic text. |
CsiUnderline | const CsiUnderline: string = "\x1b[4m"; CsiBlink: string = "\x1b[5m"; CsiInvertColors: string = "\x1b[7m"; CsiStrike: string = "\x1b[9m"; CsiNormalColors: string = "\x1b[27m"; CsiFramed: string = "\x1b[51m"; CsiEncircled: string = "\x1b[52m"; CsiResetFormat: string = "\x1b[0m"; CsiResetForeground: string = "\x1b[39m"; CsiResetBackground: string = "\x1b[49m"; CsiFgBlack: string = "\x1b[30m"; CsiFgRed: string = "\x1b[31m"; CsiFgGreen: string = "\x1b[32m"; CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Underlined text. |
CsiBlink | const CsiBlink: string = "\x1b[5m"; CsiInvertColors: string = "\x1b[7m"; CsiStrike: string = "\x1b[9m"; CsiNormalColors: string = "\x1b[27m"; CsiFramed: string = "\x1b[51m"; CsiEncircled: string = "\x1b[52m"; CsiResetFormat: string = "\x1b[0m"; CsiResetForeground: string = "\x1b[39m"; CsiResetBackground: string = "\x1b[49m"; CsiFgBlack: string = "\x1b[30m"; CsiFgRed: string = "\x1b[31m"; CsiFgGreen: string = "\x1b[32m"; CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Blinking text. |
CsiInvertColors | const CsiInvertColors: string = "\x1b[7m"; CsiStrike: string = "\x1b[9m"; CsiNormalColors: string = "\x1b[27m"; CsiFramed: string = "\x1b[51m"; CsiEncircled: string = "\x1b[52m"; CsiResetFormat: string = "\x1b[0m"; CsiResetForeground: string = "\x1b[39m"; CsiResetBackground: string = "\x1b[49m"; CsiFgBlack: string = "\x1b[30m"; CsiFgRed: string = "\x1b[31m"; CsiFgGreen: string = "\x1b[32m"; CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Foreground and background swapped. |
CsiStrike | const CsiStrike: string = "\x1b[9m"; CsiNormalColors: string = "\x1b[27m"; CsiFramed: string = "\x1b[51m"; CsiEncircled: string = "\x1b[52m"; CsiResetFormat: string = "\x1b[0m"; CsiResetForeground: string = "\x1b[39m"; CsiResetBackground: string = "\x1b[49m"; CsiFgBlack: string = "\x1b[30m"; CsiFgRed: string = "\x1b[31m"; CsiFgGreen: string = "\x1b[32m"; CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Struck-through text. |
CsiNormalColors | const CsiNormalColors: string = "\x1b[27m"; CsiFramed: string = "\x1b[51m"; CsiEncircled: string = "\x1b[52m"; CsiResetFormat: string = "\x1b[0m"; CsiResetForeground: string = "\x1b[39m"; CsiResetBackground: string = "\x1b[49m"; CsiFgBlack: string = "\x1b[30m"; CsiFgRed: string = "\x1b[31m"; CsiFgGreen: string = "\x1b[32m"; CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Ends CsiInvertColors. |
CsiFramed | const CsiFramed: string = "\x1b[51m"; CsiEncircled: string = "\x1b[52m"; CsiResetFormat: string = "\x1b[0m"; CsiResetForeground: string = "\x1b[39m"; CsiResetBackground: string = "\x1b[49m"; CsiFgBlack: string = "\x1b[30m"; CsiFgRed: string = "\x1b[31m"; CsiFgGreen: string = "\x1b[32m"; CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Framed text. |
CsiEncircled | const CsiEncircled: string = "\x1b[52m"; CsiResetFormat: string = "\x1b[0m"; CsiResetForeground: string = "\x1b[39m"; CsiResetBackground: string = "\x1b[49m"; CsiFgBlack: string = "\x1b[30m"; CsiFgRed: string = "\x1b[31m"; CsiFgGreen: string = "\x1b[32m"; CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Encircled text. |
CsiResetFormat | const CsiResetFormat: string = "\x1b[0m"; CsiResetForeground: string = "\x1b[39m"; CsiResetBackground: string = "\x1b[49m"; CsiFgBlack: string = "\x1b[30m"; CsiFgRed: string = "\x1b[31m"; CsiFgGreen: string = "\x1b[32m"; CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Resets bold, the colours and every other attribute. |
CsiResetForeground | const CsiResetForeground: string = "\x1b[39m"; CsiResetBackground: string = "\x1b[49m"; CsiFgBlack: string = "\x1b[30m"; CsiFgRed: string = "\x1b[31m"; CsiFgGreen: string = "\x1b[32m"; CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | The default foreground colour. |
CsiResetBackground | const CsiResetBackground: string = "\x1b[49m"; CsiFgBlack: string = "\x1b[30m"; CsiFgRed: string = "\x1b[31m"; CsiFgGreen: string = "\x1b[32m"; CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | The default background colour. |
CsiFgBlack | const CsiFgBlack: string = "\x1b[30m"; CsiFgRed: string = "\x1b[31m"; CsiFgGreen: string = "\x1b[32m"; CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Black foreground (SGR 30). |
CsiFgRed | const CsiFgRed: string = "\x1b[31m"; CsiFgGreen: string = "\x1b[32m"; CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Red foreground (SGR 31). |
CsiFgGreen | const CsiFgGreen: string = "\x1b[32m"; CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Green foreground (SGR 32). |
CsiFgYellow | const CsiFgYellow: string = "\x1b[33m"; CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Yellow foreground (SGR 33). |
CsiFgBlue | const CsiFgBlue: string = "\x1b[34m"; CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Blue foreground (SGR 34). |
CsiFgMagenta | const CsiFgMagenta: string = "\x1b[35m"; CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Magenta foreground (SGR 35). |
CsiFgCyan | const CsiFgCyan: string = "\x1b[36m"; CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Cyan foreground (SGR 36). |
CsiFgWhite | const CsiFgWhite: string = "\x1b[37m"; CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | White foreground (SGR 37). |
CsiBgBlack | const CsiBgBlack: string = "\x1b[40m"; CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Black background (SGR 40). |
CsiBgRed | const CsiBgRed: string = "\x1b[41m"; CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Red background (SGR 41). |
CsiBgGreen | const CsiBgGreen: string = "\x1b[42m"; CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Green background (SGR 42). |
CsiBgYellow | const CsiBgYellow: string = "\x1b[43m"; CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Yellow background (SGR 43). |
CsiBgBlue | const CsiBgBlue: string = "\x1b[44m"; CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Blue background (SGR 44). |
CsiBgMagenta | const CsiBgMagenta: string = "\x1b[45m"; CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Magenta background (SGR 45). |
CsiBgCyan | const CsiBgCyan: string = "\x1b[46m"; CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Cyan background (SGR 46). |
CsiBgWhite | const CsiBgWhite: string = "\x1b[47m"; CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | White background (SGR 47). |
CsiFgBrightBlack | const CsiFgBrightBlack: string = "\x1b[90m"; CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Bright black (grey) foreground (SGR 90). |
CsiFgBrightRed | const CsiFgBrightRed: string = "\x1b[91m"; CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Bright red foreground (SGR 91). |
CsiFgBrightGreen | const CsiFgBrightGreen: string = "\x1b[92m"; CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Bright green foreground (SGR 92). |
CsiFgBrightYellow | const CsiFgBrightYellow: string = "\x1b[93m"; CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Bright yellow foreground (SGR 93). |
CsiFgBrightBlue | const CsiFgBrightBlue: string = "\x1b[94m"; CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Bright blue foreground (SGR 94). |
CsiFgBrightMagenta | const CsiFgBrightMagenta: string = "\x1b[95m"; CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Bright magenta foreground (SGR 95). |
CsiFgBrightCyan | const CsiFgBrightCyan: string = "\x1b[96m"; CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Bright cyan foreground (SGR 96). |
CsiFgBrightWhite | const CsiFgBrightWhite: string = "\x1b[97m"; CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Bright white foreground (SGR 97). |
CsiBgBrightBlack | const CsiBgBrightBlack: string = "\x1b[100m"; CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Bright black (grey) background (SGR 100). |
CsiBgBrightRed | const CsiBgBrightRed: string = "\x1b[101m"; CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Bright red background (SGR 101). |
CsiBgBrightGreen | const CsiBgBrightGreen: string = "\x1b[102m"; CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Bright green background (SGR 102). |
CsiBgBrightYellow | const CsiBgBrightYellow: string = "\x1b[103m"; CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Bright yellow background (SGR 103). |
CsiBgBrightBlue | const CsiBgBrightBlue: string = "\x1b[104m"; CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Bright blue background (SGR 104). |
CsiBgBrightMagenta | const CsiBgBrightMagenta: string = "\x1b[105m"; CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Bright magenta background (SGR 105). |
CsiBgBrightCyan | const CsiBgBrightCyan: string = "\x1b[106m"; CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Bright cyan background (SGR 106). |
CsiBgBrightWhite | const CsiBgBrightWhite: string = "\x1b[107m"; CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | Bright white background (SGR 107). |
CsiBgDarkGrey | const CsiBgDarkGrey: string = "\x1b[48;5;238m"; KeyEnter: string = "\r"; KeyEscape: string = "\x1b"; KeyBackspace: string = "\x08"; func CsiCount(const ACount: int32; const AFinal: string): string; begin if ACount <= 0 then return ""; end; return FormatStr("\x1b[{}{}", ACount, AFinal); end; func SgrStandard(const AColor: TextColor; const ANormalBase: int32; const ABrightBase: int32): string; var LIndex: int32; begin LIndex := int32(AColor); if (LIndex < 0) or (LIndex > 15) then return ""; end; if LIndex < 8 then return FormatStr("\x1b[{}m", ANormalBase + LIndex); end; return FormatStr("\x1b[{}m", ABrightBase + LIndex - 8); end; func SgrRGB(const AColor: RGB; const ASelector: int32): string; begin return FormatStr("\x1b[{};2;{};{};{}m", ASelector, int32(AColor.R), int32(AColor.G), int32(AColor.B)); end; public func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string; var LX: int32; LY: int32; begin LX := AX; if LX < 0 then LX := 0; end; LY := AY; if LY < 0 then LY := 0; end; return FormatStr("\x1b[{};{}H", LY + 1, LX + 1); end; public func cpplink CsiCursorColumn(const AX: int32): string; var LX: int32; begin LX := AX; if LX < 0 then LX := 0; end; return FormatStr("\x1b[{}G", LX + 1); end; public func cpplink CsiCursorUp(const ALines: int32): string; begin return CsiCount(ALines, "A"); end; public func cpplink CsiCursorDown(const ALines: int32): string; begin return CsiCount(ALines, "B"); end; public func cpplink CsiCursorForward(const AColumns: int32): string; begin return CsiCount(AColumns, "C"); end; public func cpplink CsiCursorBack(const AColumns: int32): string; begin return CsiCount(AColumns, "D"); end; public func cpplink CsiScrollUp(const ALines: int32): string; begin return CsiCount(ALines, "S"); end; public func cpplink CsiScrollDown(const ALines: int32): string; begin return CsiCount(ALines, "T"); end; public func cpplink CsiInsertLines(const ALines: int32): string; begin return CsiCount(ALines, "L"); end; public func cpplink CsiDeleteLines(const ALines: int32): string; begin return CsiCount(ALines, "M"); end; public func cpplink CsiInsertChars(const ACount: int32): string; begin return CsiCount(ACount, "@"); end; public func cpplink CsiDeleteChars(const ACount: int32): string; begin return CsiCount(ACount, "P"); end; public func cpplink CsiEraseChars(const ACount: int32): string; begin return CsiCount(ACount, "X"); end; public func cpplink CsiForeground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[38;5;{}m", AIndex); end; public func cpplink CsiBackground256(const AIndex: int32): string; begin if (AIndex < 0) or (AIndex > 255) then return ""; end; return FormatStr("\x1b[48;5;{}m", AIndex); end; public func cpplink CsiForeground(const AColor: TextColor): string; begin return SgrStandard(AColor, 30, 90); end; public func cpplink CsiBackground(const AColor: TextColor): string; begin return SgrStandard(AColor, 40, 100); end; public func cpplink CsiForeground(const AColor: RGB): string; begin return SgrRGB(AColor, 38); end; public func cpplink CsiBackground(const AColor: RGB): string; begin return SgrRGB(AColor, 48); end; public func cpplink CsiTitle(const ATitle: string): string; begin return FormatStr("\x1b]0;{}\x07", DoTitleText(ATitle)); end; public func cpplink SetEscapeMode(const AMode: EscapeMode); begin atomicstore(GEscapeMode, int32(AMode)); end; public func cpplink GetEscapeMode(): EscapeMode; begin return EscapeMode(atomicload(GEscapeMode)); end; public func cpplink IsTerminal(): bool; begin return (DoTerminal() <> ADAM_CONSOLE_NONE); end; public func cpplink EscapesEnabled(): bool; var LMode: EscapeMode; begin LMode := GetEscapeMode(); if LMode = EscapeMode.On then return true; end; if LMode = EscapeMode.Off then return false; end; return DoTerminal() = ADAM_CONSOLE_ESCAPES; end; public func cpplink WriteText(const AText: string); begin DoWrite(AText); end; public func cpplink WriteEscape(const ASequence: string); begin if EscapesEnabled() then DoWrite(ASequence); end; end; public func cpplink SetCursorPosition(const AX: int32; const AY: int32); begin WriteEscape(CsiCursorPosition(AX, AY)); end; public func cpplink SetCursorColumn(const AX: int32); begin WriteEscape(CsiCursorColumn(AX)); end; public func cpplink MoveCursorUp(); begin WriteEscape(CsiCursorUp(1)); end; public func cpplink MoveCursorUp(const ALines: int32); begin WriteEscape(CsiCursorUp(ALines)); end; public func cpplink MoveCursorDown(); begin WriteEscape(CsiCursorDown(1)); end; public func cpplink MoveCursorDown(const ALines: int32); begin WriteEscape(CsiCursorDown(ALines)); end; public func cpplink MoveCursorForward(); begin WriteEscape(CsiCursorForward(1)); end; public func cpplink MoveCursorForward(const AColumns: int32); begin WriteEscape(CsiCursorForward(AColumns)); end; public func cpplink MoveCursorBack(); begin WriteEscape(CsiCursorBack(1)); end; public func cpplink MoveCursorBack(const AColumns: int32); begin WriteEscape(CsiCursorBack(AColumns)); end; public func cpplink SaveCursorPosition(); begin WriteEscape(CsiSaveCursorPosition); end; public func cpplink RestoreCursorPosition(); begin WriteEscape(CsiRestoreCursorPosition); end; public func cpplink HideCursor(); begin WriteEscape(CsiHideCursor); end; public func cpplink ShowCursor(); begin WriteEscape(CsiShowCursor); end; public func cpplink ClearScreen(); begin WriteEscape(CsiClearScreen); WriteEscape(CsiClearScrollback); WriteEscape(CsiCursorPosition(0, 0)); end; public func cpplink ClearLine(); begin WriteEscape(CsiClearLine); end; public func cpplink ClearLine(const AToLineStart: bool); begin WriteEscape(CsiClearLine); if AToLineStart then WriteEscape(CsiCr); end; end; public func cpplink ClearToEndOfLine(); begin WriteEscape(CsiClearToEndOfLine); end; public func cpplink InsertLines(); begin WriteEscape(CsiInsertLines(1)); end; public func cpplink InsertLines(const ALines: int32); begin WriteEscape(CsiInsertLines(ALines)); end; public func cpplink DeleteLines(); begin WriteEscape(CsiDeleteLines(1)); end; public func cpplink DeleteLines(const ALines: int32); begin WriteEscape(CsiDeleteLines(ALines)); end; public func cpplink ScrollUp(); begin WriteEscape(CsiScrollUp(1)); end; public func cpplink ScrollUp(const ALines: int32); begin WriteEscape(CsiScrollUp(ALines)); end; public func cpplink ScrollDown(); begin WriteEscape(CsiScrollDown(1)); end; public func cpplink ScrollDown(const ALines: int32); begin WriteEscape(CsiScrollDown(ALines)); end; public func cpplink InsertChars(); begin WriteEscape(CsiInsertChars(1)); end; public func cpplink InsertChars(const ACount: int32); begin WriteEscape(CsiInsertChars(ACount)); end; public func cpplink DeleteChars(); begin WriteEscape(CsiDeleteChars(1)); end; public func cpplink DeleteChars(const ACount: int32); begin WriteEscape(CsiDeleteChars(ACount)); end; public func cpplink EraseChars(); begin WriteEscape(CsiEraseChars(1)); end; public func cpplink EraseChars(const ACount: int32); begin WriteEscape(CsiEraseChars(ACount)); end; public func cpplink SetBold(); begin WriteEscape(CsiBold); end; public func cpplink ResetFormat(); begin WriteEscape(CsiResetFormat); end; public func cpplink SetForegroundColor(const AColor: TextColor); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetForegroundColor(const AColor: RGB); begin WriteEscape(CsiForeground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: TextColor); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink SetBackgroundColor(const AColor: RGB); begin WriteEscape(CsiBackground(AColor)); end; public func cpplink TextColorAt(const AIndex: int32): TextColor; var LIndex: int32; begin LIndex := AIndex; if LIndex < 0 then LIndex := 0; end; if LIndex > 15 then LIndex := 15; end; return TextColor(LIndex); end; public func cpplink GetTerminalWidth(): int32; begin return DoWidth(); end; public func cpplink GetTerminalHeight(): int32; begin return DoHeight(); end; public func cpplink DisplayWidth(const AText: string): int64; begin return DoColumns(AText); end; public func cpplink PadText(const AText: string; const AWidth: int32): string; begin return AText + DoFill(" ", int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string; begin return AText + DoFill(APad, int64(AWidth) - DisplayWidth(AText)); end; public func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string; var LPadTotal: int64; LPadLeft: int64; begin LPadTotal := int64(AWidth) - DisplayWidth(AText); if LPadTotal <= 0 then return AText; end; if AAlign = TextAlign.Right then return DoFill(APad, LPadTotal) + AText; end; if AAlign = TextAlign.Center then LPadLeft := LPadTotal div 2; return DoFill(APad, LPadLeft) + AText + DoFill(APad, LPadTotal - LPadLeft); end; return AText + DoFill(APad, LPadTotal); end; public func cpplink RuleText(const AChar: string; const AWidth: int32): string; begin return DoFill(AChar, int64(AWidth)); end; public func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string; var LWidth: int64; LDone: int64; LFilled: int64; LPercent: int64; begin LWidth := int64(AWidth); if LWidth < 0 then LWidth := 0; end; LFilled := 0; LPercent := 0; if ATotal > 0 then LDone := ACurrent; if LDone < 0 then LDone := 0; end; if LDone > ATotal then LDone := ATotal; end; LFilled := DoScaledFloor(LDone, LWidth, ATotal); LPercent := DoScaledFloor(LDone, 100, ATotal); end; return FormatStr("[{}{}] {:3}%", DoFill("=", LFilled), DoFill(" ", LWidth - LFilled), LPercent); end; public func cpplink SpinnerFrame(const AFrame: int32): string; var LIndex: int32; begin LIndex := ((AFrame mod 4) + 4) mod 4; if LIndex = 0 then return "\|"; end; if LIndex = 1 then return "/"; end; if LIndex = 2 then return "-"; end; return "\\"; end; public func cpplink HorizontalRule(); begin WriteText(RuleText("-", GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string); begin WriteText(RuleText(AChar, GetTerminalWidth())); WriteText(CsiLf); end; public func cpplink HorizontalRule(const AChar: string; const AWidth: int32); var LWidth: int32; begin LWidth := AWidth; if LWidth <= 0 then LWidth := GetTerminalWidth(); end; WriteText(RuleText(AChar, LWidth)); WriteText(CsiLf); end; public func cpplink WritePadded(const AText: string; const AWidth: int32); begin WriteText(PadText(AText, AWidth)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string); begin WriteText(PadText(AText, AWidth, APad)); end; public func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign); begin WriteText(PadText(AText, AWidth, APad, AAlign)); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, 40)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32); begin WriteText(CsiCr); WriteEscape(CsiForeground(TextColor.Green)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB); begin WriteText(CsiCr); WriteEscape(CsiForeground(AColor)); WriteText(ProgressBarText(ACurrent, ATotal, AWidth)); WriteEscape(CsiResetFormat); end; public func cpplink WaitForAnyKey(); begin DoWaitKey(); end; public func cpplink AnyKeyPressed(): bool; begin return ConsolePlatformKeyWaiting(); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string); var LKeyboard: bool; LCloses: bool; begin LKeyboard := ConsolePlatformKeyboard(); if not LKeyboard then return; end; LCloses := ConsolePlatformClosesWithProgram(); if (not AForce) and (not LCloses) then return; end; ConsolePlatformDropKeys(); WriteText(CsiLf); WriteEscape(CsiForeground(AColor)); if len(AMessage) = 0 then WriteText("Press any key to continue... "); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); WaitForAnyKey(); WriteText(CsiLf); end; public func cpplink Pause(); begin Pause(false, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool); begin Pause(AForce, TextColor.White, ""); end; public func cpplink Pause(const AForce: bool; const AColor: TextColor); begin Pause(AForce, AColor, ""); end; public func cpplink SetTitle(const ATitle: string); var LDone: bool; begin LDone := ConsolePlatformSetTitle(ATitle); if not LDone then WriteEscape(CsiTitle(ATitle)); end; end; public func cpplink ReadKey(): string; begin return DoReadKey(); end; public func cpplink ReadLn(var ALine: string): bool; begin return DoReadLine(ALine); end; public func cpplink IsEnterKey(const AKey: string): bool; begin return AKey = KeyEnter; end; public func cpplink IsEscapeKey(const AKey: string): bool; begin return AKey = KeyEscape; end; public func cpplink WaitForKey(const AKey: string); var LKey: string; begin repeat LKey := ReadKey(); until (len(LKey) = 0) or (LKey = AKey); end; public func cpplink WaitForKey(); begin WaitForKey(KeyEnter); end; public func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool; var LLine: string; begin WriteText(CsiLf); if len(AMessage) = 0 then WriteText("Press ENTER to continue..."); else WriteText(AMessage); end; WriteEscape(CsiResetFormat); LLine := DoReadLineText(); WriteText(CsiLf); if len(AQuitWord) = 0 then return false; end; return DoSameASCIIText(LLine, AQuitWord); end; public func cpplink WaitForEnter(): bool; begin return WaitForEnter("", ""); end; public func cpplink WaitForEnter(const AMessage: string): bool; begin return WaitForEnter(AMessage, ""); end; end. | A dark grey background: 256-colour palette entry 238. |
KeyEnter | const KeyEnter: string = "\r" | What ReadKey gives for Enter, on every target. |
KeyEscape | const KeyEscape: string = "\x1b" | What ReadKey gives for Escape, on every target. |
KeyBackspace | const KeyBackspace: string = "\x08" | What ReadKey gives for Backspace, on every target. |
Routines
CsiCursorPosition
func cpplink CsiCursorPosition(const AX: int32; const AY: int32): string
The sequence that puts the cursor at column AX, line AY (0-based, (0, 0) the top left; a position below 0 counts as 0).
Parameters
AX: the columnAY: the line
Returns: the sequence (CSI is 1-based, row first: (4, 2) is ESC[3;5H)
CsiCursorColumn
func cpplink CsiCursorColumn(const AX: int32): string
The sequence that puts the cursor at column AX of its line (0-based; below 0 counts as 0).
Parameters
AX: the column
Returns: the sequence
CsiCursorUp
func cpplink CsiCursorUp(const ALines: int32): string
The sequence that moves the cursor up ALines lines.
Parameters
ALines: how far; <= 0 gives ""
Returns: the sequence
CsiCursorDown
func cpplink CsiCursorDown(const ALines: int32): string
The sequence that moves the cursor down ALines lines.
Parameters
ALines: how far; <= 0 gives ""
Returns: the sequence
CsiCursorForward
func cpplink CsiCursorForward(const AColumns: int32): string
The sequence that moves the cursor right AColumns columns.
Parameters
AColumns: how far; <= 0 gives ""
Returns: the sequence
CsiCursorBack
func cpplink CsiCursorBack(const AColumns: int32): string
The sequence that moves the cursor left AColumns columns.
Parameters
AColumns: how far; <= 0 gives ""
Returns: the sequence
CsiScrollUp
func cpplink CsiScrollUp(const ALines: int32): string
The sequence that scrolls the screen up ALines lines.
Parameters
ALines: how far; <= 0 gives ""
Returns: the sequence
CsiScrollDown
func cpplink CsiScrollDown(const ALines: int32): string
The sequence that scrolls the screen down ALines lines.
Parameters
ALines: how far; <= 0 gives ""
Returns: the sequence
CsiInsertLines
func cpplink CsiInsertLines(const ALines: int32): string
The sequence that inserts ALines blank lines at the cursor.
Parameters
ALines: how many; <= 0 gives ""
Returns: the sequence
CsiDeleteLines
func cpplink CsiDeleteLines(const ALines: int32): string
The sequence that deletes ALines lines at the cursor.
Parameters
ALines: how many; <= 0 gives ""
Returns: the sequence
CsiInsertChars
func cpplink CsiInsertChars(const ACount: int32): string
The sequence that inserts ACount blanks at the cursor.
Parameters
ACount: how many; <= 0 gives ""
Returns: the sequence
CsiDeleteChars
func cpplink CsiDeleteChars(const ACount: int32): string
The sequence that deletes ACount characters at the cursor.
Parameters
ACount: how many; <= 0 gives ""
Returns: the sequence
CsiEraseChars
func cpplink CsiEraseChars(const ACount: int32): string
The sequence that blanks ACount characters at the cursor.
Parameters
ACount: how many; <= 0 gives ""
Returns: the sequence
CsiForeground256
func cpplink CsiForeground256(const AIndex: int32): string
The foreground sequence of a 256-colour palette entry.
Parameters
AIndex: the entry, 0-255; another value gives ""
Returns: the sequence (ESC[38;5;<index>m)
CsiBackground256
func cpplink CsiBackground256(const AIndex: int32): string
The background sequence of a 256-colour palette entry.
Parameters
AIndex: the entry, 0-255; another value gives ""
Returns: the sequence (ESC[48;5;<index>m)
CsiForeground
func cpplink CsiForeground(const AColor: TextColor): string
The foreground sequence of a standard colour.
Parameters
AColor: the colour; a value outside TextColor gives ""
Returns: the sequence (SGR 30-37 / 90-97)
CsiBackground
func cpplink CsiBackground(const AColor: TextColor): string
The background sequence of a standard colour.
Parameters
AColor: the colour; a value outside TextColor gives ""
Returns: the sequence (SGR 40-47 / 100-107)
func cpplink CsiForeground(const AColor: RGB): string
The foreground sequence of a 24-bit colour.
Parameters
AColor: the colour
Returns: the sequence (ESC[38;2;<r>;<g>;<b>m)
func cpplink CsiBackground(const AColor: RGB): string
The background sequence of a 24-bit colour.
Parameters
AColor: the colour
Returns: the sequence (ESC[48;2;<r>;<g>;<b>m)
CsiTitle
func cpplink CsiTitle(const ATitle: string): string
The sequence that sets the window title (OSC 0, ended by BEL); C0 control characters and DEL in the title are left out, UTF-8 text stays.
Parameters
ATitle: the title
Returns: the sequence
SetEscapeMode
func cpplink SetEscapeMode(const AMode: EscapeMode)
Sets when escape sequences are written (Auto by default).
Parameters
AMode: the new mode
GetEscapeMode
func cpplink GetEscapeMode(): EscapeMode
The escape mode now.
Returns: the mode SetEscapeMode set last (Auto at start)
IsTerminal
func cpplink IsTerminal(): bool
Whether standard output is a terminal (a console on Windows), decided once.
Returns: true for a terminal, false for a file or a pipe
EscapesEnabled
func cpplink EscapesEnabled(): bool
Whether the escape mode writes escape sequences now: On yes, Off no, Auto while standard output is a terminal.
Returns: true when WriteEscape writes
WriteText
func cpplink WriteText(const AText: string)
Writes text to standard output, always (the bytes as given). A terminal gets them at once.
Parameters
AText: the text
WriteEscape
func cpplink WriteEscape(const ASequence: string)
Writes an escape sequence to standard output while EscapesEnabled, else nothing.
Parameters
ASequence: the sequence
SetCursorPosition
func cpplink SetCursorPosition(const AX: int32; const AY: int32)
Puts the cursor at column AX, line AY (0-based; below 0 counts as 0).
Parameters
AX: the columnAY: the line
SetCursorColumn
func cpplink SetCursorColumn(const AX: int32)
Puts the cursor at column AX of its line (0-based).
Parameters
AX: the column
MoveCursorUp
func cpplink MoveCursorUp()
Moves the cursor up one line.
func cpplink MoveCursorUp(const ALines: int32)
Moves the cursor up ALines lines (<= 0: not at all).
Parameters
ALines: how far
MoveCursorDown
func cpplink MoveCursorDown()
Moves the cursor down one line.
func cpplink MoveCursorDown(const ALines: int32)
Moves the cursor down ALines lines (<= 0: not at all).
Parameters
ALines: how far
MoveCursorForward
func cpplink MoveCursorForward()
Moves the cursor right one column.
func cpplink MoveCursorForward(const AColumns: int32)
Moves the cursor right AColumns columns (<= 0: not at all).
Parameters
AColumns: how far
MoveCursorBack
func cpplink MoveCursorBack()
Moves the cursor left one column.
func cpplink MoveCursorBack(const AColumns: int32)
Moves the cursor left AColumns columns (<= 0: not at all).
Parameters
AColumns: how far
SaveCursorPosition
func cpplink SaveCursorPosition()
Saves the cursor's position.
RestoreCursorPosition
func cpplink RestoreCursorPosition()
Puts the cursor back where SaveCursorPosition saved it.
HideCursor
func cpplink HideCursor()
Hides the cursor.
ShowCursor
func cpplink ShowCursor()
Shows the cursor.
ClearScreen
func cpplink ClearScreen()
Clears the screen and its scrollback and puts the cursor at the top left.
ClearLine
func cpplink ClearLine()
Clears the cursor's line; the cursor stays where it is.
func cpplink ClearLine(const AToLineStart: bool)
Clears the cursor's line; AToLineStart also puts the cursor at its start (a carriage return, a cursor move: a file or a pipe does not get it).
Parameters
AToLineStart: true to move the cursor to the line's start
ClearToEndOfLine
func cpplink ClearToEndOfLine()
Clears from the cursor to the end of its line.
InsertLines
func cpplink InsertLines()
Inserts one blank line at the cursor.
func cpplink InsertLines(const ALines: int32)
Inserts ALines blank lines at the cursor (<= 0: none).
Parameters
ALines: how many
DeleteLines
func cpplink DeleteLines()
Deletes the cursor's line.
func cpplink DeleteLines(const ALines: int32)
Deletes ALines lines at the cursor (<= 0: none).
Parameters
ALines: how many
ScrollUp
func cpplink ScrollUp()
Scrolls the screen up one line.
func cpplink ScrollUp(const ALines: int32)
Scrolls the screen up ALines lines (<= 0: not at all).
Parameters
ALines: how far
ScrollDown
func cpplink ScrollDown()
Scrolls the screen down one line.
func cpplink ScrollDown(const ALines: int32)
Scrolls the screen down ALines lines (<= 0: not at all).
Parameters
ALines: how far
InsertChars
func cpplink InsertChars()
Inserts one blank at the cursor.
func cpplink InsertChars(const ACount: int32)
Inserts ACount blanks at the cursor (<= 0: none).
Parameters
ACount: how many
DeleteChars
func cpplink DeleteChars()
Deletes the character at the cursor.
func cpplink DeleteChars(const ACount: int32)
Deletes ACount characters at the cursor (<= 0: none).
Parameters
ACount: how many
EraseChars
func cpplink EraseChars()
Blanks the character at the cursor.
func cpplink EraseChars(const ACount: int32)
Blanks ACount characters at the cursor (<= 0: none).
Parameters
ACount: how many
SetBold
func cpplink SetBold()
Bold text from here (until ResetFormat or the next Write's reset).
ResetFormat
func cpplink ResetFormat()
Resets bold, the colours and every other attribute.
SetForegroundColor
func cpplink SetForegroundColor(const AColor: TextColor)
The text colour from here, a standard colour.
Parameters
AColor: the colour
func cpplink SetForegroundColor(const AColor: RGB)
The text colour from here, a 24-bit colour.
Parameters
AColor: the colour
SetBackgroundColor
func cpplink SetBackgroundColor(const AColor: TextColor)
The background colour from here, a standard colour.
Parameters
AColor: the colour
func cpplink SetBackgroundColor(const AColor: RGB)
The background colour from here, a 24-bit colour.
Parameters
AColor: the colour
TextColorAt
func cpplink TextColorAt(const AIndex: int32): TextColor
The standard colour with the number AIndex, held to 0-15 (below 0 is Black, past 15 BrightWhite): a loop's counter picks colours in turn.
Parameters
AIndex: the colour's number (TextColor's order)
Returns: the colour
Example: SetForegroundColor(TextColorAt(LIndex mod 16));
GetTerminalWidth
func cpplink GetTerminalWidth(): int32
The terminal's visible width in columns; 80 when standard output is not a terminal.
Returns: the width
GetTerminalHeight
func cpplink GetTerminalHeight(): int32
The terminal's visible height in lines; 25 when standard output is not a terminal.
Returns: the height
DisplayWidth
func cpplink DisplayWidth(const AText: string): int64
The columns a text takes in a terminal: UTF-8 code points count 1, East Asian wide / fullwidth characters and emoji 2, combining marks, zero-width characters and control characters 0; a byte that is not UTF-8 counts 1.
Parameters
AText: UTF-8 text
Returns: the columns
Example: DisplayWidth("日本語") is 6
PadText
func cpplink PadText(const AText: string; const AWidth: int32): string
The text padded with spaces after it to AWidth columns; a text at least that wide is returned as it is.
Parameters
AText: the textAWidth: the columns to fill
Returns: the padded text
func cpplink PadText(const AText: string; const AWidth: int32; const APad: string): string
The text padded with APad after it to AWidth columns; see PadText(AText, AWidth, APad, AAlign).
Parameters
AText: the textAWidth: the columns to fillAPad: the pad character
Returns: the padded text
func cpplink PadText(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign): string
The text padded with APad to AWidth columns, placed by AAlign (Center: the odd column on the right). APad is one character; a wide one fills two columns, a column left over is a space; an empty pad is a space. A text at least AWidth wide is returned as it is.
Parameters
AText: the textAWidth: the columns to fillAPad: the pad characterAAlign: where the text sits
Returns: the padded text
Example: PadText("ab", 7, ".", TextAlign.Center) is "..ab..."
RuleText
func cpplink RuleText(const AChar: string; const AWidth: int32): string
AWidth columns of AChar, filled as PadText fills.
Parameters
AChar: the characterAWidth: the columns; <= 0 gives ""
Returns: the rule
ProgressBarText
func cpplink ProgressBarText(const ACurrent: int64; const ATotal: int64; const AWidth: int32): string
A progress bar, "[==== ] 50%": ACurrent of ATotal, held to 0..ATotal, floored (full and 100% only at the end); ATotal <= 0 counts as nothing done.
Parameters
ACurrent: the work doneATotal: all the workAWidth: the bar's columns between the brackets (below 0 counts as 0)
Returns: the bar text
SpinnerFrame
func cpplink SpinnerFrame(const AFrame: int32): string
The spinner's character for a frame: | / - \ in turn, any frame (negative ones too).
Parameters
AFrame: the frame number
Returns: the character
HorizontalRule
func cpplink HorizontalRule()
A line of "-" as wide as the terminal, then a line break.
func cpplink HorizontalRule(const AChar: string)
A line of AChar as wide as the terminal, then a line break.
Parameters
AChar: the character
func cpplink HorizontalRule(const AChar: string; const AWidth: int32)
A line of AChar AWidth columns wide (<= 0: the terminal's width), then a line break.
Parameters
AChar: the characterAWidth: the columns
WritePadded
func cpplink WritePadded(const AText: string; const AWidth: int32)
Writes PadText(AText, AWidth).
Parameters
AText: the textAWidth: the columns to fill
func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string)
Writes PadText(AText, AWidth, APad).
Parameters
AText: the textAWidth: the columns to fillAPad: the pad character
func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign)
Writes PadText(AText, AWidth, APad, AAlign).
Parameters
AText: the textAWidth: the columns to fillAPad: the pad characterAAlign: where the text sits
ProgressBar
func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64)
A carriage return, then ProgressBarText 40 columns wide in green: called again, it redraws the line.
Parameters
ACurrent: the work doneATotal: all the work
func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32)
A carriage return, then ProgressBarText AWidth columns wide in green.
Parameters
ACurrent: the work doneATotal: all the workAWidth: the bar's columns
func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: TextColor)
A carriage return, then ProgressBarText in a standard colour.
Parameters
ACurrent: the work doneATotal: all the workAWidth: the bar's columnsAColor: the bar's colour
func cpplink ProgressBar(const ACurrent: int64; const ATotal: int64; const AWidth: int32; const AColor: RGB)
A carriage return, then ProgressBarText in a 24-bit colour.
Parameters
ACurrent: the work doneATotal: all the workAWidth: the bar's columnsAColor: the bar's colour
WaitForAnyKey
func cpplink WaitForAnyKey()
Waits for a key press on the console's keyboard (a modifier key alone does not count); returns at once when standard input is not a console / terminal.
AnyKeyPressed
func cpplink AnyKeyPressed(): bool
Whether a key press waits to be read (it is left there); other input events in front of it are taken off the queue.
Returns: true when a key waits
Pause
func cpplink Pause(const AForce: bool; const AColor: TextColor; const AMessage: string)
Writes the message in the colour on a new line and waits for a key. Without AForce it pauses only when the program's console closes with it: on Windows a console no other process shares (the program was started from Explorer), never on Linux (a terminal outlives the program). Keys typed before are dropped first; no keyboard = no pause.
Parameters
AForce: true to pause alwaysAColor: the message's colourAMessage: the message; "" gives "Press any key to continue... "
func cpplink Pause()
Pause(false, TextColor.White, "Press any key to continue... ").
func cpplink Pause(const AForce: bool)
Pause(AForce, TextColor.White, "Press any key to continue... ").
Parameters
AForce: true to pause always
func cpplink Pause(const AForce: bool; const AColor: TextColor)
Pause(AForce, AColor, "Press any key to continue... ").
Parameters
AForce: true to pause alwaysAColor: the message's colour
SetTitle
func cpplink SetTitle(const ATitle: string)
Sets the console window's title: on Windows through the console API, on Linux as CsiTitle (written while EscapesEnabled).
Parameters
ATitle: the title (UTF-8)
ReadKey
func cpplink ReadKey(): string
Waits for a key that types a character and returns it as UTF-8 text, the same on both targets: Enter KeyEnter, Backspace KeyBackspace, Escape KeyEscape; keys that type nothing (an arrow, a modifier alone) are skipped.
Returns: the key's text; "" when standard input is not a console / terminal
ReadLn
func cpplink ReadLn(var ALine: string): bool
Reads one line from standard input into ALine, without its line break, as UTF-8 text on both targets (a Windows console reads as UTF-16 and is converted). Standard output is flushed first, so a prompt written with WriteText shows before the read waits.
Parameters
ALine: receives the line; "" for an empty line and at the end of input
Returns: true when a line was read; false at the end of input (nothing left to read, a closed pipe, or Ctrl+Z then Enter in a Windows console)
Example: while ReadLn(LLine) do println("you typed {}", LLine); end;
IsEnterKey
func cpplink IsEnterKey(const AKey: string): bool
Whether a ReadKey result is Enter.
Parameters
AKey: a ReadKey result
Returns: true for Enter
Example: if IsEnterKey(ReadKey()) then ... end;
IsEscapeKey
func cpplink IsEscapeKey(const AKey: string): bool
Whether a ReadKey result is Escape.
Parameters
AKey: a ReadKey result
Returns: true for Escape
WaitForKey
func cpplink WaitForKey(const AKey: string)
Waits until ReadKey gives AKey; returns at once with no keyboard (ReadKey gives "").
Parameters
AKey: the key's text (KeyEnter, KeyEscape, "q" ...)
func cpplink WaitForKey()
Waits until ReadKey gives Enter; returns at once with no keyboard.
WaitForEnter
func cpplink WaitForEnter(const AMessage: string; const AQuitWord: string): bool
Writes the message on a new line, reads a line from standard input and tells whether it equals AQuitWord, ASCII letters compared without case.
Parameters
AMessage: the message; "" gives "Press ENTER to continue..."AQuitWord: the word that answers true; "" never does
Returns: true when the line is AQuitWord
Example: if WaitForEnter("Again? (q quits) ", "q") then ... end;
func cpplink WaitForEnter(): bool
WaitForEnter("Press ENTER to continue...", "").
Returns: false
func cpplink WaitForEnter(const AMessage: string): bool
WaitForEnter(AMessage, "").
Parameters
AMessage: the message; "" gives "Press ENTER to continue..."
Returns: false
System.Console.Linux64
System.Console's platform unit for x86_64-linux-gnu: the same ConsolePlatform* routines as System.Console.Win64, over glibc's terminal calls (isatty, termios, ioctl TIOCGWINSZ, poll, read; System.Linux's declarations).
Import it with import System.Console.Linux64;.
Routines
ConsolePlatformIsTerminal
func cpplink ConsolePlatformIsTerminal(): bool
True when standard output is a terminal (a pipe, a file or /dev/null is not)
Returns: true for a terminal standard output
ConsolePlatformEnableEscapes
func cpplink ConsolePlatformEnableEscapes(): bool
A terminal standard output takes UTF-8 text and VT sequences as it is: true when standard output is a terminal
Returns: true when escape sequences now reach the terminal
ConsolePlatformWidth
func cpplink ConsolePlatformWidth(): int32
The terminal's visible columns; 0 when standard output is no terminal (or tells no size)
Returns: the columns, or 0
ConsolePlatformHeight
func cpplink ConsolePlatformHeight(): int32
The terminal's visible lines; 0 when standard output is no terminal (or tells no size)
Returns: the lines, or 0
ConsolePlatformKeyboard
func cpplink ConsolePlatformKeyboard(): bool
True when standard input is a terminal (a keyboard to read)
Returns: true for a terminal standard input
ConsolePlatformDropKeys
func cpplink ConsolePlatformDropKeys()
The keys typed so far dropped (those already read and the terminal's queue)
ConsolePlatformClosesWithProgram
func cpplink ConsolePlatformClosesWithProgram(): bool
A terminal outlives the program that runs in it: never true on linux
Returns: false, always
ConsolePlatformWaitKey
func cpplink ConsolePlatformWaitKey()
Waits for a key press on a terminal standard input (an escape sequence is one key, read whole); returns at once when standard input is no terminal
ConsolePlatformKeyWaiting
func cpplink ConsolePlatformKeyWaiting(): bool
True while a key waits to be read (a byte typed, the terminal in raw mode to see it before Enter); false when standard input is no terminal
Returns: true while a key press waits
ConsolePlatformReadKey
func cpplink ConsolePlatformReadKey(): string
The next typed character as UTF-8 text; a key that types nothing (an arrow, F1) is passed over. "" when standard input is no terminal or it ends
Returns: the character typed, or ""
ConsolePlatformReadLine
func cpplink ConsolePlatformReadLine(var ALine: string): bool
One line from standard input into ALine, its line break (LF, or CR LF) left out, read as its bytes (a terminal edits the line itself). False at the end of input (Ctrl+D on an empty line), ALine then ""; a last line with no line break is still a line
Parameters
ALine: receives the line; "" at the end of input
Returns: false at the end of input
ConsolePlatformSetTitle
func cpplink ConsolePlatformSetTitle(const ATitle: string): bool
A terminal's title is set by its escape sequence (System.Console writes CsiTitle): false, no OS call does it
Parameters
ATitle: the title (not used: the escape sequence sets it)
Returns: false, always
System.Console.Win64
System.Console's platform unit for x86_64-windows-gnu: the console calls over the Win32 API (kernel32).
Import it with import System.Console.Win64;.
Routines
ConsolePlatformIsTerminal
func cpplink ConsolePlatformIsTerminal(): bool
True when standard output is a console (a pipe, a file or NUL is not)
Returns: true for a terminal standard output
ConsolePlatformEnableEscapes
func cpplink ConsolePlatformEnableEscapes(): bool
A console standard output made to take UTF-8 text and VT sequences: true when it does; false when standard output is no console or the console takes no VT sequences
Returns: true when escape sequences now reach the terminal
ConsolePlatformWidth
func cpplink ConsolePlatformWidth(): int32
The console window's visible columns; 0 when standard output is no console
Returns: the columns, or 0
ConsolePlatformHeight
func cpplink ConsolePlatformHeight(): int32
The console window's visible lines; 0 when standard output is no console
Returns: the lines, or 0
ConsolePlatformKeyboard
func cpplink ConsolePlatformKeyboard(): bool
True when standard input is a console (a keyboard to read)
Returns: true for a terminal standard input
ConsolePlatformDropKeys
func cpplink ConsolePlatformDropKeys()
The keys typed so far dropped
ConsolePlatformClosesWithProgram
func cpplink ConsolePlatformClosesWithProgram(): bool
True when the console belongs to this program alone and closes when it ends (no other process shares it: a program started from Explorer)
Returns: true when the console closes as this program ends
ConsolePlatformWaitKey
func cpplink ConsolePlatformWaitKey()
Waits for a key press on a console standard input (a modifier alone, a release, the mouse or a resize do not count); returns at once when standard input is no console
ConsolePlatformKeyWaiting
func cpplink ConsolePlatformKeyWaiting(): bool
True while a key press waits to be read; the events before it that are no key press leave the queue, the key press itself stays. False when standard input is no console
Returns: true while a key press waits
ConsolePlatformReadKey
func cpplink ConsolePlatformReadKey(): string
The next typed character as UTF-8 text (a character outside the BMP from its surrogate pair); a key that types nothing (an arrow, a modifier) is passed over. "" when standard input is no console or a read fails
Returns: the character typed, or ""
ConsolePlatformReadLine
func cpplink ConsolePlatformReadLine(var ALine: string): bool
One line from standard input into ALine, its line break (LF, or CR LF) left out. A console is read as UTF-16, anything else as its bytes. False at the end of input, ALine then ""; a last line with no line break is still a line
Parameters
ALine: receives the line; "" at the end of input
Returns: false at the end of input
ConsolePlatformSetTitle
func cpplink ConsolePlatformSetTitle(const ATitle: string): bool
The console window's title set through the OS: true (Windows' console API holds the title, no escape sequence is needed); false when the title does not fit Win32's limit
Parameters
ATitle: the title
Returns: true when the title was set
System.CustomIO
streams that work like SDL3's custom IO streams, written in Adam. An IO is a stream behind a table of callbacks (an IOInterface: Read, Write, Seek, Tell, Size, Flush, Close, Truncate), so a routine that takes an IO reads memory, a file or anything a program writes itself: CreateIO(AInterface, AUserData) makes an IO from any interface. The IO routines (IORead, IOWrite, IOSeek, IOTell, IOSize, IOFlush, IOTruncate, IOClose, IOStatus) call through the table and keep the stream's state: a callback left nil is a clean failure, never a crash; IOCanWrite / IOCanSeek say up front whether the stream can write / move. IOReadFull / IOWriteFull move a count through any short reads or writes a stream gives; IOReadAll reads a stream to its end into a string; IOSameContent compares two streams to their ends; IOCopy copies one stream to its end into another.
Import it with import System.CustomIO;.
Types
IOState
type IOState = choices(
The state of an IO after its last operation, read with IOStatus. A short count from IORead / IOWrite says why here: EOF (no more to read), Error, ReadOnly (the IO cannot write), WriteOnly (it cannot read), NotReady (a non-blocking source has nothing yet)
Members
IOState.Ready: The last operation succeeded.IOState.Error: The last operation failed.IOState.EOF: No more to read.IOState.NotReady: A non-blocking source has nothing yet.IOState.ReadOnly: The IO cannot write.IOState.WriteOnly: The IO cannot read.
SeekOrigin
type SeekOrigin = choices(
Where IOSeek counts its offset from
Members
SeekOrigin.FromStart: From the start (C's SEEK_SET).SeekOrigin.FromCurrent: From the current position (C's SEEK_CUR).SeekOrigin.FromEnd: From the end (C's SEEK_END).
FileMode
type FileMode = choices(
How CreateFileIO opens its file, by C's fopen rules: Read ("rb") the file must exist, read-only; Write ("wb") created or emptied, write-only; ReadWrite ("r+b") the file must exist, kept, read and write; Append ("ab") created when missing, write-only, every write lands at the end whatever the position
Members
FileMode.Read: "rb": the file must exist; read-only.FileMode.Write: "wb": created or emptied; write-only.FileMode.ReadWrite: "r+b": the file must exist, kept; read and write.FileMode.Append: "ab": created when missing; write-only, every write at the end.
IOReadCallback
type IOReadCallback = func(const AUserData: ptr; const ABuffer: ptr; const ASize: int64;
An IO's Read: moves up to ASize bytes into ABuffer and returns the count moved; a short count sets AState (EOF, Error, NotReady), which comes in as Ready.
IOWriteCallback
type IOWriteCallback = func(const AUserData: ptr; const ABuffer: ptr to const; const ASize: int64;
An IO's Write: moves up to ASize bytes from ABuffer and returns the count moved; a short count sets AState (Error, NotReady), which comes in as Ready.
IOSeekCallback
type IOSeekCallback = func(const AUserData: ptr; const AOffset: int64;
An IO's Seek: returns the new position, or -1.
IOTellCallback
type IOTellCallback = func(const AUserData: ptr): int64
An IO's Tell: returns the position, or -1.
IOSizeCallback
type IOSizeCallback = func(const AUserData: ptr): int64
An IO's Size: returns the size in bytes, or -1 when the stream has none.
IOFlushCallback
type IOFlushCallback = func(const AUserData: ptr; var AState: IOState): bool
An IO's Flush: writes out anything buffered; false on failure, AState says why.
IOCloseCallback
type IOCloseCallback = func(const AUserData: ptr): bool
An IO's Close: releases the stream's own resources; false when that failed.
IOTruncateCallback
type IOTruncateCallback = func(const AUserData: ptr; const ASize: int64;
An IO's Truncate: sets the size to ASize bytes (>= 0), shorter dropping the tail, longer adding zero bytes; false on failure, AState says why.
IOInterface
type IOInterface = record
The table of callbacks behind an IO (it works like SDL3's SDL_IOStreamInterface). Fill the routines the stream supports and leave the rest nil: the IO routines turn a nil callback into a failure with the state set. Truncate is optional: a stream that cannot change its size leaves it nil
Members
Read: func(const ptr; const ptr; const int64; var IOState): int64: Moves bytes out of the stream (nil: it cannot read).Write: func(const ptr; const ptr to const; const int64; var IOState): int64: Moves bytes into the stream (nil: it cannot write).Seek: func(const ptr; const int64; const SeekOrigin): int64: Moves the position (nil: it cannot seek).Tell: func(const ptr): int64: Gives the position.Size: func(const ptr): int64: Gives the size.Flush: func(const ptr; var IOState): bool: Writes out what is buffered.Close: func(const ptr): bool: Releases the stream's own resources.Truncate: func(const ptr; const int64; var IOState): bool: Sets the size (optional: nil when the stream cannot).
IOStream
type IOStream = record
What an IO points at: the callbacks CreateIO was given, the user pointer every callback receives, the state after the last operation. Reach it only through the IO routines
Members
Callbacks: IOInterface: The callbacks CreateIO was given.UserData: ptr: The pointer every callback receives.State: IOState: The state after the last operation.
IO
type IO = ptr to IOStream
A stream: made by CreateIO or a CreateIO routine, used through the IO routines, ended with IOClose. nil is no stream (a Create that failed)
IOSourceOpenCallback
type IOSourceOpenCallback = func(const AUserData: ptr; const APath: string;
A source's Open: the entry's IO in AMode, or nil (missing, or a mode the source does not offer).
IOSourceExistsCallback
type IOSourceExistsCallback = func(const AUserData: ptr; const APath: string): bool
A source's Exists: true when the entry exists and can be opened (a folder is not one).
IOSourceSizeCallback
type IOSourceSizeCallback = func(const AUserData: ptr; const APath: string): int64
A source's Size: the entry's size in bytes, or -1 when it does not exist.
IOSourceCloseCallback
type IOSourceCloseCallback = func(const AUserData: ptr): bool
A source's Close: releases the source's own resources; false when that failed (IOs opened stay valid until their own IOClose).
IOSourceRemoveCallback
type IOSourceRemoveCallback = func(const AUserData: ptr; const APath: string): bool
A source's Remove: deletes the entry; false when it does not exist or the source refuses.
IOSourceFolderCallback
type IOSourceFolderCallback = func(const AUserData: ptr; const APath: string): bool
A source's Folder: true when the path is a folder of the source (an entry's path goes through it).
IOSourceInterface
type IOSourceInterface = record
The table of callbacks behind an IOSource (it works like the read side of SDL3's SDL_StorageInterface): a source opens IOs by path, so a format with several files (a glTF and its .bin, an .obj and its .mtl) opens its siblings through the source it came from. The IOSource routines check and normalize a path before any callback sees it. Leave a callback nil when the source has no such operation; Remove is optional (nil: the source deletes nothing, as a read-only one), Folder too (nil: the source has no folders, only entries)
Members
Open: func(const ptr; const string; const FileMode): ptr to IOStream: Opens an entry as an IO.Exists: func(const ptr; const string): bool: Whether an entry exists.Size: func(const ptr; const string): int64: An entry's size.Close: func(const ptr): bool: Releases the source's own resources.Remove: func(const ptr; const string): bool: Deletes an entry (optional: nil when it deletes nothing).Folder: func(const ptr; const string): bool: Whether a path is a folder (optional: nil when it has none).
IOSourceRecord
type IOSourceRecord = record
What an IOSource points at: the callbacks CreateIOSource was given and the user pointer every callback receives. Reach it only through the IOSource routines
Members
Callbacks: IOSourceInterface: The callbacks CreateIOSource was given.UserData: ptr: The pointer every callback receives.
IOSource
type IOSource = ptr to IOSourceRecord
A source of IOs by path: made by CreateIOSource or a CreateIOSource routine, used through the IOSource routines, ended with IOSourceClose. nil is no source (a Create that failed)
ZipEntryInfo
type ZipEntryInfo = record
What a zip's central directory records about one entry, read by GetZipEntryInfo without opening or decoding the entry: Size, its uncompressed size in bytes; CRC, the CRC-32 of its uncompressed bytes as the directory records it (the CRC an entry IO checks its bytes against)
Members
Size: int64: The uncompressed size in bytes.CRC: uint32: The CRC-32 of the uncompressed bytes, as the directory records it.
ZipProgress
type ZipProgress = ref func(const AEntry: string; const APercent: int32; const ANewFile: bool)
Called by ZipDirectoryContents / ZipWriter.AddFile for each entry written: once with APercent 0 and ANewFile true before the entry's first byte, then with the percent of its bytes written and ANewFile false (100 last; an empty file gets 0 then 100). AEntry is the entry's name in the archive (UTF-8, / separated), APercent 0 to 100, ANewFile true on the entry's first call. A closure: a func literal carries the caller's own state (a plain func named as a value fits too)
ZipEntryMethod
type ZipEntryMethod = choices(
How a ZipWriter stores an entry's bytes: Deflate (deflated at the best level) or Store (as they are: for files that are compressed already, such as .png or .ogg).
Members
ZipEntryMethod.Deflate: Deflated at the best level.ZipEntryMethod.Store: As they are (files compressed already).
ZipWriter
type ZipWriter = object
A zip archive written entry by entry (the one zip writer of the std: ZipDirectoryContents and System.Pack write through it). Open makes a new archive (an existing one is replaced), each AddFile adds a file as a named entry, Close writes the central directory. Every entry gets its file's modification time; a name that is not ASCII is stored as UTF-8 (general purpose bit 11), a file of 4 GB or more as ZIP64. Paths are UTF-8 as CreateFileIO takes them ($P:, $D:, $S:). An archive still open when the writer goes is closed then (its result lost: call Close to know it).
Members
init(): A writer with no archive open.method Open(const APath: string): bool: Begins a new archive atAPath, replacing a file there; its folder must exist. Parameters:APaththe archive's path. Returns: false (the reason inErrorText) when an archive is open already, the file cannot be created or there is no roommethod AddFile(const APath: string; const AName: string; const AMethod: ZipEntryMethod; const AUnixMode: uint32; const APassword: string; const AProgress: ZipProgress): bool: Adds the fileAPathas the entryAName: its CRC read in a first pass, then its bytes. Parameters:APaththe file;ANamethe entry's name in the archive (UTF-8,/between folders);AMethodDeflateorStore;AUnixMode0: an entry made by MS-DOS with no attributes; else the Unix permission bits of a regular file (0x1ED= octal 755; at most0xFFF= octal 7777), the entry made by Unix, so unzip on Linux gives the file that mode;APasswordZipCrypto's password ("" for none);AProgresscalled for the entry's progress (ZipProgress, a closure), nil for none. Returns: false (the reason inErrorText) when no archive is open, the file cannot be read, changed between the passes, or the entry cannot be written (the archive stays open, incomplete:Closeit)method AddFile(const APath: string; const AName: string): bool: Adds the fileAPathas the entryAName, deflated, no mode, no password, no progress. Parameters:APaththe file;ANamethe entry's name in the archive. Returns: false (the reason inErrorText) as the fullAddFilemethod Close(): bool: Finishes the open archive: its central directory written, the file closed. Returns: false (the reason inErrorText) when no archive is open, or the directory or the file cannot be finished (the archive is then incomplete); the writer is closed either waydone: Closes an archive still open (its result lost: callCloseto know it).const method IsOpen(): bool: True while an archive is open (between a goodOpenandClose). Returns: true while openconst method ErrorText(): string: Why the lastOpen,AddFileorClosefailed: the step and the path; "" after a success. Returns: the reason, or ""const method EntryCRC(): uint32: The CRC-32 of the file the last goodAddFilewrote (0 before any). Returns: the CRC-32const method EntrySize(): int64: The size in bytes of the file the last goodAddFilewrote (0 before any). Returns: the size in bytes
Example: LZip.Open("out.zip"); LZip.AddFile("bin/adam", "bin/adam", ZipEntryMethod.Deflate, 0x1ED, "", nil); LZip.Close();
Routines
CreateIO
func cpplink CreateIO(const AInterface: IOInterface; const AUserData: ptr): IO
Makes an IO from a table of callbacks and the user pointer they receive (as SDL3's SDL_OpenIO does). The interface is copied; the user pointer is the caller's and is never freed by the IO (its Close callback may free it). The new IO's state is Ready; nil when there is no room
Parameters
AInterface: the callbacksAUserData: the pointer every callback receives
Returns: the IO, or nil when there is no room
IORead
func cpplink IORead(const AIO: IO; const ABuffer: ptr; const ASize: int64): int64
Reads up to ASize bytes into ABuffer: the count read, 0 to ASize (0 for a nil IO or ASize 0 or less). A short count means the end, an error or no data yet: IOStatus tells which (EOF, Error, NotReady, or WriteOnly when the IO cannot read)
Parameters
AIO: the IOABuffer: where the bytes goASize: the most bytes to read
Returns: the count read
IOWrite
func cpplink IOWrite(const AIO: IO; const ABuffer: ptr to const; const ASize: int64): int64
Writes up to ASize bytes from ABuffer: the count written, 0 to ASize (0 for a nil IO or ASize 0 or less). A short count means an error or no room yet: IOStatus tells which (Error, NotReady, or ReadOnly when the IO cannot write)
Parameters
AIO: the IOABuffer: the bytesASize: how many to write
Returns: the count written
IOSeek
func cpplink IOSeek(const AIO: IO; const AOffset: int64; const AOrigin: SeekOrigin): int64
Moves the stream's position to AOffset counted from AOrigin: the new position, or -1 (state Error) when it cannot move there. A move that succeeds sets the state Ready (an EOF is over)
Parameters
AIO: the IOAOffset: the offsetAOrigin: where it counts from
Returns: the new position, or -1
IOTell
func cpplink IOTell(const AIO: IO): int64
The stream's current position, or -1 when the IO has none (state Error)
Parameters
AIO: the IO
Returns: the position, or -1
IOSize
func cpplink IOSize(const AIO: IO): int64
The stream's size in bytes, or -1 when it has none (a pipe, a nil IO)
Parameters
AIO: the IO
Returns: the size in bytes, or -1
IOFlush
func cpplink IOFlush(const AIO: IO): bool
Writes out anything the stream has buffered: true when flushed (or nothing to flush: an IO with no Flush callback), false on failure
Parameters
AIO: the IO
Returns: false on failure
IOTruncate
func cpplink IOTruncate(const AIO: IO; const ASize: int64): bool
Sets the stream's size to ASize bytes, as ftruncate does: shorter drops the tail, longer adds zero bytes. A stream that cannot write cannot change its size (state ReadOnly); one without a Truncate callback cannot either (state Error). Where the position lands is the stream's rule: a file IO keeps it (it may then lie past the end, as with fseek); a memory IO, which never sits past its end, moves back to the new end. False for a nil IO, a negative size (state Error) or a refused or failed change (IOStatus tells which)
Parameters
AIO: the IOASize: the new size in bytes (>= 0)
Returns: false on failure
IOClose
func cpplink IOClose(const AIO: IO): bool
Ends the stream: calls its Close callback, then frees the IO, which is gone afterwards whatever the result. False for a nil IO or when the Close callback failed
Parameters
AIO: the IO
Returns: false when closing failed
IOStatus
func cpplink IOStatus(const AIO: IO): IOState
The state after the stream's last operation: why a count came up short (Error for a nil IO)
Parameters
AIO: the IO
Returns: the state
IOCanWrite
func cpplink IOCanWrite(const AIO: IO): bool
True when the stream can write (it has a Write callback), so a caller can refuse up front what IOWrite would not do later, as an open for writing refuses a read-only file (a read-only memory IO, a Read file IO, a zip entry cannot); false for a nil IO
Parameters
AIO: the IO
Returns: true when it can write
IOCanSeek
func cpplink IOCanSeek(const AIO: IO): bool
True when the stream can move (it has a Seek callback): one without (a pipe, a socket, a generator's output) reads and writes only at its own place, as a pipe does; false for a nil IO
Parameters
AIO: the IO
Returns: true when it can seek
IOReadFull
func cpplink IOReadFull(const AIO: IO; const ABuffer: ptr; const ASize: int64): int64
Reads ASize bytes into ABuffer, calling IORead until they are all in or a read gives nothing (the end, an error, a non-blocking source with nothing yet): a stream may answer one IORead with fewer bytes than it has. The count read: ASize, or fewer when the stream stopped first (IOStatus says why); 0 for a nil IO or ASize 0 or less
Parameters
AIO: the IOABuffer: where the bytes goASize: how many to read
Returns: the count read
IOWriteFull
func cpplink IOWriteFull(const AIO: IO; const ABuffer: ptr to const; const ASize: int64): int64
Writes ASize bytes from ABuffer, calling IOWrite until they are all out or a write takes nothing (an error, a full or non-blocking stream). The count written: ASize, or fewer when the stream stopped first (IOStatus says why); 0 for a nil IO or ASize 0 or less
Parameters
AIO: the IOABuffer: the bytesASize: how many to write
Returns: the count written
IOReadAll
func cpplink IOReadAll(const AIO: IO; var AData: string): bool
Reads a stream from where it stands to its end into AData, as bytes (a string holds any bytes, zeros included). A stream with a size reads exactly the rest; one without (IOSize -1) reads in chunks until its end. True when the stream was read to its end; false (AData "") for a nil IO or a read that failed (state Error) or stopped short of the end
Parameters
AIO: the IOAData: receives the bytes
Returns: false on a failure
Example: if IOReadAll(LIO, LText) then println("{} bytes", len(LText)); end;
IOSameContent
func cpplink IOSameContent(const ALeft: IO; const ARight: IO): bool
True when two streams hold the same bytes from where each stands to its end (both are read to the end; their positions move); false when they differ, either is nil, or either fails a read before its end
Parameters
ALeft: one IOARight: the other
Returns: true when their bytes are the same
IOCopy
func cpplink IOCopy(const ASource: IO; const ADest: IO): int64
Copies a stream from where it stands to its end into another, where that one stands, in chunks (a stream of any size, sized or not; both positions move). The bytes copied; -1 when either is nil, a read failed (state Error) or a write stopped short (the bytes written up to there stay in ADest)
Parameters
ASource: the IO readADest: the IO written
Returns: the count copied
CreateMemoryIO
func cpplink CreateMemoryIO(const AData: ptr; const ASize: int64; const AReadOnly: bool): IO
Makes an IO over the caller's memory: ASize bytes at AData, read-only or read / write. It never grows: a write past the end is a short count (state Error), a seek outside 0 .. ASize fails, IOTruncate moves the size only within those ASize bytes. The memory stays the caller's and must outlive the IO. AReadOnly true: IOWrite fails with state ReadOnly. Nil when AData / ASize are not a valid block (nil is valid only with ASize 0)
Parameters
AData: the memory (the caller's)ASize: its size in bytesAReadOnly: true for a read-only IO
Returns: the IO, or nil
func cpplink CreateMemoryIO(const AData: ptr; const ASize: int64): IO
Makes a read / write IO over the caller's memory (CreateMemoryIO with AReadOnly false)
Parameters
AData: the memory (the caller's)ASize: its size in bytes
Returns: the IO, or nil
func cpplink CreateMemoryIO(): IO
Makes a read / write IO over a buffer of its own, empty at first, that grows as writes pass its end; IOClose frees the buffer
Returns: the IO, or nil
CreateFileIO
func cpplink CreateFileIO(const APath: string; const AMode: FileMode): IO
Makes an IO over a file, opened in one of C's fopen modes (see FileMode); APath is UTF-8, $P: the folder of the program's exe, $D: / $S: the working folder. A Read IO fails IOWrite with state ReadOnly, a Write or Append one fails IORead with state WriteOnly. A file may be positioned past its end, as with fseek; a write there fills the gap with zero bytes. IOClose closes the file. Nil when the file cannot be opened in that mode (a missing file for Read / ReadWrite, a folder, no permission)
Parameters
APath: the fileAMode: how it opens
Returns: the IO, or nil
Example: LIO := CreateFileIO("$P:save.dat", FileMode.Write);
CreateIOSource
func cpplink CreateIOSource(const AInterface: IOSourceInterface; const AUserData: ptr): IOSource
Makes an IOSource from a table of callbacks and the user pointer they receive. The interface is copied; the user pointer is the caller's and is never freed by the source (its Close callback may free it). Nil when there is no room
Parameters
AInterface: the callbacksAUserData: the pointer every callback receives
Returns: the source, or nil
IOSourceOpen
func cpplink IOSourceOpen(const ASource: IOSource; const APath: string; const AMode: FileMode): IO
Opens an entry of the source as an IO in AMode (a read-only source offers only Read). The path is relative to the source, / separated, UTF-8; . and .. are resolved (a .. above the source's root is refused). Refused before the source is asked: an absolute or empty path, an empty segment (a//b, a trailing /), \, :, the other characters Windows refuses in a name, a segment ending in . or a space, and a Windows device name (nul, com1.txt), on every target alike. Nil for a refused path, a missing entry, a mode not offered, a nil source or no Open callback
Parameters
ASource: the sourceAPath: the entryAMode: how it opens
Returns: the IO, or nil
func cpplink IOSourceOpen(const ASource: IOSource; const APath: string): IO
Opens an entry of the source for reading (IOSourceOpen with FileMode.Read)
Parameters
ASource: the sourceAPath: the entry
Returns: the IO, or nil
IOSourceExists
func cpplink IOSourceExists(const ASource: IOSource; const APath: string): bool
True when the source has the entry (a file it can open; a folder is not an entry). The path follows IOSourceOpen's rules; a refused path does not exist. False too for a nil source or no Exists callback
Parameters
ASource: the sourceAPath: the entry
Returns: true when it has the entry
IOSourceFolderExists
func cpplink IOSourceFolderExists(const ASource: IOSource; const APath: string): bool
True when the path is a folder of the source: one an entry's path goes through (res/assets of res/assets/logo.png; a zip needs no folder entry for it). The path follows IOSourceOpen's rules; a refused path, the root itself, a nil source or no Folder callback is false
Parameters
ASource: the sourceAPath: the folder
Returns: true for a folder of the source
Example: if IOSourceFolderExists(LZip, "res/assets/models") then ... end;
IOSourceSize
func cpplink IOSourceSize(const ASource: IOSource; const APath: string): int64
The size in bytes of an entry of the source, without opening it. The path follows IOSourceOpen's rules. -1 for no such entry, a refused path, a nil source or no Size callback (any negative size the callback gives is -1)
Parameters
ASource: the sourceAPath: the entry
Returns: the size in bytes, or -1
IOSourceRemove
func cpplink IOSourceRemove(const ASource: IOSource; const APath: string): bool
Deletes an entry of the source. The path follows IOSourceOpen's rules. IOs already opened on the entry stay valid; whether the entry can go while one is open is the source's (a folder source on Windows refuses while a file IO on it is open). False for a missing entry, a refused path, a source that refused, a nil source or no Remove callback (a source that deletes nothing, such as a zip)
Parameters
ASource: the sourceAPath: the entry
Returns: true when deleted
IOSourceCanRemove
func cpplink IOSourceCanRemove(const ASource: IOSource): bool
True when the source can delete entries (it has a Remove callback), so a caller can refuse up front what IOSourceRemove would not do later (a zip source cannot); false for a nil source
Parameters
ASource: the source
Returns: true when it can delete entries
IOSourceClose
func cpplink IOSourceClose(const ASource: IOSource): bool
Ends the source: calls its Close callback, then frees the IOSource. IOs opened from it stay valid until their own IOClose. False for a nil source or when the Close callback failed
Parameters
ASource: the source
Returns: false for a nil source or a failed Close
CreateFolderIOSource
func cpplink CreateFolderIOSource(const APath: string): IOSource
Makes an IOSource over a folder: every entry is a file under it, its IOs file IOs (CreateFileIO's rules, every FileMode). The folder's path is UTF-8, with CreateFileIO's prefixes ($P: the folder of the program's exe, $D: / $S: the working folder); entry paths are relative to it (IOSourceOpen's rules), so nothing outside the folder is reached by a ... Opening in Write or Append creates the file, never a folder; IOSourceRemove deletes the entry's file. Nil when the path is not an existing folder
Parameters
APath: the folder
Returns: the source, or nil
CreateZipIOSource
func cpplink CreateZipIOSource(const AArchive: IO; const APassword: string): IOSource
Makes a read-only IOSource over a zip archive read through an IO: the archive may be a file, memory, an entry of another source or any IO that reads and seeks. Its central directory is read once, here: ZIP64 archives, data before the archive (a self-extractor) and names in UTF-8, CP437 or an Info-ZIP Unicode Path field are read. Entry paths follow IOSourceOpen's rules and match the archive's names exactly (case included, on every target); a folder is not an entry, a name no path can reach (absolute, .. above the root, \) is never found, and of two entries with one name the later is found. IOSourceSize gives an entry's uncompressed size; IOSourceOpen opens an entry (FileMode.Read only) as a read-only IO that seeks without reading from the start again (stored and deflated entries, ZipCrypto encrypted or not): an entry under 256 KB is read whole when opened, a larger one in place. An encrypted entry opens only with the right password. A CRC that does not match gives nil from the open (small entry) or fails the read that reaches the end (large entry, state Error). An entry IO stays valid after IOSourceClose. The archive IO stays the caller's: never closed by the source, its position moved by every read, it must outlive the source and its entry IOs. APassword is the password for the encrypted entries ("" for none). Nil when AArchive is nil or not a valid zip (no end record, cut short, a bad signature, several disks)
Parameters
AArchive: the archive, read and seekedAPassword: the encrypted entries' password ("" for none)
Returns: the source, or nil
func cpplink CreateZipIOSource(const AArchive: IO): IOSource
Makes a read-only IOSource over a zip archive read through an IO, with no password (CreateZipIOSource(AArchive, ""))
Parameters
AArchive: the archive, read and seeked
Returns: the source, or nil
func cpplink CreateZipIOSource(const APath: string; const APassword: string): IOSource
Makes a read-only IOSource over a zip file: CreateZipIOSource over the file opened as CreateFileIO(APath, FileMode.Read) opens it (UTF-8, $P: / $D: / $S:). The source owns that file: it is closed once the source (IOSourceClose) and every entry IO opened from it (IOClose) are closed. Nil when the file cannot be opened or is not a valid zip
Parameters
APath: the zip fileAPassword: the encrypted entries' password ("" for none)
Returns: the source, or nil
Example: LZip := CreateZipIOSource("$P:assets.zip", "Adam");
func cpplink CreateZipIOSource(const APath: string): IOSource
Makes a read-only IOSource over a zip file, with no password (CreateZipIOSource(APath, ""))
Parameters
APath: the zip file
Returns: the source, or nil
CreateZipFileIO
func cpplink CreateZipFileIO(const AArchive: IO; const AEntry: string; const APassword: string): IO
Opens one entry of a zip archive read through an IO as a read-only IO: IOSourceOpen on CreateZipIOSource(AArchive, APassword), the source closed again at once (the entry IO keeps what it needs). Reading, seeking, passwords and CRC as CreateZipIOSource says; the archive is the caller's and must outlive the IO. Nil when it is not a valid zip, has no such entry, the password is missing or wrong, or the entry cannot be read
Parameters
AArchive: the archive, read and seekedAEntry: the entryAPassword: the password ("" for none)
Returns: the IO, or nil
func cpplink CreateZipFileIO(const AArchive: IO; const AEntry: string): IO
Opens one entry of a zip archive read through an IO, with no password (CreateZipFileIO(AArchive, AEntry, ""))
Parameters
AArchive: the archive, read and seekedAEntry: the entry
Returns: the IO, or nil
func cpplink CreateZipFileIO(const APath: string; const AEntry: string; const APassword: string): IO
Opens one entry of a zip file as a read-only IO: the file opened as CreateZipIOSource(APath, APassword) opens it, and closed when the IO is (IOClose). Nil when the file cannot be opened or is not a valid zip, has no such entry, the password is missing or wrong, or the entry cannot be read
Parameters
APath: the zip fileAEntry: the entryAPassword: the password ("" for none)
Returns: the IO, or nil
func cpplink CreateZipFileIO(const APath: string; const AEntry: string): IO
Opens one entry of a zip file, with no password (CreateZipFileIO(APath, AEntry, ""))
Parameters
APath: the zip fileAEntry: the entry
Returns: the IO, or nil
GetZipEntryInfo
func cpplink GetZipEntryInfo(const APath: string; const AEntry: string; const APassword: string; var AInfo: ZipEntryInfo): bool
Reads an entry's uncompressed size and CRC-32 from a zip file's central directory, without opening or decoding the entry: a cache of an extracted entry compares its file against these to know it is current. The zip is opened as CreateZipIOSource(APath, APassword) opens it and closed again before the call returns. The directory is never encrypted, so an encrypted entry's info reads with any password; APassword is kept so the call names the archive the way CreateZipFileIO does. AInfo is set when the call succeeds and left as it was otherwise. True when the zip has the entry; false when the file cannot be opened or is not a valid zip, the path is refused or no entry has it
Parameters
APath: the zip fileAEntry: the entryAPassword: the password ("" for none; not needed to read the info)AInfo: receives the entry's size and CRC-32
Returns: true when the zip has the entry
ZipDirectoryContents
func cpplink ZipDirectoryContents(const AArchive: string; const AFolder: string; const APassword: string; const ARoot: string; const AProgress: ZipProgress): bool
Writes every file under a folder (its subfolders too) into a new zip archive (Delphi's TZipFile.ZipDirectoryContents, archive first): deflated at the best level, each entry ZipCrypto encrypted with APassword unless it is "", with its file's modification time, the entries in byte order of their names (the same archive whatever order the system lists the files in). An entry is named by its file's path below ARoot with / (ARoot "" = AFolder itself): ZipDirectoryContents("$P:assets.zip", "$P:res/assets", "secret", "$P:") names them res/assets/... A name that is not ASCII is stored as UTF-8 (general purpose bit 11); a file of 4 GB or more is stored as ZIP64. Every path is UTF-8 and taken as CreateFileIO takes it ($P:, $D:, $S:), then made full ("." and ".." folded). An archive inside AFolder is left out; an existing archive is replaced. AProgress (a closure, nil for none) is called for each entry's progress. The result reads back with CreateZipIOSource / CreateZipFileIO. True when every file is in the archive; false (the reason in ZipLastError) when AFolder is not an existing folder inside ARoot (no archive is written then), a file cannot be read or the archive cannot be written (an archive begun is then incomplete)
Parameters
AArchive: the archive to writeAFolder: the folder to packAPassword: ZipCrypto's password ("" for none)ARoot: the folder entry names start below ("" for AFolder)AProgress: called for each entry's progress; nil for none
Returns: false (the reason in ZipLastError) on a failure
func cpplink ZipDirectoryContents(const AArchive: string; const AFolder: string; const APassword: string; const ARoot: string): bool
Writes every file under a folder into a new zip archive, its entries named below ARoot, with no progress routine (ZipDirectoryContents(AArchive, AFolder, APassword, ARoot, nil))
Parameters
AArchive: the archive to writeAFolder: the folder to packAPassword: ZipCrypto's password ("" for none)ARoot: the folder entry names start below ("" for AFolder)
Returns: false (the reason in ZipLastError) on a failure
func cpplink ZipDirectoryContents(const AArchive: string; const AFolder: string; const APassword: string): bool
Writes every file under a folder into a new zip archive, its entries named below the folder itself, with no progress routine (ZipDirectoryContents(AArchive, AFolder, APassword, "", nil))
Parameters
AArchive: the archive to writeAFolder: the folder to packAPassword: ZipCrypto's password ("" for none)
Returns: false (the reason in ZipLastError) on a failure
func cpplink ZipDirectoryContents(const AArchive: string; const AFolder: string): bool
Writes every file under a folder into a new zip archive with no password, its entries named below the folder itself, with no progress routine (ZipDirectoryContents(AArchive, AFolder, "", "", nil))
Parameters
AArchive: the archive to writeAFolder: the folder to pack
Returns: false (the reason in ZipLastError) on a failure
Example: if not ZipDirectoryContents("out.zip", "data") then println(ZipLastError()); end;
ZipLastError
func cpplink ZipLastError(): string
Why the last ZipDirectoryContents or ZipTest on this thread failed: the step and the path ("cannot create the archive ...", "... is not a folder", "... changed while it was packed", "the entry ... is damaged"); "" when it succeeded. The runtime reports no system error text, so a reason names the step only
Returns: the reason, or ""
ZipTest
func cpplink ZipTest(const APath: string; const APassword: string; var ANames: StringArray): bool
Tests a zip archive as unzip -t does: its central directory read, then every entry decoded to its end (decrypted with APassword where it is encrypted) and its size and CRC-32 checked against the directory. The archive is opened as CreateZipIOSource opens it and closed again before the call returns.
Parameters
APath: the archive (UTF-8, asCreateFileIOtakes it)APassword: ZipCrypto's password ("" for none)ANames: every entry's name, in the archive's order (empty on a failure)
Returns: false (the reason in ZipLastError) when the file cannot be opened, is no valid zip, or an entry is damaged (cut short, a wrong CRC, a wrong password)
Example: if not ZipTest("release.zip", "", LNames) then println(ZipLastError()); end;
System.Diagnostics
timing: Stopwatch and GetTimeStamp
Import it with import System.Diagnostics;.
Types
Stopwatch
type Stopwatch = object
Elapsed time over the high-resolution clock: stopped at zero when made.
Members
Total: int64: The ticks of every finished run (Start .. Stop) added up.StartedAt: int64: The clock's reading at the running span's Start (meaningful while Running).Running: bool: True between Start and Stop.init(): A stopwatch stopped at zero.method Start(): Runs it from where it stands; running already, nothing changes.method Stop(): Freezes the total, the running span added on; stopped already, nothing changes.method Reset(): Stops it at zero.method Restart(): Zero and running again.method IsRunning(): bool: Whether it runs. Returns: true between Start and Stopmethod ElapsedTicks(): int64: The ticks elapsed (Frequency per second): the total, and the running span so far. Returns: the elapsed ticksmethod ElapsedMilliseconds(): int64: The whole milliseconds elapsed (ElapsedTicks scaled by Frequency, rounded down). Returns: the elapsed millisecondsmethod Frequency(): int64: The clock's ticks per second. Returns: the ticks per second (above 0)
Example: LWatch := StartNew(); Work(); println("{} ms", LWatch.ElapsedMilliseconds());
Constants
| Name | Declaration | Description |
|---|---|---|
ADAM_DIAGNOSTICS_MS_PER_SECOND | const ADAM_DIAGNOSTICS_MS_PER_SECOND: int64 = 1000 | Milliseconds in a second (ElapsedMilliseconds' scale). |
Routines
StartNew
func cpplink StartNew(): Stopwatch
A new Stopwatch, already running.
Returns: the running stopwatch
Example: LWatch := StartNew();
GetTimeStamp
func cpplink GetTimeStamp(): int64
The high-resolution clock's reading now, in Stopwatch ticks (only the difference of two readings means anything).
Returns: the clock's reading
System.ELF
the ELF file format's own names (elf.h), each once (AD.5a)
Import it with import System.ELF;.
Constants
| Name | Declaration | Description |
|---|---|---|
EI_NIDENT | const EI_NIDENT: int32 = 16 | The ELF format's EI_NIDENT: e_ident: its size, the magic bytes, and the values of its class, data, version and OS / ABI bytes at their indices |
ELFMAG0 | const ELFMAG0: uint8 = 0x7F | The ELF format's ELFMAG0: e_ident: its size, the magic bytes, and the values of its class, data, version and OS / ABI bytes at their indices |
ELFMAG1 | const ELFMAG1: uint8 = 0x45 | The ELF format's ELFMAG1: e_ident: its size, the magic bytes, and the values of its class, data, version and OS / ABI bytes at their indices |
ELFMAG2 | const ELFMAG2: uint8 = 0x4C | The ELF format's ELFMAG2: e_ident: its size, the magic bytes, and the values of its class, data, version and OS / ABI bytes at their indices |
ELFMAG3 | const ELFMAG3: uint8 = 0x46 | The ELF format's ELFMAG3: e_ident: its size, the magic bytes, and the values of its class, data, version and OS / ABI bytes at their indices |
EI_CLASS | const EI_CLASS: int32 = 4 | The ELF format's EI_CLASS: e_ident: its size, the magic bytes, and the values of its class, data, version and OS / ABI bytes at their indices |
EI_DATA | const EI_DATA: int32 = 5 | The ELF format's EI_DATA: e_ident: its size, the magic bytes, and the values of its class, data, version and OS / ABI bytes at their indices |
EI_VERSION | const EI_VERSION: int32 = 6 | The ELF format's EI_VERSION: e_ident: its size, the magic bytes, and the values of its class, data, version and OS / ABI bytes at their indices |
EI_OSABI | const EI_OSABI: int32 = 7 | The ELF format's EI_OSABI: e_ident: its size, the magic bytes, and the values of its class, data, version and OS / ABI bytes at their indices |
EI_ABIVERSION | const EI_ABIVERSION: int32 = 8 | The ELF format's EI_ABIVERSION: e_ident: its size, the magic bytes, and the values of its class, data, version and OS / ABI bytes at their indices |
ELFCLASS64 | const ELFCLASS64: uint8 = 2 | The ELF format's ELFCLASS64: e_ident: its size, the magic bytes, and the values of its class, data, version and OS / ABI bytes at their indices |
ELFDATA2LSB | const ELFDATA2LSB: uint8 = 1 | The ELF format's ELFDATA2LSB: e_ident: its size, the magic bytes, and the values of its class, data, version and OS / ABI bytes at their indices |
ELFOSABI_SYSV | const ELFOSABI_SYSV: uint8 = 0 | The ELF format's ELFOSABI_SYSV: e_ident: its size, the magic bytes, and the values of its class, data, version and OS / ABI bytes at their indices |
EV_CURRENT | const EV_CURRENT: uint32 = 1 | The ELF format's EV_CURRENT: e_ident: its size, the magic bytes, and the values of its class, data, version and OS / ABI bytes at their indices |
ET_NONE | const ET_NONE: uint16 = 0 | The ELF format's ET_NONE: e_type and e_machine |
ET_REL | const ET_REL: uint16 = 1 | The ELF format's ET_REL: e_type and e_machine |
ET_EXEC | const ET_EXEC: uint16 = 2 | The ELF format's ET_EXEC: e_type and e_machine |
ET_DYN | const ET_DYN: uint16 = 3 | The ELF format's ET_DYN: e_type and e_machine |
EM_X86_64 | const EM_X86_64: uint16 = 0x3E | The ELF format's EM_X86_64: e_type and e_machine |
SHT_NULL | const SHT_NULL: uint32 = 0 | The ELF format's SHT_NULL: sh_type |
SHT_PROGBITS | const SHT_PROGBITS: uint32 = 1 | The ELF format's SHT_PROGBITS: sh_type |
SHT_SYMTAB | const SHT_SYMTAB: uint32 = 2 | The ELF format's SHT_SYMTAB: sh_type |
SHT_STRTAB | const SHT_STRTAB: uint32 = 3 | The ELF format's SHT_STRTAB: sh_type |
SHT_RELA | const SHT_RELA: uint32 = 4 | The ELF format's SHT_RELA: sh_type |
SHT_HASH | const SHT_HASH: uint32 = 5 | The ELF format's SHT_HASH: sh_type |
SHT_DYNAMIC | const SHT_DYNAMIC: uint32 = 6 | The ELF format's SHT_DYNAMIC: sh_type |
SHT_NOTE | const SHT_NOTE: uint32 = 7 | The ELF format's SHT_NOTE: sh_type |
SHT_NOBITS | const SHT_NOBITS: uint32 = 8 | The ELF format's SHT_NOBITS: sh_type |
SHT_REL | const SHT_REL: uint32 = 9 | The ELF format's SHT_REL: sh_type |
SHT_DYNSYM | const SHT_DYNSYM: uint32 = 11 | The ELF format's SHT_DYNSYM: sh_type |
SHT_INIT_ARRAY | const SHT_INIT_ARRAY: uint32 = 14 | The ELF format's SHT_INIT_ARRAY: sh_type |
SHT_FINI_ARRAY | const SHT_FINI_ARRAY: uint32 = 15 | The ELF format's SHT_FINI_ARRAY: sh_type |
SHT_PREINIT_ARRAY | const SHT_PREINIT_ARRAY: uint32 = 16 | The ELF format's SHT_PREINIT_ARRAY: sh_type |
SHT_GROUP | const SHT_GROUP: uint32 = 17 | The ELF format's SHT_GROUP: sh_type |
SHT_SYMTAB_SHNDX | const SHT_SYMTAB_SHNDX: uint32 = 18 | The ELF format's SHT_SYMTAB_SHNDX: sh_type |
SHT_GNU_HASH | const SHT_GNU_HASH: uint32 = 0x6FFFFFF6 | The ELF format's SHT_GNU_HASH: sh_type |
SHT_GNU_verdef | const SHT_GNU_verdef: uint32 = 0x6FFFFFFD | The ELF format's SHT_GNU_verdef: sh_type |
SHT_GNU_verneed | const SHT_GNU_verneed: uint32 = 0x6FFFFFFE | The ELF format's SHT_GNU_verneed: sh_type |
SHT_GNU_versym | const SHT_GNU_versym: uint32 = 0x6FFFFFFF | The ELF format's SHT_GNU_versym: sh_type |
SHT_X86_64_UNWIND | const SHT_X86_64_UNWIND: uint32 = 0x70000001 | The ELF format's SHT_X86_64_UNWIND: sh_type |
SHF_WRITE | const SHF_WRITE: uint64 = 0x1 | The ELF format's SHF_WRITE: sh_flags |
SHF_ALLOC | const SHF_ALLOC: uint64 = 0x2 | The ELF format's SHF_ALLOC: sh_flags |
SHF_EXECINSTR | const SHF_EXECINSTR: uint64 = 0x4 | The ELF format's SHF_EXECINSTR: sh_flags |
SHF_MERGE | const SHF_MERGE: uint64 = 0x10 | The ELF format's SHF_MERGE: sh_flags |
SHF_STRINGS | const SHF_STRINGS: uint64 = 0x20 | The ELF format's SHF_STRINGS: sh_flags |
SHF_INFO_LINK | const SHF_INFO_LINK: uint64 = 0x40 | The ELF format's SHF_INFO_LINK: sh_flags |
SHF_LINK_ORDER | const SHF_LINK_ORDER: uint64 = 0x80 | The ELF format's SHF_LINK_ORDER: sh_flags |
SHF_GROUP | const SHF_GROUP: uint64 = 0x200 | The ELF format's SHF_GROUP: sh_flags |
SHF_TLS | const SHF_TLS: uint64 = 0x400 | The ELF format's SHF_TLS: sh_flags |
SHF_COMPRESSED | const SHF_COMPRESSED: uint64 = 0x800 | The ELF format's SHF_COMPRESSED: sh_flags |
SHF_EXCLUDE | const SHF_EXCLUDE: uint64 = 0x80000000 | The ELF format's SHF_EXCLUDE: sh_flags |
GRP_COMDAT | const GRP_COMDAT: uint32 = 0x1 | The ELF format's GRP_COMDAT: A section group's flag word: a COMDAT group |
SHN_UNDEF | const SHN_UNDEF: uint16 = 0 | The ELF format's SHN_UNDEF: The special section indices (st_shndx, e_shstrndx) |
SHN_LORESERVE | const SHN_LORESERVE: uint16 = 0xFF00 | The ELF format's SHN_LORESERVE: The special section indices (st_shndx, e_shstrndx) |
SHN_ABS | const SHN_ABS: uint16 = 0xFFF1 | The ELF format's SHN_ABS: The special section indices (st_shndx, e_shstrndx) |
SHN_COMMON | const SHN_COMMON: uint16 = 0xFFF2 | The ELF format's SHN_COMMON: The special section indices (st_shndx, e_shstrndx) |
SHN_XINDEX | const SHN_XINDEX: uint16 = 0xFFFF | The ELF format's SHN_XINDEX: The special section indices (st_shndx, e_shstrndx) |
STB_LOCAL | const STB_LOCAL: uint8 = 0 | The ELF format's STB_LOCAL: st_info: a symbol's binding (its high 4 bits) and type (its low 4); st_other: its visibility (the low 2 bits) |
STB_GLOBAL | const STB_GLOBAL: uint8 = 1 | The ELF format's STB_GLOBAL: st_info: a symbol's binding (its high 4 bits) and type (its low 4); st_other: its visibility (the low 2 bits) |
STB_WEAK | const STB_WEAK: uint8 = 2 | The ELF format's STB_WEAK: st_info: a symbol's binding (its high 4 bits) and type (its low 4); st_other: its visibility (the low 2 bits) |
STB_GNU_UNIQUE | const STB_GNU_UNIQUE: uint8 = 10 | The ELF format's STB_GNU_UNIQUE: st_info: a symbol's binding (its high 4 bits) and type (its low 4); st_other: its visibility (the low 2 bits) |
STT_NOTYPE | const STT_NOTYPE: uint8 = 0 | The ELF format's STT_NOTYPE: st_info: a symbol's binding (its high 4 bits) and type (its low 4); st_other: its visibility (the low 2 bits) |
STT_OBJECT | const STT_OBJECT: uint8 = 1 | The ELF format's STT_OBJECT: st_info: a symbol's binding (its high 4 bits) and type (its low 4); st_other: its visibility (the low 2 bits) |
STT_FUNC | const STT_FUNC: uint8 = 2 | The ELF format's STT_FUNC: st_info: a symbol's binding (its high 4 bits) and type (its low 4); st_other: its visibility (the low 2 bits) |
STT_SECTION | const STT_SECTION: uint8 = 3 | The ELF format's STT_SECTION: st_info: a symbol's binding (its high 4 bits) and type (its low 4); st_other: its visibility (the low 2 bits) |
STT_FILE | const STT_FILE: uint8 = 4 | The ELF format's STT_FILE: st_info: a symbol's binding (its high 4 bits) and type (its low 4); st_other: its visibility (the low 2 bits) |
STT_COMMON | const STT_COMMON: uint8 = 5 | The ELF format's STT_COMMON: st_info: a symbol's binding (its high 4 bits) and type (its low 4); st_other: its visibility (the low 2 bits) |
STT_TLS | const STT_TLS: uint8 = 6 | The ELF format's STT_TLS: st_info: a symbol's binding (its high 4 bits) and type (its low 4); st_other: its visibility (the low 2 bits) |
STT_GNU_IFUNC | const STT_GNU_IFUNC: uint8 = 10 | The ELF format's STT_GNU_IFUNC: st_info: a symbol's binding (its high 4 bits) and type (its low 4); st_other: its visibility (the low 2 bits) |
STV_DEFAULT | const STV_DEFAULT: uint8 = 0 | The ELF format's STV_DEFAULT: st_info: a symbol's binding (its high 4 bits) and type (its low 4); st_other: its visibility (the low 2 bits) |
STV_INTERNAL | const STV_INTERNAL: uint8 = 1 | The ELF format's STV_INTERNAL: st_info: a symbol's binding (its high 4 bits) and type (its low 4); st_other: its visibility (the low 2 bits) |
STV_HIDDEN | const STV_HIDDEN: uint8 = 2 | The ELF format's STV_HIDDEN: st_info: a symbol's binding (its high 4 bits) and type (its low 4); st_other: its visibility (the low 2 bits) |
STV_PROTECTED | const STV_PROTECTED: uint8 = 3 | The ELF format's STV_PROTECTED: st_info: a symbol's binding (its high 4 bits) and type (its low 4); st_other: its visibility (the low 2 bits) |
R_X86_64_NONE | const R_X86_64_NONE: uint32 = 0 | The ELF format's R_X86_64_NONE: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_64 | const R_X86_64_64: uint32 = 1 | The ELF format's R_X86_64_64: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_PC32 | const R_X86_64_PC32: uint32 = 2 | The ELF format's R_X86_64_PC32: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_GOT32 | const R_X86_64_GOT32: uint32 = 3 | The ELF format's R_X86_64_GOT32: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_PLT32 | const R_X86_64_PLT32: uint32 = 4 | The ELF format's R_X86_64_PLT32: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_COPY | const R_X86_64_COPY: uint32 = 5 | The ELF format's R_X86_64_COPY: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_GLOB_DAT | const R_X86_64_GLOB_DAT: uint32 = 6 | The ELF format's R_X86_64_GLOB_DAT: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_JUMP_SLOT | const R_X86_64_JUMP_SLOT: uint32 = 7 | The ELF format's R_X86_64_JUMP_SLOT: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_RELATIVE | const R_X86_64_RELATIVE: uint32 = 8 | The ELF format's R_X86_64_RELATIVE: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_GOTPCREL | const R_X86_64_GOTPCREL: uint32 = 9 | The ELF format's R_X86_64_GOTPCREL: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_32 | const R_X86_64_32: uint32 = 10 | The ELF format's R_X86_64_32: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_32S | const R_X86_64_32S: uint32 = 11 | The ELF format's R_X86_64_32S: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_16 | const R_X86_64_16: uint32 = 12 | The ELF format's R_X86_64_16: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_PC16 | const R_X86_64_PC16: uint32 = 13 | The ELF format's R_X86_64_PC16: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_8 | const R_X86_64_8: uint32 = 14 | The ELF format's R_X86_64_8: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_PC8 | const R_X86_64_PC8: uint32 = 15 | The ELF format's R_X86_64_PC8: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_DTPMOD64 | const R_X86_64_DTPMOD64: uint32 = 16 | The ELF format's R_X86_64_DTPMOD64: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_DTPOFF64 | const R_X86_64_DTPOFF64: uint32 = 17 | The ELF format's R_X86_64_DTPOFF64: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_TPOFF64 | const R_X86_64_TPOFF64: uint32 = 18 | The ELF format's R_X86_64_TPOFF64: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_TLSGD | const R_X86_64_TLSGD: uint32 = 19 | The ELF format's R_X86_64_TLSGD: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_TLSLD | const R_X86_64_TLSLD: uint32 = 20 | The ELF format's R_X86_64_TLSLD: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_DTPOFF32 | const R_X86_64_DTPOFF32: uint32 = 21 | The ELF format's R_X86_64_DTPOFF32: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_GOTTPOFF | const R_X86_64_GOTTPOFF: uint32 = 22 | The ELF format's R_X86_64_GOTTPOFF: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_TPOFF32 | const R_X86_64_TPOFF32: uint32 = 23 | The ELF format's R_X86_64_TPOFF32: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_PC64 | const R_X86_64_PC64: uint32 = 24 | The ELF format's R_X86_64_PC64: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_GOTOFF64 | const R_X86_64_GOTOFF64: uint32 = 25 | The ELF format's R_X86_64_GOTOFF64: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_GOTPC32 | const R_X86_64_GOTPC32: uint32 = 26 | The ELF format's R_X86_64_GOTPC32: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_SIZE32 | const R_X86_64_SIZE32: uint32 = 32 | The ELF format's R_X86_64_SIZE32: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_SIZE64 | const R_X86_64_SIZE64: uint32 = 33 | The ELF format's R_X86_64_SIZE64: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_GOTPC32_TLSDESC | const R_X86_64_GOTPC32_TLSDESC: uint32 = 34 | The ELF format's R_X86_64_GOTPC32_TLSDESC: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_TLSDESC_CALL | const R_X86_64_TLSDESC_CALL: uint32 = 35 | The ELF format's R_X86_64_TLSDESC_CALL: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_TLSDESC | const R_X86_64_TLSDESC: uint32 = 36 | The ELF format's R_X86_64_TLSDESC: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_IRELATIVE | const R_X86_64_IRELATIVE: uint32 = 37 | The ELF format's R_X86_64_IRELATIVE: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_RELATIVE64 | const R_X86_64_RELATIVE64: uint32 = 38 | The ELF format's R_X86_64_RELATIVE64: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_GOTPCRELX | const R_X86_64_GOTPCRELX: uint32 = 41 | The ELF format's R_X86_64_GOTPCRELX: The x86_64 relocation types (r_info's low 32 bits) |
R_X86_64_REX_GOTPCRELX | const R_X86_64_REX_GOTPCRELX: uint32 = 42 | The ELF format's R_X86_64_REX_GOTPCRELX: The x86_64 relocation types (r_info's low 32 bits) |
PT_NULL | const PT_NULL: uint32 = 0 | The ELF format's PT_NULL: p_type and p_flags |
PT_LOAD | const PT_LOAD: uint32 = 1 | The ELF format's PT_LOAD: p_type and p_flags |
PT_DYNAMIC | const PT_DYNAMIC: uint32 = 2 | The ELF format's PT_DYNAMIC: p_type and p_flags |
PT_INTERP | const PT_INTERP: uint32 = 3 | The ELF format's PT_INTERP: p_type and p_flags |
PT_NOTE | const PT_NOTE: uint32 = 4 | The ELF format's PT_NOTE: p_type and p_flags |
PT_PHDR | const PT_PHDR: uint32 = 6 | The ELF format's PT_PHDR: p_type and p_flags |
PT_TLS | const PT_TLS: uint32 = 7 | The ELF format's PT_TLS: p_type and p_flags |
PT_GNU_EH_FRAME | const PT_GNU_EH_FRAME: uint32 = 0x6474E550 | The ELF format's PT_GNU_EH_FRAME: p_type and p_flags |
PT_GNU_STACK | const PT_GNU_STACK: uint32 = 0x6474E551 | The ELF format's PT_GNU_STACK: p_type and p_flags |
PT_GNU_RELRO | const PT_GNU_RELRO: uint32 = 0x6474E552 | The ELF format's PT_GNU_RELRO: p_type and p_flags |
PT_GNU_PROPERTY | const PT_GNU_PROPERTY: uint32 = 0x6474E553 | The ELF format's PT_GNU_PROPERTY: p_type and p_flags |
PF_X | const PF_X: uint32 = 0x1 | The ELF format's PF_X: p_type and p_flags |
PF_W | const PF_W: uint32 = 0x2 | The ELF format's PF_W: p_type and p_flags |
PF_R | const PF_R: uint32 = 0x4 | The ELF format's PF_R: p_type and p_flags |
DT_NULL | const DT_NULL: int64 = 0 | The ELF format's DT_NULL: d_tag |
DT_NEEDED | const DT_NEEDED: int64 = 1 | The ELF format's DT_NEEDED: d_tag |
DT_PLTRELSZ | const DT_PLTRELSZ: int64 = 2 | The ELF format's DT_PLTRELSZ: d_tag |
DT_PLTGOT | const DT_PLTGOT: int64 = 3 | The ELF format's DT_PLTGOT: d_tag |
DT_HASH | const DT_HASH: int64 = 4 | The ELF format's DT_HASH: d_tag |
DT_STRTAB | const DT_STRTAB: int64 = 5 | The ELF format's DT_STRTAB: d_tag |
DT_SYMTAB | const DT_SYMTAB: int64 = 6 | The ELF format's DT_SYMTAB: d_tag |
DT_RELA | const DT_RELA: int64 = 7 | The ELF format's DT_RELA: d_tag |
DT_RELASZ | const DT_RELASZ: int64 = 8 | The ELF format's DT_RELASZ: d_tag |
DT_RELAENT | const DT_RELAENT: int64 = 9 | The ELF format's DT_RELAENT: d_tag |
DT_STRSZ | const DT_STRSZ: int64 = 10 | The ELF format's DT_STRSZ: d_tag |
DT_SYMENT | const DT_SYMENT: int64 = 11 | The ELF format's DT_SYMENT: d_tag |
DT_INIT | const DT_INIT: int64 = 12 | The ELF format's DT_INIT: d_tag |
DT_FINI | const DT_FINI: int64 = 13 | The ELF format's DT_FINI: d_tag |
DT_SONAME | const DT_SONAME: int64 = 14 | The ELF format's DT_SONAME: d_tag |
DT_RPATH | const DT_RPATH: int64 = 15 | The ELF format's DT_RPATH: d_tag |
DT_SYMBOLIC | const DT_SYMBOLIC: int64 = 16 | The ELF format's DT_SYMBOLIC: d_tag |
DT_PLTREL | const DT_PLTREL: int64 = 20 | The ELF format's DT_PLTREL: d_tag |
DT_DEBUG | const DT_DEBUG: int64 = 21 | The ELF format's DT_DEBUG: d_tag |
DT_TEXTREL | const DT_TEXTREL: int64 = 22 | The ELF format's DT_TEXTREL: d_tag |
DT_JMPREL | const DT_JMPREL: int64 = 23 | The ELF format's DT_JMPREL: d_tag |
DT_BIND_NOW | const DT_BIND_NOW: int64 = 24 | The ELF format's DT_BIND_NOW: d_tag |
DT_INIT_ARRAY | const DT_INIT_ARRAY: int64 = 25 | The ELF format's DT_INIT_ARRAY: d_tag |
DT_FINI_ARRAY | const DT_FINI_ARRAY: int64 = 26 | The ELF format's DT_FINI_ARRAY: d_tag |
DT_INIT_ARRAYSZ | const DT_INIT_ARRAYSZ: int64 = 27 | The ELF format's DT_INIT_ARRAYSZ: d_tag |
DT_FINI_ARRAYSZ | const DT_FINI_ARRAYSZ: int64 = 28 | The ELF format's DT_FINI_ARRAYSZ: d_tag |
DT_RUNPATH | const DT_RUNPATH: int64 = 29 | The ELF format's DT_RUNPATH: d_tag |
DT_FLAGS | const DT_FLAGS: int64 = 30 | The ELF format's DT_FLAGS: d_tag |
DT_PREINIT_ARRAY | const DT_PREINIT_ARRAY: int64 = 32 | The ELF format's DT_PREINIT_ARRAY: d_tag |
DT_PREINIT_ARRAYSZ | const DT_PREINIT_ARRAYSZ: int64 = 33 | The ELF format's DT_PREINIT_ARRAYSZ: d_tag |
DT_GNU_HASH | const DT_GNU_HASH: int64 = 0x6FFFFEF5 | The ELF format's DT_GNU_HASH: d_tag |
DT_VERSYM | const DT_VERSYM: int64 = 0x6FFFFFF0 | The ELF format's DT_VERSYM: d_tag |
DT_RELACOUNT | const DT_RELACOUNT: int64 = 0x6FFFFFF9 | The ELF format's DT_RELACOUNT: d_tag |
DT_FLAGS_1 | const DT_FLAGS_1: int64 = 0x6FFFFFFB | The ELF format's DT_FLAGS_1: d_tag |
DT_VERNEED | const DT_VERNEED: int64 = 0x6FFFFFFE | The ELF format's DT_VERNEED: d_tag |
DT_VERNEEDNUM | const DT_VERNEEDNUM: int64 = 0x6FFFFFFF | The ELF format's DT_VERNEEDNUM: d_tag |
DF_ORIGIN | const DF_ORIGIN: uint64 = 0x1 | The ELF format's DF_ORIGIN: DT_FLAGS / DT_FLAGS_1 bits, the version records' values |
DF_SYMBOLIC | const DF_SYMBOLIC: uint64 = 0x2 | The ELF format's DF_SYMBOLIC: DT_FLAGS / DT_FLAGS_1 bits, the version records' values |
DF_TEXTREL | const DF_TEXTREL: uint64 = 0x4 | The ELF format's DF_TEXTREL: DT_FLAGS / DT_FLAGS_1 bits, the version records' values |
DF_BIND_NOW | const DF_BIND_NOW: uint64 = 0x8 | The ELF format's DF_BIND_NOW: DT_FLAGS / DT_FLAGS_1 bits, the version records' values |
DF_STATIC_TLS | const DF_STATIC_TLS: uint64 = 0x10 | The ELF format's DF_STATIC_TLS: DT_FLAGS / DT_FLAGS_1 bits, the version records' values |
DF_1_NOW | const DF_1_NOW: uint64 = 0x1 | The ELF format's DF_1_NOW: DT_FLAGS / DT_FLAGS_1 bits, the version records' values |
DF_1_ORIGIN | const DF_1_ORIGIN: uint64 = 0x80 | The ELF format's DF_1_ORIGIN: DT_FLAGS / DT_FLAGS_1 bits, the version records' values |
DF_1_PIE | const DF_1_PIE: uint64 = 0x08000000 | The ELF format's DF_1_PIE: DT_FLAGS / DT_FLAGS_1 bits, the version records' values |
VER_NEED_CURRENT | const VER_NEED_CURRENT: uint16 = 1 | The ELF format's VER_NEED_CURRENT: DT_FLAGS / DT_FLAGS_1 bits, the version records' values |
VER_FLG_WEAK | const VER_FLG_WEAK: uint16 = 0x2 | The ELF format's VER_FLG_WEAK: DT_FLAGS / DT_FLAGS_1 bits, the version records' values |
VER_NDX_LOCAL | const VER_NDX_LOCAL: uint16 = 0 | The ELF format's VER_NDX_LOCAL: DT_FLAGS / DT_FLAGS_1 bits, the version records' values |
VER_NDX_GLOBAL | const VER_NDX_GLOBAL: uint16 = 1 | The ELF format's VER_NDX_GLOBAL: DT_FLAGS / DT_FLAGS_1 bits, the version records' values |
System.Hash
message digests: MD5 (RFC 1321), SHA-1 (FIPS 180-4), SHA-256 / SHA-512 (FIPS 180-4) and BLAKE2b-512 (RFC 7693), written in Adam.
Import it with import System.Hash;.
Types
HashKind
type HashKind = choices(
The digest a Hasher (or ComputeHash) makes.
Members
HashKind.MD5: 16 bytes (RFC 1321): file checks and cache keys only, never security.HashKind.SHA1: 20 bytes (FIPS 180-4): the same caution as MD5 (git's object names use it).HashKind.SHA256: 32 bytes (FIPS 180-4): the one to pick when in doubt.HashKind.BLAKE2B512: 64 bytes (RFC 7693, unkeyed): fast and secure; the digest minisign signs.HashKind.SHA512: 64 bytes (FIPS 180-4): the hash inside Ed25519 (RFC 8032).
Hasher
type Hasher = object
A digest made from input given in pieces: make one for a kind, Update it with each piece in order, then Final gives the digest and makes it fresh again, ready for the next input. Pieces may be any size (one byte, a whole file); the digest is that of all of them joined. A copy carries its progress: two copies go on apart.
Members
method Reset(): Starts over: no input taken, the kind kept.init(): A SHA-256 hasher with no input yet (Hasher(HashKind.SHA256)).init(const AKind: HashKind): A hasher forAKindwith no input yet. Parameters:AKindthe digest to make.const method Kind(): HashKind: The digest this hasher makes. Returns: its kindmethod Update(const ABytes: ByteArray): The bytes ofABytesadded to the input. Parameters:ABytesthe next piece (empty adds nothing).method Update(const AText: string): The UTF-8 bytes ofATextadded to the input (no terminating zero). Parameters:ATextthe next piece ("" adds nothing).method Update(const AData: ptr to const; const ACount: int64):ACountbytes of memory atADataadded to the input: a buffer a C library or a file read filled. Parameters:ADatathe first byte (nil only withACount0);ACounthow many bytes (0 or below adds nothing).method Final(): ByteArray: The digest of all the input so far; the hasher then starts over (same kind). Returns: the digest's bytes: 16 for MD5, 20 for SHA-1, 32 for SHA-256, 64 for SHA-512 / BLAKE2b-512
Example: LHash := Hasher(HashKind.SHA256); LHash.Update("abc"); println(DigestToHex(LHash.Final()));
Routines
ComputeHash
func cpplink ComputeHash(const AKind: HashKind; const ABytes: ByteArray): ByteArray
The AKind digest of ABytes in one call (a Hasher given them all at once).
Parameters
AKind: the digest to makeABytes: the input
Returns: the digest's bytes
Example: LDigest := ComputeHash(HashKind.MD5, LBytes);
func cpplink ComputeHash(const AKind: HashKind; const AText: string): ByteArray
The AKind digest of the UTF-8 bytes of AText in one call.
Parameters
AKind: the digest to makeAText: the input
Returns: the digest's bytes
Example: println(DigestToHex(ComputeHash(HashKind.SHA256, "abc")));
DigestToHex
func cpplink DigestToHex(const ADigest: ByteArray): string
A digest written as lowercase hex, two digits a byte, as md5sum / sha256sum print it.
Parameters
ADigest: the digest's bytes (any bytes: an empty array gives "")
Returns: the hex text
Example: DigestToHex(ComputeHash(HashKind.MD5, "")) is "d41d8cd98f00b204e9800998ecf8427e"
System.HookABI
link-time hooks of C functions
Import it with import System.HookABI;.
Types
Hook
type Hook = record
A run-time hook, filled by HookInstall: while installed, every call of the hooked name through a module's import slot reaches the replacement instead. A Hook variable starts zeroed (not installed); keep it while installed. Original: the function the name's slots reached before the install (the replacement calls it for the real work: calling the name itself would reach the replacement again); it stays valid after HookUninstall (a replacement still running on another thread may call it). State: the install's record, nil when not installed.
Members
Original: ptr: The function the name's slots reached before the install.State: ptr: The install's record; nil when not installed.
Constants
| Name | Declaration | Description |
|---|---|---|
ADAM_HOOK_EINVAL | const ADAM_HOOK_EINVAL: int32 = ADAM_ERRNO_EINVAL | HookErrno's EINVAL: a name or argument refused. |
ADAM_HOOK_EEXIST | const ADAM_HOOK_EEXIST: int32 = ADAM_ERRNO_EEXIST | HookErrno's EEXIST: the hook or the name is already installed. |
ADAM_HOOK_ENOENT | const ADAM_HOOK_ENOENT: int32 = ADAM_ERRNO_ENOENT | HookErrno's ENOENT: no loaded module defines the name. |
ADAM_HOOK_EACCES | const ADAM_HOOK_EACCES: int32 = ADAM_ERRNO_EACCES | HookErrno's EACCES: an import slot could not be written. |
ADAM_HOOK_ENOMEM | const ADAM_HOOK_ENOMEM: int32 = ADAM_ERRNO_ENOMEM | HookErrno's ENOMEM: out of memory. |
Routines
HookReal
func HookReal(var ASlot: ptr; const AName: ptr to const char): ptr
The C runtime's function AName (NUL-terminated), looked up the first time into ASlot (the hook's own pointer, nil until then); nil while the C runtime has no function of that name
Parameters
ASlot: the hook's own pointer: nil until the first call, then the functionAName: the function's C name
Returns: the function, or nil
func HookReal(var ASlot: ptr; const ALibrary: ptr to const char; const AName: ptr to const char): ptr
The function AName (NUL-terminated) of the library ALibrary (its NUL-terminated UTF-8 file name, "kernel32.dll"), looked up the first time into ASlot (nil until then) when the process has the library loaded (it is never loaded here); nil while it is not loaded or has no function of that name
Parameters
ASlot: the hook's own pointer: nil until the first call, then the functionALibrary: the library's file name ("kernel32.dll")AName: the function's C name
Returns: the function, or nil
HookErrno
func HookErrno(): int32
The calling thread's C errno after a HookInstall / HookUninstall that returned false (one of ADAM_HOOK_*; System.Runtime's CErrno)
Returns: the errno value
HookInstall
func HookInstall(var AHook: Hook; literal AName: ptr to const char; const AReplacement: ptr): bool
Installs a run-time hook: every call of AName (a NUL-terminated C name, as the modules import it) through a module's import slot reaches AReplacement (a routine of the same C signature, ptr(F)), in every module loaded now and every module the program loads later. AName is a literal parameter (BNF sec 4): a constant such as "getenv", or the caller's own literal parameter, so every name a program hooks is known when it links (a linux exe exports a stub per name, which every module loaded now or later binds to). On x86_64-linux-gnu an install from a shared object (.so) a C program loads reaches only the modules loaded at the install: glibc has no load notification, and a loaded object's own definition of a name interposes neither its host nor a library loaded later (a platform limit); install from the exe, or after the libraries load. Code that calls AName directly, not through an import slot, is not reached. One install per name at a time; installs and uninstalls run one at a time. True when installed (AHook.Original and AHook.State set; a name no module imports yet is installed for the modules loaded later); false with C's errno (HookErrno): ADAM_HOOK_EINVAL (nil or empty AName, nil AReplacement), ADAM_HOOK_EEXIST (AHook is installed, or AName already is), ADAM_HOOK_ENOENT (no loaded module defines AName), ADAM_HOOK_EACCES (a slot could not be written: every slot written is put back), ADAM_HOOK_ENOMEM
Parameters
AHook: the hook, zeroed (not installed); filled when installedAName: the C name, a compile-time constantAReplacement: the replacement,ptr(F)
Returns: true when installed; false with HookErrno set
Example: if not HookInstall(GGetenv, "getenv", ptr(MyGetenv)) then println("{}", HookErrno()); end;
HookUninstall
func HookUninstall(var AHook: Hook): bool
Uninstalls a run-time hook: every slot it wrote whose module is still loaded gets back exactly what it held; nothing else is written. AHook.State becomes nil; AHook.Original stays. True when uninstalled; false with C's errno (HookErrno): ADAM_HOOK_EINVAL (AHook is not installed), ADAM_HOOK_EACCES (a slot could not be written back: the hook stays installed, the slots that went back stay back), ADAM_HOOK_ENOMEM
Parameters
AHook: the installed hook
Returns: true when uninstalled; false with HookErrno set
System.HookIO
C's file calls on Adam streams
Import it with import System.HookIO;.
Constants
| Name | Declaration | Description |
|---|---|---|
ADAM_HOOKIO_EOF | const ADAM_HOOKIO_EOF: int32 = System.HookIO.Core.ADAM_HOOKIO_EOF | C's EOF: what the hooked stream calls return on a failure or at the end |
ADAM_HOOKIO_SEEK_SET | const ADAM_HOOKIO_SEEK_SET: int32 = System.HookIO.Core.ADAM_HOOKIO_SEEK_SET | C's SEEK_SET: fseek from the start. |
ADAM_HOOKIO_SEEK_CUR | const ADAM_HOOKIO_SEEK_CUR: int32 = System.HookIO.Core.ADAM_HOOKIO_SEEK_CUR | C's SEEK_CUR: fseek from the current position. |
ADAM_HOOKIO_SEEK_END | const ADAM_HOOKIO_SEEK_END: int32 = System.HookIO.Core.ADAM_HOOKIO_SEEK_END | C's SEEK_END: fseek from the end. |
ADAM_HOOKIO_WEOF | const ADAM_HOOKIO_WEOF: int32 = System.HookIO.Win64.ADAM_HOOKIO_WEOF | C's WEOF (the target's wint_t): what the hooked wide calls return on a failure. |
Routines
RegisterIO
func cpplink RegisterIO(const AIO: IO): string
Registers an IO under a new prefix: from now on fopen("<prefix>") and fopen("<prefix>/<any name>"), in the program or in any C library linked into it, opens it. Every open gets its own handle with its own place. The IO stays the caller's: the registry never closes it. The prefix, io://<n>; "" when AIO is nil or there is no room
Parameters
AIO: the IO
Returns: the prefix (io://<n>), or "" when AIO is nil or there is no room
Example: LPrefix := RegisterIO(LIO); LDoc := JSON.FromFile(LPrefix + "/doc.json");
RegisterIOSource
func cpplink RegisterIOSource(const ASource: IOSource): string
Registers an IOSource under a new prefix: from now on fopen("<prefix>/<entry>"), in the program or in any C library linked into it, opens that entry of the source (IOSourceOpen). The source stays the caller's: the registry never closes it. The prefix, io://<n>; "" when ASource is nil or there is no room
Parameters
ASource: the source
Returns: the prefix (io://<n>), or "" when ASource is nil or there is no room
UnregisterIO
func cpplink UnregisterIO(const APrefix: string): bool
Removes a prefix: opening a path under it fails as a missing file does (ENOENT) from now on. Handles already open stay as they are; close them before closing what was registered. True when APrefix (exactly what RegisterIO / RegisterIOSource returned) was registered
Parameters
APrefix: exactly what RegisterIO / RegisterIOSource returned
Returns: true when it was registered
FileIO
func cpplink FileIO(const AFile: ptr): IO
The IO behind a handle a hooked open returned: the registered IO, or the entry's IO for a source; nil for a C runtime FILE or nil
Parameters
AFile: the C stream (a FILE pointer)
Returns: the IO, or nil
SetIOPathSource
func cpplink SetIOPathSource(const ASource: IOSource): bool
Makes an IOSource the path source: while it is set, a plain path (not io://) that a hooked open names, in the program or in any C library linked into it, is looked up in the source first, as an entry name (a separator as '/': on Windows '\' is one; every leading "./" or separator dropped). When the source has that entry, the path opens as <prefix>/<entry> would; otherwise it goes to the real file system untouched. While a hooked open runs, the files a source opens itself reach the real file system. One setting for the whole program; setting a source replaces the one before. The source stays the caller's: unset it (nil) before closing it. CustomIO's file IO and folder source always mean the disk. False when the source could not be registered (no room): nothing changed
Parameters
ASource: the source; nil to unset it
Returns: false when it could not be registered
SetIOThreadPathSource
func cpplink SetIOThreadPathSource(const ASource: IOSource): bool
Makes an IOSource the calling thread's own path source: while it is set, a plain path that a hooked open names on this thread is looked up in it, as SetIOPathSource describes, instead of in the program's path source; every other thread keeps the program's. A loader that pulls in files by plain relative paths sets one for the load and unsets it after, without moving the program's path source under another thread. Set and unset it on the same thread, unset it (nil) before the thread ends and before closing the source; nil: the program's path source applies to this thread again. False when the source could not be registered (no room): nothing changed
Parameters
ASource: the source; nil to unset it
Returns: false when it could not be registered
GetIOThreadPathSource
func cpplink GetIOThreadPathSource(): IOSource
The calling thread's own path source, as SetIOThreadPathSource last set it on this thread, so a loader can set its own for a call and put the caller's back after; nil when none is set on this thread (the program's path source, if any, applies)
Returns: the source, or nil
System.HookIO.Core
what every HookIO platform unit shares
Import it with import System.HookIO.Core;.
Types
HookStreamLock
type HookStreamLock = record
The lock every handle on one stream shares: a registered IO's (Listed: one per IO in GStreamLocks however often the IO is registered) or a source entry's handle's own. Users: the entries and handles that hold it; it goes with its last user
Members
Stream: ptr to IOStream: The registered IO it guards (nil for a handle's own).Listed: bool: True when listed in GStreamLocks (a registered IO's).Users: int64: The entries and handles that hold it.Lock: mutex: The lock itself.
HookEntry
type HookEntry = record
A registered prefix: exactly one of Stream (RegisterIO, with its stream lock) and Source (RegisterIOSource)
Members
Id: uint64: The prefix number.Stream: ptr to IOStream: The registered IO (RegisterIO), or nil.Source: ptr to IOSourceRecord: The registered source (RegisterIOSource), or nil.Lock: ptr to HookStreamLock: The IO's stream lock (nil for a source).
HookQuery
type HookQuery = record
What a query found at a virtual path (DoQuery): whether the file exists, its size (0 when the IO cannot tell) and whether a write open that empties nothing ("r+") would succeed
Members
Found: bool: True when the file exists.Size: int64: Its size in bytes (0 when the IO cannot tell).Writable: bool: True when an "r+" open would succeed.
HookEntryUse
type HookEntryUse = record
How open handles use one source entry (ucrt's share rules for D): the plain and the D handles, counted before the entry opens; Removing while its last D close removes it
Members
Source: ptr to IOSourceRecord: The source.EntryName: string: The entry's name.Plain: int64: How many plain handles use it.Temporary: int64: How many D handles use it.Removing: bool: True while its last D close removes it.
HookOpenMode
type HookOpenMode = record
What a mode string asks for, as ucrt's fopen reads it. First: 'r', 'w' or 'a'. Mode: r Read, w Write, a Append, any with + ReadWrite (First then says whether the open empties, w, or appends, a). Text: reads and writes translate. Exclusive: x. Temporary: D. Encoded: a ccs= part, Encoding its name (1 UTF-8, 2 UTF-16LE, 3 UNICODE)
Members
First: char: The mode's first letter: 'r', 'w' or 'a'.Mode: FileMode: The FileMode it opens with.Plus: bool: True with '+'.Text: bool: True when reads and writes translate.Exclusive: bool: True with 'x'.Temporary: bool: True with 'D'.Encoded: bool: True with a ccs= part.Encoding: int32: The ccs= encoding: 1 UTF-8, 2 UTF-16LE, 3 UNICODE.
HookStream
type HookStream = record
A handle's neutral part, what the core opens fill: Stream (the IO it reads and writes), Owned (the handle opened Stream itself, a source entry, and closes it), Position (its place in Stream), Lock (the stream lock guarding Stream), Source / EntryName / Temporary (the source entry it holds a use of and whether with D; Source nil on a registered IO and once the use is given back), OwnedSource (a folder IOSource the handle made for itself, closed once the entry use is given back)
Members
Stream: ptr to IOStream: The IO it reads and writes.Owned: bool: True when the handle opened Stream itself and closes it.Position: int64: Its place in Stream.Lock: ptr to HookStreamLock: The stream lock guarding Stream.Source: ptr to IOSourceRecord: The source entry's source (nil on a registered IO, and once the use is given back).EntryName: string: The source entry's name.Temporary: bool: True when it holds a D use.OwnedSource: ptr to IOSourceRecord: A folder IOSource the handle made for itself, or nil.
Constants
| Name | Declaration | Description |
|---|---|---|
ADAM_HOOKIO_EOF | const ADAM_HOOKIO_EOF: int32 = -1 | C's EOF: what the hooked stream calls return on a failure or at the end |
ADAM_HOOKIO_SEEK_SET | const ADAM_HOOKIO_SEEK_SET: int32 = 0 | C's SEEK_SET: fseek from the start. |
ADAM_HOOKIO_SEEK_CUR | const ADAM_HOOKIO_SEEK_CUR: int32 = 1 | C's SEEK_CUR: fseek from the current position. |
ADAM_HOOKIO_SEEK_END | const ADAM_HOOKIO_SEEK_END: int32 = 2 | C's SEEK_END: fseek from the end. |
Variables
| Name | Declaration | Description |
|---|---|---|
GLock | var GLock: mutex | The registry lock: the entries, the stream locks, the open list and the entry uses. Never held while CustomIO runs: a source that opens files comes back through these hooks |
Routines
HookIOReleaseLock
func cpplink HookIOReleaseLock(const ALock: ptr to HookStreamLock)
Gives back one user of ALock (nil: nothing); its last user takes it out of GStreamLocks and frees it
Parameters
ALock: the lock; nil for nothing
HookIOStreamLockOf
func cpplink HookIOStreamLockOf(const AStream: IO): ptr to HookStreamLock
AStream's shared stream lock with one more user, made on first use (the caller holds GLock); nil when there is no room. One IO has one lock however often it is registered, also after an unregister while its handles stay open
Parameters
AStream: the registered IO
Returns: the lock, or nil
HookIOOwnLock
func cpplink HookIOOwnLock(): ptr to HookStreamLock
A stream lock of a handle's own, with the handle as its one user (a source entry's IO is that handle's alone); nil when there is no room
Returns: the lock, or nil
HookIOIsSeparator
func cpplink HookIOIsSeparator(const AChar: char): bool
True when AChar separates a path's folders on the target: '/' on every target, '\' too on x86_64-windows-gnu (on x86_64-linux-gnu '\' is a byte of a name like any other)
Parameters
AChar: the character
Returns: true for a separator
HookIOSchemeAt
func cpplink HookIOSchemeAt(const APath: string; const AFrom: int64): bool
True when APath from AFrom on starts with the scheme: "io:" and two separators of the target (HookIOIsSeparator)
Parameters
APath: the pathAFrom: where to look
Returns: true when the scheme starts there
HookIOParse
func cpplink HookIOParse(const APath: string; const AFrom: int64; var AId: uint64; var ARest: string): bool
True when APath from AFrom on is virtual (starts with io://, HookIOSchemeAt). AId: its prefix number, 0 when the number is missing, has a leading zero, passes uint64 or is followed by anything but the end or a separator (no prefix is 0, so the path is a missing file). ARest: what follows the number, "" or "/<name>", each separator in it written '/'
Parameters
APath: the pathAFrom: where it startsAId: receives the prefix numberARest: receives what follows it
Returns: true for a virtual path
HookIOSkipCurrentFolder
func cpplink HookIOSkipCurrentFolder(const APath: string): int64
Where APath's io:// path starts when every leading "./" (on Windows ".\" too, the same step: HookIOIsSeparator) is followed by one, else 0. A C library joining a folder with no root and a name writes "./<folder>" (raylib's GetDirectoryPath), so "./io://3/a.png" names "io://3/a.png"
Parameters
APath: the path
Returns: the io:// path's place, or 0
HookIOJoinWorkFolder
func cpplink HookIOJoinWorkFolder(const APath: string): string
APath joined to the working folder a hooked chdir set: a relative path (not DoRootedPath) becomes "<folder>/<path>"; any other path, or every path while none is set or inside HookIO's own path work, is APath itself
Parameters
APath: the path
Returns: the joined path
HookIOWorkFolder
func cpplink HookIOWorkFolder(): string
The working folder a hooked chdir set ("" for none: the C runtime's applies)
Returns: the folder, or ""
HookIOClearWorkFolder
func cpplink HookIOClearWorkFolder()
The C runtime's working folder applies again (a real chdir succeeded)
HookIOIsVirtual
func cpplink HookIOIsVirtual(const APath: string): bool
True when APath names a virtual path (io://, after HookIOSkipCurrentFolder; a relative path in an io:// working folder too, HookIOJoinWorkFolder)
Parameters
APath: the path
Returns: true for a virtual path
HookIOFind
func cpplink HookIOFind(const AId: uint64; var AEntry: HookEntry): bool
The registered entry of AId copied out under the lock, its stream lock with one more user (the open gives it back when it is done); false when none
Parameters
AId: the prefix numberAEntry: receives the entry
Returns: false when none is registered
HookIORegisterWithId
func cpplink HookIORegisterWithId(const AStream: IO; const ASource: IOSource; var AId: uint64): string
Registers one stream under the next prefix number, AId that number (0 when nothing is registered); "" when both are nil or there is no room. The prefix text is built before the entry is added, so a failure registers nothing
Parameters
AStream: the IO, or nilASource: the source, or nilAId: receives the prefix number
Returns: the prefix, or ""
HookIORegister
func cpplink HookIORegister(const AStream: IO; const ASource: IOSource): string
Registers one stream under the next prefix number, as HookIORegisterWithId
Parameters
AStream: the IO, or nilASource: the source, or nil
Returns: the prefix, or ""
HookIOUnregisterId
func cpplink HookIOUnregisterId(const AId: uint64): bool
Removes the entry of prefix number AId; false when none is registered under it
Parameters
AId: the prefix number
Returns: false when none is registered under it
HookIOUnregister
func cpplink HookIOUnregister(const APrefix: string): bool
Removes a registered prefix (exactly io://<n>); false when it is not one
Parameters
APrefix: the prefix
Returns: false when it is not one
HookIOPathSourceIdOf
func cpplink HookIOPathSourceIdOf(const ASource: IOSource; var AId: uint64): bool
The prefix number of a source registered for a path source (nil: 0, nothing registered); false when there is no room, nothing registered
Parameters
ASource: the source; nil for noneAId: receives the prefix number
Returns: false when there is no room
HookIOSetPathSource
func cpplink HookIOSetPathSource(const ASource: IOSource): bool
Makes ASource the program's path source (nil: none). It is registered under a prefix of its own first (false, nothing changed, when that fails); the one it replaces is unregistered after the swap, so a lookup meanwhile sees either source, never neither by mistake
Parameters
ASource: the source; nil for none
Returns: false when it could not be registered
HookIOSetThreadPathSource
func cpplink HookIOSetThreadPathSource(const ASource: IOSource): bool
Makes ASource this thread's own path source (nil: none, the program's applies again), as HookIOSetPathSource; only this thread reads GThreadPathSourceId, so the swap needs no atomic
Parameters
ASource: the source; nil for none
Returns: false when it could not be registered
HookIOThreadPathSource
func cpplink HookIOThreadPathSource(): IOSource
The source this thread's own path source was set from (nil: none set)
Returns: the source, or nil
HookIOResetPathSourceIf
func cpplink HookIOResetPathSourceIf(const ASource: IOSource): bool
Unsets the program's path source only while it is still ASource (a loader that set one for the program unsets its own, never one the program set since): true when it was ASource and is unset now; the swap is one compare-and-swap, so a SetIOPathSource meanwhile wins
Parameters
ASource: the source it must still be
Returns: true when it was and is unset now
HookIOActivePathSourceId
func cpplink HookIOActivePathSourceId(): uint64
The prefix number a plain path on this thread is looked up in: the thread's own path source when one is set, else the program's (0: none)
Returns: the prefix number, or 0
HookIOPathSourceActive
func cpplink HookIOPathSourceActive(): bool
True when a plain path may be looked up in a path source: one is set (this thread's own or the program's) and this thread is not inside HookIO's own path work. CustomIO's own file system work needs no such check: it opens and queries its files through System.Runtime's file handles and paths, never a hooked C name, so its file IO and folder source never come back through these hooks
Returns: true when a lookup may happen
HookIOPathEntryName
func cpplink HookIOPathEntryName(const APath: string): string
A plain path as an entry name of the path source: a separator turned to '/' (on Windows '\' is one: HookIOIsSeparator), and every leading "./" or separator dropped (a source's names are relative), as raylib's file callbacks name them; "" when nothing is left
Parameters
APath: the path
Returns: the entry name, or ""
HookIOChangeFolder
func cpplink HookIOChangeFolder(const APath: string): bool
A hooked chdir to APath (joined to the working folder first): true when APath is a folder of a registered source (io://<n>[/<folder>]) or of the path source, which becomes the working folder (a source wins over the disk, as HookIOResolve's lookup does); false for anything else, the C runtime's chdir to answer it. Inside HookIO's own path work, false
Parameters
APath: the folder
Returns: true when it became the working folder
HookIOResolve
func cpplink HookIOResolve(const APath: string; var AId: uint64; var ARest: string): bool
As HookIOParse (after HookIOSkipCurrentFolder), and a plain path the path source holds (this thread's own when set, else the program's): then AId is that source's prefix number and ARest "/<entry>". A relative path is joined to the working folder first. A plain path the source lacks (or any path while no source is set, or inside HookIO's own path work) is false: the C runtime gets it
Parameters
APath: the pathAId: receives the prefix numberARest: receives the rest
Returns: false when the C runtime gets it
HookIOFindEntryUse
func cpplink HookIOFindEntryUse(const ASource: IOSource; const AEntry: string): int64
The place of ASource's entry AEntry in GEntryUses (the caller holds GLock), or -1
Parameters
ASource: the sourceAEntry: the entry
Returns: the place, or -1
HookIODropEntryUseAt
func cpplink HookIODropEntryUseAt(const AAt: int64)
Takes the use record at AAt out of GEntryUses (the caller holds GLock) and frees it
Parameters
AAt: the place
HookIOReserveEntry
func cpplink HookIOReserveEntry(const ASource: IOSource; const AEntry: string; const ATemporary: bool): bool
Takes a use of a source entry before it is opened (ucrt's share rules for D: a D open asks DELETE access and shares deletion, every other open shares reading and writing only, so a D handle and a plain one refuse each other). False with errno set: EACCES when the other kind holds it, ENOENT while its last D close is removing it, ENOMEM
Parameters
ASource: the sourceAEntry: the entryATemporary: true for a D open
Returns: false with errno set
HookIOReleaseEntry
func cpplink HookIOReleaseEntry(const ASource: IOSource; const AEntry: string; const ATemporary: bool; const ARemove: bool): bool
Gives a use back. True when it was the entry's last D use and ARemove asks for the removal: the entry is then marked Removing and the caller removes it (HookIOFinishRemove). ARemove is false when the open that took the use failed before its IO was opened
Parameters
ASource: the sourceAEntry: the entryATemporary: true for a D useARemove: true when the removal may happen
Returns: true when the caller removes the entry
HookIOFinishRemove
func cpplink HookIOFinishRemove(const ASource: IOSource; const AEntry: string)
Removes an entry whose last D handle closed (GLock is not held: the source runs), then forgets its use. The result is not reported: ucrt's fclose cannot see whether the OS deleted the file either
Parameters
ASource: the sourceAEntry: the entry
HookIOGiveBackEntry
func cpplink HookIOGiveBackEntry(const AHandle: ptr to HookStream; const ARemove: bool)
Gives back the entry use a handle holds, once (Source is cleared), and removes the entry when that was its last D handle. A no-op on a registered IO
Parameters
AHandle: the handleARemove: true when the removal may happen
HookIOEntryName
func cpplink HookIOEntryName(const ARest: string): string
The entry name in a path's rest after the prefix: "/<entry>" -> "<entry>"
Parameters
ARest: the rest after the prefix
Returns: the entry name
HookIOExists
func cpplink HookIOExists(const AEntry: HookEntry; const ARest: string): bool
True when the open's target exists: always for a registered IO (every name under its prefix is that IO), IOSourceExists for a source entry
Parameters
AEntry: the registered entryARest: the rest after its prefix
Returns: true when it exists
HookIOEmptyIO
func cpplink HookIOEmptyIO(const AHandle: ptr to HookStream): bool
w / w+ empty the handle's IO, as the C runtime's open truncates the file (on a registered IO every other handle sees it emptied). An IO that cannot write refuses the open with EACCES (a read-only file); one that cannot be emptied (no Truncate, or a failed one) with ucrt's EINVAL for a file it cannot truncate. An IO that cannot seek is a pipe: there is nothing to empty (the OS opens a pipe or a FIFO for writing without truncating it) and the open goes on. False with errno set; the handle starts at 0
Parameters
AHandle: the handle
Returns: false with errno set
HookIOCreateEntry
func cpplink HookIOCreateEntry(const ASource: IOSource; const AEntry: string; const AParsed: HookOpenMode): bool
w+ / a+ on a source entry: CustomIO has no mode that creates AND reads, so a missing entry is created first by IOSourceOpen in Write (w+) or Append (a+) and closed at once; the handle then opens it ReadWrite. False with errno set: ENOENT when the source would not create it, EIO when closing the new entry failed
Parameters
ASource: the sourceAEntry: the entryAParsed: the open's mode
Returns: false with errno set
HookIOTemporaryAllowed
func cpplink HookIOTemporaryAllowed(const ASource: IOSource; const AEntry: string; const AParsed: HookOpenMode): bool
ucrt's D open asks DELETE access, which a file that cannot be deleted refuses with EACCES before anything is opened. For an entry: a source that cannot remove entries (a zip), or an existing entry that does not open for writing. A missing entry opened with r is left to the open's own ENOENT. False with errno set
Parameters
ASource: the sourceAEntry: the entryAParsed: the open's mode
Returns: false with errno set
HookIOOpenShared
func cpplink HookIOOpenShared(const AEntry: HookEntry; const AParsed: HookOpenMode; const AHandle: ptr to HookStream): bool
A handle on a registered IO, sharing the entry's stream lock (one more user for the handle). An open that writes refuses an IO that cannot write (EACCES); w / w+ empty the IO (HookIOEmptyIO); every handle starts at 0 (an appending one is placed by its platform unit)
Parameters
AEntry: the registered entryAParsed: the open's modeAHandle: the handle to fill
Returns: false with errno set
HookIOOpenEntryIO
func cpplink HookIOOpenEntryIO(const ASource: IOSource; const AEntry: string; const AParsed: HookOpenMode; const AHandle: ptr to HookStream): bool
A handle's IO on the source entry AEntry; the handle owns the IO and a stream lock of its own. w+ / a+ open it ReadWrite (HookIOCreateEntry first), w+ then empties it (HookIOEmptyIO). A failed open sets errno: EACCES when the entry exists (the source does not offer that mode), ENOENT otherwise (missing, or a path IOSourceOpen refuses)
Parameters
ASource: the sourceAEntry: the entryAParsed: the open's modeAHandle: the handle to fill
Returns: false with errno set
HookIOOpenEntry
func cpplink HookIOOpenEntry(const ASource: IOSource; const ARest: string; const AParsed: HookOpenMode; const AHandle: ptr to HookStream): bool
A handle on a source entry (HookIOOpenEntryIO): the handle takes a use of the entry first (ucrt's share rules for D, HookIOReserveEntry) and a D open checks the entry can be removed (HookIOTemporaryAllowed); the handle keeps the entry and gives the use back at its close
Parameters
ASource: the sourceARest: the rest after its prefixAParsed: the open's modeAHandle: the handle to fill
Returns: false with errno set
HookIOCloseOwnedSource
func cpplink HookIOCloseOwnedSource(const AHandle: ptr to HookStream): bool
Closes the folder source a handle made for itself (a freopen onto a real path, DoReopen), once its entry use is given back. False when closing the source failed
Parameters
AHandle: the handle
Returns: false when closing the source failed
HookIOQuery
func cpplink HookIOQuery(const APath: string; var AQuery: HookQuery): bool
The query family (access, stat, GetFileAttributesA) answers a virtual path, or one the path source holds (HookIOResolve), as fopen would find it. False: neither, the caller passes it to the C runtime. True: answered in AQuery; a missing file sets errno ENOENT, a found one leaves errno as the caller had it. Writable: a write open that empties nothing ("r+") would succeed: on a registered IO when it can write (IOCanWrite, as HookIOOpenShared refuses), on a source entry when IOSourceOpen gives it in ReadWrite (opened and closed at once). Under a registered IO's prefix every name is that IO; a source entry exists when IOSourceExists says so. Directories are not answered: CustomIO has no directory query, and a source's root is a missing file, as opendir finds it. GLock is never held while CustomIO runs
Parameters
APath: the pathAQuery: receives the answer
Returns: false when the C runtime answers it
HookIOEnterPathWork
func cpplink HookIOEnterPathWork()
Enters HookIO's own path work on this thread (a hooked open's or a query's): until the matching HookIOLeavePathWork a plain path is never looked up in a path source, so a source's own opens reach the real file system
HookIOLeavePathWork
func cpplink HookIOLeavePathWork()
Leaves the path work HookIOEnterPathWork entered
System.HookIO.Linux64
System.HookIO's platform unit for x86_64-linux-gnu: glibc's C file calls on Adam streams
Import it with import System.HookIO.Linux64;.
Constants
| Name | Declaration | Description |
|---|---|---|
ADAM_HOOKIO_WEOF | const ADAM_HOOKIO_WEOF: int32 = -1 | C's WEOF (glibc's wint_t is 32 bits, WEOF 0xFFFFFFFF): what the hooked wide calls return on a failure |
Routines
HookIOStreamOf
func HookIOStreamOf(const AFile: ptr): IO
The IO behind a handle a hooked open returned: the registered IO, or the entry's IO for a source; nil for a C runtime FILE or nil (System.HookIO's FileIO)
Parameters
AFile: the C stream (a FILE pointer)
Returns: the IO, or nil
fopen
func fopen(const APath: ptr to const char; const AMode: ptr to const char): ptr
C's fopen, hooked: a virtual path opens a handle
Parameters
APath: as C'sfopentakes itAMode: as C'sfopentakes it
Returns: as C's fopen returns it
fopen64
func fopen64(const APath: ptr to const char; const AMode: ptr to const char): ptr
C's fopen64, hooked. fopen64 (a large-file open: the same on a 64-bit target)
Parameters
APath: as C'sfopen64takes itAMode: as C'sfopen64takes it
Returns: as C's fopen64 returns it
freopen
func freopen(const APath: ptr to const char; const AMode: ptr to const char; const AFile: ptr): ptr
C's freopen, hooked: a handle is reopened in place, whatever the path; a real FILE goes to the C runtime, whatever the path
Parameters
APath: as C'sfreopentakes itAMode: as C'sfreopentakes itAFile: as C'sfreopentakes it
Returns: as C's freopen returns it
freopen64
func freopen64(const APath: ptr to const char; const AMode: ptr to const char; const AFile: ptr): ptr
C's freopen64, hooked: freopen
Parameters
APath: as C'sfreopen64takes itAMode: as C'sfreopen64takes itAFile: as C'sfreopen64takes it
Returns: as C's freopen64 returns it
fclose
func fclose(const AFile: ptr): int32
C's fclose, hooked: a handle is closed (its own IO with it), anything else goes to the C runtime
Parameters
AFile: as C'sfclosetakes it
Returns: as C's fclose returns it
pclose
func pclose(const AFile: ptr): int32
C's pclose, hooked: glibc's is fclose of the stream (a popen one waits for its process): a handle closes
Parameters
AFile: as C'spclosetakes it
Returns: as C's pclose returns it
fread
func fread(const ABuffer: ptr; const ASize: int64; const ACount: int64; const AFile: ptr): int64
C's fread, hooked. fread and fread_unlocked: a handle reads through its libio model (size_t's bits in int64, as System.HookIO.Win64 takes them)
Parameters
ABuffer: as C'sfreadtakes itASize: as C'sfreadtakes itACount: as C'sfreadtakes itAFile: as C'sfreadtakes it
Returns: as C's fread returns it
fread_unlocked
func fread_unlocked(const ABuffer: ptr; const ASize: int64; const ACount: int64; const AFile: ptr): int64
C's fread_unlocked, hooked.
Parameters
ABuffer: as C'sfread_unlockedtakes itASize: as C'sfread_unlockedtakes itACount: as C'sfread_unlockedtakes itAFile: as C'sfread_unlockedtakes it
Returns: as C's fread_unlocked returns it
__fread_chk
func __fread_chk(const ABuffer: ptr; const ABufferSize: uint64; const ASize: uint64; const ACount: uint64; const AFile: ptr): uint64
C's __fread_chk, hooked. __fread_chk / __fread_unlocked_chk (C built with -D_FORTIFY_SOURCE): glibc's check, then fread
Parameters
ABuffer: as C's__fread_chktakes itABufferSize: as C's__fread_chktakes itASize: as C's__fread_chktakes itACount: as C's__fread_chktakes itAFile: as C's__fread_chktakes it
Returns: as C's __fread_chk returns it
__fread_unlocked_chk
func __fread_unlocked_chk(const ABuffer: ptr; const ABufferSize: uint64; const ASize: uint64; const ACount: uint64; const AFile: ptr): uint64
C's __fread_unlocked_chk, hooked.
Parameters
ABuffer: as C's__fread_unlocked_chktakes itABufferSize: as C's__fread_unlocked_chktakes itASize: as C's__fread_unlocked_chktakes itACount: as C's__fread_unlocked_chktakes itAFile: as C's__fread_unlocked_chktakes it
Returns: as C's __fread_unlocked_chk returns it
fwrite
func fwrite(const ABuffer: ptr; const ASize: int64; const ACount: int64; const AFile: ptr): int64
C's fwrite, hooked. fwrite and fwrite_unlocked: a handle writes through its libio model
Parameters
ABuffer: as C'sfwritetakes itASize: as C'sfwritetakes itACount: as C'sfwritetakes itAFile: as C'sfwritetakes it
Returns: as C's fwrite returns it
fwrite_unlocked
func fwrite_unlocked(const ABuffer: ptr; const ASize: int64; const ACount: int64; const AFile: ptr): int64
C's fwrite_unlocked, hooked.
Parameters
ABuffer: as C'sfwrite_unlockedtakes itASize: as C'sfwrite_unlockedtakes itACount: as C'sfwrite_unlockedtakes itAFile: as C'sfwrite_unlockedtakes it
Returns: as C's fwrite_unlocked returns it
fgetc
func fgetc(const AFile: ptr): int32
C's fgetc, hooked. The byte reads: getc's macro body on a handle (the get area's byte, else __uflow)
Parameters
AFile: as C'sfgetctakes it
Returns: as C's fgetc returns it
getc
func getc(const AFile: ptr): int32
C's getc, hooked.
Parameters
AFile: as C'sgetctakes it
Returns: as C's getc returns it
fgetc_unlocked
func fgetc_unlocked(const AFile: ptr): int32
C's fgetc_unlocked, hooked.
Parameters
AFile: as C'sfgetc_unlockedtakes it
Returns: as C's fgetc_unlocked returns it
getc_unlocked
func getc_unlocked(const AFile: ptr): int32
C's getc_unlocked, hooked.
Parameters
AFile: as C'sgetc_unlockedtakes it
Returns: as C's getc_unlocked returns it
_IO_getc
func _IO_getc(const AFile: ptr): int32
C's _IO_getc, hooked.
Parameters
AFile: as C's_IO_getctakes it
Returns: as C's _IO_getc returns it
getw
func getw(const AFile: ptr): int32
C's getw, hooked: an int's bytes (EOF when fewer came)
Parameters
AFile: as C'sgetwtakes it
Returns: as C's getw returns it
_IO_peekc_locked
func _IO_peekc_locked(const AFile: ptr): int32
C's _IO_peekc_locked, hooked: the next byte, not taken
Parameters
AFile: as C's_IO_peekc_lockedtakes it
Returns: as C's _IO_peekc_locked returns it
__uflow
func __uflow(const AFile: ptr): int32
C's __uflow, hooked. __uflow / __underflow: where glibc's inline getc_unlocked falls when the get area is empty (a handle's always is)
Parameters
AFile: as C's__uflowtakes it
Returns: as C's __uflow returns it
__underflow
func __underflow(const AFile: ptr): int32
C's __underflow, hooked.
Parameters
AFile: as C's__underflowtakes it
Returns: as C's __underflow returns it
fgets
func fgets(const AText: ptr to char; const ACount: int32; const AFile: ptr): ptr to char
C's fgets, hooked. fgets and fgets_unlocked: up to ACount - 1 bytes, to and with a newline
Parameters
AText: as C'sfgetstakes itACount: as C'sfgetstakes itAFile: as C'sfgetstakes it
Returns: as C's fgets returns it
fgets_unlocked
func fgets_unlocked(const AText: ptr to char; const ACount: int32; const AFile: ptr): ptr to char
C's fgets_unlocked, hooked.
Parameters
AText: as C'sfgets_unlockedtakes itACount: as C'sfgets_unlockedtakes itAFile: as C'sfgets_unlockedtakes it
Returns: as C's fgets_unlocked returns it
__fgets_chk
func __fgets_chk(const AText: ptr to char; const ASize: uint64; const ACount: int32; const AFile: ptr): ptr to char
C's __fgets_chk, hooked. __fgets_chk / __fgets_unlocked_chk (C built with -D_FORTIFY_SOURCE)
Parameters
AText: as C's__fgets_chktakes itASize: as C's__fgets_chktakes itACount: as C's__fgets_chktakes itAFile: as C's__fgets_chktakes it
Returns: as C's __fgets_chk returns it
__fgets_unlocked_chk
func __fgets_unlocked_chk(const AText: ptr to char; const ASize: uint64; const ACount: int32; const AFile: ptr): ptr to char
C's __fgets_unlocked_chk, hooked.
Parameters
AText: as C's__fgets_unlocked_chktakes itASize: as C's__fgets_unlocked_chktakes itACount: as C's__fgets_unlocked_chktakes itAFile: as C's__fgets_unlocked_chktakes it
Returns: as C's __fgets_unlocked_chk returns it
getdelim
func getdelim(const ALine: ptr to ptr; const ASize: ptr to uint64; const ADelim: int32; const AFile: ptr): int64
C's getdelim, hooked. getdelim / __getdelim / getline: a whole line into the caller's malloc'd buffer
Parameters
ALine: as C'sgetdelimtakes itASize: as C'sgetdelimtakes itADelim: as C'sgetdelimtakes itAFile: as C'sgetdelimtakes it
Returns: as C's getdelim returns it
__getdelim
func __getdelim(const ALine: ptr to ptr; const ASize: ptr to uint64; const ADelim: int32; const AFile: ptr): int64
C's __getdelim, hooked.
Parameters
ALine: as C's__getdelimtakes itASize: as C's__getdelimtakes itADelim: as C's__getdelimtakes itAFile: as C's__getdelimtakes it
Returns: as C's __getdelim returns it
getline
func getline(const ALine: ptr to ptr; const ASize: ptr to uint64; const AFile: ptr): int64
C's getline, hooked.
Parameters
ALine: as C'sgetlinetakes itASize: as C'sgetlinetakes itAFile: as C'sgetlinetakes it
Returns: as C's getline returns it
ungetc
func ungetc(const AChar: int32; const AFile: ptr): int32
C's ungetc, hooked: a byte given back (the backup area past the buffer's start)
Parameters
AChar: as C'sungetctakes itAFile: as C'sungetctakes it
Returns: as C's ungetc returns it
fputc
func fputc(const AChar: int32; const AFile: ptr): int32
C's fputc, hooked. The byte writes: putc's macro body on a handle (the put area's room, else __overflow)
Parameters
AChar: as C'sfputctakes itAFile: as C'sfputctakes it
Returns: as C's fputc returns it
putc
func putc(const AChar: int32; const AFile: ptr): int32
C's putc, hooked.
Parameters
AChar: as C'sputctakes itAFile: as C'sputctakes it
Returns: as C's putc returns it
fputc_unlocked
func fputc_unlocked(const AChar: int32; const AFile: ptr): int32
C's fputc_unlocked, hooked.
Parameters
AChar: as C'sfputc_unlockedtakes itAFile: as C'sfputc_unlockedtakes it
Returns: as C's fputc_unlocked returns it
putc_unlocked
func putc_unlocked(const AChar: int32; const AFile: ptr): int32
C's putc_unlocked, hooked.
Parameters
AChar: as C'sputc_unlockedtakes itAFile: as C'sputc_unlockedtakes it
Returns: as C's putc_unlocked returns it
_IO_putc
func _IO_putc(const AChar: int32; const AFile: ptr): int32
C's _IO_putc, hooked.
Parameters
AChar: as C's_IO_putctakes itAFile: as C's_IO_putctakes it
Returns: as C's _IO_putc returns it
putw
func putw(const AWord: int32; const AFile: ptr): int32
C's putw, hooked: an int's bytes (0, or EOF)
Parameters
AWord: as C'sputwtakes itAFile: as C'sputwtakes it
Returns: as C's putw returns it
__overflow
func __overflow(const AFile: ptr; const AChar: int32): int32
C's __overflow, hooked: where glibc's inline putc_unlocked falls when the put area is full (a handle's always is)
Parameters
AFile: as C's__overflowtakes itAChar: as C's__overflowtakes it
Returns: as C's __overflow returns it
fputs
func fputs(const AText: ptr to const char; const AFile: ptr): int32
C's fputs, hooked. fputs and fputs_unlocked: the text's bytes (1, or EOF)
Parameters
AText: as C'sfputstakes itAFile: as C'sfputstakes it
Returns: as C's fputs returns it
fputs_unlocked
func fputs_unlocked(const AText: ptr to const char; const AFile: ptr): int32
C's fputs_unlocked, hooked.
Parameters
AText: as C'sfputs_unlockedtakes itAFile: as C'sfputs_unlockedtakes it
Returns: as C's fputs_unlocked returns it
feof
func feof(const AFile: ptr): int32
C's feof, hooked. The flags: feof / ferror and their forms, clearerr
Parameters
AFile: as C'sfeoftakes it
Returns: as C's feof returns it
feof_unlocked
func feof_unlocked(const AFile: ptr): int32
C's feof_unlocked, hooked.
Parameters
AFile: as C'sfeof_unlockedtakes it
Returns: as C's feof_unlocked returns it
_IO_feof
func _IO_feof(const AFile: ptr): int32
C's _IO_feof, hooked.
Parameters
AFile: as C's_IO_feoftakes it
Returns: as C's _IO_feof returns it
ferror
func ferror(const AFile: ptr): int32
C's ferror, hooked.
Parameters
AFile: as C'sferrortakes it
Returns: as C's ferror returns it
ferror_unlocked
func ferror_unlocked(const AFile: ptr): int32
C's ferror_unlocked, hooked.
Parameters
AFile: as C'sferror_unlockedtakes it
Returns: as C's ferror_unlocked returns it
_IO_ferror
func _IO_ferror(const AFile: ptr): int32
C's _IO_ferror, hooked.
Parameters
AFile: as C's_IO_ferrortakes it
Returns: as C's _IO_ferror returns it
clearerr
func clearerr(const AFile: ptr)
C's clearerr, hooked.
Parameters
AFile: as C'sclearerrtakes it
clearerr_unlocked
func clearerr_unlocked(const AFile: ptr)
C's clearerr_unlocked, hooked.
Parameters
AFile: as C'sclearerr_unlockedtakes it
fseek
func fseek(const AFile: ptr; const AOffset: clong; const AOrigin: int32): int32
C's fseek, hooked. The seeks: fseek (C's long, as on every target: clong), fseeko and fseeko64 (off_t / off64_t: 64 bits)
Parameters
AFile: as C'sfseektakes itAOffset: as C'sfseektakes itAOrigin: as C'sfseektakes it
Returns: as C's fseek returns it
fseeko
func fseeko(const AFile: ptr; const AOffset: int64; const AOrigin: int32): int32
C's fseeko, hooked.
Parameters
AFile: as C'sfseekotakes itAOffset: as C'sfseekotakes itAOrigin: as C'sfseekotakes it
Returns: as C's fseeko returns it
fseeko64
func fseeko64(const AFile: ptr; const AOffset: int64; const AOrigin: int32): int32
C's fseeko64, hooked.
Parameters
AFile: as C'sfseeko64takes itAOffset: as C'sfseeko64takes itAOrigin: as C'sfseeko64takes it
Returns: as C's fseeko64 returns it
ftell
func ftell(const AFile: ptr): clong
C's ftell, hooked. The tells: ftell, ftello, ftello64
Parameters
AFile: as C'sftelltakes it
Returns: as C's ftell returns it
ftello
func ftello(const AFile: ptr): int64
C's ftello, hooked.
Parameters
AFile: as C'sftellotakes it
Returns: as C's ftello returns it
ftello64
func ftello64(const AFile: ptr): int64
C's ftello64, hooked.
Parameters
AFile: as C'sftello64takes it
Returns: as C's ftello64 returns it
rewind
func rewind(const AFile: ptr)
C's rewind, hooked: a seek to 0, then both flags cleared
Parameters
AFile: as C'srewindtakes it
fgetpos
func fgetpos(const AFile: ptr; const APos: ptr to fpos_t): int32
C's fgetpos, hooked. fgetpos / fsetpos and their 64 forms (one fpos_t on a 64-bit target)
Parameters
AFile: as C'sfgetpostakes itAPos: as C'sfgetpostakes it
Returns: as C's fgetpos returns it
fgetpos64
func fgetpos64(const AFile: ptr; const APos: ptr to fpos_t): int32
C's fgetpos64, hooked.
Parameters
AFile: as C'sfgetpos64takes itAPos: as C'sfgetpos64takes it
Returns: as C's fgetpos64 returns it
fsetpos
func fsetpos(const AFile: ptr; const APos: ptr to fpos_t): int32
C's fsetpos, hooked.
Parameters
AFile: as C'sfsetpostakes itAPos: as C'sfsetpostakes it
Returns: as C's fsetpos returns it
fsetpos64
func fsetpos64(const AFile: ptr; const APos: ptr to fpos_t): int32
C's fsetpos64, hooked.
Parameters
AFile: as C'sfsetpos64takes itAPos: as C'sfsetpos64takes it
Returns: as C's fsetpos64 returns it
fflush
func fflush(const AFile: ptr): int32
C's fflush, hooked.
Parameters
AFile: as C'sfflushtakes it
Returns: as C's fflush returns it
fflush_unlocked
func fflush_unlocked(const AFile: ptr): int32
C's fflush_unlocked, hooked.
Parameters
AFile: as C'sfflush_unlockedtakes it
Returns: as C's fflush_unlocked returns it
setvbuf
func setvbuf(const AFile: ptr; const ABuffer: ptr to char; const AMode: int32; const ASize: uint64): int32
C's setvbuf, hooked: the model's buffering (the caller's array used as glibc uses it)
Parameters
AFile: as C'ssetvbuftakes itABuffer: as C'ssetvbuftakes itAMode: as C'ssetvbuftakes itASize: as C'ssetvbuftakes it
Returns: as C's setvbuf returns it
setbuffer
func setbuffer(const AFile: ptr; const ABuffer: ptr to char; const ASize: uint64)
C's setbuffer, hooked.
Parameters
AFile: as C'ssetbuffertakes itABuffer: as C'ssetbuffertakes itASize: as C'ssetbuffertakes it
setbuf
func setbuf(const AFile: ptr; const ABuffer: ptr to char)
C's setbuf, hooked.
Parameters
AFile: as C'ssetbuftakes itABuffer: as C'ssetbuftakes it
setlinebuf
func setlinebuf(const AFile: ptr)
C's setlinebuf, hooked: setvbuf(_IOLBF) with no array
Parameters
AFile: as C'ssetlinebuftakes it
fileno
func fileno(const AFile: ptr): int32
C's fileno, hooked. fileno / fileno_unlocked: a handle's descriptor (DoDescriptorLocked: reserved at the first ask; -1 with errno when none can be)
Parameters
AFile: as C'sfilenotakes it
Returns: as C's fileno returns it
fileno_unlocked
func fileno_unlocked(const AFile: ptr): int32
C's fileno_unlocked, hooked.
Parameters
AFile: as C'sfileno_unlockedtakes it
Returns: as C's fileno_unlocked returns it
flockfile
func flockfile(const AFile: ptr)
C's flockfile, hooked. The stream locks: nothing on a handle (every call takes the handle's own lock)
Parameters
AFile: as C'sflockfiletakes it
funlockfile
func funlockfile(const AFile: ptr)
C's funlockfile, hooked.
Parameters
AFile: as C'sfunlockfiletakes it
ftrylockfile
func ftrylockfile(const AFile: ptr): int32
C's ftrylockfile, hooked.
Parameters
AFile: as C'sftrylockfiletakes it
Returns: as C's ftrylockfile returns it
fwide
func fwide(const AFile: ptr; const AMode: int32): int32
C's fwide, hooked: the orientation (AMode > 0 wide, < 0 byte, 0 only asks)
Parameters
AFile: as C'sfwidetakes itAMode: as C'sfwidetakes it
Returns: as C's fwide returns it
__fpending
func __fpending(const AFile: ptr): uint64
C's __fpending, hooked. stdio_ext.h's queries and __fpurge, on the model's fields as glibc reads them
Parameters
AFile: as C's__fpendingtakes it
Returns: as C's __fpending returns it
__freading
func __freading(const AFile: ptr): int32
C's __freading, hooked.
Parameters
AFile: as C's__freadingtakes it
Returns: as C's __freading returns it
__fwriting
func __fwriting(const AFile: ptr): int32
C's __fwriting, hooked.
Parameters
AFile: as C's__fwritingtakes it
Returns: as C's __fwriting returns it
__freadable
func __freadable(const AFile: ptr): int32
C's __freadable, hooked.
Parameters
AFile: as C's__freadabletakes it
Returns: as C's __freadable returns it
__fwritable
func __fwritable(const AFile: ptr): int32
C's __fwritable, hooked.
Parameters
AFile: as C's__fwritabletakes it
Returns: as C's __fwritable returns it
__flbf
func __flbf(const AFile: ptr): int32
C's __flbf, hooked.
Parameters
AFile: as C's__flbftakes it
Returns: as C's __flbf returns it
__fbufsize
func __fbufsize(const AFile: ptr): uint64
C's __fbufsize, hooked.
Parameters
AFile: as C's__fbufsizetakes it
Returns: as C's __fbufsize returns it
__fpurge
func __fpurge(const AFile: ptr)
C's __fpurge, hooked.
Parameters
AFile: as C's__fpurgetakes it
__fsetlocking
func __fsetlocking(const AFile: ptr; const AType: int32): int32
C's __fsetlocking, hooked: the stream's locking kind, _IO_USER_LOCK kept as glibc keeps it (1 FSETLOCKING_INTERNAL, 2 FSETLOCKING_BYCALLER; 0 only asks)
Parameters
AFile: as C's__fsetlockingtakes itAType: as C's__fsetlockingtakes it
Returns: as C's __fsetlocking returns it
fprintf
func fprintf(const AFile: ptr; const AFormat: ptr to const char; ...): int32
C's fprintf, hooked.
Parameters
AFile: as C'sfprintftakes itAFormat: as C'sfprintftakes it...: as C'sfprintftakes them
Returns: as C's fprintf returns it
vfprintf
func vfprintf(const AFile: ptr; const AFormat: ptr to const char; const AArgs: ptr): int32
C's vfprintf, hooked.
Parameters
AFile: as C'svfprintftakes itAFormat: as C'svfprintftakes itAArgs: as C'svfprintftakes it
Returns: as C's vfprintf returns it
__fprintf_chk
func __fprintf_chk(const AFile: ptr; const AFlag: int32; const AFormat: ptr to const char; ...): int32
C's __fprintf_chk, hooked.
Parameters
AFile: as C's__fprintf_chktakes itAFlag: as C's__fprintf_chktakes itAFormat: as C's__fprintf_chktakes it...: as C's__fprintf_chktakes them
Returns: as C's __fprintf_chk returns it
__vfprintf_chk
func __vfprintf_chk(const AFile: ptr; const AFlag: int32; const AFormat: ptr to const char; const AArgs: ptr): int32
C's __vfprintf_chk, hooked.
Parameters
AFile: as C's__vfprintf_chktakes itAFlag: as C's__vfprintf_chktakes itAFormat: as C's__vfprintf_chktakes itAArgs: as C's__vfprintf_chktakes it
Returns: as C's __vfprintf_chk returns it
fwprintf
func fwprintf(const AFile: ptr; const AFormat: ptr to const uint32; ...): int32
C's fwprintf, hooked.
Parameters
AFile: as C'sfwprintftakes itAFormat: as C'sfwprintftakes it...: as C'sfwprintftakes them
Returns: as C's fwprintf returns it
vfwprintf
func vfwprintf(const AFile: ptr; const AFormat: ptr to const uint32; const AArgs: ptr): int32
C's vfwprintf, hooked.
Parameters
AFile: as C'svfwprintftakes itAFormat: as C'svfwprintftakes itAArgs: as C'svfwprintftakes it
Returns: as C's vfwprintf returns it
__fwprintf_chk
func __fwprintf_chk(const AFile: ptr; const AFlag: int32; const AFormat: ptr to const uint32; ...): int32
C's __fwprintf_chk, hooked.
Parameters
AFile: as C's__fwprintf_chktakes itAFlag: as C's__fwprintf_chktakes itAFormat: as C's__fwprintf_chktakes it...: as C's__fwprintf_chktakes them
Returns: as C's __fwprintf_chk returns it
__vfwprintf_chk
func __vfwprintf_chk(const AFile: ptr; const AFlag: int32; const AFormat: ptr to const uint32; const AArgs: ptr): int32
C's __vfwprintf_chk, hooked.
Parameters
AFile: as C's__vfwprintf_chktakes itAFlag: as C's__vfwprintf_chktakes itAFormat: as C's__vfwprintf_chktakes itAArgs: as C's__vfwprintf_chktakes it
Returns: as C's __vfwprintf_chk returns it
fscanf
func fscanf(const AFile: ptr; const AFormat: ptr to const char; ...): int32
C's fscanf, hooked. The scans: glibc's own scan (vfscanf, __isoc99_vfscanf, and the wide ones) over a handle's stand-in, anything else straight to it
Parameters
AFile: as C'sfscanftakes itAFormat: as C'sfscanftakes it...: as C'sfscanftakes them
Returns: as C's fscanf returns it
vfscanf
func vfscanf(const AFile: ptr; const AFormat: ptr to const char; const AArgs: ptr): int32
C's vfscanf, hooked.
Parameters
AFile: as C'svfscanftakes itAFormat: as C'svfscanftakes itAArgs: as C'svfscanftakes it
Returns: as C's vfscanf returns it
__isoc99_fscanf
func __isoc99_fscanf(const AFile: ptr; const AFormat: ptr to const char; ...): int32
C's __isoc99_fscanf, hooked.
Parameters
AFile: as C's__isoc99_fscanftakes itAFormat: as C's__isoc99_fscanftakes it...: as C's__isoc99_fscanftakes them
Returns: as C's __isoc99_fscanf returns it
__isoc99_vfscanf
func __isoc99_vfscanf(const AFile: ptr; const AFormat: ptr to const char; const AArgs: ptr): int32
C's __isoc99_vfscanf, hooked.
Parameters
AFile: as C's__isoc99_vfscanftakes itAFormat: as C's__isoc99_vfscanftakes itAArgs: as C's__isoc99_vfscanftakes it
Returns: as C's __isoc99_vfscanf returns it
fwscanf
func fwscanf(const AFile: ptr; const AFormat: ptr to const uint32; ...): int32
C's fwscanf, hooked.
Parameters
AFile: as C'sfwscanftakes itAFormat: as C'sfwscanftakes it...: as C'sfwscanftakes them
Returns: as C's fwscanf returns it
vfwscanf
func vfwscanf(const AFile: ptr; const AFormat: ptr to const uint32; const AArgs: ptr): int32
C's vfwscanf, hooked.
Parameters
AFile: as C'svfwscanftakes itAFormat: as C'svfwscanftakes itAArgs: as C'svfwscanftakes it
Returns: as C's vfwscanf returns it
__isoc99_fwscanf
func __isoc99_fwscanf(const AFile: ptr; const AFormat: ptr to const uint32; ...): int32
C's __isoc99_fwscanf, hooked.
Parameters
AFile: as C's__isoc99_fwscanftakes itAFormat: as C's__isoc99_fwscanftakes it...: as C's__isoc99_fwscanftakes them
Returns: as C's __isoc99_fwscanf returns it
__isoc99_vfwscanf
func __isoc99_vfwscanf(const AFile: ptr; const AFormat: ptr to const uint32; const AArgs: ptr): int32
C's __isoc99_vfwscanf, hooked.
Parameters
AFile: as C's__isoc99_vfwscanftakes itAFormat: as C's__isoc99_vfwscanftakes itAArgs: as C's__isoc99_vfwscanftakes it
Returns: as C's __isoc99_vfwscanf returns it
fgetwc
func fgetwc(const AFile: ptr): uint32
C's fgetwc, hooked. The wide reads: fgetwc and its forms (WEOF at the end or on a failure)
Parameters
AFile: as C'sfgetwctakes it
Returns: as C's fgetwc returns it
getwc
func getwc(const AFile: ptr): uint32
C's getwc, hooked.
Parameters
AFile: as C'sgetwctakes it
Returns: as C's getwc returns it
fgetwc_unlocked
func fgetwc_unlocked(const AFile: ptr): uint32
C's fgetwc_unlocked, hooked.
Parameters
AFile: as C'sfgetwc_unlockedtakes it
Returns: as C's fgetwc_unlocked returns it
getwc_unlocked
func getwc_unlocked(const AFile: ptr): uint32
C's getwc_unlocked, hooked.
Parameters
AFile: as C'sgetwc_unlockedtakes it
Returns: as C's getwc_unlocked returns it
fgetws
func fgetws(const AText: ptr to uint32; const ACount: int32; const AFile: ptr): ptr to uint32
C's fgetws, hooked. fgetws and fgetws_unlocked: up to ACount - 1 characters, to and with a newline
Parameters
AText: as C'sfgetwstakes itACount: as C'sfgetwstakes itAFile: as C'sfgetwstakes it
Returns: as C's fgetws returns it
fgetws_unlocked
func fgetws_unlocked(const AText: ptr to uint32; const ACount: int32; const AFile: ptr): ptr to uint32
C's fgetws_unlocked, hooked.
Parameters
AText: as C'sfgetws_unlockedtakes itACount: as C'sfgetws_unlockedtakes itAFile: as C'sfgetws_unlockedtakes it
Returns: as C's fgetws_unlocked returns it
__fgetws_chk
func __fgetws_chk(const AText: ptr to uint32; const ASize: uint64; const ACount: int32; const AFile: ptr): ptr to uint32
C's __fgetws_chk, hooked.
Parameters
AText: as C's__fgetws_chktakes itASize: as C's__fgetws_chktakes itACount: as C's__fgetws_chktakes itAFile: as C's__fgetws_chktakes it
Returns: as C's __fgetws_chk returns it
__fgetws_unlocked_chk
func __fgetws_unlocked_chk(const AText: ptr to uint32; const ASize: uint64; const ACount: int32; const AFile: ptr): ptr to uint32
C's __fgetws_unlocked_chk, hooked.
Parameters
AText: as C's__fgetws_unlocked_chktakes itASize: as C's__fgetws_unlocked_chktakes itACount: as C's__fgetws_unlocked_chktakes itAFile: as C's__fgetws_unlocked_chktakes it
Returns: as C's __fgetws_unlocked_chk returns it
ungetwc
func ungetwc(const AChar: uint32; const AFile: ptr): uint32
C's ungetwc, hooked: a character kept back
Parameters
AChar: as C'sungetwctakes itAFile: as C'sungetwctakes it
Returns: as C's ungetwc returns it
fputwc
func fputwc(const AChar: uint32; const AFile: ptr): uint32
C's fputwc, hooked. The wide writes: fputwc and its forms, fputws and fputws_unlocked
Parameters
AChar: as C'sfputwctakes itAFile: as C'sfputwctakes it
Returns: as C's fputwc returns it
putwc
func putwc(const AChar: uint32; const AFile: ptr): uint32
C's putwc, hooked.
Parameters
AChar: as C'sputwctakes itAFile: as C'sputwctakes it
Returns: as C's putwc returns it
fputwc_unlocked
func fputwc_unlocked(const AChar: uint32; const AFile: ptr): uint32
C's fputwc_unlocked, hooked.
Parameters
AChar: as C'sfputwc_unlockedtakes itAFile: as C'sfputwc_unlockedtakes it
Returns: as C's fputwc_unlocked returns it
putwc_unlocked
func putwc_unlocked(const AChar: uint32; const AFile: ptr): uint32
C's putwc_unlocked, hooked.
Parameters
AChar: as C'sputwc_unlockedtakes itAFile: as C'sputwc_unlockedtakes it
Returns: as C's putwc_unlocked returns it
fputws
func fputws(const AText: ptr to const uint32; const AFile: ptr): int32
C's fputws, hooked.
Parameters
AText: as C'sfputwstakes itAFile: as C'sfputwstakes it
Returns: as C's fputws returns it
fputws_unlocked
func fputws_unlocked(const AText: ptr to const uint32; const AFile: ptr): int32
C's fputws_unlocked, hooked.
Parameters
AText: as C'sfputws_unlockedtakes itAFile: as C'sfputws_unlockedtakes it
Returns: as C's fputws_unlocked returns it
chdir
func chdir(const APath: ptr to const char): int32
C's chdir, hooked: a folder of a registered source or of the path source becomes the working folder every relative path is then looked up in (HookIOChangeFolder: 0); anything else glibc's, a success there letting the process's own working folder apply again
Parameters
APath: as C'schdirtakes it
Returns: as C's chdir returns it
getcwd
func getcwd(const ABuffer: ptr to char; const ASize: uint64): ptr to char
C's getcwd, hooked: the working folder a hooked chdir set, else glibc's
Parameters
ABuffer: as C'sgetcwdtakes itASize: as C'sgetcwdtakes it
Returns: as C's getcwd returns it
__getcwd_chk
func __getcwd_chk(const ABuffer: ptr to char; const ASize: uint64; const ABufferSize: uint64): ptr to char
C's __getcwd_chk, hooked. __getcwd_chk (C built with _FORTIFY_SOURCE): getcwd's answer; a size past the buffer's ABufferSize bytes aborts (__chk_fail), as glibc's does
Parameters
ABuffer: as C's__getcwd_chktakes itASize: as C's__getcwd_chktakes itABufferSize: as C's__getcwd_chktakes it
Returns: as C's __getcwd_chk returns it
access
func access(const APath: ptr to const char; const AMode: int32): int32
C's access, hooked. The query family: a virtual path answered as fopen would find it (DoAccess / DoStat), anything else glibc's. glibc before 2.33 has no stat / stat64 / lstat / lstat64 symbol (C reached them through __xstat and its kin, _STAT_VER 1): the real call falls back on those
Parameters
APath: as C'saccesstakes itAMode: as C'saccesstakes it
Returns: as C's access returns it
stat
func stat(const APath: ptr to const char; const ABuf: ptr): int32
C's stat, hooked.
Parameters
APath: as C'sstattakes itABuf: as C'sstattakes it
Returns: as C's stat returns it
stat64
func stat64(const APath: ptr to const char; const ABuf: ptr): int32
C's stat64, hooked.
Parameters
APath: as C'sstat64takes itABuf: as C'sstat64takes it
Returns: as C's stat64 returns it
lstat
func lstat(const APath: ptr to const char; const ABuf: ptr): int32
C's lstat, hooked.
Parameters
APath: as C'slstattakes itABuf: as C'slstattakes it
Returns: as C's lstat returns it
lstat64
func lstat64(const APath: ptr to const char; const ABuf: ptr): int32
C's lstat64, hooked.
Parameters
APath: as C'slstat64takes itABuf: as C'slstat64takes it
Returns: as C's lstat64 returns it
__xstat
func __xstat(const AVersion: int32; const APath: ptr to const char; const ABuf: ptr): int32
C's __xstat, hooked.
Parameters
AVersion: as C's__xstattakes itAPath: as C's__xstattakes itABuf: as C's__xstattakes it
Returns: as C's __xstat returns it
__xstat64
func __xstat64(const AVersion: int32; const APath: ptr to const char; const ABuf: ptr): int32
C's __xstat64, hooked.
Parameters
AVersion: as C's__xstat64takes itAPath: as C's__xstat64takes itABuf: as C's__xstat64takes it
Returns: as C's __xstat64 returns it
__lxstat
func __lxstat(const AVersion: int32; const APath: ptr to const char; const ABuf: ptr): int32
C's __lxstat, hooked.
Parameters
AVersion: as C's__lxstattakes itAPath: as C's__lxstattakes itABuf: as C's__lxstattakes it
Returns: as C's __lxstat returns it
__lxstat64
func __lxstat64(const AVersion: int32; const APath: ptr to const char; const ABuf: ptr): int32
C's __lxstat64, hooked.
Parameters
AVersion: as C's__lxstat64takes itAPath: as C's__lxstat64takes itABuf: as C's__lxstat64takes it
Returns: as C's __lxstat64 returns it
open
func open(const APath: ptr to const char; const AFlags: int32; ...): int32
C's open, hooked. open / open64 (the same on a 64-bit target): the mode after the flags is read only with O_CREAT or O_TMPFILE, as glibc's open reads it
Parameters
APath: as C'sopentakes itAFlags: as C'sopentakes it...: as C'sopentakes them
Returns: as C's open returns it
open64
func open64(const APath: ptr to const char; const AFlags: int32; ...): int32
C's open64, hooked.
Parameters
APath: as C'sopen64takes itAFlags: as C'sopen64takes it...: as C'sopen64takes them
Returns: as C's open64 returns it
__open_2
func __open_2(const APath: ptr to const char; const AFlags: int32): int32
C's __open_2, hooked. __open_2 / __open64_2 (_FORTIFY_SOURCE's open with no mode): O_CREAT or O_TMPFILE goes to glibc's, which ends the program as a fortify failure before it looks at the path
Parameters
APath: as C's__open_2takes itAFlags: as C's__open_2takes it
Returns: as C's __open_2 returns it
__open64_2
func __open64_2(const APath: ptr to const char; const AFlags: int32): int32
C's __open64_2, hooked.
Parameters
APath: as C's__open64_2takes itAFlags: as C's__open64_2takes it
Returns: as C's __open64_2 returns it
read
func read(const AFile: int32; const ABuffer: ptr; const ACount: uint64): int64
C's read, hooked.
Parameters
AFile: as C'sreadtakes itABuffer: as C'sreadtakes itACount: as C'sreadtakes it
Returns: as C's read returns it
__read_chk
func __read_chk(const AFile: int32; const ABuffer: ptr; const ACount: uint64; const ABufferSize: uint64): int64
C's __read_chk, hooked. __read_chk (_FORTIFY_SOURCE's read): a count past the buffer's size ends the program
Parameters
AFile: as C's__read_chktakes itABuffer: as C's__read_chktakes itACount: as C's__read_chktakes itABufferSize: as C's__read_chktakes it
Returns: as C's __read_chk returns it
pread
func pread(const AFile: int32; const ABuffer: ptr; const ACount: uint64; const AOffset: int64): int64
C's pread, hooked. pread / pread64 (the same on a 64-bit target)
Parameters
AFile: as C'spreadtakes itABuffer: as C'spreadtakes itACount: as C'spreadtakes itAOffset: as C'spreadtakes it
Returns: as C's pread returns it
pread64
func pread64(const AFile: int32; const ABuffer: ptr; const ACount: uint64; const AOffset: int64): int64
C's pread64, hooked.
Parameters
AFile: as C'spread64takes itABuffer: as C'spread64takes itACount: as C'spread64takes itAOffset: as C'spread64takes it
Returns: as C's pread64 returns it
__pread_chk
func __pread_chk(const AFile: int32; const ABuffer: ptr; const ACount: uint64; const AOffset: int64; const ABufferSize: uint64): int64
C's __pread_chk, hooked. __pread_chk / __pread64_chk (_FORTIFY_SOURCE's pread): a count past the buffer's size ends the program
Parameters
AFile: as C's__pread_chktakes itABuffer: as C's__pread_chktakes itACount: as C's__pread_chktakes itAOffset: as C's__pread_chktakes itABufferSize: as C's__pread_chktakes it
Returns: as C's __pread_chk returns it
__pread64_chk
func __pread64_chk(const AFile: int32; const ABuffer: ptr; const ACount: uint64; const AOffset: int64; const ABufferSize: uint64): int64
C's __pread64_chk, hooked.
Parameters
AFile: as C's__pread64_chktakes itABuffer: as C's__pread64_chktakes itACount: as C's__pread64_chktakes itAOffset: as C's__pread64_chktakes itABufferSize: as C's__pread64_chktakes it
Returns: as C's __pread64_chk returns it
write
func write(const AFile: int32; const ABuffer: ptr to const; const ACount: uint64): int64
C's write, hooked.
Parameters
AFile: as C'swritetakes itABuffer: as C'swritetakes itACount: as C'swritetakes it
Returns: as C's write returns it
pwrite
func pwrite(const AFile: int32; const ABuffer: ptr to const; const ACount: uint64; const AOffset: int64): int64
C's pwrite, hooked. pwrite / pwrite64 (the same on a 64-bit target)
Parameters
AFile: as C'spwritetakes itABuffer: as C'spwritetakes itACount: as C'spwritetakes itAOffset: as C'spwritetakes it
Returns: as C's pwrite returns it
pwrite64
func pwrite64(const AFile: int32; const ABuffer: ptr to const; const ACount: uint64; const AOffset: int64): int64
C's pwrite64, hooked.
Parameters
AFile: as C'spwrite64takes itABuffer: as C'spwrite64takes itACount: as C'spwrite64takes itAOffset: as C'spwrite64takes it
Returns: as C's pwrite64 returns it
lseek
func lseek(const AFile: int32; const AOffset: int64; const AWhence: int32): int64
C's lseek, hooked. lseek / lseek64 (the same on a 64-bit target)
Parameters
AFile: as C'slseektakes itAOffset: as C'slseektakes itAWhence: as C'slseektakes it
Returns: as C's lseek returns it
lseek64
func lseek64(const AFile: int32; const AOffset: int64; const AWhence: int32): int64
C's lseek64, hooked.
Parameters
AFile: as C'slseek64takes itAOffset: as C'slseek64takes itAWhence: as C'slseek64takes it
Returns: as C's lseek64 returns it
mmap
func mmap(const AAddress: ptr; const ALength: uint64; const AProt: int32; const AFlags: int32; const AFile: int32; const AOffset: int64): ptr
C's mmap, hooked. mmap / mmap64 (the same on a 64-bit target); munmap and mprotect stay glibc's (a handle's mapping is an anonymous one)
Parameters
AAddress: as C'smmaptakes itALength: as C'smmaptakes itAProt: as C'smmaptakes itAFlags: as C'smmaptakes itAFile: as C'smmaptakes itAOffset: as C'smmaptakes it
Returns: as C's mmap returns it
mmap64
func mmap64(const AAddress: ptr; const ALength: uint64; const AProt: int32; const AFlags: int32; const AFile: int32; const AOffset: int64): ptr
C's mmap64, hooked.
Parameters
AAddress: as C'smmap64takes itALength: as C'smmap64takes itAProt: as C'smmap64takes itAFlags: as C'smmap64takes itAFile: as C'smmap64takes itAOffset: as C'smmap64takes it
Returns: as C's mmap64 returns it
close
func close(const AFile: int32): int32
C's close, hooked.
Parameters
AFile: as C'sclosetakes it
Returns: as C's close returns it
dup
func dup(const AFile: int32): int32
C's dup, hooked. dup / dup2 / dup3: a copy of a handle's number is another number on its description (shared place and rights, as the kernel's); a copy onto a handle's number takes it over
Parameters
AFile: as C'sduptakes it
Returns: as C's dup returns it
dup2
func dup2(const AFile: int32; const ATarget: int32): int32
C's dup2, hooked.
Parameters
AFile: as C'sdup2takes itATarget: as C'sdup2takes it
Returns: as C's dup2 returns it
dup3
func dup3(const AFile: int32; const ATarget: int32; const AFlags: int32): int32
C's dup3, hooked.
Parameters
AFile: as C'sdup3takes itATarget: as C'sdup3takes itAFlags: as C'sdup3takes it
Returns: as C's dup3 returns it
fcntl
func fcntl(const AFile: int32; const ACommand: int32; ...): int32
C's fcntl, hooked. fcntl / fcntl64 (the same on a 64-bit target): the one argument after the command is read as a register's word (an int or a pointer, as glibc's own fcntl reads it)
Parameters
AFile: as C'sfcntltakes itACommand: as C'sfcntltakes it...: as C'sfcntltakes them
Returns: as C's fcntl returns it
fcntl64
func fcntl64(const AFile: int32; const ACommand: int32; ...): int32
C's fcntl64, hooked.
Parameters
AFile: as C'sfcntl64takes itACommand: as C'sfcntl64takes it...: as C'sfcntl64takes them
Returns: as C's fcntl64 returns it
fdopen
func fdopen(const AFile: int32; const AMode: ptr to const char): ptr
C's fdopen, hooked. fdopen of a handle's number: a FILE on its description
Parameters
AFile: as C'sfdopentakes itAMode: as C'sfdopentakes it
Returns: as C's fdopen returns it
fstat
func fstat(const AFile: int32; const ABuf: ptr): int32
C's fstat, hooked.
Parameters
AFile: as C'sfstattakes itABuf: as C'sfstattakes it
Returns: as C's fstat returns it
fstat64
func fstat64(const AFile: int32; const ABuf: ptr): int32
C's fstat64, hooked.
Parameters
AFile: as C'sfstat64takes itABuf: as C'sfstat64takes it
Returns: as C's fstat64 returns it
__fxstat
func __fxstat(const AVersion: int32; const AFile: int32; const ABuf: ptr): int32
C's __fxstat, hooked.
Parameters
AVersion: as C's__fxstattakes itAFile: as C's__fxstattakes itABuf: as C's__fxstattakes it
Returns: as C's __fxstat returns it
__fxstat64
func __fxstat64(const AVersion: int32; const AFile: int32; const ABuf: ptr): int32
C's __fxstat64, hooked.
Parameters
AVersion: as C's__fxstat64takes itAFile: as C's__fxstat64takes itABuf: as C's__fxstat64takes it
Returns: as C's __fxstat64 returns it
System.HookIO.Win64
System.HookIO's platform unit for x86_64-windows-gnu: ucrt's C file calls on Adam streams
Import it with import System.HookIO.Win64;.
Constants
| Name | Declaration | Description |
|---|---|---|
ADAM_HOOKIO_WEOF | const ADAM_HOOKIO_WEOF: int32 = 0xFFFF | C's WEOF (Windows' wint_t is 16 bits): what the hooked wide calls return on a failure |
Routines
HookIOStreamOf
func HookIOStreamOf(const AFile: ptr): IO
The IO behind a handle: the registered IO, or the entry's IO for a source; nil for anything else, and for a handle being closed
Parameters
AFile: the C stream (a FILE pointer)
Returns: the IO, or nil
fopen
func fopen(const APath: ptr to const char; const AMode: ptr to const char): ptr
C's fopen, hooked: a virtual path opens a handle
Parameters
APath: as C'sfopentakes itAMode: as C'sfopentakes it
Returns: as C's fopen returns it
fopen_s
func fopen_s(const AFile: ptr to ptr; const APath: ptr to const char; const AMode: ptr to const char): int32
C's fopen_s, hooked: the stream in AFile^, 0 or the error code returned. A nil AFile is the real function's to refuse
Parameters
AFile: as C'sfopen_stakes itAPath: as C'sfopen_stakes itAMode: as C'sfopen_stakes it
Returns: as C's fopen_s returns it
_wfopen
func _wfopen(const APath: ptr to const wchar; const AMode: ptr to const wchar): ptr
C's _wfopen, hooked: a UTF-16 path, opened as fopen opens its UTF-8 form
Parameters
APath: as C's_wfopentakes itAMode: as C's_wfopentakes it
Returns: as C's _wfopen returns it
_access
func _access(const APath: ptr to const char; const AMode: int32): int32
C's _access, hooked: a virtual path answered as fopen would find it, anything else ucrt's
Parameters
APath: as C's_accesstakes itAMode: as C's_accesstakes it
Returns: as C's _access returns it
access
func access(const APath: ptr to const char; const AMode: int32): int32
C's access, hooked. mingw's oldnames access (what C built without the dllimport declaration reaches): the same answer, a real path to ucrt's _access
Parameters
APath: as C'saccesstakes itAMode: as C'saccesstakes it
Returns: as C's access returns it
_chdir
func _chdir(const APath: ptr to const char): int32
C's _chdir, hooked: a folder of a registered source or of the path source becomes the working folder every relative path is then looked up in (raylib's OBJ loader moves into the model's folder for its .mtl); anything else ucrt's
Parameters
APath: as C's_chdirtakes it
Returns: as C's _chdir returns it
chdir
func chdir(const APath: ptr to const char): int32
C's chdir, hooked. mingw's oldnames chdir: _chdir's answer
Parameters
APath: as C'schdirtakes it
Returns: as C's chdir returns it
_wchdir
func _wchdir(const APath: ptr to const wchar): int32
C's _wchdir, hooked: _chdir's answer for a UTF-16 path (a path that does not convert is ucrt's)
Parameters
APath: as C's_wchdirtakes it
Returns: as C's _wchdir returns it
_getcwd
func _getcwd(const ABuffer: ptr to char; const ASize: int32): ptr to char
C's _getcwd, hooked: the working folder a hooked chdir set, else ucrt's
Parameters
ABuffer: as C's_getcwdtakes itASize: as C's_getcwdtakes it
Returns: as C's _getcwd returns it
getcwd
func getcwd(const ABuffer: ptr to char; const ASize: int32): ptr to char
C's getcwd, hooked. mingw's oldnames getcwd: _getcwd's answer
Parameters
ABuffer: as C'sgetcwdtakes itASize: as C'sgetcwdtakes it
Returns: as C's getcwd returns it
_wgetcwd
func _wgetcwd(const ABuffer: ptr to wchar; const ASize: int32): ptr to wchar
C's _wgetcwd, hooked: the working folder a hooked chdir set as UTF-16, else ucrt's
Parameters
ABuffer: as C's_wgetcwdtakes itASize: as C's_wgetcwdtakes it
Returns: as C's _wgetcwd returns it
stat64i32
func stat64i32(const APath: ptr to const char; const ABuf: ptr): int32
C's stat64i32, hooked. mingw's stat (libmingwex's stat64i32, not an import): a virtual path answered, a real path to ucrt's _stat64i32. ABuf is a struct _stat64i32
Parameters
APath: as C'sstat64i32takes itABuf: as C'sstat64i32takes it
Returns: as C's stat64i32 returns it
GetFileAttributesA
func GetFileAttributesA(const APath: ptr to const char): uint32
Windows' GetFileAttributesA, hooked: a virtual path answered, anything else kernel32's
Parameters
APath: as Windows'GetFileAttributesAtakes it
Returns: as Windows' GetFileAttributesA returns it
fclose
func fclose(const AFile: ptr): int32
C's fclose, hooked: a handle is closed (its own IO with it), anything else goes to the C runtime
Parameters
AFile: as C'sfclosetakes it
Returns: as C's fclose returns it
freopen
func freopen(const APath: ptr to const char; const AMode: ptr to const char; const AFile: ptr): ptr
C's freopen, hooked: a handle is reopened in place, whatever the path; a real FILE goes to the C runtime, whatever the path
Parameters
APath: as C'sfreopentakes itAMode: as C'sfreopentakes itAFile: as C'sfreopentakes it
Returns: as C's freopen returns it
fread
func fread(const ABuffer: ptr; const ASize: int64; const ACount: int64; const AFile: ptr): int64
C's fread, hooked: a handle reads through its ucrt FILE model
Parameters
ABuffer: as C'sfreadtakes itASize: as C'sfreadtakes itACount: as C'sfreadtakes itAFile: as C'sfreadtakes it
Returns: as C's fread returns it
_fread_nolock
func _fread_nolock(const ABuffer: ptr; const ASize: int64; const ACount: int64; const AFile: ptr): int64
C's _fread_nolock, hooked: fread (a handle has no CRT lock)
Parameters
ABuffer: as C's_fread_nolocktakes itASize: as C's_fread_nolocktakes itACount: as C's_fread_nolocktakes itAFile: as C's_fread_nolocktakes it
Returns: as C's _fread_nolock returns it
fwrite
func fwrite(const ABuffer: ptr; const ASize: int64; const ACount: int64; const AFile: ptr): int64
C's fwrite, hooked: a handle writes through its ucrt FILE model. The runtime's own printing comes here too (its external fwrite binds to this hook): stdout is no handle, so it goes to the real one
Parameters
ABuffer: as C'sfwritetakes itASize: as C'sfwritetakes itACount: as C'sfwritetakes itAFile: as C'sfwritetakes it
Returns: as C's fwrite returns it
_fwrite_nolock
func _fwrite_nolock(const ABuffer: ptr; const ASize: int64; const ACount: int64; const AFile: ptr): int64
C's _fwrite_nolock, hooked: fwrite
Parameters
ABuffer: as C's_fwrite_nolocktakes itASize: as C's_fwrite_nolocktakes itACount: as C's_fwrite_nolocktakes itAFile: as C's_fwrite_nolocktakes it
Returns: as C's _fwrite_nolock returns it
fgetc
func fgetc(const AFile: ptr): int32
C's fgetc, hooked. fgetc / getc and their _nolock forms: the byte (0..255) or EOF
Parameters
AFile: as C'sfgetctakes it
Returns: as C's fgetc returns it
getc
func getc(const AFile: ptr): int32
C's getc, hooked.
Parameters
AFile: as C'sgetctakes it
Returns: as C's getc returns it
_fgetc_nolock
func _fgetc_nolock(const AFile: ptr): int32
C's _fgetc_nolock, hooked.
Parameters
AFile: as C's_fgetc_nolocktakes it
Returns: as C's _fgetc_nolock returns it
_getc_nolock
func _getc_nolock(const AFile: ptr): int32
C's _getc_nolock, hooked.
Parameters
AFile: as C's_getc_nolocktakes it
Returns: as C's _getc_nolock returns it
fgets
func fgets(const AText: ptr to char; const ACount: int32; const AFile: ptr): ptr to char
C's fgets, hooked: up to ACount - 1 bytes into AText, stopping after a newline, then a 0; AText, or nil when nothing was read before the end, on an error, or for a count of 0 or less (EINVAL)
Parameters
AText: as C'sfgetstakes itACount: as C'sfgetstakes itAFile: as C'sfgetstakes it
Returns: as C's fgets returns it
ungetc
func ungetc(const AChar: int32; const AFile: ptr): int32
C's ungetc, hooked. ungetc / _ungetc_nolock: AChar put back by ucrt's rules; the byte (0..255) or EOF
Parameters
AChar: as C'sungetctakes itAFile: as C'sungetctakes it
Returns: as C's ungetc returns it
_ungetc_nolock
func _ungetc_nolock(const AChar: int32; const AFile: ptr): int32
C's _ungetc_nolock, hooked.
Parameters
AChar: as C's_ungetc_nolocktakes itAFile: as C's_ungetc_nolocktakes it
Returns: as C's _ungetc_nolock returns it
feof
func feof(const AFile: ptr): int32
C's feof, hooked. feof / ferror: 1 when the flag is set, else 0
Parameters
AFile: as C'sfeoftakes it
Returns: as C's feof returns it
ferror
func ferror(const AFile: ptr): int32
C's ferror, hooked.
Parameters
AFile: as C'sferrortakes it
Returns: as C's ferror returns it
clearerr
func clearerr(const AFile: ptr)
C's clearerr, hooked: both flags cleared
Parameters
AFile: as C'sclearerrtakes it
fseek
func fseek(const AFile: ptr; const AOffset: clong; const AOrigin: int32): int32
C's fseek, hooked. fseek / _fseek_nolock / _fseeki64 / _fseeki64_nolock: 0 or -1
Parameters
AFile: as C'sfseektakes itAOffset: as C'sfseektakes itAOrigin: as C'sfseektakes it
Returns: as C's fseek returns it
_fseek_nolock
func _fseek_nolock(const AFile: ptr; const AOffset: clong; const AOrigin: int32): int32
C's _fseek_nolock, hooked.
Parameters
AFile: as C's_fseek_nolocktakes itAOffset: as C's_fseek_nolocktakes itAOrigin: as C's_fseek_nolocktakes it
Returns: as C's _fseek_nolock returns it
_fseeki64
func _fseeki64(const AFile: ptr; const AOffset: int64; const AOrigin: int32): int32
C's _fseeki64, hooked.
Parameters
AFile: as C's_fseeki64takes itAOffset: as C's_fseeki64takes itAOrigin: as C's_fseeki64takes it
Returns: as C's _fseeki64 returns it
_fseeki64_nolock
func _fseeki64_nolock(const AFile: ptr; const AOffset: int64; const AOrigin: int32): int32
C's _fseeki64_nolock, hooked.
Parameters
AFile: as C's_fseeki64_nolocktakes itAOffset: as C's_fseeki64_nolocktakes itAOrigin: as C's_fseeki64_nolocktakes it
Returns: as C's _fseeki64_nolock returns it
ftell
func ftell(const AFile: ptr): clong
C's ftell, hooked. ftell / _ftell_nolock / _ftelli64 / _ftelli64_nolock: the caller's place, or -1
Parameters
AFile: as C'sftelltakes it
Returns: as C's ftell returns it
_ftell_nolock
func _ftell_nolock(const AFile: ptr): clong
C's _ftell_nolock, hooked.
Parameters
AFile: as C's_ftell_nolocktakes it
Returns: as C's _ftell_nolock returns it
_ftelli64
func _ftelli64(const AFile: ptr): int64
C's _ftelli64, hooked.
Parameters
AFile: as C's_ftelli64takes it
Returns: as C's _ftelli64 returns it
_ftelli64_nolock
func _ftelli64_nolock(const AFile: ptr): int64
C's _ftelli64_nolock, hooked.
Parameters
AFile: as C's_ftelli64_nolocktakes it
Returns: as C's _ftelli64_nolock returns it
rewind
func rewind(const AFile: ptr)
C's rewind, hooked: to the start, both flags cleared
Parameters
AFile: as C'srewindtakes it
fileno
func fileno(const AFile: ptr): int32
C's fileno, hooked. fileno / _fileno: a handle's descriptor (reserved at the first call, given back at fclose)
Parameters
AFile: as C'sfilenotakes it
Returns: as C's fileno returns it
_fileno
func _fileno(const AFile: ptr): int32
C's _fileno, hooked.
Parameters
AFile: as C's_filenotakes it
Returns: as C's _fileno returns it
_lock_file
func _lock_file(const AFile: ptr)
C's _lock_file, hooked. _lock_file / _unlock_file: nothing on a handle
Parameters
AFile: as C's_lock_filetakes it
_unlock_file
func _unlock_file(const AFile: ptr)
C's _unlock_file, hooked.
Parameters
AFile: as C's_unlock_filetakes it
_pclose
func _pclose(const AFile: ptr): int32
C's _pclose, hooked: a handle is never a pipe; ucrt's _pclose refuses a stream _popen did not open with -1 and EBADF and leaves it open, and so does this hook on a handle
Parameters
AFile: as C's_pclosetakes it
Returns: as C's _pclose returns it
fputc
func fputc(const AChar: int32; const AFile: ptr): int32
C's fputc, hooked. fputc / putc and their _nolock forms: the byte written (0..255) or EOF
Parameters
AChar: as C'sfputctakes itAFile: as C'sfputctakes it
Returns: as C's fputc returns it
putc
func putc(const AChar: int32; const AFile: ptr): int32
C's putc, hooked.
Parameters
AChar: as C'sputctakes itAFile: as C'sputctakes it
Returns: as C's putc returns it
_fputc_nolock
func _fputc_nolock(const AChar: int32; const AFile: ptr): int32
C's _fputc_nolock, hooked.
Parameters
AChar: as C's_fputc_nolocktakes itAFile: as C's_fputc_nolocktakes it
Returns: as C's _fputc_nolock returns it
_putc_nolock
func _putc_nolock(const AChar: int32; const AFile: ptr): int32
C's _putc_nolock, hooked.
Parameters
AChar: as C's_putc_nolocktakes itAFile: as C's_putc_nolocktakes it
Returns: as C's _putc_nolock returns it
fputs
func fputs(const AText: ptr to const char; const AFile: ptr): int32
C's fputs, hooked: ucrt's success value (0) or EOF
Parameters
AText: as C'sfputstakes itAFile: as C'sfputstakes it
Returns: as C's fputs returns it
fputwc
func fputwc(const AChar: wchar; const AFile: ptr): uint16
C's fputwc, hooked. fputwc / putwc and their _nolock forms (putwc is fputwc in ucrt): the character written, or WEOF
Parameters
AChar: as C'sfputwctakes itAFile: as C'sfputwctakes it
Returns: as C's fputwc returns it
putwc
func putwc(const AChar: wchar; const AFile: ptr): uint16
C's putwc, hooked.
Parameters
AChar: as C'sputwctakes itAFile: as C'sputwctakes it
Returns: as C's putwc returns it
_fputwc_nolock
func _fputwc_nolock(const AChar: wchar; const AFile: ptr): uint16
C's _fputwc_nolock, hooked.
Parameters
AChar: as C's_fputwc_nolocktakes itAFile: as C's_fputwc_nolocktakes it
Returns: as C's _fputwc_nolock returns it
_putwc_nolock
func _putwc_nolock(const AChar: wchar; const AFile: ptr): uint16
C's _putwc_nolock, hooked.
Parameters
AChar: as C's_putwc_nolocktakes itAFile: as C's_putwc_nolocktakes it
Returns: as C's _putwc_nolock returns it
fputws
func fputws(const AText: ptr to const wchar; const AFile: ptr): int32
C's fputws, hooked: ucrt's success value (0) or EOF
Parameters
AText: as C'sfputwstakes itAFile: as C'sfputwstakes it
Returns: as C's fputws returns it
fgetwc
func fgetwc(const AFile: ptr): uint16
C's fgetwc, hooked. fgetwc / getwc and their _nolock forms (getwc is fgetwc in ucrt): the wide character, or WEOF
Parameters
AFile: as C'sfgetwctakes it
Returns: as C's fgetwc returns it
getwc
func getwc(const AFile: ptr): uint16
C's getwc, hooked.
Parameters
AFile: as C'sgetwctakes it
Returns: as C's getwc returns it
_fgetwc_nolock
func _fgetwc_nolock(const AFile: ptr): uint16
C's _fgetwc_nolock, hooked.
Parameters
AFile: as C's_fgetwc_nolocktakes it
Returns: as C's _fgetwc_nolock returns it
_getwc_nolock
func _getwc_nolock(const AFile: ptr): uint16
C's _getwc_nolock, hooked.
Parameters
AFile: as C's_getwc_nolocktakes it
Returns: as C's _getwc_nolock returns it
fgetws
func fgetws(const AText: ptr to wchar; const ACount: int32; const AFile: ptr): ptr to wchar
C's fgetws, hooked: up to ACount - 1 wide characters into AText, stopping after L'\n', then a 0; AText, or nil when nothing was read, for a count of 0, and for no text with a count or a negative count (EINVAL)
Parameters
AText: as C'sfgetwstakes itACount: as C'sfgetwstakes itAFile: as C'sfgetwstakes it
Returns: as C's fgetws returns it
ungetwc
func ungetwc(const AChar: wchar; const AFile: ptr): uint16
C's ungetwc, hooked. ungetwc / _ungetwc_nolock: AChar put back by ucrt's rules; the character or WEOF
Parameters
AChar: as C'sungetwctakes itAFile: as C'sungetwctakes it
Returns: as C's ungetwc returns it
_ungetwc_nolock
func _ungetwc_nolock(const AChar: wchar; const AFile: ptr): uint16
C's _ungetwc_nolock, hooked.
Parameters
AChar: as C's_ungetwc_nolocktakes itAFile: as C's_ungetwc_nolocktakes it
Returns: as C's _ungetwc_nolock returns it
__stdio_common_vfprintf
func __stdio_common_vfprintf(const AOptions: uint64; const AFile: ptr; const AFormat: ptr to const char; const ALocale: ptr; const AArgs: ptr): int32
C's __stdio_common_vfprintf, hooked: what ucrt's fprintf and the headers' inline vfprintf / printf family call (AArgs is their va_list), parsed by ucrt's standard processor
Parameters
AOptions: as C's__stdio_common_vfprintftakes itAFile: as C's__stdio_common_vfprintftakes itAFormat: as C's__stdio_common_vfprintftakes itALocale: as C's__stdio_common_vfprintftakes itAArgs: as C's__stdio_common_vfprintftakes it
Returns: as C's __stdio_common_vfprintf returns it
__stdio_common_vfprintf_s
func __stdio_common_vfprintf_s(const AOptions: uint64; const AFile: ptr; const AFormat: ptr to const char; const ALocale: ptr; const AArgs: ptr): int32
C's __stdio_common_vfprintf_s, hooked: what the headers' inline fprintf_s / vfprintf_s / printf_s family calls, parsed by ucrt's validating processor (DoVfprintf: %n and a malformed format a failed parameter check)
Parameters
AOptions: as C's__stdio_common_vfprintf_stakes itAFile: as C's__stdio_common_vfprintf_stakes itAFormat: as C's__stdio_common_vfprintf_stakes itALocale: as C's__stdio_common_vfprintf_stakes itAArgs: as C's__stdio_common_vfprintf_stakes it
Returns: as C's __stdio_common_vfprintf_s returns it
__stdio_common_vfprintf_p
func __stdio_common_vfprintf_p(const AOptions: uint64; const AFile: ptr; const AFormat: ptr to const char; const ALocale: ptr; const AArgs: ptr): int32
C's __stdio_common_vfprintf_p, hooked: what the headers' inline _fprintf_p / _vfprintf_p / _printf_p family calls, parsed by ucrt's positional processor (DoVfprintf: %N$ parameters, validated)
Parameters
AOptions: as C's__stdio_common_vfprintf_ptakes itAFile: as C's__stdio_common_vfprintf_ptakes itAFormat: as C's__stdio_common_vfprintf_ptakes itALocale: as C's__stdio_common_vfprintf_ptakes itAArgs: as C's__stdio_common_vfprintf_ptakes it
Returns: as C's __stdio_common_vfprintf_p returns it
__stdio_common_vfscanf
func __stdio_common_vfscanf(const AOptions: uint64; const AFile: ptr; const AFormat: ptr to const char; const ALocale: ptr; const AArgs: ptr): int32
C's __stdio_common_vfscanf, hooked: what ucrt's fscanf / vfscanf and the headers' inline scan forms (fscanf_s, _fscanf_l, ...) call (AArgs is their va_list). A handle is scanned by the real function over a stand-in FILE, a real FILE by the real function directly (EOF with ENOSYS when the C runtime has none)
Parameters
AOptions: as C's__stdio_common_vfscanftakes itAFile: as C's__stdio_common_vfscanftakes itAFormat: as C's__stdio_common_vfscanftakes itALocale: as C's__stdio_common_vfscanftakes itAArgs: as C's__stdio_common_vfscanftakes it
Returns: as C's __stdio_common_vfscanf returns it
__stdio_common_vfwprintf
func __stdio_common_vfwprintf(const AOptions: uint64; const AFile: ptr; const AFormat: ptr to const wchar; const ALocale: ptr; const AArgs: ptr): int32
C's __stdio_common_vfwprintf, hooked: what ucrt's fwprintf / vfwprintf (mingw's stubs of them) and the headers' inline wide printf family call (AArgs is their va_list), parsed by ucrt's standard processor
Parameters
AOptions: as C's__stdio_common_vfwprintftakes itAFile: as C's__stdio_common_vfwprintftakes itAFormat: as C's__stdio_common_vfwprintftakes itALocale: as C's__stdio_common_vfwprintftakes itAArgs: as C's__stdio_common_vfwprintftakes it
Returns: as C's __stdio_common_vfwprintf returns it
__stdio_common_vfwprintf_s
func __stdio_common_vfwprintf_s(const AOptions: uint64; const AFile: ptr; const AFormat: ptr to const wchar; const ALocale: ptr; const AArgs: ptr): int32
C's __stdio_common_vfwprintf_s, hooked: what the headers' inline fwprintf_s / vfwprintf_s / wprintf_s family calls, parsed by ucrt's validating processor
Parameters
AOptions: as C's__stdio_common_vfwprintf_stakes itAFile: as C's__stdio_common_vfwprintf_stakes itAFormat: as C's__stdio_common_vfwprintf_stakes itALocale: as C's__stdio_common_vfwprintf_stakes itAArgs: as C's__stdio_common_vfwprintf_stakes it
Returns: as C's __stdio_common_vfwprintf_s returns it
__stdio_common_vfwprintf_p
func __stdio_common_vfwprintf_p(const AOptions: uint64; const AFile: ptr; const AFormat: ptr to const wchar; const ALocale: ptr; const AArgs: ptr): int32
C's __stdio_common_vfwprintf_p, hooked: what the headers' inline _fwprintf_p / _vfwprintf_p / _wprintf_p family calls, parsed by ucrt's positional processor
Parameters
AOptions: as C's__stdio_common_vfwprintf_ptakes itAFile: as C's__stdio_common_vfwprintf_ptakes itAFormat: as C's__stdio_common_vfwprintf_ptakes itALocale: as C's__stdio_common_vfwprintf_ptakes itAArgs: as C's__stdio_common_vfwprintf_ptakes it
Returns: as C's __stdio_common_vfwprintf_p returns it
__stdio_common_vfwscanf
func __stdio_common_vfwscanf(const AOptions: uint64; const AFile: ptr; const AFormat: ptr to const wchar; const ALocale: ptr; const AArgs: ptr): int32
C's __stdio_common_vfwscanf, hooked: what ucrt's fwscanf / vfwscanf (mingw's stubs of them) and the headers' inline wide scan forms call (AArgs is their va_list). A handle is scanned by the real function over stand-in FILEs, a real FILE by the real function directly (EOF with ENOSYS when the C runtime has none)
Parameters
AOptions: as C's__stdio_common_vfwscanftakes itAFile: as C's__stdio_common_vfwscanftakes itAFormat: as C's__stdio_common_vfwscanftakes itALocale: as C's__stdio_common_vfwscanftakes itAArgs: as C's__stdio_common_vfwscanftakes it
Returns: as C's __stdio_common_vfwscanf returns it
setvbuf
func setvbuf(const AFile: ptr; const ABuffer: ptr to char; const AMode: int32; const ASize: uint64): int32
C's setvbuf, hooked: a handle's buffer as ucrt's setvbuf sets it: 0, or -1 (EINVAL for a mode or size ucrt refuses). Anything else goes to the real function (-1 with ENOSYS when the C runtime has none)
Parameters
AFile: as C'ssetvbuftakes itABuffer: as C'ssetvbuftakes itAMode: as C'ssetvbuftakes itASize: as C'ssetvbuftakes it
Returns: as C's setvbuf returns it
setbuf
func setbuf(const AFile: ptr; const ABuffer: ptr to char)
C's setbuf, hooked. setbuf, as ucrt's: no array is setvbuf's _IONBF, an array is _IOFBF at BUFSIZ. Anything else goes to the real function (ENOSYS when the C runtime has none)
Parameters
AFile: as C'ssetbuftakes itABuffer: as C'ssetbuftakes it
fflush
func fflush(const AFile: ptr): int32
C's fflush, hooked: a handle's written bytes, then its IO's own flush; fflush(NULL) flushes every stream, the C runtime's and every handle. The runtime's own external fflush binds here too: stdout is no handle, so it goes to the real one
Parameters
AFile: as C'sfflushtakes it
Returns: as C's fflush returns it
_fflush_nolock
func _fflush_nolock(const AFile: ptr): int32
C's _fflush_nolock, hooked: fflush
Parameters
AFile: as C's_fflush_nolocktakes it
Returns: as C's _fflush_nolock returns it
_fclose_nolock
func _fclose_nolock(const AFile: ptr): int32
C's _fclose_nolock, hooked: fclose
Parameters
AFile: as C's_fclose_nolocktakes it
Returns: as C's _fclose_nolock returns it
fgetpos
func fgetpos(const AFile: ptr; const APosition: ptr to int64): int32
C's fgetpos, hooked. fgetpos (ucrt's fgetpos.cpp): the handle's place (_ftelli64's, DoTellCall) in APosition^, then 0, or -1 when that place is -1. No position, and anything that is no handle, goes to the real function (it checks the position before the stream: EINVAL, -1)
Parameters
AFile: as C'sfgetpostakes itAPosition: as C'sfgetpostakes it
Returns: as C's fgetpos returns it
fsetpos
func fsetpos(const AFile: ptr; const APosition: ptr to int64): int32
C's fsetpos, hooked. fsetpos (ucrt's fsetpos.cpp): _fseeki64 to APosition^ from the start. No position, and anything that is no handle, goes to the real function
Parameters
AFile: as C'sfsetpostakes itAPosition: as C'sfsetpostakes it
Returns: as C's fsetpos returns it
clearerr_s
func clearerr_s(const AFile: ptr): int32
C's clearerr_s, hooked. clearerr_s (ucrt's clearerr.cpp): clearerr's flags on a handle, then 0
Parameters
AFile: as C'sclearerr_stakes it
Returns: as C's clearerr_s returns it
_getw
func _getw(const AFile: ptr): int32
C's _getw, hooked. _getw (ucrt's getw.cpp): the int of the next 4 bytes (_getc_nolock each, little-endian), or EOF when the end or an error came on the way (as feof / ferror tell after the 4 reads)
Parameters
AFile: as C's_getwtakes it
Returns: as C's _getw returns it
_putw
func _putw(const AValue: int32; const AFile: ptr): int32
C's _putw, hooked. _putw (ucrt's putw.cpp): AValue's 4 bytes (_fputc_nolock each, little-endian), then AValue, or EOF when ferror tells of an error after them
Parameters
AValue: as C's_putwtakes itAFile: as C's_putwtakes it
Returns: as C's _putw returns it
freopen_s
func freopen_s(const AResult: ptr to ptr; const APath: ptr to const char; const AMode: ptr to const char; const AFile: ptr): int32
C's freopen_s, hooked. freopen_s (ucrt's freopen.cpp common_freopen): the reopened stream in AResult^ (nil first), 0, or the reopen's errno. No AResult goes to the real function (it checks it before the stream: EINVAL), and so does anything that is no handle
Parameters
AResult: as C'sfreopen_stakes itAPath: as C'sfreopen_stakes itAMode: as C'sfreopen_stakes itAFile: as C'sfreopen_stakes it
Returns: as C's freopen_s returns it
_wfreopen
func _wfreopen(const APath: ptr to const wchar; const AMode: ptr to const wchar; const AFile: ptr): ptr
C's _wfreopen, hooked: freopen of a wide path and mode
Parameters
APath: as C's_wfreopentakes itAMode: as C's_wfreopentakes itAFile: as C's_wfreopentakes it
Returns: as C's _wfreopen returns it
_wfreopen_s
func _wfreopen_s(const AResult: ptr to ptr; const APath: ptr to const wchar; const AMode: ptr to const wchar; const AFile: ptr): int32
C's _wfreopen_s, hooked: freopen_s of a wide path and mode
Parameters
AResult: as C's_wfreopen_stakes itAPath: as C's_wfreopen_stakes itAMode: as C's_wfreopen_stakes itAFile: as C's_wfreopen_stakes it
Returns: as C's _wfreopen_s returns it
fread_s
func fread_s(const ABuffer: ptr; const ARoom: int64; const ASize: int64; const ACount: int64; const AFile: ptr): int64
C's fread_s, hooked.
Parameters
ABuffer: as C'sfread_stakes itARoom: as C'sfread_stakes itASize: as C'sfread_stakes itACount: as C'sfread_stakes itAFile: as C'sfread_stakes it
Returns: as C's fread_s returns it
_fread_nolock_s
func _fread_nolock_s(const ABuffer: ptr; const ARoom: int64; const ASize: int64; const ACount: int64; const AFile: ptr): int64
C's _fread_nolock_s, hooked.
Parameters
ABuffer: as C's_fread_nolock_stakes itARoom: as C's_fread_nolock_stakes itASize: as C's_fread_nolock_stakes itACount: as C's_fread_nolock_stakes itAFile: as C's_fread_nolock_stakes it
Returns: as C's _fread_nolock_s returns it
_open
func _open(const APath: ptr to const char; const AFlags: int32; ...): int32
C's _open, hooked: the mode (pmode) is read only with _O_CREAT, as ucrt reads its variadic argument
Parameters
APath: as C's_opentakes itAFlags: as C's_opentakes it...: as C's_opentakes them
Returns: as C's _open returns it
_wopen
func _wopen(const APath: ptr to const wchar; const AFlags: int32; ...): int32
C's _wopen, hooked: _open of a UTF-16 path
Parameters
APath: as C's_wopentakes itAFlags: as C's_wopentakes it...: as C's_wopentakes them
Returns: as C's _wopen returns it
_sopen
func _sopen(const APath: ptr to const char; const AFlags: int32; const AShare: int32; ...): int32
C's _sopen, hooked: _open with a sharing mode
Parameters
APath: as C's_sopentakes itAFlags: as C's_sopentakes itAShare: as C's_sopentakes it...: as C's_sopentakes them
Returns: as C's _sopen returns it
_wsopen
func _wsopen(const APath: ptr to const wchar; const AFlags: int32; const AShare: int32; ...): int32
C's _wsopen, hooked: _sopen of a UTF-16 path
Parameters
APath: as C's_wsopentakes itAFlags: as C's_wsopentakes itAShare: as C's_wsopentakes it...: as C's_wsopentakes them
Returns: as C's _wsopen returns it
_sopen_s
func _sopen_s(const AFile: ptr to int32; const APath: ptr to const char; const AFlags: int32; const AShare: int32; const APMode: int32): int32
C's _sopen_s, hooked: the descriptor through AFile, the answer an errno. No AFile or no path is ucrt's own check (the real function's)
Parameters
AFile: as C's_sopen_stakes itAPath: as C's_sopen_stakes itAFlags: as C's_sopen_stakes itAShare: as C's_sopen_stakes itAPMode: as C's_sopen_stakes it
Returns: as C's _sopen_s returns it
_wsopen_s
func _wsopen_s(const AFile: ptr to int32; const APath: ptr to const wchar; const AFlags: int32; const AShare: int32; const APMode: int32): int32
C's _wsopen_s, hooked: _sopen_s of a UTF-16 path
Parameters
AFile: as C's_wsopen_stakes itAPath: as C's_wsopen_stakes itAFlags: as C's_wsopen_stakes itAShare: as C's_wsopen_stakes itAPMode: as C's_wsopen_stakes it
Returns: as C's _wsopen_s returns it
_creat
func _creat(const APath: ptr to const char; const APMode: int32): int32
C's _creat, hooked: ucrt's _sopen(APath, _O_CREAT | _O_TRUNC | _O_RDWR, _SH_DENYNO, APMode)
Parameters
APath: as C's_creattakes itAPMode: as C's_creattakes it
Returns: as C's _creat returns it
_wcreat
func _wcreat(const APath: ptr to const wchar; const APMode: int32): int32
C's _wcreat, hooked: _creat of a UTF-16 path
Parameters
APath: as C's_wcreattakes itAPMode: as C's_wcreattakes it
Returns: as C's _wcreat returns it
_read
func _read(const AFile: int32; const ABuffer: ptr; const ACount: uint32): int32
C's _read, hooked: a handle's descriptor reads its handle
Parameters
AFile: as C's_readtakes itABuffer: as C's_readtakes itACount: as C's_readtakes it
Returns: as C's _read returns it
_write
func _write(const AFile: int32; const ABuffer: ptr; const ACount: uint32): int32
C's _write, hooked: a handle's descriptor writes its handle
Parameters
AFile: as C's_writetakes itABuffer: as C's_writetakes itACount: as C's_writetakes it
Returns: as C's _write returns it
_lseek
func _lseek(const AFile: int32; const AOffset: clong; const AOrigin: int32): clong
C's _lseek, hooked: a handle's descriptor moves (DoFdSeek, a long's place)
Parameters
AFile: as C's_lseektakes itAOffset: as C's_lseektakes itAOrigin: as C's_lseektakes it
Returns: as C's _lseek returns it
_lseeki64
func _lseeki64(const AFile: int32; const AOffset: int64; const AOrigin: int32): int64
C's _lseeki64, hooked: a handle's descriptor moves
Parameters
AFile: as C's_lseeki64takes itAOffset: as C's_lseeki64takes itAOrigin: as C's_lseeki64takes it
Returns: as C's _lseeki64 returns it
_tell
func _tell(const AFile: int32): clong
C's _tell, hooked: ucrt's _lseek(AFile, 0, SEEK_CUR)
Parameters
AFile: as C's_telltakes it
Returns: as C's _tell returns it
_telli64
func _telli64(const AFile: int32): int64
C's _telli64, hooked: ucrt's _lseeki64(AFile, 0, SEEK_CUR)
Parameters
AFile: as C's_telli64takes it
Returns: as C's _telli64 returns it
_eof
func _eof(const AFile: int32): int32
C's _eof, hooked: a handle's descriptor at its IO's end
Parameters
AFile: as C's_eoftakes it
Returns: as C's _eof returns it
_filelength
func _filelength(const AFile: int32): clong
C's _filelength, hooked: a handle's descriptor's length (DoFdEnd, a long's)
Parameters
AFile: as C's_filelengthtakes it
Returns: as C's _filelength returns it
_filelengthi64
func _filelengthi64(const AFile: int32): int64
C's _filelengthi64, hooked: a handle's descriptor's length
Parameters
AFile: as C's_filelengthi64takes it
Returns: as C's _filelengthi64 returns it
_commit
func _commit(const AFile: int32): int32
C's _commit, hooked: a handle's descriptor flushes its IO
Parameters
AFile: as C's_committakes it
Returns: as C's _commit returns it
_close
func _close(const AFile: int32): int32
C's _close, hooked: a handle's descriptor closes
Parameters
AFile: as C's_closetakes it
Returns: as C's _close returns it
_fstat32
func _fstat32(const AFile: int32; const ABuf: ptr): int32
C's _fstat32, hooked. _fstat32 / _fstat32i64 / _fstat64i32 / _fstat64: a handle's descriptor answered (DoFdStat; ABuf a struct _stat32 / _stat32i64 / _stat64i32 / _stat64)
Parameters
AFile: as C's_fstat32takes itABuf: as C's_fstat32takes it
Returns: as C's _fstat32 returns it
_fstat32i64
func _fstat32i64(const AFile: int32; const ABuf: ptr): int32
C's _fstat32i64, hooked.
Parameters
AFile: as C's_fstat32i64takes itABuf: as C's_fstat32i64takes it
Returns: as C's _fstat32i64 returns it
_fstat64i32
func _fstat64i32(const AFile: int32; const ABuf: ptr): int32
C's _fstat64i32, hooked.
Parameters
AFile: as C's_fstat64i32takes itABuf: as C's_fstat64i32takes it
Returns: as C's _fstat64i32 returns it
_fstat64
func _fstat64(const AFile: int32; const ABuf: ptr): int32
C's _fstat64, hooked.
Parameters
AFile: as C's_fstat64takes itABuf: as C's_fstat64takes it
Returns: as C's _fstat64 returns it
_setmode
func _setmode(const AFile: int32; const AMode: int32): int32
C's _setmode, hooked. _setmode (mingw's oldnames setmode reaches it too): a handle's descriptor's text mode , else ucrt's
Parameters
AFile: as C's_setmodetakes itAMode: as C's_setmodetakes it
Returns: as C's _setmode returns it
_chsize_s
func _chsize_s(const AFile: int32; const ASize: int64): int32
C's _chsize_s, hooked: a handle's descriptor's IO cut or grown, else ucrt's
Parameters
AFile: as C's_chsize_stakes itASize: as C's_chsize_stakes it
Returns: as C's _chsize_s returns it
_chsize
func _chsize(const AFile: int32; const ASize: clong): int32
C's _chsize, hooked. _chsize (mingw's oldnames chsize reaches it too): _chsize_s's 0, else -1 (ucrt's own _chsize over _chsize_s)
Parameters
AFile: as C's_chsizetakes itASize: as C's_chsizetakes it
Returns: as C's _chsize returns it
_get_osfhandle
func _get_osfhandle(const AFile: int32): int64
C's _get_osfhandle, hooked: a handle's descriptor has no OS handle, else ucrt's
Parameters
AFile: as C's_get_osfhandletakes it
Returns: as C's _get_osfhandle returns it
_dup
func _dup(const AFile: int32): int32
C's _dup, hooked. _dup (mingw's oldnames dup reaches it too): a handle's descriptor's dup, else ucrt's
Parameters
AFile: as C's_duptakes it
Returns: as C's _dup returns it
_dup2
func _dup2(const AFile: int32; const ATarget: int32): int32
C's _dup2, hooked. _dup2 (mingw's oldnames dup2 reaches it too): a handle's descriptor onto ATarget , any other onto a handle's number, else ucrt's
Parameters
AFile: as C's_dup2takes itATarget: as C's_dup2takes it
Returns: as C's _dup2 returns it
_fdopen
func _fdopen(const AFile: int32; const AMode: ptr to const char): ptr
C's _fdopen, hooked. _fdopen (mingw's oldnames fdopen reaches it too): a FILE on a handle's descriptor , else ucrt's. ucrt checks the mode before the number: a nil one is EINVAL with the handler run, whoever's the number is
Parameters
AFile: as C's_fdopentakes itAMode: as C's_fdopentakes it
Returns: as C's _fdopen returns it
_wfdopen
func _wfdopen(const AFile: int32; const AMode: ptr to const wchar): ptr
C's _wfdopen, hooked: _fdopen with a UTF-16 mode (DoFdFdopen over its UTF-8; one ucrt cannot convert is EINVAL), else ucrt's
Parameters
AFile: as C's_wfdopentakes itAMode: as C's_wfdopentakes it
Returns: as C's _wfdopen returns it
_stat32
func _stat32(const APath: ptr to const char; const ABuf: ptr): int32
C's _stat32, hooked. ucrt's stat family (_stat32 / _stat32i64 / _stat64i32 / _stat64 and the _w forms; mingw's stat, _stat, _stati64 and _wstat are libcextras aliases of them): a virtual path answered (DoPathStat; ABuf a struct _stat32 / _stat32i64 / _stat64i32 / _stat64), anything else ucrt's
Parameters
APath: as C's_stat32takes itABuf: as C's_stat32takes it
Returns: as C's _stat32 returns it
_stat32i64
func _stat32i64(const APath: ptr to const char; const ABuf: ptr): int32
C's _stat32i64, hooked.
Parameters
APath: as C's_stat32i64takes itABuf: as C's_stat32i64takes it
Returns: as C's _stat32i64 returns it
_stat64i32
func _stat64i32(const APath: ptr to const char; const ABuf: ptr): int32
C's _stat64i32, hooked.
Parameters
APath: as C's_stat64i32takes itABuf: as C's_stat64i32takes it
Returns: as C's _stat64i32 returns it
_stat64
func _stat64(const APath: ptr to const char; const ABuf: ptr): int32
C's _stat64, hooked.
Parameters
APath: as C's_stat64takes itABuf: as C's_stat64takes it
Returns: as C's _stat64 returns it
_wstat32
func _wstat32(const APath: ptr to const wchar; const ABuf: ptr): int32
C's _wstat32, hooked.
Parameters
APath: as C's_wstat32takes itABuf: as C's_wstat32takes it
Returns: as C's _wstat32 returns it
_wstat32i64
func _wstat32i64(const APath: ptr to const wchar; const ABuf: ptr): int32
C's _wstat32i64, hooked.
Parameters
APath: as C's_wstat32i64takes itABuf: as C's_wstat32i64takes it
Returns: as C's _wstat32i64 returns it
_wstat64i32
func _wstat64i32(const APath: ptr to const wchar; const ABuf: ptr): int32
C's _wstat64i32, hooked.
Parameters
APath: as C's_wstat64i32takes itABuf: as C's_wstat64i32takes it
Returns: as C's _wstat64i32 returns it
_wstat64
func _wstat64(const APath: ptr to const wchar; const ABuf: ptr): int32
C's _wstat64, hooked.
Parameters
APath: as C's_wstat64takes itABuf: as C's_wstat64takes it
Returns: as C's _wstat64 returns it
System.IO
files, folders, paths and the clock, the same on every target: import System.IO; and no OS is named.
Import it with import System.IO;.
Routines
FileExists
func cpplink FileExists(const APath: string): bool
True when APath names a file (not a folder).
Parameters
APath: the path to look at
Returns: true for a file, false for a folder or nothing there
Example: if FileExists("game.toml") then LoadSettings(); end;
DirectoryExists
func cpplink DirectoryExists(const APath: string): bool
True when APath names a folder.
Parameters
APath: the path to look at
Returns: true for a folder, false for a file or nothing there
FileSize
func cpplink FileSize(const APath: string): int64
The size of the file APath in bytes.
Parameters
APath: the file
Returns: its size, or -1 when it cannot be read
FileWriteTime
func cpplink FileWriteTime(const APath: string): int64
The last write time of APath in nanoseconds since 1970-01-01 UTC, the same on every target (a file seen from two hosts gives one value, at the file system's own precision).
Parameters
APath: the file
Returns: the time, or -1 when it is a folder, is missing or cannot be read
NowNanos
func cpplink NowNanos(): int64
The time now in nanoseconds since 1970-01-01 UTC, on the scale FileWriteTime gives, so the two compare. Only as closely as the file system's clock allows: a file system stamps a write from a coarser clock (a timer tick, 2 s on FAT) or from another host's (a network or WSL drive), so a file written just after a reading can show a write time a little before it; compare with a margin.
Returns: the time now
Example: if FileWriteTime(LPath) >= NowNanos() - LMarginNs then .. end;
ReadAllBytes
func cpplink ReadAllBytes(const APath: string; var ABytes: ByteArray): bool
The whole file APath read into ABytes, its bytes as they are; a file that reports no size (Linux's /proc files, a pipe) is read on to its end.
Parameters
APath: the file to readABytes: receives the bytes (empty on failure)
Returns: false when it is a folder, is missing, or cannot be opened or read
ReadAllText
func cpplink ReadAllText(const APath: string; var AText: string): bool
The whole file APath read into AText, its bytes as they are (UTF-8; no newline or code page conversion); a file that reports no size (Linux's /proc files, a pipe) is read on to its end.
Parameters
APath: the file to readAText: receives the text ("" on failure)
Returns: false when it is a folder, is missing, or cannot be opened or read
Example: if ReadAllText("notes.txt", LText) then println(LText); end;
WriteAllBytes
func cpplink WriteAllBytes(const APath: string; const ABytes: ByteArray): bool
ABytes written as the whole file APath: a file there is replaced, a missing one is made in a folder that exists.
Parameters
APath: the file to writeABytes: its new contents
Returns: false when the path is a folder, its folder is missing, or it cannot be fully written
WriteAllText
func cpplink WriteAllText(const APath: string; const AText: string): bool
AText's bytes written as the whole file APath (no BOM; line ends as the caller wrote them), straight from AText: the same replacing and the same failures as WriteAllBytes.
Parameters
APath: the file to writeAText: its new contents
Returns: false when the path is a folder, its folder is missing, or it cannot be fully written
Example: WriteAllText("out.txt", "hello");
ReplaceFile
func cpplink ReplaceFile(const ASourcePath: string; const ATargetPath: string): bool
ASourcePath renamed over ATargetPath in one step, so a file written whole elsewhere is put in place at once.
Parameters
ASourcePath: the new fileATargetPath: the file it replaces
Returns: true when the target now holds the source
DeleteFile
func cpplink DeleteFile(const APath: string): bool
The file APath deleted.
Parameters
APath: the file
Returns: false when it is not there or cannot be deleted
CreateDir
func cpplink CreateDir(const APath: string): bool
The folder APath made; its parent must exist (ForceDirectories makes the parents too).
Parameters
APath: the folder
Returns: false when it cannot be made
ForceDirectories
func cpplink ForceDirectories(const APath: string): bool
The folder APath made with every missing parent.
Parameters
APath: the folder
Returns: true when it is there afterwards
GetFiles
func cpplink GetFiles(const ADir: string; var AList: StringArray): bool
The names of the files in the folder ADir, in a fixed order.
Parameters
ADir: the folderAList: receives the names (no path)
Returns: false when the folder cannot be read
GetDirectories
func cpplink GetDirectories(const ADir: string; var AList: StringArray): bool
The names of the folders in the folder ADir, in a fixed order.
Parameters
ADir: the folderAList: receives the names (no path)
Returns: false when the folder cannot be read
func cpplink GetFiles(const ADir: string; const AMask: string; const ARecursive: bool; var AList: StringArray): bool
The files under the folder ADir whose names match AMask, as paths relative to it with / between parts ("x.png", "sprites/ship.png"): a folder's files in GetFiles' fixed order, then (with ARecursive) each of its folders the same way. A folder link is listed through but never entered.
Parameters
ADir: the folderAMask: one or moreMatchesGlobmasks split by;("*.png;*.jpg"), matched to the name alone with ASCII case aside (*.pngtakesA.PNG);""takes every fileARecursive: true to look in every folder below it as wellAList: the files found (empty on a failure)
Returns: false when ADir (or a folder below it) cannot be read
Example: if GetFiles("$P:res/assets", "*.png", true, LImages) then .. end;
ResolvePath
func cpplink ResolvePath(const APath: string; const ABaseDir: string): string
APath as a full path: a $P: prefix is the program's folder; $D: or no prefix is ABaseDir.
Parameters
APath: the path to resolveABaseDir: the folder a relative path starts from (the working folder when "")
Returns: the full path, or "" when it resolves to nothing
Example: ResolvePath("$P:assets.zip", "")
func cpplink ResolvePath(const APath: string): string
APath resolved as ResolvePath does, against the working folder.
Parameters
APath: the path to resolve
Returns: the full path, or "" when it resolves to nothing
SamePath
func cpplink SamePath(const AFirst: string; const ASecond: string): bool
True when the two paths name the same file, compared as this OS compares names.
Parameters
AFirst: one pathASecond: the other path
Returns: true for the same file
SystemDir
func cpplink SystemDir(): string
The OS's own library folder (where its system libraries are).
Returns: the folder
UserCacheDir
func cpplink UserCacheDir(): string
The user's cache folder for Adam.
Returns: the folder, or "" when the OS gives none
SecureRandomBytes
func cpplink SecureRandomBytes(const ACount: int64; var ABytes: ByteArray): bool
ACount bytes from the OS's secure random generator.
Parameters
ACount: how many bytesABytes: receives them
Returns: false when the generator fails
TickCountMs
func cpplink TickCountMs(): int64
Milliseconds since a start the OS chooses: for timing, never a date.
Returns: the count
Delay
func cpplink Delay(const AMilliseconds: int32)
Waits AMilliseconds, then returns: at least that long (the OS may wake the program a little later). A wait of 0 or less returns at once.
Parameters
AMilliseconds: how long to wait
Example: Delay(250);
PerformanceCounter
func cpplink PerformanceCounter(): int64
The high-resolution clock's reading: it never goes back, for timing, never a date; only the difference of two readings means anything, in PerformanceFrequency's units.
Returns: the reading
Example: LMs := (PerformanceCounter() - LStart) * 1000 div PerformanceFrequency();
PerformanceFrequency
func cpplink PerformanceFrequency(): int64
The high-resolution clock's counts per second (fixed while the program runs, above 0).
Returns: the counts per second
ExeDir
func cpplink ExeDir(): string
The folder of this program's exe (asked of the OS, never argv[0]), in ResolvePath's form.
Returns: the folder, or "" when the OS cannot tell
TempDir
func cpplink TempDir(): string
The system's folder for temporary files (Windows: GetTempPathW's; Linux: $TMPDIR, else /tmp), resolved.
Returns: the folder, or "" when the system names none
RemoveDir
func cpplink RemoveDir(const APath: string): bool
The empty folder APath removed; a folder holding anything is left as it is.
Parameters
APath: the folder
Returns: false when it is not empty, is a file, is missing or the OS refuses it
func cpplink RemoveDir(const APath: string; const ARecursive: bool): bool
The folder APath removed; with ARecursive everything in it first, folder by folder. A link inside (on x86_64-windows-gnu a junction or a symbolic link, on x86_64-linux-gnu a symbolic link, a broken one too) is removed as the link, never followed, so nothing outside APath is touched; APath itself a link to a folder: only the link goes. A read-only file is removed as well (x86_64-windows-gnu clears its read-only attribute first). Without ARecursive it is the one-argument RemoveDir (an empty folder only).
Parameters
APath: the folder (ResolvePath's prefixes taken)ARecursive: true to remove what it holds too
Returns: true when APath is gone after; false when it is no folder or something in it cannot be removed (an open file on x86_64-windows-gnu, a folder without write permission on x86_64-linux-gnu): what could be removed is gone, the rest is left
Example: if DirectoryExists(LScratch) then RemoveDir(LScratch, true); end;
RenameFile
func cpplink RenameFile(const AOldPath: string; const ANewPath: string): bool
The file AOldPath given the new name ANewPath, moved to another folder, drive or file system too (there copied, then removed). Something at ANewPath is never replaced (ReplaceFile does that).
Parameters
AOldPath: the fileANewPath: its new path
Returns: false when AOldPath is not a file, ANewPath exists, its folder is missing or the OS refuses it
SetFileReadOnly
func cpplink SetFileReadOnly(const APath: string; const AReadOnly: bool): bool
The file APath marked read-only (AReadOnly) or writable again, its other attributes kept. Windows: the read-only attribute, so the file is never replaced, renamed over or deleted while it is set. Linux: every write permission bit off, or the owner's back on; there the folder's permissions, not the file's, decide a rename or a delete.
Parameters
APath: the fileAReadOnly: true to make it read-only, false to make it writable again
Returns: false for a folder or a missing path
SetFileExecutable
func cpplink SetFileExecutable(const APath: string): bool
The file APath made runnable as a program: on x86_64-linux-gnu an execute bit is added for each of the owner, group and others that may read it (chmod), the other bits kept; on x86_64-windows-gnu a program runs by its extension, so nothing changes
Parameters
APath: the file (a program or a shared library just written)
Returns: true when the file can be run after; false for a folder, a missing path or a change the OS refuses
Example: if not SetFileExecutable(LExe) then println("cannot run {}", LExe); end;
GetEnvironmentVariable
func cpplink GetEnvironmentVariable(const AName: string): string
The value of this process's environment variable AName.
Parameters
AName: the variable
Returns: its value; "" when it is not set (or set to "") or AName is ""
Example: LHome := GetEnvironmentVariable("HOME");
SetEnvironmentVariable
func cpplink SetEnvironmentVariable(const AName: string; const AValue: string): bool
This process's environment variable AName set to AValue; a process it starts inherits it.
Parameters
AName: the variableAValue: its value ("" leaves it empty, whichGetEnvironmentVariablereads as not set)
Returns: true when it holds the asked value afterwards
IsFileHidden
func cpplink IsFileHidden(const APath: string): bool
True when APath names an existing file or folder the system hides from a plain listing: on x86_64-windows-gnu its hidden attribute is set, on x86_64-linux-gnu its name starts with . (a dot file). False for a missing path.
Parameters
APath: the file or folder (ResolvePath's prefixes taken)
Returns: true when it is hidden
Example: if not IsFileHidden(LPath) then LShown.Add(LPath); end;
IsPathAbsolute
func cpplink IsPathAbsolute(const APath: string): bool
True when APath is a full path by this target's rule, as text (the disk is never asked): x86_64-windows-gnu a drive and a separator (C:\x, d:/x) or two separators (\\server\share); x86_64-linux-gnu a leading / (or \). ResolvePath makes any path full.
Parameters
APath: the path
Returns: true when it needs no base folder
Example: if not IsPathAbsolute(LPath) then LPath := ResolvePath(LPath, LBase); end;
CurrentDir
func cpplink CurrentDir(): string
The process's working folder as the OS keeps it (the one a relative path is found from), in ResolvePath's form; "" when the OS cannot tell.
Returns: the working folder
Example: LStart := CurrentDir(); SetCurrentDir(LProject); .. SetCurrentDir(LStart);
SetCurrentDir
func cpplink SetCurrentDir(const APath: string): bool
Makes the folder APath the process's working folder (the OS's own: a C library's hooked chdir into a mounted source is another matter, HookIO's). A program it starts inherits it.
Parameters
APath: the folder (ResolvePath's prefixes taken)
Returns: false for a file, a missing path or one the OS refuses (the working folder kept)
Example: if SetCurrentDir("$P:") then .. end;
CopyFile
func cpplink CopyFile(const ASourcePath: string; const ATargetPath: string; const AOverwrite: bool): bool
Copies the file ASourcePath to ATargetPath: its bytes and permissions (on x86_64-windows-gnu its attributes and times as well).
Parameters
ASourcePath: the file copiedATargetPath: the new file (its folder must exist)AOverwrite: true to replace a file already atATargetPath
Returns: false when ASourcePath is not a file, ATargetPath is a folder, a file is there and not AOverwrite, the two name one file, or a read or write fails (no half-written file is left)
Example: CopyFile("save.dat", "save.bak", true);
FormatCList
func cpplink FormatCList(const AFormat: ptr to const char; const AArgs: ptr): string
The text of the C format AFormat over the C va_list AArgs, as C's printf writes it: for a C callback that hands over a format and its arguments (a library's log hook), or a clink variadic's own varargs.clist(). "" when the C runtime cannot make it (or AFormat is nil).
Parameters
AFormat: the NUL-terminated printf formatAArgs: the C va_list of its arguments (on x86_64-linux-gnu read once: format it once)
Returns: the formatted text
Example: func clink OnLog(ALevel: int32; AText: ptr to const char; AArgs: ptr); begin println(FormatCList(AText, AArgs)); end;
System.IO.Linux64
System.IO's platform unit for x86_64-linux-gnu: the same IOPlatform* routines as System.IO.Win64, over glibc (System.Linux's declarations) and System.Runtime's neutral path routines (PathKind, ListFolder, RemoveFile, FullPath, ProgramPath).
Import it with import System.IO.Linux64;.
Routines
IOPlatformResolvePath
func cpplink IOPlatformResolvePath(const APath: string; const ABaseDir: string): string
System.IO's ResolvePath: $P: the exe's folder, $D: the working folder, $S: (or none) ABaseDir ("" = the working folder), $R: ""; a path rooted at '/' only normalized; '\' read as '/'; the result full, folded, no trailing '/' but the root's. "" for an empty path, a prefix alone, or a path that cannot be made full.
Parameters
APath: asResolvePathtakes itABaseDir: asResolvePathtakes it
Returns: as ResolvePath returns it
func cpplink IOPlatformResolvePath(const APath: string): string
System.IO's ResolvePath against the working folder.
Parameters
APath: asResolvePathtakes it
Returns: as ResolvePath returns it
IOPlatformFileExists
func cpplink IOPlatformFileExists(const APath: string): bool
System.IO's FileExists: a file, a link followed.
Parameters
APath: asFileExiststakes it
Returns: as FileExists returns it
IOPlatformDirectoryExists
func cpplink IOPlatformDirectoryExists(const APath: string): bool
System.IO's DirectoryExists: a folder, a link followed.
Parameters
APath: asDirectoryExiststakes it
Returns: as DirectoryExists returns it
IOPlatformFileSize
func cpplink IOPlatformFileSize(const APath: string): int64
System.IO's FileSize: a file's size in bytes; -1 for a folder, a missing path or one that cannot be read.
Parameters
APath: asFileSizetakes it
Returns: as FileSize returns it
IOPlatformFileWriteTime
func cpplink IOPlatformFileWriteTime(const APath: string): int64
System.IO's FileWriteTime: st_mtim as nanoseconds since 1970-01-01 UTC, as on every target; -1 for a folder, a missing path or one that cannot be read.
Parameters
APath: asFileWriteTimetakes it
Returns: as FileWriteTime returns it
IOPlatformNowNanos
func cpplink IOPlatformNowNanos(): int64
System.IO's NowNanos: CLOCK_REALTIME as nanoseconds since 1970-01-01 UTC, the clock IOPlatformFileWriteTime's st_mtim gives.
Returns: as NowNanos returns it
IOPlatformReplaceFile
func cpplink IOPlatformReplaceFile(const ASourcePath: string; const ATargetPath: string): bool
System.IO's ReplaceFile: rename(2), which puts the file in the target's place in one step; false when ASourcePath is not a file, ATargetPath is a folder or the OS refuses it (another file system).
Parameters
ASourcePath: asReplaceFiletakes itATargetPath: asReplaceFiletakes it
Returns: as ReplaceFile returns it
IOPlatformDeleteFile
func cpplink IOPlatformDeleteFile(const APath: string): bool
System.IO's DeleteFile: a file only, never a folder.
Parameters
APath: asDeleteFiletakes it
Returns: as DeleteFile returns it
IOPlatformCreateDir
func cpplink IOPlatformCreateDir(const APath: string): bool
System.IO's CreateDir: one folder, its parent there already; false when the name exists.
Parameters
APath: asCreateDirtakes it
Returns: as CreateDir returns it
IOPlatformForceDirectories
func cpplink IOPlatformForceDirectories(const APath: string): bool
System.IO's ForceDirectories: every missing folder made, the top first; true when the path is a folder after. A loop, never a recursion, so a deep path takes no stack.
Parameters
APath: asForceDirectoriestakes it
Returns: as ForceDirectories returns it
IOPlatformGetFiles
func cpplink IOPlatformGetFiles(const ADir: string; var AList: StringArray): bool
System.IO's GetFiles: the files in ADir, sorted by their bytes.
Parameters
ADir: asGetFilestakes itAList: asGetFilestakes it
Returns: as GetFiles returns it
IOPlatformGetDirectories
func cpplink IOPlatformGetDirectories(const ADir: string; var AList: StringArray): bool
System.IO's GetDirectories: the folders in ADir, sorted by their bytes.
Parameters
ADir: asGetDirectoriestakes itAList: asGetDirectoriestakes it
Returns: as GetDirectories returns it
IOPlatformSamePath
func cpplink IOPlatformSamePath(const AFirst: string; const ASecond: string): bool
System.IO's SamePath: the two resolved paths byte for byte (Linux's names keep their case); false when either resolves to "".
Parameters
AFirst: asSamePathtakes itASecond: asSamePathtakes it
Returns: as SamePath returns it
IOPlatformSystemDir
func cpplink IOPlatformSystemDir(): string
System.IO's SystemDir: the first of glibc's library folders that holds libc.so.6; "" when none does.
Returns: as SystemDir returns it
IOPlatformUserCacheDir
func cpplink IOPlatformUserCacheDir(): string
System.IO's UserCacheDir: $XDG_CACHE_HOME when it is an absolute path, else $HOME/.cache (the XDG base directory spec), resolved; "" when neither is set.
Returns: as UserCacheDir returns it
IOPlatformSecureRandomBytes
func cpplink IOPlatformSecureRandomBytes(const ACount: int64; var ABytes: ByteArray): bool
System.IO's SecureRandomBytes: getrandom(2) from the kernel's generator, a call a signal broke off made again; false when it fails (ABytes then empty).
Parameters
ACount: asSecureRandomBytestakes itABytes: asSecureRandomBytestakes it
Returns: as SecureRandomBytes returns it
IOPlatformTickCountMs
func cpplink IOPlatformTickCountMs(): int64
System.IO's TickCountMs: CLOCK_MONOTONIC in milliseconds.
Returns: as TickCountMs returns it
IOPlatformDelay
func cpplink IOPlatformDelay(const AMilliseconds: int32)
System.IO's Delay: nanosleep(2), the time left slept again when a signal woke it.
Parameters
AMilliseconds: asDelaytakes it
IOPlatformPerformanceCounter
func cpplink IOPlatformPerformanceCounter(): int64
System.IO's PerformanceCounter: CLOCK_MONOTONIC in nanoseconds.
Returns: as PerformanceCounter returns it
IOPlatformPerformanceFrequency
func cpplink IOPlatformPerformanceFrequency(): int64
System.IO's PerformanceFrequency: nanoseconds, 10^9 counts a second.
Returns: as PerformanceFrequency returns it
IOPlatformExeDir
func cpplink IOPlatformExeDir(): string
System.IO's ExeDir: the folder of /proc/self/exe's target, resolved; "" when the OS cannot tell.
Returns: as ExeDir returns it
IOPlatformTempDir
func cpplink IOPlatformTempDir(): string
System.IO's TempDir: $TMPDIR when it is an absolute path, else stdio.h's P_tmpdir (/tmp), resolved.
Returns: as TempDir returns it
IOPlatformRemoveTree
func cpplink IOPlatformRemoveTree(const APath: string): bool
System.IO's recursive RemoveDir: the folder and everything in it (DoRemoveTree); APath itself a link to a folder: only the link goes.
Parameters
APath: asRemoveDirtakes it
Returns: as RemoveDir returns it
IOPlatformRemoveDir
func cpplink IOPlatformRemoveDir(const APath: string): bool
System.IO's RemoveDir: rmdir(2), an empty folder only.
Parameters
APath: asRemoveDirtakes it
Returns: as RemoveDir returns it
IOPlatformRenameFile
func cpplink IOPlatformRenameFile(const AOldPath: string; const ANewPath: string): bool
System.IO's RenameFile: rename(2) of a file onto a name nothing holds (a dangling link is a name too: never replaced); across file systems (EXDEV) the file copied, then removed.
Parameters
AOldPath: asRenameFiletakes itANewPath: asRenameFiletakes it
Returns: as RenameFile returns it
IOPlatformSetFileReadOnly
func cpplink IOPlatformSetFileReadOnly(const APath: string; const AReadOnly: bool): bool
System.IO's SetFileReadOnly: chmod(2), every write bit off (read-only) or the owner's back on (writable), the other bits kept.
Parameters
APath: asSetFileReadOnlytakes itAReadOnly: asSetFileReadOnlytakes it
Returns: as SetFileReadOnly returns it
IOPlatformSetFileExecutable
func cpplink IOPlatformSetFileExecutable(const APath: string): bool
System.IO's SetFileExecutable: chmod(2), an execute bit added beside every read bit, the other bits kept.
Parameters
APath: asSetFileExecutabletakes it
Returns: as SetFileExecutable returns it
IOPlatformGetEnvironmentVariable
func cpplink IOPlatformGetEnvironmentVariable(const AName: string): string
System.IO's GetEnvironmentVariable: getenv(3); "" when it is not set or AName is "".
Parameters
AName: asGetEnvironmentVariabletakes it
Returns: as GetEnvironmentVariable returns it
IOPlatformSetEnvironmentVariable
func cpplink IOPlatformSetEnvironmentVariable(const AName: string; const AValue: string): bool
System.IO's SetEnvironmentVariable: setenv(3), an existing value replaced; false for "" or a name holding '='.
Parameters
AName: asSetEnvironmentVariabletakes itAValue: asSetEnvironmentVariabletakes it
Returns: as SetEnvironmentVariable returns it
IOPlatformFormatCList
func cpplink IOPlatformFormatCList(const AFormat: ptr to const char; const AArgs: ptr): string
System.IO's FormatCList: glibc's vasprintf, in one call (a linux va_list is the state of its arguments, read once), its text given back with free; "" when glibc cannot make it.
Parameters
AFormat: asFormatCListtakes itAArgs: asFormatCListtakes it
Returns: as FormatCList returns it
IOPlatformIsFileHidden
func cpplink IOPlatformIsFileHidden(const APath: string): bool
System.IO's IsFileHidden by Linux's rule: an existing file or folder whose name starts with '.' (a dot file: what ls and file managers leave out).
Parameters
APath: asIsFileHiddentakes it
Returns: as IsFileHidden returns it
IOPlatformIsPathAbsolute
func cpplink IOPlatformIsPathAbsolute(const APath: string): bool
System.IO's IsPathAbsolute by Linux's rule, as text: rooted at '/' ('\' read as '/').
Parameters
APath: asIsPathAbsolutetakes it
Returns: as IsPathAbsolute returns it
IOPlatformSetCurrentDir
func cpplink IOPlatformSetCurrentDir(const APath: string): bool
System.IO's SetCurrentDir: the kernel's chdir (SYS_chdir through syscall: HookIO's chdir hook, which can enter a mounted source's folder, is not between), so the working folder is the OS's own on both targets; false for a file, a missing path or one the kernel refuses.
Parameters
APath: asSetCurrentDirtakes it
Returns: as SetCurrentDir returns it
IOPlatformCopyFile
func cpplink IOPlatformCopyFile(const ASourcePath: string; const ATargetPath: string; const AOverwrite: bool): bool
System.IO's CopyFile: DoCopy over the two paths resolved; false when ASourcePath is not a file or ATargetPath is a folder.
Parameters
ASourcePath: asCopyFiletakes itATargetPath: asCopyFiletakes itAOverwrite: asCopyFiletakes it
Returns: as CopyFile returns it
System.IO.Win64
System.IO's platform unit for x86_64-windows-gnu: each IOPlatform* routine is System.Windows' Win* routine of the same job.
Import it with import System.IO.Win64;.
Routines
IOPlatformFileExists
func cpplink IOPlatformFileExists(const APath: string): bool
System.IO's FileExists: System.Windows' Win* routine of the same job.
Parameters
APath: asFileExiststakes it
Returns: as FileExists returns it
IOPlatformDirectoryExists
func cpplink IOPlatformDirectoryExists(const APath: string): bool
System.IO's DirectoryExists: System.Windows' Win* routine of the same job.
Parameters
APath: asDirectoryExiststakes it
Returns: as DirectoryExists returns it
IOPlatformFileSize
func cpplink IOPlatformFileSize(const APath: string): int64
System.IO's FileSize: System.Windows' Win* routine of the same job.
Parameters
APath: asFileSizetakes it
Returns: as FileSize returns it
IOPlatformFileWriteTime
func cpplink IOPlatformFileWriteTime(const APath: string): int64
System.IO's FileWriteTime: System.Windows' WinFileWriteTime (FILETIME ticks) as nanoseconds since 1970-01-01 UTC, as on every target (ACU4); -1 as WinFileWriteTime's.
Parameters
APath: asFileWriteTimetakes it
Returns: as FileWriteTime returns it
IOPlatformNowNanos
func cpplink IOPlatformNowNanos(): int64
System.IO's NowNanos: System.Windows' WinSystemTime (FILETIME ticks) as nanoseconds since 1970-01-01 UTC, the clock IOPlatformFileWriteTime gives.
Returns: as NowNanos returns it
IOPlatformReplaceFile
func cpplink IOPlatformReplaceFile(const ASourcePath: string; const ATargetPath: string): bool
System.IO's ReplaceFile: System.Windows' Win* routine of the same job.
Parameters
ASourcePath: asReplaceFiletakes itATargetPath: asReplaceFiletakes it
Returns: as ReplaceFile returns it
IOPlatformDeleteFile
func cpplink IOPlatformDeleteFile(const APath: string): bool
System.IO's DeleteFile: System.Windows' Win* routine of the same job.
Parameters
APath: asDeleteFiletakes it
Returns: as DeleteFile returns it
IOPlatformCreateDir
func cpplink IOPlatformCreateDir(const APath: string): bool
System.IO's CreateDir: System.Windows' Win* routine of the same job.
Parameters
APath: asCreateDirtakes it
Returns: as CreateDir returns it
IOPlatformForceDirectories
func cpplink IOPlatformForceDirectories(const APath: string): bool
System.IO's ForceDirectories: System.Windows' Win* routine of the same job.
Parameters
APath: asForceDirectoriestakes it
Returns: as ForceDirectories returns it
IOPlatformGetFiles
func cpplink IOPlatformGetFiles(const ADir: string; var AList: StringArray): bool
System.IO's GetFiles: System.Windows' Win* routine of the same job.
Parameters
ADir: asGetFilestakes itAList: asGetFilestakes it
Returns: as GetFiles returns it
IOPlatformGetDirectories
func cpplink IOPlatformGetDirectories(const ADir: string; var AList: StringArray): bool
System.IO's GetDirectories: System.Windows' Win* routine of the same job.
Parameters
ADir: asGetDirectoriestakes itAList: asGetDirectoriestakes it
Returns: as GetDirectories returns it
IOPlatformResolvePath
func cpplink IOPlatformResolvePath(const APath: string; const ABaseDir: string): string
System.IO's ResolvePath: System.Windows' Win* routine of the same job.
Parameters
APath: asResolvePathtakes itABaseDir: asResolvePathtakes it
Returns: as ResolvePath returns it
func cpplink IOPlatformResolvePath(const APath: string): string
System.IO's ResolvePath: System.Windows' Win* routine of the same job.
Parameters
APath: asResolvePathtakes it
Returns: as ResolvePath returns it
IOPlatformSamePath
func cpplink IOPlatformSamePath(const AFirst: string; const ASecond: string): bool
System.IO's SamePath: System.Windows' Win* routine of the same job.
Parameters
AFirst: asSamePathtakes itASecond: asSamePathtakes it
Returns: as SamePath returns it
IOPlatformSystemDir
func cpplink IOPlatformSystemDir(): string
System.IO's SystemDir: System.Windows' Win* routine of the same job.
Returns: as SystemDir returns it
IOPlatformUserCacheDir
func cpplink IOPlatformUserCacheDir(): string
System.IO's UserCacheDir: System.Windows' Win* routine of the same job.
Returns: as UserCacheDir returns it
IOPlatformSecureRandomBytes
func cpplink IOPlatformSecureRandomBytes(const ACount: int64; var ABytes: ByteArray): bool
System.IO's SecureRandomBytes: System.Windows' Win* routine of the same job.
Parameters
ACount: asSecureRandomBytestakes itABytes: asSecureRandomBytestakes it
Returns: as SecureRandomBytes returns it
IOPlatformTickCountMs
func cpplink IOPlatformTickCountMs(): int64
System.IO's TickCountMs: System.Windows' Win* routine of the same job.
Returns: as TickCountMs returns it
IOPlatformDelay
func cpplink IOPlatformDelay(const AMilliseconds: int32)
System.IO's Delay: System.Windows' Win* routine of the same job.
Parameters
AMilliseconds: asDelaytakes it
IOPlatformPerformanceCounter
func cpplink IOPlatformPerformanceCounter(): int64
System.IO's PerformanceCounter: System.Windows' Win* routine of the same job.
Returns: as PerformanceCounter returns it
IOPlatformPerformanceFrequency
func cpplink IOPlatformPerformanceFrequency(): int64
System.IO's PerformanceFrequency: System.Windows' Win* routine of the same job.
Returns: as PerformanceFrequency returns it
IOPlatformExeDir
func cpplink IOPlatformExeDir(): string
System.IO's ExeDir: System.Windows' Win* routine of the same job.
Returns: as ExeDir returns it
IOPlatformTempDir
func cpplink IOPlatformTempDir(): string
System.IO's TempDir: System.Windows' Win* routine of the same job.
Returns: as TempDir returns it
IOPlatformRemoveDir
func cpplink IOPlatformRemoveDir(const APath: string): bool
System.IO's RemoveDir: System.Windows' Win* routine of the same job.
Parameters
APath: asRemoveDirtakes it
Returns: as RemoveDir returns it
IOPlatformRemoveTree
func cpplink IOPlatformRemoveTree(const APath: string): bool
System.IO's recursive RemoveDir: System.Windows' Win* routine of the same job.
Parameters
APath: asRemoveDirtakes it
Returns: as RemoveDir returns it
IOPlatformRenameFile
func cpplink IOPlatformRenameFile(const AOldPath: string; const ANewPath: string): bool
System.IO's RenameFile: System.Windows' Win* routine of the same job.
Parameters
AOldPath: asRenameFiletakes itANewPath: asRenameFiletakes it
Returns: as RenameFile returns it
IOPlatformSetFileReadOnly
func cpplink IOPlatformSetFileReadOnly(const APath: string; const AReadOnly: bool): bool
System.IO's SetFileReadOnly: System.Windows' Win* routine of the same job.
Parameters
APath: asSetFileReadOnlytakes itAReadOnly: asSetFileReadOnlytakes it
Returns: as SetFileReadOnly returns it
IOPlatformSetFileExecutable
func cpplink IOPlatformSetFileExecutable(const APath: string): bool
System.IO's SetFileExecutable: a Windows program runs by its extension, so nothing to set; true for a file.
Parameters
APath: asSetFileExecutabletakes it
Returns: as SetFileExecutable returns it
IOPlatformGetEnvironmentVariable
func cpplink IOPlatformGetEnvironmentVariable(const AName: string): string
System.IO's GetEnvironmentVariable: System.Windows' Win* routine of the same job.
Parameters
AName: asGetEnvironmentVariabletakes it
Returns: as GetEnvironmentVariable returns it
IOPlatformSetEnvironmentVariable
func cpplink IOPlatformSetEnvironmentVariable(const AName: string; const AValue: string): bool
System.IO's SetEnvironmentVariable: System.Windows' Win* routine of the same job.
Parameters
AName: asSetEnvironmentVariabletakes itAValue: asSetEnvironmentVariabletakes it
Returns: as SetEnvironmentVariable returns it
IOPlatformFormatCList
func cpplink IOPlatformFormatCList(const AFormat: ptr to const char; const AArgs: ptr): string
System.IO's FormatCList: System.Windows' Win* routine of the same job.
Parameters
AFormat: asFormatCListtakes itAArgs: asFormatCListtakes it
Returns: as FormatCList returns it
IOPlatformIsFileHidden
func cpplink IOPlatformIsFileHidden(const APath: string): bool
System.IO's IsFileHidden: System.Windows' Win* routine of the same job (the hidden attribute).
Parameters
APath: asIsFileHiddentakes it
Returns: as IsFileHidden returns it
IOPlatformIsPathAbsolute
func cpplink IOPlatformIsPathAbsolute(const APath: string): bool
System.IO's IsPathAbsolute by Windows' rule, as text: a drive and a separator (C:\, d:/) or two separators (\server\share, \?\..); "C:x" (the drive's own folder) and "\x" (the working drive's root) are relative to something.
Parameters
APath: asIsPathAbsolutetakes it
Returns: as IsPathAbsolute returns it
IOPlatformSetCurrentDir
func cpplink IOPlatformSetCurrentDir(const APath: string): bool
System.IO's SetCurrentDir: System.Windows' Win* routine of the same job.
Parameters
APath: asSetCurrentDirtakes it
Returns: as SetCurrentDir returns it
IOPlatformCopyFile
func cpplink IOPlatformCopyFile(const ASourcePath: string; const ATargetPath: string; const AOverwrite: bool): bool
System.IO's CopyFile: System.Windows' Win* routine of the same job.
Parameters
ASourcePath: asCopyFiletakes itATargetPath: asCopyFiletakes itAOverwrite: asCopyFiletakes it
Returns: as CopyFile returns it
System.JSON.Ext
JSON documents in Adam, over yyjson's C API (System.JSON.C): StdApp.JSON's fluent surface. A JSON is a value: a view of one node of a document tree that every view of it shares (held by a ref, so the tree lives while any view does; a view costs no copy). A plain LJ: JSON; is an empty object, its tree made at its first change; a copy taken before that change is an empty object of its own.
Import it with import System.JSON.Ext;.
Types
JSONCallback
type JSONCallback = func(const AItem: JSON; const AUserData: ptr)
ForEach's callback: each item of an array or value of an object, and the pointer given.
JSON
type JSON = object
A JSON value: a view of one node of a document tree every view of it shares (no copy). A plain LJ: JSON; is an empty object, its tree made at its first change.
Members
method Parse(const AText: string): bool: Parses JSON text into this value's tree. Parameters:ATextthe JSON text. Returns: false with ErrorText (<text>(line,col): message) when it is no valid JSONmethod LoadFromFile(const APath: string): bool: Reads a JSON file into this value's tree, through C's file calls (so a HookIO path reads its IO). Parameters:APaththe file. Returns: false with ErrorText (APath: message (byte N), or that the file cannot be opened)method LoadFromIO(const AIO: IO): bool: Reads the JSON text an IO holds, from its place to its end, into this value's tree. Parameters:AIOthe IO. Returns: false with ErrorText (<io>(line,col): message)const method ErrorText(): string: Why the last Parse, LoadFromFile, LoadFromIO or JSON.From* failed. Returns: the reason, or "" when it did not failstatic method FromString(const AText: string): JSON: A JSON value parsed from text. Parameters:ATextthe JSON text. Returns: the value; a missing value with its ErrorText when it is no valid JSON Example:LCfg := JSON.FromString("{\"port\": 8080}"); println("{}", LCfg.Get("port").AsInt32());static method FromFile(const APath: string): JSON: A JSON value read from a file, through C's file calls (a HookIO path reads its IO). Parameters:APaththe file. Returns: the value; a missing value with its ErrorText on a failurestatic method FromIO(const AIO: IO): JSON: A JSON value read from the text an IO holds, from its place to its end. Parameters:AIOthe IO. Returns: the value; a missing value with its ErrorText on a failurestatic method TryFromString(const AText: string; var AJSON: JSON): bool: A JSON value parsed from text, the outcome as a result. Parameters:ATextthe JSON text;AJSONreceives the value (a missing value, its ErrorText why, on a failure). Returns: false when it is no valid JSONconst method ToString(): string: The value as compact JSON text. Returns: the text ("{}" for a fresh value, "null" for a missing one)const method ToPrettyString(): string: The value as JSON text, a line per member, 2 spaces a level. Returns: the textconst method ToPrettyString(const AIndent: int32): string: The value as JSON text, a line per member. Parameters:AIndentthe spaces per level. Returns: the textmethod SaveToFile(const APath: string): bool: Writes the value to a file, pretty (2 spaces), through C's file calls (a HookIO path writes its IO). Parameters:APaththe file. Returns: false when it cannot be writtenmethod SaveToFile(const APath: string; const APretty: bool): bool: Writes the value to a file, through C's file calls. Parameters:APaththe file;APrettytrue for 2 spaces a level, false for compact text. Returns: false when it cannot be writtenmethod SaveToIO(const AIO: IO): bool: Writes the value's text to an IO at its place, pretty (2 spaces). Parameters:AIOthe IO. Returns: false when not all of it could be writtenmethod SaveToIO(const AIO: IO; const APretty: bool): bool: Writes the value's text to an IO at its place. Parameters:AIOthe IO;APrettytrue for 2 spaces a level, false for compact text. Returns: false when not all of it could be writtenmethod Add(const AKey: string; const AValue: string): JSON: Adds a string under a key to the open object (every integer type has its own overload, so a Adds a string under a key to the open object (nothing changes in an array). Parameters:AKeythe key;AValuethe value. Returns: this value, so calls chainmethod Add(const AKey: string; const AValue: int32): JSON: Adds a signed number under a key to the open object (every integer type has its own overload, so a call is never ambiguous; nothing changes in an array). Parameters:AKeythe key;AValuethe value. Returns: this value, so calls chainmethod Add(const AKey: string; const AValue: int64): JSON: Adds a signed number under a key to the open object (every integer type has its own overload, so a call is never ambiguous; nothing changes in an array). Parameters:AKeythe key;AValuethe value. Returns: this value, so calls chainmethod Add(const AKey: string; const AValue: uint32): JSON: Adds an unsigned number under a key to the open object (every integer type has its own overload, so a call is never ambiguous; nothing changes in an array). Parameters:AKeythe key;AValuethe value. Returns: this value, so calls chainmethod Add(const AKey: string; const AValue: uint64): JSON: Adds an unsigned number under a key to the open object (every integer type has its own overload, so a call is never ambiguous; nothing changes in an array). Parameters:AKeythe key;AValuethe value. Returns: this value, so calls chainmethod Add(const AKey: string; const AValue: float64): JSON: Adds a number under a key to the open object (every integer type has its own overload, so a call is never ambiguous; nothing changes in an array). Parameters:AKeythe key;AValuethe value. Returns: this value, so calls chainmethod Add(const AKey: string; const AValue: bool): JSON: Adds true or false under a key to the open object (every integer type has its own overload, so a call is never ambiguous; nothing changes in an array). Parameters:AKeythe key;AValuethe value. Returns: this value, so calls chainmethod Add(const AKey: string; const AValue: JSON): JSON: Adds a copy of a value's tree under a key to the open object (a fresh value: an empty object; a missing one: null). Parameters:AKeythe key;AValuethe value copied. Returns: this value, so calls chainmethod AddNull(const AKey: string): JSON: Adds null under a key to the open object. Parameters:AKeythe key. Returns: this value, so calls chainmethod AddRaw(const AKey: string; const AJSONText: string): JSON: Adds the value JSON text holds under a key to the open object; nothing when the text is no valid JSON. Parameters:AKeythe key;AJSONTextthe JSON text. Returns: this value, so calls chainmethod Add(const AValue: string): JSON: Appends a string to the open array (nothing changes in an object). Parameters:AValuethe value. Returns: this value, so calls chainmethod Add(const AValue: int32): JSON: Appends a signed number to the open array (nothing changes in an object). Parameters:AValuethe value. Returns: this value, so calls chainmethod Add(const AValue: int64): JSON: Appends a signed number to the open array (nothing changes in an object). Parameters:AValuethe value. Returns: this value, so calls chainmethod Add(const AValue: uint32): JSON: Appends an unsigned number to the open array (nothing changes in an object). Parameters:AValuethe value. Returns: this value, so calls chainmethod Add(const AValue: uint64): JSON: Appends an unsigned number to the open array (nothing changes in an object). Parameters:AValuethe value. Returns: this value, so calls chainmethod Add(const AValue: float64): JSON: Appends a number to the open array (nothing changes in an object). Parameters:AValuethe value. Returns: this value, so calls chainmethod Add(const AValue: bool): JSON: Appends true or false to the open array (nothing changes in an object). Parameters:AValuethe value. Returns: this value, so calls chainmethod Add(const AValue: JSON): JSON: Appends a copy of a value's tree to the open array. Parameters:AValuethe value copied. Returns: this value, so calls chainmethod AddNull(): JSON: Appends null to the open array. Returns: this value, so calls chainmethod AddStrings(const AKey: string; const AValues: StringArray): JSON: Adds an array of strings under a key to the open object. Parameters:AKeythe key;AValuesthe strings. Returns: this value, so calls chainmethod AddIntegers(const AKey: string; const AValues: Int64Array): JSON: Adds an array of whole numbers under a key to the open object. Parameters:AKeythe key;AValuesthe numbers. Returns: this value, so calls chainmethod AddDoubles(const AKey: string; const AValues: array of float64): JSON: Adds an array of numbers under a key to the open object. Parameters:AKeythe key;AValuesthe numbers. Returns: this value, so calls chainmethod BeginObject(const AKey: string): JSON: Opens an object under a key in the open object: the next Adds go into it until EndObject. Parameters:AKeythe key. Returns: this value, so calls chain Example:LJ.BeginObject("window").Add("width", 1280).Add("height", 720).EndObject();method BeginObject(): JSON: Opens an object appended to the open array: the next Adds go into it until EndObject. Returns: this value, so calls chainmethod EndObject(): JSON: Closes the object BeginObject opened. Returns: this value, so calls chainmethod BeginArray(const AKey: string): JSON: Opens an array under a key in the open object: the next Adds go into it until EndArray. Parameters:AKeythe key. Returns: this value, so calls chainmethod BeginArray(): JSON: Opens an array appended to the open array: the next Adds go into it until EndArray. Returns: this value, so calls chainmethod EndArray(): JSON: Closes the array BeginArray opened. Returns: this value, so calls chainconst method Get(const APath: string): JSON: The value a path names, a view sharing this tree. Parameters:APaththe path (keys joined by., an item as[N]; "" the value itself). Returns: the value; a missing value when the path names none Example:LPort := LCfg.Get("servers[0].ports[1]").AsInt32();const method Has(const APath: string): bool: Whether a path names a value. Parameters:APaththe path (keys joined by., an item as[N]; "" the value itself). Returns: true when it doesconst method Get(const APath: string; const ALiteral: bool): JSON: The value a path (or one key) names, a view sharing this tree. Parameters:APaththe path (keys joined by., an item as[N]; "" the value itself);ALiteraltrue to take APath as one key of this object (no.or[N]split). Returns: the value; a missing value when it names noneconst method Has(const APath: string; const ALiteral: bool): bool: Whether a path (or one key) names a value. Parameters:APaththe path (keys joined by., an item as[N]; "" the value itself);ALiteraltrue to take APath as one key of this object (no.or[N]split). Returns: true when it doesconst method TryGetString(const APath: string; var AValue: string): bool: Reads the value a path names when it is of this kind: A string (a number is none). Parameters:APaththe path (keys joined by., an item as[N]; "" the value itself);AValuereceives the value; "" when the kind differs. Returns: true when the value is of this kindconst method TryGetString(const APath: string; var AValue: string; const ALiteral: bool): bool: Reads the value a path names when it is of this kind: A string (a number is none). Parameters:APaththe path (keys joined by., an item as[N]; "" the value itself);AValuereceives the value; "" when the kind differs;ALiteraltrue to take APath as one key of this object (no.or[N]split). Returns: true when the value is of this kindconst method TryGetInt32(const APath: string; var AValue: int32): bool: Reads the value a path names when it is of this kind: A whole number int32 holds (a real such as 2.5 is none). Parameters:APaththe path (keys joined by., an item as[N]; "" the value itself);AValuereceives the value; 0 when the kind differs. Returns: true when the value is of this kindconst method TryGetInt32(const APath: string; var AValue: int32; const ALiteral: bool): bool: Reads the value a path names when it is of this kind: A whole number int32 holds (a real such as 2.5 is none). Parameters:APaththe path (keys joined by., an item as[N]; "" the value itself);AValuereceives the value; 0 when the kind differs;ALiteraltrue to take APath as one key of this object (no.or[N]split). Returns: true when the value is of this kindconst method TryGetInt64(const APath: string; var AValue: int64): bool: Reads the value a path names when it is of this kind: A whole number int64 holds (a real such as 2.5 is none). Parameters:APaththe path (keys joined by., an item as[N]; "" the value itself);AValuereceives the value; 0 when the kind differs. Returns: true when the value is of this kindconst method TryGetInt64(const APath: string; var AValue: int64; const ALiteral: bool): bool: Reads the value a path names when it is of this kind: A whole number int64 holds (a real such as 2.5 is none). Parameters:APaththe path (keys joined by., an item as[N]; "" the value itself);AValuereceives the value; 0 when the kind differs;ALiteraltrue to take APath as one key of this object (no.or[N]split). Returns: true when the value is of this kindconst method TryGetBoolean(const APath: string; var AValue: bool): bool: Reads the value a path names when it is of this kind: true or false (a number or a string is none). Parameters:APaththe path (keys joined by., an item as[N]; "" the value itself);AValuereceives the value; false when the kind differs. Returns: true when the value is of this kindconst method TryGetBoolean(const APath: string; var AValue: bool; const ALiteral: bool): bool: Reads the value a path names when it is of this kind: true or false (a number or a string is none). Parameters:APaththe path (keys joined by., an item as[N]; "" the value itself);AValuereceives the value; false when the kind differs;ALiteraltrue to take APath as one key of this object (no.or[N]split). Returns: true when the value is of this kindconst method TryGetObject(const APath: string; var AValue: JSON): bool: Reads the value a path names when it is of this kind: An object, AValue a view of it sharing this tree. Parameters:APaththe path (keys joined by., an item as[N]; "" the value itself);AValuereceives the value; an empty JSON when the kind differs. Returns: true when the value is of this kindconst method TryGetObject(const APath: string; var AValue: JSON; const ALiteral: bool): bool: Reads the value a path names when it is of this kind: An object, AValue a view of it sharing this tree. Parameters:APaththe path (keys joined by., an item as[N]; "" the value itself);AValuereceives the value; an empty JSON when the kind differs;ALiteraltrue to take APath as one key of this object (no.or[N]split). Returns: true when the value is of this kindconst method TryGetArray(const APath: string; var AValue: JSON): bool: Reads the value a path names when it is of this kind: An array, AValue a view of it sharing this tree. Parameters:APaththe path (keys joined by., an item as[N]; "" the value itself);AValuereceives the value; an empty JSON when the kind differs. Returns: true when the value is of this kindconst method TryGetArray(const APath: string; var AValue: JSON; const ALiteral: bool): bool: Reads the value a path names when it is of this kind: An array, AValue a view of it sharing this tree. Parameters:APaththe path (keys joined by., an item as[N]; "" the value itself);AValuereceives the value; an empty JSON when the kind differs;ALiteraltrue to take APath as one key of this object (no.or[N]split). Returns: true when the value is of this kindconst method Count(): int64: How many items an array or members an object holds. Returns: the count; 0 for any other valueconst method Keys(): StringArray: An object's keys, in order. Returns: the keys; none for any other valueconst method Items(): array of JSON: An array's items or an object's values, in order, each a view (for .. inwalks them). Returns: the values; none for any other value Example:for LItem in LList.Items() do println(LItem.AsString()); end;const method Pairs(): array of JSONPair: An object's members, in order: each key and a view of its value. Returns: the members; none for any other valueconst method First(): JSON: An array's first item. Returns: the item; a missing value for an empty array or any other valueconst method Last(): JSON: An array's last item. Returns: the item; a missing value for an empty array or any other valueconst method Contains(const AValue: string): bool: Whether the value is an array holding a string. Parameters:AValuethe string. Returns: true when it holds itconst method Contains(const AValue: int64): bool: Whether the value is an array holding a whole number. Parameters:AValuethe number. Returns: true when it holds itconst method AsString(): string: A string as itself, a number / true / false as its JSON text, an array / object as its compact text. Returns: the value; the kind's zero when the value gives noneconst method AsString(const ADefault: string): string: A string as itself, a number / true / false as its JSON text, an array / object as its compact text. Parameters:ADefaultthe result when the value gives none. Returns: the value, or ADefaultconst method AsBoolean(): bool: true / false, a number (not 0), or the string "true" (any case). Returns: the value; the kind's zero when the value gives noneconst method AsBoolean(const ADefault: bool): bool: true / false, a number (not 0), or the string "true" (any case). Parameters:ADefaultthe result when the value gives none. Returns: the value, or ADefaultconst method AsInt64(): int64: A number (a real one truncated toward 0) or a decimal string, when int64 holds it. Returns: the value; the kind's zero when the value gives noneconst method AsInt64(const ADefault: int64): int64: A number (a real one truncated toward 0) or a decimal string, when int64 holds it. Parameters:ADefaultthe result when the value gives none. Returns: the value, or ADefaultconst method AsInt32(): int32: AsInt64's number, when int32 holds it. Returns: the value; the kind's zero when the value gives noneconst method AsInt32(const ADefault: int32): int32: AsInt64's number, when int32 holds it. Parameters:ADefaultthe result when the value gives none. Returns: the value, or ADefaultconst method AsUInt64(): uint64: A whole number of 0 or more (beyond int64 too), when uint64 holds it. Returns: the value; the kind's zero when the value gives noneconst method AsUInt64(const ADefault: uint64): uint64: A whole number of 0 or more (beyond int64 too), when uint64 holds it. Parameters:ADefaultthe result when the value gives none. Returns: the value, or ADefaultconst method AsUInt32(): uint32: AsUInt64's number, when uint32 holds it. Returns: the value; the kind's zero when the value gives noneconst method AsUInt32(const ADefault: uint32): uint32: AsUInt64's number, when uint32 holds it. Parameters:ADefaultthe result when the value gives none. Returns: the value, or ADefaultconst method AsDouble(): float64: A number or a decimal string, as a float64. Returns: the value; the kind's zero when the value gives noneconst method AsDouble(const ADefault: float64): float64: A number or a decimal string, as a float64. Parameters:ADefaultthe result when the value gives none. Returns: the value, or ADefaultconst method AsSingle(): float32: AsDouble's number as a float32 (past its range: an infinity). Returns: the value; the kind's zero when the value gives noneconst method AsSingle(const ADefault: float32): float32: AsDouble's number as a float32 (past its range: an infinity). Parameters:ADefaultthe result when the value gives none. Returns: the value, or ADefaultconst method AsStringArray(): StringArray: An array's items as strings (AsString each). Returns: the strings; none for any other valueconst method AsInt32Array(): array of int32: An array's items as int32 numbers (AsInt32 each). Returns: the numbers; none for any other valueconst method AsInt64Array(): Int64Array: An array's items as int64 numbers (AsInt64 each). Returns: the numbers; none for any other valueconst method AsDoubleArray(): array of float64: An array's items as float64 numbers (AsDouble each). Returns: the numbers; none for any other valueconst method IsNull(): bool: Whether the value is null (a missing value is). Returns: true for nullconst method IsObject(): bool: Whether the value is an object (a fresh value is). Returns: true for an objectconst method IsArray(): bool: Whether the value is an array. Returns: true for an arrayconst method IsNumber(): bool: Whether the value is a number. Returns: true for a numberconst method IsString(): bool: Whether the value is a string. Returns: true for a stringconst method IsBoolean(): bool: Whether the value is true or false. Returns: true for a booleanmethod ForEach(const ACallback: JSONCallback; const AUserData: ptr): JSON: Calls a routine with each of Items. Parameters:ACallbackthe routine;AUserDatathe pointer it is given. Returns: this value, so calls chainmethod Remove(const AKey: string): JSON: Removes an object's members of a key. Parameters:AKeythe key. Returns: this value, so calls chainmethod Merge(const AOther: JSON): JSON: Copies another object's members in, each replacing this one's of its key (both objects). Parameters:AOtherthe object copied from. Returns: this value, so calls chainconst method Clone(): JSON: The value copied into a tree of its own. Returns: the copy (a missing value stays missing)
Example: LJ.Add("name", "Ada").Add("age", 36); println(LJ.ToString());
JSONPair
type JSONPair = object
An object's member as Pairs gives it: its key and a view of its value.
Members
NodeName: string: The member's key.Value: JSON: A view of the member's value.
System.Linux
glibc's POSIX declarations for Adam's x86_64-linux-gnu units (the SDK block, AD.5a): each name, value and layout as glibc's x86_64 headers spell it, declared once here and imported wherever a std platform unit needs it (System.IO.Linux64, System.Console.Linux64, System.Process.Linux64, System.HookIO.Linux64). Declarations only, no Adam routine: the jobs over them are the platform units'.
Import it with import System.Linux;.
Types
timespec
type timespec = record
Linux's timespec: struct timespec (time.h): seconds and nanoseconds
Members
tv_sec: int64: Linux'stimespec.tv_sec.tv_nsec: int64: Linux'stimespec.tv_nsec.
itimerspec
type itimerspec = record
Linux's itimerspec: struct itimerspec (time.h): a timer's period (zero: once) and its first expiry
Members
it_interval: timespec: Linux'sitimerspec.it_interval.it_value: timespec: Linux'sitimerspec.it_value.
sigevent
type sigevent = record
Linux's sigevent: struct sigevent (x86_64, 64 bytes; bits/types/sigevent_t.h) as SIGEV_THREAD fills it: the value (union sigval, its sival_ptr) passed to sigev_notify_function, run on a thread glibc starts itself (its attributes, a pthread_attr_t or nil); the union's other members (_tid) and its padding are pad0
Members
sigev_value: ptr: Linux'ssigevent.sigev_value.sigev_signo: int32: Linux'ssigevent.sigev_signo.sigev_notify: int32: Linux'ssigevent.sigev_notify.sigev_notify_function: func(ptr): Linux'ssigevent.sigev_notify_function.sigev_notify_attributes: ptr: Linux'ssigevent.sigev_notify_attributes.pad0: array[0..7] of int32: Linux'ssigevent.pad0.
stat
type stat = record
Linux's stat: struct stat (x86_64, 144 bytes; bits/struct_stat.h)
Members
st_dev: uint64: Linux'sstat.st_dev.st_ino: uint64: Linux'sstat.st_ino.st_nlink: uint64: Linux'sstat.st_nlink.st_mode: uint32: Linux'sstat.st_mode.st_uid: uint32: Linux'sstat.st_uid.st_gid: uint32: Linux'sstat.st_gid.pad0: int32: Linux'sstat.pad0.st_rdev: uint64: Linux'sstat.st_rdev.st_size: int64: Linux'sstat.st_size.st_blksize: int64: Linux'sstat.st_blksize.st_blocks: int64: Linux'sstat.st_blocks.st_atim: timespec: Linux'sstat.st_atim.st_mtim: timespec: Linux'sstat.st_mtim.st_ctim: timespec: Linux'sstat.st_ctim.reserved: array[0..2] of int64: Linux'sstat.reserved.
termios
type termios = record
Linux's termios: struct termios (x86_64, 60 bytes; bits/termios-struct.h): the four mode words, the line discipline, the NCCS control characters, the two speeds
Members
c_iflag: uint32: Linux'stermios.c_iflag.c_oflag: uint32: Linux'stermios.c_oflag.c_cflag: uint32: Linux'stermios.c_cflag.c_lflag: uint32: Linux'stermios.c_lflag.c_line: uint8: Linux'stermios.c_line.c_cc: array[0..31] of uint8: Linux'stermios.c_cc.c_ispeed: uint32: Linux'stermios.c_ispeed.c_ospeed: uint32: Linux'stermios.c_ospeed.
winsize
type winsize = record
Linux's winsize: struct winsize (sys/ioctl.h, bits/ioctl-types.h): a terminal's size in characters and pixels
Members
ws_row: uint16: Linux'swinsize.ws_row.ws_col: uint16: Linux'swinsize.ws_col.ws_xpixel: uint16: Linux'swinsize.ws_xpixel.ws_ypixel: uint16: Linux'swinsize.ws_ypixel.
pollfd
type pollfd = record
Linux's pollfd: struct pollfd (sys/poll.h): one descriptor, the events asked for, the events seen
Members
fd: int32: Linux'spollfd.fd.events: int16: Linux'spollfd.events.revents: int16: Linux'spollfd.revents.
sigset_t
type sigset_t = record
Linux's sigset_t (x86_64, 128 bytes; bits/types/__sigset_t.h): one bit per signal
Members
val: array[0..15] of uint64: Linux'ssigset_t.val.
sched_param
type sched_param = record
Linux's sched_param: struct sched_param (bits/types/struct_sched_param.h): a scheduling priority
Members
sched_priority: int32: Linux'ssched_param.sched_priority.
posix_spawn_file_actions_t
type posix_spawn_file_actions_t = record
Linux's posix_spawn_file_actions_t (x86_64, 80 bytes; spawn.h): what a started program's descriptors are made, in order; filled by the posix_spawn_file_actions_* calls only
Members
allocated: int32: Linux'sposix_spawn_file_actions_t.allocated.used: int32: Linux'sposix_spawn_file_actions_t.used.actions: ptr: Linux'sposix_spawn_file_actions_t.actions.pad: array[0..15] of int32: Linux'sposix_spawn_file_actions_t.pad.
posix_spawnattr_t
type posix_spawnattr_t = record
Linux's posix_spawnattr_t (x86_64, 336 bytes; spawn.h): a start's flags, process group, signal defaults and mask, scheduling; filled by the posix_spawnattr_* calls only
Members
flags: int16: Linux'sposix_spawnattr_t.flags.pgrp: int32: Linux'sposix_spawnattr_t.pgrp.sd: sigset_t: Linux'sposix_spawnattr_t.sd.ss: sigset_t: Linux'sposix_spawnattr_t.ss.sp: sched_param: Linux'sposix_spawnattr_t.sp.policy: int32: Linux'sposix_spawnattr_t.policy.pad: array[0..15] of int32: Linux'sposix_spawnattr_t.pad.
utsname
type utsname = record
Linux's utsname: struct utsname (sys/utsname.h): uname's answer, each field a NUL-terminated text of at most 64 bytes (_UTSNAME_LENGTH 65)
Members
sysname: array[0..64] of char: Linux'sutsname.sysname: the kernel's name ("Linux").nodename: array[0..64] of char: Linux'sutsname.nodename.release: array[0..64] of char: Linux'sutsname.release: the kernel's release ("6.6.87.2-microsoft-standard-WSL2").version: array[0..64] of char: Linux'sutsname.version.machine: array[0..64] of char: Linux'sutsname.machine.domainname: array[0..64] of char: Linux'sutsname.domainname.
Constants
| Name | Declaration | Description |
|---|---|---|
_SC_PAGESIZE | const _SC_PAGESIZE: int32 = 30 | Linux's _SC_PAGESIZE: unistd.h: sysconf's page size in bytes |
_SC_PHYS_PAGES | const _SC_PHYS_PAGES: int32 = 85 | Linux's _SC_PHYS_PAGES: unistd.h: sysconf's count of physical memory pages |
_SC_NPROCESSORS_ONLN | const _SC_NPROCESSORS_ONLN: int32 = 84 | Linux's _SC_NPROCESSORS_ONLN: unistd.h: sysconf's count of processors online |
_STAT_VER | const _STAT_VER: int32 = 1 | Linux's _STAT_VER: sys/stat.h: the stat version x86_64's __xstat takes (_STAT_VER_LINUX); st_mode's file type bits and its kinds |
S_IFMT | const S_IFMT: uint32 = 0xF000 | Linux's S_IFMT: sys/stat.h: the stat version x86_64's __xstat takes (_STAT_VER_LINUX); st_mode's file type bits and its kinds |
S_IFDIR | const S_IFDIR: uint32 = 0x4000 | Linux's S_IFDIR: sys/stat.h: the stat version x86_64's __xstat takes (_STAT_VER_LINUX); st_mode's file type bits and its kinds |
S_IFREG | const S_IFREG: uint32 = 0x8000 | Linux's S_IFREG: sys/stat.h: the stat version x86_64's __xstat takes (_STAT_VER_LINUX); st_mode's file type bits and its kinds |
S_IFLNK | const S_IFLNK: uint32 = 0xA000 | Linux's S_IFLNK: sys/stat.h: the stat version x86_64's __xstat takes (_STAT_VER_LINUX); st_mode's file type bits and its kinds |
S_IFIFO | const S_IFIFO: uint32 = 0x1000 | Linux's S_IFIFO: sys/stat.h: the stat version x86_64's __xstat takes (_STAT_VER_LINUX); st_mode's file type bits and its kinds |
S_IRUSR | const S_IRUSR: uint32 = 0x100 | Linux's S_IRUSR: sys/stat.h: st_mode's permission bits (the owner's read and write, the group's, others') |
S_IWUSR | const S_IWUSR: uint32 = 0x80 | Linux's S_IWUSR: sys/stat.h: st_mode's permission bits (the owner's read and write, the group's, others') |
S_IRGRP | const S_IRGRP: uint32 = 0x20 | Linux's S_IRGRP: sys/stat.h: st_mode's permission bits (the owner's read and write, the group's, others') |
S_IWGRP | const S_IWGRP: uint32 = 0x10 | Linux's S_IWGRP: sys/stat.h: st_mode's permission bits (the owner's read and write, the group's, others') |
S_IROTH | const S_IROTH: uint32 = 0x4 | Linux's S_IROTH: sys/stat.h: st_mode's permission bits (the owner's read and write, the group's, others') |
S_IWOTH | const S_IWOTH: uint32 = 0x2 | Linux's S_IWOTH: sys/stat.h: st_mode's permission bits (the owner's read and write, the group's, others') |
S_IXUSR | const S_IXUSR: uint32 = 0x40 | Linux's S_IXUSR: sys/stat.h: st_mode's execute bits (the owner's, the group's, others') and every permission bit (set-id and sticky included) |
S_IXGRP | const S_IXGRP: uint32 = 0x8 | Linux's S_IXGRP: sys/stat.h: st_mode's execute bits (the owner's, the group's, others') and every permission bit (set-id and sticky included) |
S_IXOTH | const S_IXOTH: uint32 = 0x1 | Linux's S_IXOTH: sys/stat.h: st_mode's execute bits (the owner's, the group's, others') and every permission bit (set-id and sticky included) |
ALLPERMS | const ALLPERMS: uint32 = 0xFFF | Linux's ALLPERMS: sys/stat.h: st_mode's execute bits (the owner's, the group's, others') and every permission bit (set-id and sticky included) |
O_ACCMODE | const O_ACCMODE: int32 = 3 | Linux's O_ACCMODE: fcntl.h: open's access modes (their mask; read only, write only, read and write) and its flags (made when missing, refused when there, never as the controlling terminal, emptied, every write at the end, a folder only, closed across an exec, an unnamed file) |
O_RDONLY | const O_RDONLY: int32 = 0 | Linux's O_RDONLY: fcntl.h: open's access modes (their mask; read only, write only, read and write) and its flags (made when missing, refused when there, never as the controlling terminal, emptied, every write at the end, a folder only, closed across an exec, an unnamed file) |
O_WRONLY | const O_WRONLY: int32 = 1 | Linux's O_WRONLY: fcntl.h: open's access modes (their mask; read only, write only, read and write) and its flags (made when missing, refused when there, never as the controlling terminal, emptied, every write at the end, a folder only, closed across an exec, an unnamed file) |
O_RDWR | const O_RDWR: int32 = 2 | Linux's O_RDWR: fcntl.h: open's access modes (their mask; read only, write only, read and write) and its flags (made when missing, refused when there, never as the controlling terminal, emptied, every write at the end, a folder only, closed across an exec, an unnamed file) |
O_CREAT | const O_CREAT: int32 = 0x40 | Linux's O_CREAT: fcntl.h: open's access modes (their mask; read only, write only, read and write) and its flags (made when missing, refused when there, never as the controlling terminal, emptied, every write at the end, a folder only, closed across an exec, an unnamed file) |
O_EXCL | const O_EXCL: int32 = 0x80 | Linux's O_EXCL: fcntl.h: open's access modes (their mask; read only, write only, read and write) and its flags (made when missing, refused when there, never as the controlling terminal, emptied, every write at the end, a folder only, closed across an exec, an unnamed file) |
O_NOCTTY | const O_NOCTTY: int32 = 0x100 | Linux's O_NOCTTY: fcntl.h: open's access modes (their mask; read only, write only, read and write) and its flags (made when missing, refused when there, never as the controlling terminal, emptied, every write at the end, a folder only, closed across an exec, an unnamed file) |
O_TRUNC | const O_TRUNC: int32 = 0x200 | Linux's O_TRUNC: fcntl.h: open's access modes (their mask; read only, write only, read and write) and its flags (made when missing, refused when there, never as the controlling terminal, emptied, every write at the end, a folder only, closed across an exec, an unnamed file) |
O_APPEND | const O_APPEND: int32 = 0x400 | Linux's O_APPEND: fcntl.h: open's access modes (their mask; read only, write only, read and write) and its flags (made when missing, refused when there, never as the controlling terminal, emptied, every write at the end, a folder only, closed across an exec, an unnamed file) |
O_DIRECTORY | const O_DIRECTORY: int32 = 0x10000 | Linux's O_DIRECTORY: fcntl.h: open's access modes (their mask; read only, write only, read and write) and its flags (made when missing, refused when there, never as the controlling terminal, emptied, every write at the end, a folder only, closed across an exec, an unnamed file) |
O_CLOEXEC | const O_CLOEXEC: int32 = 0x80000 | Linux's O_CLOEXEC: fcntl.h: open's access modes (their mask; read only, write only, read and write) and its flags (made when missing, refused when there, never as the controlling terminal, emptied, every write at the end, a folder only, closed across an exec, an unnamed file) |
O_TMPFILE | const O_TMPFILE: int32 = 0x410000 | Linux's O_TMPFILE: fcntl.h: open's access modes (their mask; read only, write only, read and write) and its flags (made when missing, refused when there, never as the controlling terminal, emptied, every write at the end, a folder only, closed across an exec, an unnamed file) |
F_DUPFD | const F_DUPFD: int32 = 0 | Linux's F_DUPFD: fcntl.h: fcntl's requests: a copy of a descriptor at or above its argument (closed across an exec: F_DUPFD_CLOEXEC), the status flags read and set |
F_GETFL | const F_GETFL: int32 = 3 | Linux's F_GETFL: fcntl.h: fcntl's requests: a copy of a descriptor at or above its argument (closed across an exec: F_DUPFD_CLOEXEC), the status flags read and set |
F_SETFL | const F_SETFL: int32 = 4 | Linux's F_SETFL: fcntl.h: fcntl's requests: a copy of a descriptor at or above its argument (closed across an exec: F_DUPFD_CLOEXEC), the status flags read and set |
F_DUPFD_CLOEXEC | const F_DUPFD_CLOEXEC: int32 = 1030 | Linux's F_DUPFD_CLOEXEC: fcntl.h: fcntl's requests: a copy of a descriptor at or above its argument (closed across an exec: F_DUPFD_CLOEXEC), the status flags read and set |
F_OK | const F_OK: int32 = 0 | Linux's F_OK: unistd.h: access's modes (there, executable, writable, readable) |
X_OK | const X_OK: int32 = 1 | Linux's X_OK: unistd.h: access's modes (there, executable, writable, readable) |
W_OK | const W_OK: int32 = 2 | Linux's W_OK: unistd.h: access's modes (there, executable, writable, readable) |
R_OK | const R_OK: int32 = 4 | Linux's R_OK: unistd.h: access's modes (there, executable, writable, readable) |
PROT_WRITE | const PROT_WRITE: int32 = 2 | Linux's PROT_WRITE: sys/mman.h: a mapping's write right, its sharing (shared, private), one of no file, and mmap's failure (MAP_FAILED, (void *) -1) |
MAP_SHARED | const MAP_SHARED: int32 = 1 | Linux's MAP_SHARED: sys/mman.h: a mapping's write right, its sharing (shared, private), one of no file, and mmap's failure (MAP_FAILED, (void *) -1) |
MAP_PRIVATE | const MAP_PRIVATE: int32 = 2 | Linux's MAP_PRIVATE: sys/mman.h: a mapping's write right, its sharing (shared, private), one of no file, and mmap's failure (MAP_FAILED, (void *) -1) |
MAP_ANONYMOUS | const MAP_ANONYMOUS: int32 = 0x20 | Linux's MAP_ANONYMOUS: sys/mman.h: a mapping's write right, its sharing (shared, private), one of no file, and mmap's failure (MAP_FAILED, (void *) -1) |
MAP_FAILED | const MAP_FAILED: uint64 = 18446744073709551615u | Linux's MAP_FAILED: sys/mman.h: a mapping's write right, its sharing (shared, private), one of no file, and mmap's failure (MAP_FAILED, (void *) -1) |
SSIZE_MAX | const SSIZE_MAX: int64 = 9223372036854775807 | Linux's SSIZE_MAX: limits.h (bits/posix1_lim.h, x86_64): the largest ssize_t, the most one read(2) moves |
_IOFBF | const _IOFBF: int32 = 0 | Linux's _IOFBF: stdio.h: setvbuf's modes (full, line, no buffering) and setbuf's buffer size |
_IOLBF | const _IOLBF: int32 = 1 | Linux's _IOLBF: stdio.h: setvbuf's modes (full, line, no buffering) and setbuf's buffer size |
_IONBF | const _IONBF: int32 = 2 | Linux's _IONBF: stdio.h: setvbuf's modes (full, line, no buffering) and setbuf's buffer size |
BUFSIZ | const BUFSIZ: uint64 = 8192u | Linux's BUFSIZ: stdio.h: setvbuf's modes (full, line, no buffering) and setbuf's buffer size |
CODESET | const CODESET: int32 = 14 | Linux's CODESET: langinfo.h: nl_langinfo's item for the locale's character set name |
P_tmpdir | const P_tmpdir: string = "/tmp" | Linux's P_tmpdir: stdio.h: the folder for temporary files when $TMPDIR names none |
CLOCK_REALTIME | const CLOCK_REALTIME: int32 = 0 | Linux's CLOCK_REALTIME: time.h: the wall clock, seconds since 1970-01-01 UTC (st_mtim's clock) |
CLOCK_MONOTONIC | const CLOCK_MONOTONIC: int32 = 1 | Linux's CLOCK_MONOTONIC: time.h: the clock from a fixed point, never going back |
SIGEV_THREAD | const SIGEV_THREAD: int32 = 2 | Linux's SIGEV_THREAD: signal.h: a sigevent's notification on a thread glibc starts (sigev_notify_function) |
SYS_chdir | const SYS_chdir: int64 = 80 | Linux's SYS_chdir: sys/syscall.h (x86_64): the kernel's chdir (System.IO's SetCurrentDir: no hook between) |
EINTR | const EINTR: int32 = 4 | Linux's EINTR: errno.h (x86_64 glibc; System.Runtime's CErrno reads errno): a call a signal broke off, an output full (iconv's), nothing there yet, no such device, not a folder, too many open files, a seek on a pipe; a rename across file systems |
EXDEV | const EXDEV: int32 = 18 | Linux's EXDEV: errno.h (x86_64 glibc; System.Runtime's CErrno reads errno): a call a signal broke off, an output full (iconv's), nothing there yet, no such device, not a folder, too many open files, a seek on a pipe; a rename across file systems |
E2BIG | const E2BIG: int32 = 7 | Linux's E2BIG: errno.h (x86_64 glibc; System.Runtime's CErrno reads errno): a call a signal broke off, an output full (iconv's), nothing there yet, no such device, not a folder, too many open files, a seek on a pipe; a rename across file systems |
EAGAIN | const EAGAIN: int32 = 11 | Linux's EAGAIN: errno.h (x86_64 glibc; System.Runtime's CErrno reads errno): a call a signal broke off, an output full (iconv's), nothing there yet, no such device, not a folder, too many open files, a seek on a pipe; a rename across file systems |
ENODEV | const ENODEV: int32 = 19 | Linux's ENODEV: errno.h (x86_64 glibc; System.Runtime's CErrno reads errno): a call a signal broke off, an output full (iconv's), nothing there yet, no such device, not a folder, too many open files, a seek on a pipe; a rename across file systems |
ENOTDIR | const ENOTDIR: int32 = 20 | Linux's ENOTDIR: errno.h (x86_64 glibc; System.Runtime's CErrno reads errno): a call a signal broke off, an output full (iconv's), nothing there yet, no such device, not a folder, too many open files, a seek on a pipe; a rename across file systems |
EMFILE | const EMFILE: int32 = 24 | Linux's EMFILE: errno.h (x86_64 glibc; System.Runtime's CErrno reads errno): a call a signal broke off, an output full (iconv's), nothing there yet, no such device, not a folder, too many open files, a seek on a pipe; a rename across file systems |
ESPIPE | const ESPIPE: int32 = 29 | Linux's ESPIPE: errno.h (x86_64 glibc; System.Runtime's CErrno reads errno): a call a signal broke off, an output full (iconv's), nothing there yet, no such device, not a folder, too many open files, a seek on a pipe; a rename across file systems |
STDIN_FILENO | const STDIN_FILENO: int32 = 0 | Linux's STDIN_FILENO: unistd.h: the standard descriptors |
STDOUT_FILENO | const STDOUT_FILENO: int32 = 1 | Linux's STDOUT_FILENO: unistd.h: the standard descriptors |
STDERR_FILENO | const STDERR_FILENO: int32 = 2 | Linux's STDERR_FILENO: unistd.h: the standard descriptors |
WNOHANG | const WNOHANG: int32 = 1 | Linux's WNOHANG: sys/wait.h: waitpid returns at once when no child has changed state |
POSIX_SPAWN_SETSIGDEF | const POSIX_SPAWN_SETSIGDEF: int16 = 0x4 | Linux's POSIX_SPAWN_SETSIGDEF: spawn.h: posix_spawnattr_setflags' flags (the signal defaults and mask set; a new session) |
POSIX_SPAWN_SETSIGMASK | const POSIX_SPAWN_SETSIGMASK: int16 = 0x8 | Linux's POSIX_SPAWN_SETSIGMASK: spawn.h: posix_spawnattr_setflags' flags (the signal defaults and mask set; a new session) |
POSIX_SPAWN_SETSID | const POSIX_SPAWN_SETSID: int16 = 0x80 | Linux's POSIX_SPAWN_SETSID: spawn.h: posix_spawnattr_setflags' flags (the signal defaults and mask set; a new session) |
TCSANOW | const TCSANOW: int32 = 0 | Linux's TCSANOW: termios.h (bits/termios-*.h, x86_64): tcsetattr's when (TCSANOW: at once), tcflush's queue (TCIFLUSH: the input received, not yet read), c_cc's indexes (VTIME, VMIN; NCCS of them) |
TCIFLUSH | const TCIFLUSH: int32 = 0 | Linux's TCIFLUSH: termios.h (bits/termios-*.h, x86_64): tcsetattr's when (TCSANOW: at once), tcflush's queue (TCIFLUSH: the input received, not yet read), c_cc's indexes (VTIME, VMIN; NCCS of them) |
NCCS | const NCCS: int32 = 32 | Linux's NCCS: termios.h (bits/termios-*.h, x86_64): tcsetattr's when (TCSANOW: at once), tcflush's queue (TCIFLUSH: the input received, not yet read), c_cc's indexes (VTIME, VMIN; NCCS of them) |
VTIME | const VTIME: int32 = 5 | Linux's VTIME: termios.h (bits/termios-*.h, x86_64): tcsetattr's when (TCSANOW: at once), tcflush's queue (TCIFLUSH: the input received, not yet read), c_cc's indexes (VTIME, VMIN; NCCS of them) |
VMIN | const VMIN: int32 = 6 | Linux's VMIN: termios.h (bits/termios-*.h, x86_64): tcsetattr's when (TCSANOW: at once), tcflush's queue (TCIFLUSH: the input received, not yet read), c_cc's indexes (VTIME, VMIN; NCCS of them) |
ICRNL | const ICRNL: uint32 = 0x100 | Linux's ICRNL: termios.h: c_iflag's CR read as NL and XON / XOFF flow control; c_lflag's signal keys, line editing (canonical mode), echo and the implementation's extra keys (Ctrl+V) |
IXON | const IXON: uint32 = 0x400 | Linux's IXON: termios.h: c_iflag's CR read as NL and XON / XOFF flow control; c_lflag's signal keys, line editing (canonical mode), echo and the implementation's extra keys (Ctrl+V) |
ISIG | const ISIG: uint32 = 0x1 | Linux's ISIG: termios.h: c_iflag's CR read as NL and XON / XOFF flow control; c_lflag's signal keys, line editing (canonical mode), echo and the implementation's extra keys (Ctrl+V) |
ICANON | const ICANON: uint32 = 0x2 | Linux's ICANON: termios.h: c_iflag's CR read as NL and XON / XOFF flow control; c_lflag's signal keys, line editing (canonical mode), echo and the implementation's extra keys (Ctrl+V) |
ECHO | const ECHO: uint32 = 0x8 | Linux's ECHO: termios.h: c_iflag's CR read as NL and XON / XOFF flow control; c_lflag's signal keys, line editing (canonical mode), echo and the implementation's extra keys (Ctrl+V) |
IEXTEN | const IEXTEN: uint32 = 0x8000 | Linux's IEXTEN: termios.h: c_iflag's CR read as NL and XON / XOFF flow control; c_lflag's signal keys, line editing (canonical mode), echo and the implementation's extra keys (Ctrl+V) |
TIOCGWINSZ | const TIOCGWINSZ: uint64 = 0x5413 | Linux's TIOCGWINSZ: asm-generic/ioctls.h: a terminal's size read / set (struct winsize) |
TIOCSWINSZ | const TIOCSWINSZ: uint64 = 0x5414 | Linux's TIOCSWINSZ: asm-generic/ioctls.h: a terminal's size read / set (struct winsize) |
POLLIN | const POLLIN: int16 = 0x1 | Linux's POLLIN: poll.h: data to read |
Variables
| Name | Declaration | Description |
|---|---|---|
environ | var environ: ptr to ptr to char | Linux's environ: glibc (unistd.h): the process's environment as it is now (setenv changes it), NULL-ended |
Routines
__xstat
func __xstat(const AVersion: int32; const APath: ptr to const char; var AStat: stat): int32
Linux's __xstat: glibc: a path's facts, a link followed to its target (stat as every glibc exports it)
Parameters
AVersion: as Linux's__xstattakes itAPath: as Linux's__xstattakes itAStat: as Linux's__xstattakes it
Returns: as Linux's __xstat returns it
mkdir
func mkdir(const APath: ptr to const char; const AMode: uint32): int32
Linux's mkdir: glibc: a folder made (AMode before the umask), a name moved over another in one step
Parameters
APath: as Linux'smkdirtakes itAMode: as Linux'smkdirtakes it
Returns: as Linux's mkdir returns it
rename
func rename(const AOldPath: ptr to const char; const ANewPath: ptr to const char): int32
Linux's rename.
Parameters
AOldPath: as Linux'srenametakes itANewPath: as Linux'srenametakes it
Returns: as Linux's rename returns it
symlink
func symlink(const ATarget: ptr to const char; const ALinkPath: ptr to const char): int32
Linux's symlink: glibc: a symbolic link at ALinkPath made, leading to ATarget
Parameters
ATarget: as Linux'ssymlinktakes itALinkPath: as Linux'ssymlinktakes it
Returns: as Linux's symlink returns it
rmdir
func rmdir(const APath: ptr to const char): int32
Linux's rmdir: glibc: an empty folder removed, a file's permission bits set
Parameters
APath: as Linux'srmdirtakes it
Returns: as Linux's rmdir returns it
chmod
func chmod(const APath: ptr to const char; const AMode: uint32): int32
Linux's chmod.
Parameters
APath: as Linux'schmodtakes itAMode: as Linux'schmodtakes it
Returns: as Linux's chmod returns it
getenv
func getenv(const AName: ptr to const char): ptr to char
Linux's getenv: glibc: an environment variable's value (nil when it is not set)
Parameters
AName: as Linux'sgetenvtakes it
Returns: as Linux's getenv returns it
setenv
func setenv(const AName: ptr to const char; const AValue: ptr to const char; const AOverwrite: int32): int32
Linux's setenv: glibc: an environment variable set (AOverwrite <> 0: an existing value replaced)
Parameters
AName: as Linux'ssetenvtakes itAValue: as Linux'ssetenvtakes itAOverwrite: as Linux'ssetenvtakes it
Returns: as Linux's setenv returns it
vasprintf
func vasprintf(const ATextOut: ptr to ptr to char; const AFormat: ptr to const char; const AArgs: ptr): int32
Linux's vasprintf: glibc: the text of a printf format over a C va_list, in memory it allocates (ATextOut, given back with free); its length, -1 when it could not be made
Parameters
ATextOut: as Linux'svasprintftakes itAFormat: as Linux'svasprintftakes itAArgs: as Linux'svasprintftakes it
Returns: as Linux's vasprintf returns it
free
func free(const APointer: ptr)
Linux's free: glibc: memory malloc, realloc or vasprintf gave, given back
Parameters
APointer: as Linux'sfreetakes it
getrandom
func getrandom(const ABuffer: ptr; const ACount: uint64; const AFlags: uint32): int64
Linux's getrandom: glibc: bytes from the kernel's secure random generator (AFlags 0: the urandom source, waits only until it is first seeded)
Parameters
ABuffer: as Linux'sgetrandomtakes itACount: as Linux'sgetrandomtakes itAFlags: as Linux'sgetrandomtakes it
Returns: as Linux's getrandom returns it
clock_gettime
func clock_gettime(const AClock: int32; var ATime: timespec): int32
Linux's clock_gettime: glibc: a clock read, the calling thread asleep (ARemaining: what is left when a signal woke it)
Parameters
AClock: as Linux'sclock_gettimetakes itATime: as Linux'sclock_gettimetakes it
Returns: as Linux's clock_gettime returns it
nanosleep
func nanosleep(const ATime: ptr to const timespec; const ARemaining: ptr to timespec): int32
Linux's nanosleep.
Parameters
ATime: as Linux'snanosleeptakes itARemaining: as Linux'snanosleeptakes it
Returns: as Linux's nanosleep returns it
read
func read(const AFile: int32; const ABuffer: ptr; const ACount: uint64): int64
Linux's read: glibc: bytes read from / written to a descriptor (read: 0 at its end; -1 on an error). read / write / open / close / dup2 / fcntl bind glibc's own __read / __write / __open / __close / __dup2 / __fcntl, never the plain names System.HookIO.Linux64 hooks: Adam's std works on the real file system on every target (System.IO.Win64's calls are no hook's either)
Parameters
AFile: as Linux'sreadtakes itABuffer: as Linux'sreadtakes itACount: as Linux'sreadtakes it
Returns: as Linux's read returns it
write
func write(const AFile: int32; const ABuffer: ptr to const; const ACount: uint64): int64
Linux's write.
Parameters
AFile: as Linux'swritetakes itABuffer: as Linux'swritetakes itACount: as Linux'swritetakes it
Returns: as Linux's write returns it
open
func open(const APath: ptr to const char; const AFlags: int32; ...): int32
Linux's open: glibc: a file opened as a descriptor (AFlags O_; a mode after it when it creates one), a descriptor closed, copied (ATarget itself), asked or changed (F_; F_DUPFD_CLOEXEC copies to the lowest free one)
Parameters
APath: as Linux'sopentakes itAFlags: as Linux'sopentakes it...: as Linux'sopentakes them
Returns: as Linux's open returns it
close
func close(const AFile: int32): int32
Linux's close.
Parameters
AFile: as Linux'sclosetakes it
Returns: as Linux's close returns it
dup2
func dup2(const AFile: int32; const ATarget: int32): int32
Linux's dup2.
Parameters
AFile: as Linux'sdup2takes itATarget: as Linux'sdup2takes it
Returns: as Linux's dup2 returns it
fcntl
func fcntl(const AFile: int32; const ACommand: int32; ...): int32
Linux's fcntl.
Parameters
AFile: as Linux'sfcntltakes itACommand: as Linux'sfcntltakes it...: as Linux'sfcntltakes them
Returns: as Linux's fcntl returns it
pipe2
func pipe2(const AFiles: ptr to int32; const AFlags: int32): int32
Linux's pipe2: glibc: a pipe, its read end AFiles[0] and write end AFiles[1] (AFlags O_CLOEXEC ..)
Parameters
AFiles: as Linux'spipe2takes itAFlags: as Linux'spipe2takes it
Returns: as Linux's pipe2 returns it
isatty
func isatty(const AFile: int32): int32
Linux's isatty: glibc: true (1) when a descriptor is a terminal
Parameters
AFile: as Linux'sisattytakes it
Returns: as Linux's isatty returns it
tcgetattr
func tcgetattr(const AFile: int32; var ATerm: termios): int32
Linux's tcgetattr: glibc: a terminal's modes read / set, its input received but not read dropped
Parameters
AFile: as Linux'stcgetattrtakes itATerm: as Linux'stcgetattrtakes it
Returns: as Linux's tcgetattr returns it
tcsetattr
func tcsetattr(const AFile: int32; const AWhen: int32; const ATerm: ptr to const termios): int32
Linux's tcsetattr.
Parameters
AFile: as Linux'stcsetattrtakes itAWhen: as Linux'stcsetattrtakes itATerm: as Linux'stcsetattrtakes it
Returns: as Linux's tcsetattr returns it
tcflush
func tcflush(const AFile: int32; const AQueue: int32): int32
Linux's tcflush.
Parameters
AFile: as Linux'stcflushtakes itAQueue: as Linux'stcflushtakes it
Returns: as Linux's tcflush returns it
ioctl
func ioctl(const AFile: int32; const ARequest: uint64; ...): int32
Linux's ioctl: glibc: a device's control request (the terminal's size: TIOCGWINSZ with a ptr to winsize)
Parameters
AFile: as Linux'sioctltakes itARequest: as Linux'sioctltakes it...: as Linux'sioctltakes them
Returns: as Linux's ioctl returns it
poll
func poll(const AFds: ptr to pollfd; const ACount: uint64; const ATimeout: int32): int32
Linux's poll: glibc: waits up to ATimeout ms (-1: no limit) for an event on the descriptors; how many have one
Parameters
AFds: as Linux'spolltakes itACount: as Linux'spolltakes itATimeout: as Linux'spolltakes it
Returns: as Linux's poll returns it
posix_openpt
func posix_openpt(const AFlags: int32): int32
Linux's posix_openpt: glibc: a pseudo terminal's master side opened (AFlags O_RDWR, O_NOCTTY ..), its slave made ready to open, the slave's path (ptsname: glibc's own buffer; ptsname_r: into ABuffer)
Parameters
AFlags: as Linux'sposix_openpttakes it
Returns: as Linux's posix_openpt returns it
grantpt
func grantpt(const AFile: int32): int32
Linux's grantpt.
Parameters
AFile: as Linux'sgrantpttakes it
Returns: as Linux's grantpt returns it
unlockpt
func unlockpt(const AFile: int32): int32
Linux's unlockpt.
Parameters
AFile: as Linux'sunlockpttakes it
Returns: as Linux's unlockpt returns it
ptsname
func ptsname(const AFile: int32): ptr to char
Linux's ptsname.
Parameters
AFile: as Linux'sptsnametakes it
Returns: as Linux's ptsname returns it
ptsname_r
func ptsname_r(const AFile: int32; const ABuffer: ptr to char; const ASize: uint64): int32
Linux's ptsname_r.
Parameters
AFile: as Linux'sptsname_rtakes itABuffer: as Linux'sptsname_rtakes itASize: as Linux'sptsname_rtakes it
Returns: as Linux's ptsname_r returns it
sigemptyset
func sigemptyset(var ASet: sigset_t): int32
Linux's sigemptyset: glibc: a signal set emptied / filled (every signal a program may handle)
Parameters
ASet: as Linux'ssigemptysettakes it
Returns: as Linux's sigemptyset returns it
sigfillset
func sigfillset(var ASet: sigset_t): int32
Linux's sigfillset.
Parameters
ASet: as Linux'ssigfillsettakes it
Returns: as Linux's sigfillset returns it
posix_spawn
func posix_spawn(var APid: int32; const APath: ptr to const char; const AActions: ptr to const posix_spawn_file_actions_t; const AAttributes: ptr to const posix_spawnattr_t; const AArgv: ptr to const ptr to char; const AEnvp: ptr to const ptr to char): int32
Linux's posix_spawn: glibc: a program started as a new process (APath named in full, AArgv and AEnvp NULL-ended, C's char *const []); its id in APid; 0 when it started, else the error number
Parameters
APid: as Linux'sposix_spawntakes itAPath: as Linux'sposix_spawntakes itAActions: as Linux'sposix_spawntakes itAAttributes: as Linux'sposix_spawntakes itAArgv: as Linux'sposix_spawntakes itAEnvp: as Linux'sposix_spawntakes it
Returns: as Linux's posix_spawn returns it
posix_spawn_file_actions_init
func posix_spawn_file_actions_init(var AActions: posix_spawn_file_actions_t): int32
Linux's posix_spawn_file_actions_init: glibc: a start's file actions made / released, and one added: a descriptor copied to ATarget, a file opened as ATarget, a descriptor closed, the working folder changed (2.29)
Parameters
AActions: as Linux'sposix_spawn_file_actions_inittakes it
Returns: as Linux's posix_spawn_file_actions_init returns it
posix_spawn_file_actions_destroy
func posix_spawn_file_actions_destroy(var AActions: posix_spawn_file_actions_t): int32
Linux's posix_spawn_file_actions_destroy.
Parameters
AActions: as Linux'sposix_spawn_file_actions_destroytakes it
Returns: as Linux's posix_spawn_file_actions_destroy returns it
posix_spawn_file_actions_adddup2
func posix_spawn_file_actions_adddup2(var AActions: posix_spawn_file_actions_t; const AFile: int32; const ATarget: int32): int32
Linux's posix_spawn_file_actions_adddup2.
Parameters
AActions: as Linux'sposix_spawn_file_actions_adddup2takes itAFile: as Linux'sposix_spawn_file_actions_adddup2takes itATarget: as Linux'sposix_spawn_file_actions_adddup2takes it
Returns: as Linux's posix_spawn_file_actions_adddup2 returns it
posix_spawn_file_actions_addopen
func posix_spawn_file_actions_addopen(var AActions: posix_spawn_file_actions_t; const ATarget: int32; const APath: ptr to const char; const AFlags: int32; const AMode: uint32): int32
Linux's posix_spawn_file_actions_addopen.
Parameters
AActions: as Linux'sposix_spawn_file_actions_addopentakes itATarget: as Linux'sposix_spawn_file_actions_addopentakes itAPath: as Linux'sposix_spawn_file_actions_addopentakes itAFlags: as Linux'sposix_spawn_file_actions_addopentakes itAMode: as Linux'sposix_spawn_file_actions_addopentakes it
Returns: as Linux's posix_spawn_file_actions_addopen returns it
posix_spawn_file_actions_addclose
func posix_spawn_file_actions_addclose(var AActions: posix_spawn_file_actions_t; const AFile: int32): int32
Linux's posix_spawn_file_actions_addclose.
Parameters
AActions: as Linux'sposix_spawn_file_actions_addclosetakes itAFile: as Linux'sposix_spawn_file_actions_addclosetakes it
Returns: as Linux's posix_spawn_file_actions_addclose returns it
posix_spawn_file_actions_addchdir_np
func posix_spawn_file_actions_addchdir_np(var AActions: posix_spawn_file_actions_t; const APath: ptr to const char): int32
Linux's posix_spawn_file_actions_addchdir_np.
Parameters
AActions: as Linux'sposix_spawn_file_actions_addchdir_nptakes itAPath: as Linux'sposix_spawn_file_actions_addchdir_nptakes it
Returns: as Linux's posix_spawn_file_actions_addchdir_np returns it
posix_spawnattr_init
func posix_spawnattr_init(var AAttributes: posix_spawnattr_t): int32
Linux's posix_spawnattr_init: glibc: a start's attributes made / released, its flags (POSIX_SPAWN_*), its signal mask and the signals it puts back to their default action
Parameters
AAttributes: as Linux'sposix_spawnattr_inittakes it
Returns: as Linux's posix_spawnattr_init returns it
posix_spawnattr_destroy
func posix_spawnattr_destroy(var AAttributes: posix_spawnattr_t): int32
Linux's posix_spawnattr_destroy.
Parameters
AAttributes: as Linux'sposix_spawnattr_destroytakes it
Returns: as Linux's posix_spawnattr_destroy returns it
posix_spawnattr_setflags
func posix_spawnattr_setflags(var AAttributes: posix_spawnattr_t; const AFlags: int16): int32
Linux's posix_spawnattr_setflags.
Parameters
AAttributes: as Linux'sposix_spawnattr_setflagstakes itAFlags: as Linux'sposix_spawnattr_setflagstakes it
Returns: as Linux's posix_spawnattr_setflags returns it
posix_spawnattr_setsigmask
func posix_spawnattr_setsigmask(var AAttributes: posix_spawnattr_t; const AMask: ptr to const sigset_t): int32
Linux's posix_spawnattr_setsigmask.
Parameters
AAttributes: as Linux'sposix_spawnattr_setsigmasktakes itAMask: as Linux'sposix_spawnattr_setsigmasktakes it
Returns: as Linux's posix_spawnattr_setsigmask returns it
posix_spawnattr_setsigdefault
func posix_spawnattr_setsigdefault(var AAttributes: posix_spawnattr_t; const ADefault: ptr to const sigset_t): int32
Linux's posix_spawnattr_setsigdefault.
Parameters
AAttributes: as Linux'sposix_spawnattr_setsigdefaulttakes itADefault: as Linux'sposix_spawnattr_setsigdefaulttakes it
Returns: as Linux's posix_spawnattr_setsigdefault returns it
waitpid
func waitpid(const APid: int32; var AStatus: int32; const AOptions: int32): int32
Linux's waitpid: glibc: waits for the child APid to change state (AOptions WNOHANG: not at all), its status into AStatus; its id, 0 (WNOHANG, still running) or -1
Parameters
APid: as Linux'swaitpidtakes itAStatus: as Linux'swaitpidtakes itAOptions: as Linux'swaitpidtakes it
Returns: as Linux's waitpid returns it
syscall
func syscall(const ANumber: int64; ...): int64
Linux's syscall: glibc: the kernel call ANumber with its arguments (a C variadic); its result, -1 with errno on a failure
Parameters
ANumber: as Linux'ssyscalltakes it...: as Linux'ssyscalltakes them
Returns: as Linux's syscall returns it
pthread_create
func pthread_create(var AThread: uint64; const AAttributes: ptr; const AStart: func(AArgument: ptr): ptr; const AArgument: ptr): int32
glibc: a new thread running AStart(AArgument) (its pthread_t into AThread; AAttributes a pthread_attr_t or nil), 0 or an error number; one waited for, its result into AResult when not nil
Parameters
AThread: as Linux'spthread_createtakes itAAttributes: as Linux'spthread_createtakes itAStart: as Linux'spthread_createtakes itAArgument: as Linux'spthread_createtakes it
Returns: as Linux's pthread_create returns it
pthread_join
func pthread_join(const AThread: uint64; const AResult: ptr): int32
Linux's pthread_join.
Parameters
AThread: as Linux'spthread_jointakes itAResult: as Linux'spthread_jointakes it
Returns: as Linux's pthread_join returns it
timer_create
func timer_create(const AClock: int32; const AEvent: ptr to sigevent; var ATimer: ptr): int32
Linux's timer_create: glibc: a new timer on the clock AClock telling AEvent's way when it expires (its timer_t into ATimer), 0 or -1 with errno; armed by timer_settime (AFlags 0: AValue's times are relative; AOld, when not nil, the times it had), stopped and freed by timer_delete
Parameters
AClock: as Linux'stimer_createtakes itAEvent: as Linux'stimer_createtakes itATimer: as Linux'stimer_createtakes it
Returns: as Linux's timer_create returns it
timer_settime
func timer_settime(const ATimer: ptr; const AFlags: int32; const AValue: ptr to const itimerspec; const AOld: ptr to itimerspec): int32
Linux's timer_settime.
Parameters
ATimer: as Linux'stimer_settimetakes itAFlags: as Linux'stimer_settimetakes itAValue: as Linux'stimer_settimetakes itAOld: as Linux'stimer_settimetakes it
Returns: as Linux's timer_settime returns it
timer_delete
func timer_delete(const ATimer: ptr): int32
Linux's timer_delete.
Parameters
ATimer: as Linux'stimer_deletetakes it
Returns: as Linux's timer_delete returns it
sysconf
func sysconf(const AName: int32): int64
Linux's sysconf: unistd.h: a system limit or fact by its _SC_ name (-1 when unknown)
Parameters
AName: as Linux'ssysconftakes it
Returns: as Linux's sysconf returns it
uname
func uname(var ABuffer: utsname): int32
Linux's uname: sys/utsname.h: the kernel's name, release and machine
Parameters
ABuffer: as Linux'sunametakes it
Returns: as Linux's uname returns it
System.Machine
the machine a program runs on, the same on every target: import System.Machine; and no OS is named. CPUName, CPUCount, OSName and MemoryTotal answer what a report or a log says about where it ran (adam bench's report header); each asks the OS through this unit's platform part (System.Machine.Win64 / System.Machine.Linux64) and never fails: what the OS will not tell gives "" or 0 (CPUCount at least 1).
Import it with import System.Machine;.
Routines
CPUName
func cpplink CPUName(): string
The processor's name as its maker gives it, padding trimmed.
Returns: the name ("AMD Ryzen 9 7950X 16-Core Processor"), or "" when the OS does not say
Example: println("cpu {}", CPUName());
CPUCount
func cpplink CPUCount(): int64
The logical processors this process may run on (a for parallel's default worker count).
Returns: the count, at least 1
Example: println("{} threads", CPUCount());
OSName
func cpplink OSName(): string
The operating system's name and version: "Windows <major>.<minor>.<build>" on x86_64-windows-gnu, "Linux <kernel release>" on x86_64-linux-gnu.
Returns: the text ("Windows 10.0.26100", "Linux 6.6.87.2-microsoft-standard-WSL2")
Example: println("os {}", OSName());
MemoryTotal
func cpplink MemoryTotal(): int64
The physical memory installed.
Returns: the bytes, or 0 when the OS does not say
Example: println("{} GB", MemoryTotal() div (1024 * 1024 * 1024));
System.Machine.Linux64
System.Machine's platform unit for x86_64-linux-gnu, over System.Linux and System.IO: the processor's name is /proc/cpuinfo's first "model name" line, the OS uname's sysname and release, the processors and the memory sysconf's.
Import it with import System.Machine.Linux64;.
Routines
MachinePlatformCPUName
func cpplink MachinePlatformCPUName(): string
System.Machine's CPUName on x86_64-linux-gnu: /proc/cpuinfo's first "model name" value.
Returns: the processor's name, or ""
MachinePlatformCPUCount
func cpplink MachinePlatformCPUCount(): int64
System.Machine's CPUCount on x86_64-linux-gnu (sysconf's processors online).
Returns: the count, at least 1
MachinePlatformOSName
func cpplink MachinePlatformOSName(): string
System.Machine's OSName on x86_64-linux-gnu: uname's "<sysname> <release>".
Returns: "Linux <kernel release>", or "Linux" when uname fails
MachinePlatformMemoryTotal
func cpplink MachinePlatformMemoryTotal(): int64
System.Machine's MemoryTotal on x86_64-linux-gnu (sysconf's physical pages x page size).
Returns: the bytes, or 0
System.Machine.Win64
System.Machine's platform unit for x86_64-windows-gnu: each MachinePlatform* routine is System.Windows' Win* routine of the same job (the registry's processor name, RtlGetVersion, GetActiveProcessorCount, GlobalMemoryStatusEx).
Import it with import System.Machine.Win64;.
Routines
MachinePlatformCPUName
func cpplink MachinePlatformCPUName(): string
System.Machine's CPUName on x86_64-windows-gnu (WinCPUName).
Returns: the processor's name, or ""
MachinePlatformCPUCount
func cpplink MachinePlatformCPUCount(): int64
System.Machine's CPUCount on x86_64-windows-gnu (WinCPUCount).
Returns: the count, at least 1
MachinePlatformOSName
func cpplink MachinePlatformOSName(): string
System.Machine's OSName on x86_64-windows-gnu (WinOSVersion).
Returns: "Windows <major>.<minor>.<build>"
MachinePlatformMemoryTotal
func cpplink MachinePlatformMemoryTotal(): int64
System.Machine's MemoryTotal on x86_64-windows-gnu (WinMemoryTotal).
Returns: the bytes, or 0
System.Math
the maths a program reaches for beside the language's own operators: import System.Math;. PerceivedVolume turns a level a person sets (a slider, 0 to 1) into the linear volume an audio API takes, so equal steps sound like equal steps; PerceivedLevel turns a volume back into its level. Beside them: the constants (Pi, DegToRad / RadToDeg, the Epsilons, NaN), the everyday functions under Delphi's names (Sin, Cos, Sqrt, Power, Abs, and Round / Trunc / Floor / Ceil to int64), Clamp and Wrap, SameSign and SameValue, Lerp, AngleDifference, SmoothMove, the Easing curves (Ease, EaseBetween) and Random, a seeded generator whose numbers are the same on every target. And the 2D geometry of a game, with no graphics library: Vector2 (laid out as SFML's, raylib's and SDL's {x, y}), Rect and Extent, the oriented box Obb, and the collisions between them (points, circles, triangles, rectangles, segments, boxes). Angles are degrees. A name is read bare when no other imported unit exports it (PerceivedVolume), or qualified (System.Math.PerceivedVolume).
Import it with import System.Math;.
Types
Easing
type Easing = choices(
The shape of an easing curve (Robert Penner's): In starts slow, Out ends slow, InOut does both; Quad .. Quint are the powers 2 .. 5, Sine a quarter wave, Expo powers of 2, Circle a quarter circle.
Members
Easing.Linear: No easing: the fraction as it is.Easing.InQuad: Power 2, slow start.Easing.OutQuad: Power 2, slow end.Easing.InOutQuad: Power 2, slow start and end.Easing.InCubic: Power 3, slow start.Easing.OutCubic: Power 3, slow end.Easing.InOutCubic: Power 3, slow start and end.Easing.InQuart: Power 4, slow start.Easing.OutQuart: Power 4, slow end.Easing.InOutQuart: Power 4, slow start and end.Easing.InQuint: Power 5, slow start.Easing.OutQuint: Power 5, slow end.Easing.InOutQuint: Power 5, slow start and end.Easing.InSine: A quarter sine wave, slow start.Easing.OutSine: A quarter sine wave, slow end.Easing.InOutSine: A half sine wave, slow start and end.Easing.InExpo: Powers of 2, slow start.Easing.OutExpo: Powers of 2, slow end.Easing.InOutExpo: Powers of 2, slow start and end.Easing.InCircle: A quarter circle, slow start.Easing.OutCircle: A quarter circle, slow end.Easing.InOutCircle: Two quarter circles, slow start and end.
Since: 0.2
See also: Ease
RandomGenerator
type RandomGenerator = object
A source of random numbers: an MT19937 (C++'s std::mt19937) with this unit's own mapping, so a seed gives the same numbers on every target and every standard library. Built with a seed it repeats that sequence; built without one it takes a seed from the system's entropy source. Integer ranges hold both ends, float ranges the low end only; bounds may come in either order.
Members
Engine: Mt19937: The generator's engine (MT19937's state); use the methods, which keep Seed() trueSeedValue: uint32: The seed the sequence started from, as Seed() returns itinit(): A generator seeded from the system's entropy source. See Randomize.init(const ASeed: uint32): A generator that gives the sequence of ASeed. Parameters:ASeedthe seed.method SetSeed(const ASeed: uint32): Starts the sequence of ASeed again. Parameters:ASeedthe seed.const method Seed(): uint32: The seed the sequence started from (the last one set). Returns: the seedmethod Randomize(): Starts a fresh sequence from a seed taken from the system's entropy source. A generator built without a seed calls this on creation. Seed() then returns the new seed, so SetSeed(Seed()) repeats the sequence from here. Example:LRng.Randomize(); LAgain := LRng.Seed();SeeSetSeed,Seed, SetRandomSeed.method NextInt(const AMin: int32; const AMax: int32): int32: A whole number from AMin to AMax, both included. Parameters:AMinone end;AMaxthe other end. Returns: the numbermethod NextInt64(const AMin: int64; const AMax: int64): int64: NextInt for int64 bounds (a method name has one form per object). Parameters:AMinone end;AMaxthe other end. Returns: the numbermethod NextFloat(const AMin: float64; const AMax: float64): float64: A number from AMin (included) to AMax (left out); equal bounds give AMin. Parameters:AMinthe low end, included;AMaxthe high end, left out. Returns: the numbermethod NextFloat32(const AMin: float32; const AMax: float32): float32: NextFloat for float32 bounds: AMin (included) to AMax (left out). Parameters:AMinthe low end, included;AMaxthe high end, left out. Returns: the numbermethod NextBool(): bool: True or false, each half the time. Returns: the value
Since: 0.2
See also: RandomInt
Example: LRng: RandomGenerator(42); LDie := LRng.NextInt(1, 6);
Vector2
type Vector2 = object
A 2D vector or point of float32 X and Y, laid out as SFML's sf::Vector2f, raylib's Vector2 and SDL's SDL_FPoint ({x, y}). Angles are degrees, SFML's way: 0 points along +X, 90 along +Y (down the screen, as sf::Transformable::setRotation turns). A zero vector is well defined everywhere: its length, heading and normal are 0.
Members
X: float32: The X coordinate (+X to the right)Y: float32: The Y coordinate (+Y down the screen)init(): The zero vector.init(const AX: float32; const AY: float32): The vector (AX, AY). Parameters:AXthe X part;AYthe Y part.const method Length(): float32: Its length. Returns: the lengthconst method LengthSquared(): float32: Its length squared (no square root: for comparing lengths). Returns: the length squaredconst method Distance(const AOther: Vector2): float32: The distance between this point and AOther. Parameters:AOtherthe other point. Returns: the distanceconst method Dot(const AOther: Vector2): float32: The dot product with AOther. Parameters:AOtherthe other vector. Returns: X x AOther.X + Y x AOther.Yconst method Cross(const AOther: Vector2): float32: The 2D cross product with AOther (the Z of the 3D one): positive when AOther turns the way the angles grow. Parameters:AOtherthe other vector. Returns: X x AOther.Y - Y x AOther.Xconst method Normalized(): Vector2: The same direction at length 1; a zero vector stays zero. Returns: the unit vectorconst method Truncated(const AMax: float32): Vector2: The same vector, shortened to AMax when it is longer; a max of 0 or less gives the zero vector. Parameters:AMaxthe longest length. Returns: the vector, at most AMax longconst method Project(const AOnto: Vector2): Vector2: This vector projected onto AOnto (its part along AOnto); onto a zero vector it is the zero vector. Parameters:AOntothe vector projected onto. Returns: the projectionconst method Perpendicular(): Vector2: The vector turned 90 degrees the way the angles grow: (-Y, X), as SFML. Returns: the perpendicular vectorconst method Rotated(const ADegrees: float32): Vector2: The vector turned by ADegrees (positive turns the way the angles grow); computed in float64. Parameters:ADegreesthe turn, in degrees. Returns: the turned vectorconst method Heading(): float32: The direction it points, in degrees: -180 (left out) to 180 (included), 0 along +X, 90 along +Y; a zero vector heads 0. Returns: the heading, in degreesconst method Thrust(const ADegrees: float32; const ASpeed: float32): Vector2: This point moved ASpeed along the heading ADegrees (one step of a thrust); computed in float64. Parameters:ADegreesthe heading, in degrees;ASpeedthe distance moved. Returns: the moved pointconst method Lerp(const ATo: Vector2; const AT: float32): Vector2: The point AT of the way to ATo (std::lerp on each part): 0 gives this point, 1 exactly ATo. Parameters:ATothe end point;ATthe fraction of the way. Returns: the point betweenoperator +(const A: Vector2; const B: Vector2): Vector2: The sum, component by component. Parameters:Athe first vector;Bthe second vector. Returns: (A.X + B.X, A.Y + B.Y)operator -(const A: Vector2; const B: Vector2): Vector2: The difference, component by component: the vector from B to A. Parameters:Athe vector subtracted from;Bthe vector subtracted. Returns: (A.X - B.X, A.Y - B.Y)operator -(const A: Vector2): Vector2: The vector turned around: the same length, the opposite way. Parameters:Athe vector. Returns: (-A.X, -A.Y)operator *(const A: Vector2; const AScale: float32): Vector2: The vector scaled. Parameters:Athe vector;AScalethe factor. Returns: (A.X * AScale, A.Y * AScale)operator *(const AScale: float32; const A: Vector2): Vector2: The vector scaled, the factor written first. Parameters:AScalethe factor;Athe vector. Returns: (A.X * AScale, A.Y * AScale)operator /(const A: Vector2; const AScale: float32): Vector2: The vector divided by a factor, by float rules: a factor of 0 gives infinities or NaN. Parameters:Athe vector;AScalethe divisor. Returns: (A.X / AScale, A.Y / AScale)operator =(const A: Vector2; const B: Vector2): bool: Whether two vectors are exactly equal, component by component (for a tolerance, use SameValue on each component). Parameters:Athe first vector;Bthe second vector. Returns: true when A.X = B.X and A.Y = B.Yoperator <>(const A: Vector2; const B: Vector2): bool: Whether two vectors differ in any component: the opposite of=. Parameters:Athe first vector;Bthe second vector. Returns: true when A.X <> B.X or A.Y <> B.Y
Since: 0.2
See also: Rect
Example: LPos: Vector2(10.0f, 20.0f); LPos := LPos + LVel * LDelta;
Rect
type Rect = object
An axis-aligned rectangle: its corner (X, Y) and its size, laid out as sf::FloatRect and raylib's Rectangle. It follows SFML's rules exactly: a negative size spans the other way, a point on the far edges is outside ([X, X + Width)), and rectangles that only touch do not overlap.
Members
X: float32: The left edge (the corner's X)Y: float32: The top edge (the corner's Y)Width: float32: The width; negative spans to the left of XHeight: float32: The height; negative spans above Yinit(): The empty rectangle at (0, 0).init(const AX: float32; const AY: float32; const AWidth: float32; const AHeight: float32): The rectangle with corner (AX, AY) and size AWidth x AHeight. Parameters:AXthe corner's X;AYthe corner's Y;AWidththe width;AHeightthe height.const method Contains(const APoint: Vector2): bool: True when APoint is inside: [left, right) x [top, bottom). Parameters:APointthe point. Returns: whether the rectangle holds itconst method Intersection(const AOther: Rect; var AResult: Rect): bool: The rectangle both cover, in AResult (the empty one when they do not overlap; touching edges do not). Parameters:AOtherthe other rectangle;AResultthe overlap. Returns: whether they overlapconst method Overlaps(const AOther: Rect): bool: True when the rectangles share an area (touching is not enough). Parameters:AOtherthe other rectangle. Returns: whether they overlapconst method Center(): Vector2: The centre point. Returns: the centre
Since: 0.2
See also: Extent
Example: LBox: Rect(0.0f, 0.0f, 32.0f, 32.0f); if LBox.Contains(LMouse) then ... end;
Extent
type Extent = object
A rectangle as its two corners: the smallest and the largest X and Y.
Members
MinX: float32: The smallest X (the left edge)MinY: float32: The smallest Y (the top edge)MaxX: float32: The largest X (the right edge)MaxY: float32: The largest Y (the bottom edge)init(): The empty extent at (0, 0).init(const AMinX: float32; const AMinY: float32; const AMaxX: float32; const AMaxY: float32): The extent from (AMinX, AMinY) to (AMaxX, AMaxY), as given. Parameters:AMinXthe smallest X;AMinYthe smallest Y;AMaxXthe largest X;AMaxYthe largest Y.const method ToRect(): Rect: The same area as a Rect: corner (MinX, MinY), size max - min. Returns: the rectangle
Since: 0.2
See also: Rect
LineHitKind
type LineHitKind = choices(
How two line segments meet (LineIntersection).
Members
LineHitKind.Miss: They do not meet.LineHitKind.Point: They cross or touch at one point.LineHitKind.Parallel: Parallel and apart.LineHitKind.Collinear: On one line and overlapping.
Since: 0.2
LineHit
type LineHit = object
Where two line segments meet: Kind, and Point when Kind is Point.
Members
Kind: LineHitKind: How the segments meetPoint: Vector2: The point where they meet; read it only when Kind is Pointinit(): No meeting: Kind Miss, Point (0, 0).
Since: 0.2
See also: LineIntersection
Obb
type Obb = object
An oriented box: a centre, half its width and height, and the angle it is turned by, in degrees (positive the way the angles grow).
Members
Center: Vector2: The box's centreHalfSize: Vector2: Half its width (X) and half its height (Y)Angle: float32: The turn, in degrees (positive the way angles grow)init(): The box of no size at (0, 0).init(const ACenter: Vector2; const AHalfSize: Vector2; const ADegrees: float32): The box at ACenter, AHalfSize from its centre to its sides, turned by ADegrees. Parameters:ACenterthe centre;AHalfSizehalf the width and height;ADegreesthe turn, in degrees.
Since: 0.2
See also: ObbsOverlap
Constants
| Name | Declaration | Description |
|---|---|---|
Pi | const Pi: float64 = 3.141592653589793 | The ratio of a circle's circumference to its diameter. |
DegToRad | const DegToRad: float64 = 0.017453292519943295 | Degrees times DegToRad are radians: 90.0 * DegToRad is Pi / 2. See RadToDeg. |
RadToDeg | const RadToDeg: float64 = 57.29577951308232 | Radians times RadToDeg are degrees: Pi * RadToDeg is 180. See DegToRad. |
Epsilon32 | const Epsilon32: float32 = 0.00001f | The float32 tolerance SameValue uses when none is given (scaled by the values' size past 1). See SameValue. |
Epsilon64 | const Epsilon64: float64 = 0.000000000001 | The float64 tolerance SameValue uses when none is given (scaled by the values' size past 1). See SameValue. |
NaN | const NaN: float64 = 0.0 / 0.0 | Not a number. It compares unequal to everything, itself included: test a value with X <> X. |
Routines
PerceivedVolume
func cpplink PerceivedVolume(const ALevel: float64; const AMax: float64; const ARangeDb: float64): float64
The linear volume for a level a person sets, so that equal steps of the level sound like equal steps of loudness. The level maps to decibels over ARangeDb (1 = 0 dB = AMax, the knee level 0.1 = -ARangeDb dB), and below the knee the volume fades in a straight line to exact silence at 0. A level past 1 gives AMax, at or below 0 (or NaN) gives 0. A range of 0 or less makes the curve linear (ALevel * AMax).
Parameters
ALevel: the level, 0 (silent) to 1 (full)AMax: the volume at level 1 (100 for SFML's setVolume)ARangeDb: the loudness range in decibels the level spans
Returns: the linear volume, 0 to AMax
Since: 0.2
See also: PerceivedLevel
Example: LSound.setVolume(PerceivedVolume(0.5, 100.0, 40.0));
func cpplink PerceivedVolume(const ALevel: float64; const AMax: float64): float64
PerceivedVolume over the default 50 dB range.
Parameters
ALevel: the level, 0 (silent) to 1 (full)AMax: the volume at level 1
Returns: the linear volume, 0 to AMax
Since: 0.2
See also: PerceivedLevel
Example: LMusic.setVolume(PerceivedVolume(LSlider, 100.0));
func cpplink PerceivedVolume(const ALevel: float32; const AMax: float32; const ARangeDb: float32): float32
PerceivedVolume for float32 values (computed in float64).
Parameters
ALevel: the level, 0 (silent) to 1 (full)AMax: the volume at level 1ARangeDb: the loudness range in decibels the level spans
Returns: the linear volume, 0 to AMax
Since: 0.2
func cpplink PerceivedVolume(const ALevel: float32; const AMax: float32): float32
PerceivedVolume for float32 values over the default 50 dB range.
Parameters
ALevel: the level, 0 (silent) to 1 (full)AMax: the volume at level 1
Returns: the linear volume, 0 to AMax
Since: 0.2
PerceivedLevel
func cpplink PerceivedLevel(const AVolume: float64; const AMax: float64; const ARangeDb: float64): float64
The level that gives a linear volume: PerceivedVolume's inverse over the same curve, so PerceivedLevel(PerceivedVolume(L, M, R), M, R) is L for any L in 0 .. 1. A volume of AMax or more gives 1, of 0 or less (or NaN) gives 0; a max of 0 or less gives 0.
Parameters
AVolume: the linear volumeAMax: the volume at level 1ARangeDb: the loudness range in decibels the level spans
Returns: the level, 0 to 1
Since: 0.2
See also: PerceivedVolume
Example: LSlider := PerceivedLevel(LMusic.getVolume(), 100.0, 40.0);
func cpplink PerceivedLevel(const AVolume: float64; const AMax: float64): float64
PerceivedLevel over the default 50 dB range.
Parameters
AVolume: the linear volumeAMax: the volume at level 1
Returns: the level, 0 to 1
Since: 0.2
See also: PerceivedVolume
func cpplink PerceivedLevel(const AVolume: float32; const AMax: float32; const ARangeDb: float32): float32
PerceivedLevel for float32 values (computed in float64).
Parameters
AVolume: the linear volumeAMax: the volume at level 1ARangeDb: the loudness range in decibels the level spans
Returns: the level, 0 to 1
Since: 0.2
func cpplink PerceivedLevel(const AVolume: float32; const AMax: float32): float32
PerceivedLevel for float32 values over the default 50 dB range.
Parameters
AVolume: the linear volumeAMax: the volume at level 1
Returns: the level, 0 to 1
Since: 0.2
Sin
func cpplink Sin(const AValue: float64): float64
The sine of an angle in radians (Sin(90.0 * DegToRad) is 1).
Parameters
AValue: the angle, radians
Returns: its sine, in [-1, 1]; NaN for a NaN or an infinity
Since: 0.3
See also: Cos
Example: LY := CRadius * Sin(LAngle);
func cpplink Sin(const AValue: float32): float32
Sin for a float32 angle, computed in float32.
Parameters
AValue: the angle, radians
Returns: its sine
Since: 0.3
Cos
func cpplink Cos(const AValue: float64): float64
The cosine of an angle in radians (Cos(Pi) is -1).
Parameters
AValue: the angle, radians
Returns: its cosine, in [-1, 1]; NaN for a NaN or an infinity
Since: 0.3
See also: Sin
Example: LX := CRadius * Cos(LAngle);
func cpplink Cos(const AValue: float32): float32
Cos for a float32 angle, computed in float32.
Parameters
AValue: the angle, radians
Returns: its cosine
Since: 0.3
Sqrt
func cpplink Sqrt(const AValue: float64): float64
The square root.
Parameters
AValue: the value
Returns: its non-negative square root; NaN for a negative value or a NaN
Since: 0.3
Example: LDistance := Sqrt(LDX * LDX + LDY * LDY);
func cpplink Sqrt(const AValue: float32): float32
Sqrt for a float32 value, computed in float32.
Parameters
AValue: the value
Returns: its square root
Since: 0.3
Power
func cpplink Power(const ABase: float64; const AExponent: float64): float64
ABase raised to the power AExponent (Delphi's Math.Power): any real exponent, so roots and fractional steps too.
Parameters
ABase: the baseAExponent: the exponent
Returns: ABase to the AExponent; 1 for any base when AExponent is 0; NaN for a negative base with a fractional exponent
Since: 0.4
Example: LRatio := Power(2.0, LSemitones / 12.0); // a note's pitch ratio
func cpplink Power(const ABase: float32; const AExponent: float32): float32
Power for float32 values, computed in float32.
Parameters
ABase: the baseAExponent: the exponent
Returns: ABase to the AExponent
Since: 0.4
Exp
func cpplink Exp(const AValue: float64): float64
e raised to the power AValue (Delphi's Exp): Ln's inverse.
Parameters
AValue: the exponent
Returns: e to the AValue; +infinity past about 709.78, 0 far below 0; NaN stays NaN
Since: 0.4
See also: Ln
Example: LDecay := Exp(-LTime / LHalfLife);
func cpplink Exp(const AValue: float32): float32
Exp for a float32 value, computed in float32.
Parameters
AValue: the exponent
Returns: e to the AValue
Since: 0.4
Ln
func cpplink Ln(const AValue: float64): float64
The natural logarithm, base e (Delphi's Ln): Exp's inverse.
Parameters
AValue: the value
Returns: its natural logarithm; -infinity for 0; NaN for a negative value or a NaN
Since: 0.4
Example: LOctaves := Ln(LRatio) / Ln(2.0);
func cpplink Ln(const AValue: float32): float32
Ln for a float32 value, computed in float32.
Parameters
AValue: the value
Returns: its natural logarithm
Since: 0.4
Log2
func cpplink Log2(const AValue: float64): float64
The base 2 logarithm (Delphi's Log2): exact for a power of two (Log2(1024.0) is 10).
Parameters
AValue: the value
Returns: its base 2 logarithm; -infinity for 0; NaN for a negative value or a NaN
Since: 0.4
See also: Ln
Example: LLevels := Trunc(Log2(float64(LSize))) + 1;
func cpplink Log2(const AValue: float32): float32
Log2 for a float32 value, computed in float32.
Parameters
AValue: the value
Returns: its base 2 logarithm
Since: 0.4
Log10
func cpplink Log10(const AValue: float64): float64
The base 10 logarithm (Delphi's Log10): exact for a power of ten (Log10(1000.0) is 3).
Parameters
AValue: the value
Returns: its base 10 logarithm; -infinity for 0; NaN for a negative value or a NaN
Since: 0.4
See also: Ln
Example: LDecibels := 20.0 * Log10(LAmplitude);
func cpplink Log10(const AValue: float32): float32
Log10 for a float32 value, computed in float32.
Parameters
AValue: the value
Returns: its base 10 logarithm
Since: 0.4
Abs
func cpplink Abs(const AValue: float64): float64
The absolute value: AValue without its sign.
Parameters
AValue: the value
Returns: |AValue|; NaN stays NaN
Since: 0.3
Example: LGap := Abs(LTarget - LPosition);
func cpplink Abs(const AValue: float32): float32
Abs for a float32 value.
Parameters
AValue: the value
Returns: |AValue|
Since: 0.3
func cpplink Abs(const AValue: int64): int64
Abs for an int64 value.
Parameters
AValue: the value
Returns: |AValue|
Raises: ADAM_MATH_EXC_OVERFLOW (5) for the lowest int64, which has no positive counterpart
Since: 0.3
func cpplink Abs(const AValue: int32): int32
Abs for an int32 value.
Parameters
AValue: the value
Returns: |AValue|
Raises: ADAM_MATH_EXC_OVERFLOW (5) for the lowest int32, which has no positive counterpart
Since: 0.3
Round
func cpplink Round(const AValue: float64): int64
The nearest whole number, as Delphi rounds: a value exactly halfway goes to the even neighbour (banker's rounding), so Round(2.5) is 2, Round(3.5) is 4 and Round(-2.5) is -2.
Parameters
AValue: the value
Returns: the nearest whole number
Raises: ADAM_MATH_EXC_OVERFLOW (5) when the result does not fit int64, or AValue is a NaN or an infinity
Since: 0.3
See also: Trunc
Example: LSample := int16(Round(CAmplitude * Sin(LPhase)));
func cpplink Round(const AValue: float32): int64
Round for a float32 value (widened exactly to float64 first).
Parameters
AValue: the value
Returns: the nearest whole number, halfway to even
Raises: ADAM_MATH_EXC_OVERFLOW (5) as Round
Since: 0.3
Trunc
func cpplink Trunc(const AValue: float64): int64
The whole part: the fraction dropped, toward zero (Trunc(-2.7) is -2).
Parameters
AValue: the value
Returns: the whole part
Raises: ADAM_MATH_EXC_OVERFLOW (5) when it does not fit int64, or AValue is a NaN or an infinity
Since: 0.3
See also: Round
Example: LSeconds := Trunc(LElapsed);
func cpplink Trunc(const AValue: float32): int64
Trunc for a float32 value.
Parameters
AValue: the value
Returns: the whole part
Raises: ADAM_MATH_EXC_OVERFLOW (5) as Trunc
Since: 0.3
Floor
func cpplink Floor(const AValue: float64): int64
The greatest whole number not above AValue (Floor(-2.5) is -3).
Parameters
AValue: the value
Returns: AValue rounded down
Raises: ADAM_MATH_EXC_OVERFLOW (5) when it does not fit int64, or AValue is a NaN or an infinity
Since: 0.3
See also: Ceil
Example: LTileX := Floor(LWorldX / CTileSize);
func cpplink Floor(const AValue: float32): int64
Floor for a float32 value.
Parameters
AValue: the value
Returns: AValue rounded down
Raises: ADAM_MATH_EXC_OVERFLOW (5) as Floor
Since: 0.3
Ceil
func cpplink Ceil(const AValue: float64): int64
The least whole number not below AValue (Ceil(-2.5) is -2).
Parameters
AValue: the value
Returns: AValue rounded up
Raises: ADAM_MATH_EXC_OVERFLOW (5) when it does not fit int64, or AValue is a NaN or an infinity
Since: 0.3
See also: Floor
Example: LPages := Ceil(LLines / CLinesPerPage);
func cpplink Ceil(const AValue: float32): int64
Ceil for a float32 value.
Parameters
AValue: the value
Returns: AValue rounded up
Raises: ADAM_MATH_EXC_OVERFLOW (5) as Ceil
Since: 0.3
Clamp
func cpplink Clamp(const AValue: float64; const AMin: float64; const AMax: float64): float64
AValue held inside the bounds: below the lower one it is the lower one, above the upper one the upper one. The bounds may come in either order. A NaN stays NaN.
Parameters
AValue: the valueAMin: one boundAMax: the other bound
Returns: AValue inside [AMin, AMax]
Since: 0.2
See also: Wrap
Example: LHealth := Clamp(LHealth - LDamage, 0, 100);
func cpplink Clamp(const AValue: float32; const AMin: float32; const AMax: float32): float32
Clamp for float32 values.
Parameters
AValue: the valueAMin: one boundAMax: the other bound
Returns: AValue inside [AMin, AMax]
Since: 0.2
func cpplink Clamp(const AValue: int64; const AMin: int64; const AMax: int64): int64
Clamp for int64 values.
Parameters
AValue: the valueAMin: one boundAMax: the other bound
Returns: AValue inside [AMin, AMax]
Since: 0.2
func cpplink Clamp(const AValue: int32; const AMin: int32; const AMax: int32): int32
Clamp for int32 values.
Parameters
AValue: the valueAMin: one boundAMax: the other bound
Returns: AValue inside [AMin, AMax]
Since: 0.2
Min
func cpplink Min(const AA: float64; const AB: float64): float64
The smaller of two values (Delphi's Min): AA when it is less than AB, else AB, so a NaN in either gives AB.
Parameters
AA: one valueAB: the other value
Returns: the smaller of AA and AB
Since: 0.3
See also: Max
Example: LZoom := Min(LFitX, LFitY);
func cpplink Min(const AA: float32; const AB: float32): float32
Min for float32 values.
Parameters
AA: one valueAB: the other value
Returns: the smaller of AA and AB
Since: 0.3
func cpplink Min(const AA: int64; const AB: int64): int64
Min for int64 values.
Parameters
AA: one valueAB: the other value
Returns: the smaller of AA and AB
Since: 0.3
func cpplink Min(const AA: int32; const AB: int32): int32
Min for int32 values.
Parameters
AA: one valueAB: the other value
Returns: the smaller of AA and AB
Since: 0.3
Max
func cpplink Max(const AA: float64; const AB: float64): float64
The larger of two values (Delphi's Max): AA when it is more than AB, else AB, so a NaN in either gives AB.
Parameters
AA: one valueAB: the other value
Returns: the larger of AA and AB
Since: 0.3
See also: Min
Example: LWidth := Max(LWidth, 1);
func cpplink Max(const AA: float32; const AB: float32): float32
Max for float32 values.
Parameters
AA: one valueAB: the other value
Returns: the larger of AA and AB
Since: 0.3
func cpplink Max(const AA: int64; const AB: int64): int64
Max for int64 values.
Parameters
AA: one valueAB: the other value
Returns: the larger of AA and AB
Since: 0.3
func cpplink Max(const AA: int32; const AB: int32): int32
Max for int32 values.
Parameters
AA: one valueAB: the other value
Returns: the larger of AA and AB
Since: 0.3
Wrap
func cpplink Wrap(const AValue: float64; const AMin: float64; const AMax: float64): float64
AValue wrapped around the range [AMin, AMax): going past the top comes in again at the bottom, as an angle does (Wrap(370.0, 0.0, 360.0) is 10), however far outside it is. The bounds may come in either order; equal bounds give AMin. A NaN stays NaN.
Parameters
AValue: the valueAMin: the bottom of the range, includedAMax: the top of the range, left out
Returns: AValue inside [AMin, AMax)
Since: 0.2
See also: Clamp
Example: LHeading := Wrap(LHeading + LTurn, 0.0, 360.0);
func cpplink Wrap(const AValue: float32; const AMin: float32; const AMax: float32): float32
Wrap for float32 values.
Parameters
AValue: the valueAMin: the bottom of the range, includedAMax: the top of the range, left out
Returns: AValue inside [AMin, AMax)
Since: 0.2
func cpplink Wrap(const AValue: int64; const AMin: int64; const AMax: int64): int64
AValue wrapped around the whole numbers AMin .. AMax, both included: one past the top is the bottom (Wrap(360, 0, 359) is 0), however far outside it is. The bounds may come in either order.
Parameters
AValue: the valueAMin: one end of the range, includedAMax: the other end, included
Returns: AValue inside [AMin, AMax]
Since: 0.2
Example: LFrame := Wrap(LFrame + 1, 0, LFrameCount - 1);
func cpplink Wrap(const AValue: int32; const AMin: int32; const AMax: int32): int32
Wrap for int32 values (both ends included).
Parameters
AValue: the valueAMin: one end of the range, includedAMax: the other end, included
Returns: AValue inside [AMin, AMax]
Since: 0.2
SameSign
func cpplink SameSign(const AValue1: int64; const AValue2: int64): bool
True when both values have the same sign: both above 0, both below 0, or both 0 (0 has its own sign, so 0 and 5 differ).
Parameters
AValue1: the first valueAValue2: the second value
Returns: whether their signs match
Since: 0.2
func cpplink SameSign(const AValue1: int32; const AValue2: int32): bool
SameSign for int32 values.
Parameters
AValue1: the first valueAValue2: the second value
Returns: whether their signs match
Since: 0.2
func cpplink SameSign(const AValue1: float64; const AValue2: float64): bool
SameSign for float64 values; -0.0 is 0, a NaN matches nothing.
Parameters
AValue1: the first valueAValue2: the second value
Returns: whether their signs match
Since: 0.2
func cpplink SameSign(const AValue1: float32; const AValue2: float32): bool
SameSign for float32 values.
Parameters
AValue1: the first valueAValue2: the second value
Returns: whether their signs match
Since: 0.2
SameValue
func cpplink SameValue(const A: float64; const B: float64; const AEpsilon: float64): bool
True when A and B are no more than AEpsilon apart. Equal values (equal infinities too) are the same; a NaN is never the same as anything.
Parameters
A: the first valueB: the second valueAEpsilon: the largest difference still counted as the same
Returns: whether A and B are the same within AEpsilon
Since: 0.2
See also: Epsilon64
Example: if SameValue(LSpeed, 0.0, 0.001) then ... end;
func cpplink SameValue(const A: float64; const B: float64): bool
SameValue with Epsilon64 as the tolerance, scaled by the larger value's size once it is past 1 (1e15 and 1e15 + 0.5 are the same; 1 and 1.0001 are not).
Parameters
A: the first valueB: the second value
Returns: whether A and B are the same
Since: 0.2
func cpplink SameValue(const A: float32; const B: float32; const AEpsilon: float32): bool
SameValue for float32 values.
Parameters
A: the first valueB: the second valueAEpsilon: the largest difference still counted as the same
Returns: whether A and B are the same within AEpsilon
Since: 0.2
func cpplink SameValue(const A: float32; const B: float32): bool
SameValue for float32 values with Epsilon32 as the tolerance, scaled by the larger value's size once it is past 1.
Parameters
A: the first valueB: the second value
Returns: whether A and B are the same
Since: 0.2
Lerp
func cpplink Lerp(const AFrom: float64; const ATo: float64; const AT: float64): float64
The value AT of the way from AFrom to ATo: 0 gives AFrom, 1 gives exactly ATo, values outside 0 .. 1 go on past them (std::lerp's rule).
Parameters
AFrom: the startATo: the endAT: the fraction of the way
Returns: AFrom + (ATo - AFrom) x AT
Since: 0.2
See also: EaseBetween
Example: LX := Lerp(LStartX, LEndX, LElapsed / LDuration);
func cpplink Lerp(const AFrom: float32; const ATo: float32; const AT: float32): float32
Lerp for float32 values.
Parameters
AFrom: the startATo: the endAT: the fraction of the way
Returns: AFrom + (ATo - AFrom) x AT
Since: 0.2
InverseLerp
func cpplink InverseLerp(const AFrom: float64; const ATo: float64; const AValue: float64): float64
Where AValue stands between AFrom and ATo as a fraction: 0 at AFrom, 1 at ATo, beyond 0..1 outside them (never clamped): Lerp's inverse, raymath's Normalize.
Parameters
AFrom: the value that gives 0ATo: the value that gives 1AValue: the value placed
Returns: its fraction; 0 when AFrom = ATo (no span to place it in)
Example: InverseLerp(0.0, 10.0, 2.5) is 0.25
func cpplink InverseLerp(const AFrom: float32; const ATo: float32; const AValue: float32): float32
InverseLerp's float32 form.
Parameters
AFrom: the value that gives 0ATo: the value that gives 1AValue: the value placed
Returns: its fraction; 0 when AFrom = ATo
Remap
func cpplink Remap(const AValue: float64; const AFromLow: float64; const AFromHigh: float64; const AToLow: float64; const AToHigh: float64): float64
AValue moved from the range AFromLow..AFromHigh to the same place in AToLow..AToHigh (Lerp of InverseLerp, never clamped), raymath's Remap.
Parameters
AValue: the valueAFromLow: the first range's startAFromHigh: the first range's endAToLow: the second range's startAToHigh: the second range's end
Returns: the value in the second range (AToLow when the first range is empty)
Example: Remap(5.0, 0.0, 10.0, 100.0, 200.0) is 150.0
func cpplink Remap(const AValue: float32; const AFromLow: float32; const AFromHigh: float32; const AToLow: float32; const AToHigh: float32): float32
Remap's float32 form.
Parameters
AValue: the valueAFromLow: the first range's startAFromHigh: the first range's endAToLow: the second range's startAToHigh: the second range's end
Returns: the value in the second range
AngleDifference
func cpplink AngleDifference(const ASource: float64; const ADest: float64): float64
The shortest turn, in degrees, from the angle ASource to the angle ADest: -180 (included) to 180 (left out); positive turns the way the angles grow. AngleDifference(350.0, 10.0) is 20.
Parameters
ASource: the angle turned from, in degreesADest: the angle turned to, in degrees
Returns: the turn, in [-180, 180)
Since: 0.2
func cpplink AngleDifference(const ASource: float32; const ADest: float32): float32
AngleDifference for float32 values.
Parameters
ASource: the angle turned from, in degreesADest: the angle turned to, in degrees
Returns: the turn, in [-180, 180)
Since: 0.2
SmoothMove
func cpplink SmoothMove(const AValue: float64; const AAmount: float64; const AMax: float64; const ADrag: float64): float64
One step of a speed that is pushed and slows down by itself: a push (AAmount not 0) adds AAmount, up to AMax that way; no push slows the value toward 0 by ADrag, stopping at 0. Called once per update, the drag is per update. AMax and ADrag are taken as their size (their sign is ignored).
Parameters
AValue: the speed nowAAmount: the push this update, 0 for noneAMax: the largest speed either wayADrag: how much the speed falls per update with no push
Returns: the new speed
Since: 0.2
Example: LSpeed := SmoothMove(LSpeed, LPush, 8.0, 0.5);
func cpplink SmoothMove(const AValue: float32; const AAmount: float32; const AMax: float32; const ADrag: float32): float32
SmoothMove for float32 values.
Parameters
AValue: the speed nowAAmount: the push this update, 0 for noneAMax: the largest speed either wayADrag: how much the speed falls per update with no push
Returns: the new speed
Since: 0.2
Ease
func cpplink Ease(const AKind: Easing; const AFraction: float64): float64
The easing curve AKind at AFraction of the way: 0 to 1 in, 0 to 1 out. Every curve gives exactly 0 at 0 and exactly 1 at 1; a fraction below 0 (or NaN) is 0, past 1 is 1.
Parameters
AKind: the curveAFraction: how far along, 0 to 1 (elapsed / duration)
Returns: the eased fraction, 0 to 1
Since: 0.2
See also: EaseBetween
Example: LAlpha := Ease(Easing.OutCubic, LElapsed / LDuration);
func cpplink Ease(const AKind: Easing; const AFraction: float32): float32
Ease for a float32 fraction (computed in float64).
Parameters
AKind: the curveAFraction: how far along, 0 to 1
Returns: the eased fraction, 0 to 1
Since: 0.2
EaseBetween
func cpplink EaseBetween(const AKind: Easing; const AFrom: float64; const ATo: float64; const AFraction: float64): float64
The value AFraction of the way from AFrom to ATo along the easing curve AKind: exactly AFrom at 0 and exactly ATo at 1, the fraction held to 0 .. 1. Penner's ease(t, b, c, d) is EaseBetween(AKind, b, b + c, t / d).
Parameters
AKind: the curveAFrom: the start valueATo: the end valueAFraction: how far along, 0 to 1 (elapsed / duration)
Returns: the eased value between AFrom and ATo
Since: 0.2
See also: Ease
Example: LY := EaseBetween(Easing.OutQuad, 0.0, 300.0, LElapsed / 2.0);
func cpplink EaseBetween(const AKind: Easing; const AFrom: float32; const ATo: float32; const AFraction: float32): float32
EaseBetween for float32 values.
Parameters
AKind: the curveAFrom: the start valueATo: the end valueAFraction: how far along, 0 to 1
Returns: the eased value between AFrom and ATo
Since: 0.2
RandomInt
func cpplink RandomInt(const AMin: int32; const AMax: int32): int32
A whole number from AMin to AMax, both included, from the unit's own generator (seeded from the system at start-up; SetRandomSeed repeats a sequence).
Parameters
AMin: one endAMax: the other end
Returns: the number
Since: 0.2
See also: RandomGenerator
Example: LDie := RandomInt(1, 6);
func cpplink RandomInt(const AMin: int64; const AMax: int64): int64
RandomInt for int64 bounds.
Parameters
AMin: one endAMax: the other end
Returns: the number
Since: 0.2
RandomFloat
func cpplink RandomFloat(const AMin: float64; const AMax: float64): float64
A number from AMin (included) to AMax (left out), from the unit's own generator.
Parameters
AMin: the low end, includedAMax: the high end, left out
Returns: the number
Since: 0.2
Example: LX := RandomFloat(0.0, 640.0);
func cpplink RandomFloat(const AMin: float32; const AMax: float32): float32
RandomFloat for float32 bounds.
Parameters
AMin: the low end, includedAMax: the high end, left out
Returns: the number
Since: 0.2
RandomBool
func cpplink RandomBool(): bool
True or false, each half the time, from the unit's own generator.
Returns: the value
Since: 0.2
RandomSeed
func cpplink RandomSeed(): uint32
The seed the unit's own generator started from (the last one set).
Returns: the seed
Since: 0.2
SetRandomSeed
func cpplink SetRandomSeed(const ASeed: uint32)
Starts the unit's own generator on the sequence of ASeed, so the next RandomInt / RandomFloat / RandomBool calls repeat it.
Parameters
ASeed: the seed
Since: 0.2
Randomize
func cpplink Randomize()
Starts the unit's own generator on a fresh sequence, seeded from the system's entropy source. RandomSeed() then returns the new seed, so SetRandomSeed(RandomSeed()) repeats the sequence from here.
Since: 0.2
See also: SetRandomSeed, RandomSeed, RandomGenerator
Example: Randomize(); LRoll := RandomInt(1, 6);
PointInCircle
func cpplink PointInCircle(const APoint: Vector2; const ACenter: Vector2; const ARadius: float32): bool
True when APoint is in the circle (its edge included).
Parameters
APoint: the pointACenter: the circle's centreARadius: the circle's radius
Returns: whether the circle holds the point
Since: 0.2
PointInTriangle
func cpplink PointInTriangle(const APoint: Vector2; const A: Vector2; const B: Vector2; const C: Vector2): bool
True when APoint is strictly inside the triangle A B C (either winding; a point on an edge is outside, a flat triangle holds nothing).
Parameters
APoint: the pointA: a cornerB: a cornerC: a corner
Returns: whether the triangle holds the point
Since: 0.2
CirclesOverlap
func cpplink CirclesOverlap(const ACenter1: Vector2; const ARadius1: float32; const ACenter2: Vector2; const ARadius2: float32): bool
True when two circles overlap or touch.
Parameters
ACenter1: the first circle's centreARadius1: the first circle's radiusACenter2: the second circle's centreARadius2: the second circle's radius
Returns: whether they overlap
Since: 0.2
CircleOverlapsRect
func cpplink CircleOverlapsRect(const ACenter: Vector2; const ARadius: float32; const ARect: Rect): bool
True when a circle overlaps a rectangle (touching counts): the point of the rectangle nearest the centre is within the radius.
Parameters
ACenter: the circle's centreARadius: the circle's radiusARect: the rectangle
Returns: whether they overlap
Since: 0.2
LineIntersection
func cpplink LineIntersection(const A1: Vector2; const A2: Vector2; const B1: Vector2; const B2: Vector2): LineHit
Where the segment A1 - A2 meets the segment B1 - B2 (ends included). A segment of no length is a point, which meets the other segment when it lies on it.
Parameters
A1: the first segment's startA2: the first segment's endB1: the second segment's startB2: the second segment's end
Returns: the kind of meeting and, for Point, where
Since: 0.2
RadiusOverlap
func cpplink RadiusOverlap(const ARadius1: float32; const ACenter1: Vector2; const ARadius2: float32; const ACenter2: Vector2; const AShrink: float32): bool
True when two circles, each radius scaled by AShrink (1 = as given, 0.8 = a fifth smaller, for a forgiving hit), overlap: their centres are closer than the scaled radii's sum.
Parameters
ARadius1: the first radiusACenter1: the first centreARadius2: the second radiusACenter2: the second centreAShrink: the scale both radii take
Returns: whether they overlap
Since: 0.2
ObbsOverlap
func cpplink ObbsOverlap(const A: Obb; const B: Obb): bool
True when two oriented boxes overlap or touch (the separating axis test over both boxes' sides, angles exact, in float64).
Parameters
A: one boxB: the other box
Returns: whether they overlap
Since: 0.2
ExtentOf
func cpplink ExtentOf(const ARect: Rect): Extent
The Extent of ARect: its smallest and largest X and Y (a negative size spans the other way).
Parameters
ARect: the rectangle
Returns: its extent
Since: 0.2
See also: Extent
CosineSimilarity
func cpplink CosineSimilarity(const AFirst: array of float32; const ASecond: array of float32): float64
How alike two vectors point: the cosine of the angle between them, 1 for the same direction, 0 at right angles, -1 for opposite ones; their lengths do not count. Two text embeddings (EmbedLlama) are alike as their texts' meanings are. A vector of zeros (or two empty ones) gives 0. The sums run in float64.
Parameters
AFirst: the first vectorASecond: the second vector, as long as AFirst
Returns: the cosine, -1 to 1
Raises: EXC_SOFTWARE (1) when the vectors differ in length
Since: 0.3
Example: LScore := CosineSimilarity(LEmbeddingA, LEmbeddingB);
func cpplink CosineSimilarity(const AFirst: array of float64; const ASecond: array of float64): float64
CosineSimilarity for float64 vectors.
Parameters
AFirst: the first vectorASecond: the second vector, as long as AFirst
Returns: the cosine, -1 to 1
Raises: EXC_SOFTWARE (1) when the vectors differ in length
Since: 0.3
System.Pack
release and backup zips from a TOML pack spec, for any Adam developer (what StdApp's AppPacker did, in Adam, with Unix modes).
Import it with import System.Pack;.
Types
PackEntry
type PackEntry = record
One file a pack puts in an archive (Packer.Discover lists them in the archive's order).
Members
SourcePath: string: The file's full path,/between foldersArchiveName: string: Its entry name in the archive: its path below its source's folder,/between folders, the source's prefix firstMethod: ZipEntryMethod:Storewhen astoreglob matches its name, elseDeflateUnixMode: uint32: The permission bits the first matchingunix_modeglob gives it, 0 when none matches
PackEntries
type PackEntries = array of PackEntry
The files of one archive, in its order
PackProgress
type PackProgress = ref func(const AArchive: string; const AEntry: string; const AIndex: int64;
Called by Packer.Build / BuildArchive before each entry is written: AArchive the archive's full path, AEntry the entry's name, AIndex its place (0-based) among ACount. A closure: a func literal carries the caller's own state (a plain func named as a value fits too)
Packer
type Packer = object
Writes the zips a TOML pack spec describes (see the unit's description for the rules): LoadSpec, then Build (every archive) or Discover / BuildArchive one at a time. Each archive is written, tested whole, then given its .sha256 (checksum = true) and .minisig (a [sign] table) when its spec asks. A spec:
name = "Adam"
version = "0.1.0"
[sign]
seckey = 'C:\keys\release.key'
trusted_comment = "{name} {version} {file}"
[[archive]]
output = "distro/{name}-{version}-x86_64-linux.zip"
root = "repo"
include = ["bin/res/**", "bin/adam", "README.md"]
exclude = ["bin/output/**", "**/*.bak"]
store = ["**/*.png", "**/*.ogg"]
checksum = true
unix_mode = { "bin/adam" = 0o755 }
Members
init(): A packer with no spec loaded (LoadSpec reads one).method LoadSpec(const APath: string): bool: Reads and checks a pack spec: every key known, every value of its kind, every glob and prefix a relative path; the outputs, roots, source paths and the signing key made full against the spec file's folder,{name}/{version}put in. Nothing is written. Parameters:APaththe spec file (.toml). Returns: false (the reason inErrorText, at the spec's line and column) when it cannot be read or is no valid spec; no spec is held thenconst method ArchiveCount(): int64: The number of archives the loaded spec writes. Returns: the archive count (0 when no spec is loaded)const method ArchiveOutput(const AIndex: int64): string: The full path of an archive the loaded spec writes. Parameters:AIndexthe archive (0-based). Returns: its output path ("" when there is no such archive)const method SpecName(): string: The spec'sname. Returns: the name ("" when the spec has none)const method SpecVersion(): string: The spec'sversion. Returns: the version ("" when the spec has none)method Discover(const AIndex: int64; var AEntries: PackEntries): bool: The files archiveAIndextakes, in its order (byte order of the entry names), each with its method and Unix mode; nothing is written. Parameters:AIndexthe archive (0-based);AEntriesthe files (empty on a failure). Returns: false (the reason inErrorText) when no spec is loaded, there is no such archive, a source folder is missing or cannot be listed, no file matches, or the signing key would be packedmethod BuildArchive(const AIndex: int64; const AProgress: PackProgress): bool: Writes archiveAIndex: its files found (Discover), its folder made, an old.sha256/.minisigbeside it removed, every entry written (an existing archive replaced), the archive tested whole (ZipTest: every entry decoded and its CRC checked, the names as written), then its.sha256when the spec asks and its.minisigwhen the spec has a[sign]table. Parameters:AIndexthe archive (0-based);AProgresscalled before each entry (PackProgress, a closure), nil for none. Returns: false (the reason inErrorText) at the first step that failsmethod Build(const AProgress: PackProgress): bool: Writes every archive of the loaded spec in its order (BuildArchivefor each). Parameters:AProgresscalled before each entry (PackProgress, a closure), nil for none. Returns: false (the reason inErrorText) at the first archive that failsconst method EntryCount(const AIndex: int64): int64: The entries the last good build of an archive wrote. Parameters:AIndexthe archive (0-based). Returns: the entry count (0 before a good build, or for no such archive)const method ErrorText(): string: Why the last call failed. Returns: a spec error asfile(line,col): message, a build error naming the step and the path; "" after a success
Example: if not LPacker.LoadSpec("distro.toml") or not LPacker.Build(nil) then println(LPacker.ErrorText()); end;
System.Process
running other programs, the same on every target: import System.Process; and no OS is named (StdApp.Utils' process set).
Import it with import System.Process;.
Types
ProcessOutput
type ProcessOutput = interface
Where a captured run's output goes: each line (ProcessCapture.Pipes) or chunk (ProcessCapture.Terminal), in order, as it comes.
Members
method Output(const AText: string): One line (its line end left out) or one chunk of the program's output. Parameters:ATextthe line or chunk, UTF-8 (a chunk holds whole characters only).
Example: RunPE(LExe, LArgs, LDir, LCode, LSink, ProcessCapture.Pipes, nil);
ProcessTerminal
type ProcessTerminal = interface
A running terminal run's console, handed to its ProcessHost at Start.
Members
method WriteKeys(const AText: string): bool: Types text into the program, as keys pressed. Parameters:ATextthe keys, UTF-8. Returns: false when the program is gonemethod Resize(const ACols: int32; const ARows: int32): bool: Gives the terminal a new size; each side is held to 1 .. 32767. Parameters:AColsthe columns;ARowsthe lines. Returns: false when the size is refused
ProcessHost
type ProcessHost = interface
The other end of a captured run: its standard input and, for a terminal run, its size and the keys typed into it. No host (nil) means no input and the size of this program's console (else 120 x 30).
Members
method InitialSize(var ACols: int32; var ARows: int32): bool: The size a terminal run starts with. Parameters:AColsreceives the columns;ARowsreceives the lines. Returns: false to take this program's console sizemethod StdInput(): uint64: A handle the program reads as its standard input (its end of input, asprog < file), read before the start. Returns: the handle; 0 = none (no input, or for a terminal run the keys typed through Start)method Start(const ATerminal: ref ProcessTerminal): bool: A terminal run is about to start: keys and sizes go to ATerminal from now until Stop. Parameters:ATerminalthe run's console. Returns: false when the host cannot serve: the program is then not startedmethod Stop(): The program ended (or never started after Start): no more keys or sizes.
ProcessCapture
type ProcessCapture = choices(
How a captured run (RunPE's / RunELF's capture forms) reads its program.
Members
ProcessCapture.Pipes: stdout and stderr through one pipe, handed over line by line in the order written.ProcessCapture.Terminal: A pseudo console, handed over as chunks of terminal text (VT sequences included).
Routines
RunProcess
func cpplink RunProcess(const AExe: string; const AArgs: StringArray; const AWorkDir: string; var AOutput: string; var AExitCode: uint32): bool
Runs a program and captures its output whole.
Parameters
AExe: the programAArgs: its argumentsAWorkDir: the folder it runs inAOutput: receives everything it wroteAExitCode: receives its exit code
Returns: false when it cannot start
Example: if RunProcess("git", ["--version"], ".", LText, LCode) then println("{}", LText); end;
RunAttached
func cpplink RunAttached(const AExe: string; const AArgs: StringArray; const AWorkDir: string; var AExitCode: uint32): bool
Runs a program on this program's own console (stdin, stdout, stderr) and waits for it. What this program wrote is flushed first, so a shared stdout keeps the order written.
Parameters
AExe: the programAArgs: its argumentsAWorkDir: the folder it runs inAExitCode: receives its exit code
Returns: false when it cannot start
RunPE
func cpplink RunPE(const AExe: string; const AArgs: StringArray; const AWorkDir: string; const AWait: bool; var AExitCode: uint32): bool
Starts a Windows program (PE) shown, named in full (no PATH search), inheriting no handle of this program; waits for it or leaves it running (it may outlive this program). On a target that runs no PE (x86_64-linux-gnu) nothing starts.
Parameters
AExe: the program, its full pathAArgs: its argumentsAWorkDir: the folder it runs inAWait: true to wait for it to endAExitCode: receives its exit code when waited for, else 0
Returns: false when it cannot start or its exit code cannot be read, and on a target that runs no PE
func cpplink RunPE(const AExe: string; const AArgs: StringArray; const AWorkDir: string; var AExitCode: uint32; const AOutput: ref ProcessOutput; const ACapture: ProcessCapture; const AHost: ref ProcessHost): bool
Runs a Windows program (PE) with its output captured and handed to AOutput as it comes, through pipes or a pseudo console (ProcessCapture). On a target that runs no PE (x86_64-linux-gnu) nothing starts and the host is never asked.
Parameters
AExe: the program, its full pathAArgs: its argumentsAWorkDir: the folder it runs inAExitCode: receives its exit code (0 when it never ran)AOutput: gets the output, line by line or chunk by chunkACapture: pipes or a terminalAHost: the run's standard input, size and keys; nil for none
Returns: false when it cannot start or its exit code cannot be read, and on a target that runs no PE
RunELF
func cpplink RunELF(const AELF: string; const AArgs: StringArray; const AWorkDir: string; var AExitCode: uint32; const AOutput: ref ProcessOutput; const ACapture: ProcessCapture; const AHost: ref ProcessHost): bool
Runs a Linux ELF program with its output captured, as RunPE's capture form runs one: made executable first, on x86_64-windows-gnu through WSL (pipes join its stderr to its stdout inside Linux, so the order written is kept), on x86_64-linux-gnu natively.
Parameters
AELF: the ELF fileAArgs: its argumentsAWorkDir: the folder it runs inAExitCode: receives its exit code (0 when it never ran)AOutput: gets the output, line by line or chunk by chunkACapture: pipes or a terminalAHost: the run's standard input, size and keys; nil for none
Returns: false when it cannot start there (no WSL, the execute bits cannot be set, a path WSL cannot name) or its exit code cannot be read
Example: RunELF("game", [], ".", LCode, LSink, ProcessCapture.Pipes, nil);
func cpplink RunELF(const AELF: string; const AArgs: StringArray; const AWorkDir: string; var AExitCode: uint32): bool
Runs a Linux ELF program on this program's own console, as RunAttached runs one (what this program wrote is flushed first; its stderr stays its own): made executable first, on x86_64-windows-gnu through WSL, on x86_64-linux-gnu natively.
Parameters
AELF: the ELF fileAArgs: its argumentsAWorkDir: the folder it runs inAExitCode: receives its exit code (0 when it never ran)
Returns: false when it cannot start there (as the capture form's)
ELFCommand
func cpplink ELFCommand(const AELF: string; const AArgs: StringArray; const AWorkDir: string; const AJoinErrors: bool; var AExe: string; var AArgsOut: StringArray): bool
The program and arguments that start a Linux ELF program on this host, for a caller that launches it itself (a debug adapter's own run): on x86_64-windows-gnu WSL's launcher with the ELF as its argument, on x86_64-linux-gnu the ELF itself. The ELF is made executable first.
Parameters
AELF: the ELF fileAArgs: its argumentsAWorkDir: the folder it runs inAJoinErrors: true to join its stderr to its stdout (a pipe read as one stream)AExe: receives the program to startAArgsOut: receives that program's arguments
Returns: false when it cannot be started there (as RunELF's)
ELFPath
func cpplink ELFPath(const APath: string): string
The path a Linux ELF program started on this host (RunELF, ELFCommand) sees for one of this program's files, for a path handed to it as an argument.
Parameters
APath: the path, as this program names it
Returns: on x86_64-windows-gnu WSL's name of its resolved drive path (C:\x is /mnt/c/x; "" for one WSL cannot name, such as a share); on x86_64-linux-gnu the path resolved
Example: RunELF(LGame, [ELFPath("level1.map")], ".", LCode);
CanRunELF
func cpplink CanRunELF(): bool
Whether this host can run a Linux ELF program (RunELF).
Returns: on x86_64-windows-gnu true when WSL is there with a distribution that starts (asked once, the answer kept); on x86_64-linux-gnu always true
OpenURL
func cpplink OpenURL(const AURL: string): bool
Opens AURL with the user's own handler for its scheme (a browser for https:, the mail program for mailto: ..), not waiting for it: x86_64-windows-gnu through the shell's open verb, x86_64-linux-gnu through xdg-open found on PATH.
Parameters
AURL: the URL, its scheme first (https://adamlang.org); a text with no scheme, such as a bare host or a file path, is refused, so no program is ever run by its path
Returns: true when the system took it
Example: OpenURL("https://adamlang.org");
System.Process.Linux64
System.Process's platform unit for x86_64-linux-gnu, over System.Linux (glibc's posix_spawn, pipes, pseudo terminals, waitpid); paths resolved by System.IO's ResolvePath, as System.Process.Win64's by WinResolvePath.
Import it with import System.Process.Linux64;.
Types
ProcessPlatformRun
type ProcessPlatformRun = object
One captured run. Its descriptors are closed by Close or at its end
Members
init(): A run with nothing open yet (Prepare makes it).method Prepare(const ATerminal: bool; const ACols: int32; const ARows: int32; const AHasHost: bool; const AStdin: uint64): bool: The output channel and standard input made. ATerminal: a pseudo terminal of ACols x ARows (0 x 0: this process's terminal's size, else 120 x 30); else pipes. Standard input: AStdin (a host's descriptor, copied: the host keeps its own) when not 0; else /dev/null, except a terminal run with a host (AHasHost): the terminal (the keys the host types). False when the system refuses (nothing left open) Parameters:ATerminaltrue for a terminal run, false for pipes;AColsthe terminal's columns (0 with ARows 0: this process's size);ARowsthe terminal's lines;AHasHosttrue when a host types the keys;AStdinthe host's standard input, or 0. Returns: false when the system refusesmethod Launch(const AExe: string; const AArgs: StringArray; const AWorkDir: string): bool: AExe (named in full, no PATH search) started with AArgs in AWorkDir ("" = this process's folder) on what Prepare made. False when it does not start Parameters:AExethe program, its full path;AArgsits arguments;AWorkDirthe folder it runs in; "" for this process's. Returns: false when it does not startmethod Next(var ABytes: string): bool: The program's output appended to ABytes as it comes (pipes: one read, waiting for it; terminal: what came within one wait, maybe nothing). False once all of it was handed over Parameters:ABytesgets the output appended. Returns: false once all of it was handed overmethod Exited(): bool: A terminal run's program has ended (its last output may still come from Next) Returns: true once the program has endedmethod WriteKeys(const AText: string): bool: AText typed into a terminal run's program (every byte written). False for a pipes run or when it is gone Parameters:ATextthe keys, UTF-8. Returns: false for a pipes run or when it is gonemethod Resize(const ACols: int32; const ARows: int32): bool: A terminal run's new size (each side held to 1..32767; the program gets SIGWINCH). False for a pipes run or when refused Parameters:AColsthe columns;ARowsthe lines. Returns: false for a pipes run or when refusedmethod ExitCode(var ACode: uint32): bool: Waits for the program and takes its exit code into ACode. False when it never started or its status cannot be read Parameters:ACodereceives the exit code. Returns: false when it never started or its exit code cannot be readmethod Close(): Every descriptor closed; it may be prepared again. A program still running is left running (as on win64): it is reaped here when it has already ended, else by the system once this program endsdone: Closes whatever the run still holds open (as Close).
Routines
ProcessPlatformRunProcess
func cpplink ProcessPlatformRunProcess(const AExe: string; const AArgs: StringArray; const AWorkDir: string; var AOutput: string; var AExitCode: uint32): bool
System.Process's RunProcess: a pipes run (stdin /dev/null, stdout and stderr in the order written), its whole output into AOutput (what was read, if anything, when it fails later)
Parameters
AExe: asRunProcesstakes itAArgs: asRunProcesstakes itAWorkDir: asRunProcesstakes itAOutput: asRunProcesstakes itAExitCode: asRunProcesstakes it
Returns: as RunProcess returns it
ProcessPlatformRunAttached
func cpplink ProcessPlatformRunAttached(const AExe: string; const AArgs: StringArray; const AWorkDir: string; var AExitCode: uint32): bool
System.Process's RunAttached: the program on this process's own stdin, stdout and stderr, waited for
Parameters
AExe: asRunAttachedtakes itAArgs: asRunAttachedtakes itAWorkDir: asRunAttachedtakes itAExitCode: asRunAttachedtakes it
Returns: as RunAttached returns it
ProcessPlatformRunPE
func cpplink ProcessPlatformRunPE(const AExe: string; const AArgs: StringArray; const AWorkDir: string; const AWait: bool; var AExitCode: uint32): bool
System.Process's RunPE (the launch form): a PE runs nowhere here, so false (AExitCode 0)
Parameters
AExe: asRunPEtakes itAArgs: asRunPEtakes itAWorkDir: asRunPEtakes itAWait: asRunPEtakes itAExitCode: asRunPEtakes it
Returns: as RunPE returns it
ProcessPlatformCanRunPE
func cpplink ProcessPlatformCanRunPE(): bool
False: no PE runs here (System.Process' RunPE forms)
Returns: false, always
ProcessPlatformDecodeLine
func cpplink ProcessPlatformDecodeLine(const ABytes: string): string
One output line's bytes as text: as they are when they are UTF-8, else each malformed byte read as U+FFFD and the rest kept
Parameters
ABytes: the line's bytes, its line end left out
Returns: the line as UTF-8 text
ProcessPlatformELFCommand
func cpplink ProcessPlatformELFCommand(const AELF: string; const AArgs: StringArray; const AWorkDir: string; const APipes: bool; var AExe: string; var AArgsOut: StringArray): bool
RunELF's launch on linux64 : AExe is AELF resolved, AArgsOut AArgs (APipes changes nothing: stdout and stderr already share one pipe here). False when AELF is no file or its execute bits cannot be set
Parameters
AELF: asELFCommandtakes itAArgs: asELFCommandtakes itAWorkDir: asELFCommandtakes itAPipes: asELFCommand's AJoinErrors (changes nothing here)AExe: asELFCommandtakes itAArgsOut: asELFCommandtakes it
Returns: as ELFCommand returns it
ProcessPlatformELFPath
func cpplink ProcessPlatformELFPath(const APath: string): string
System.Process's ELFPath on linux64: APath resolved (an ELF shares this file system)
Parameters
APath: asELFPathtakes it
Returns: as ELFPath returns it
ProcessPlatformCanRunELF
func cpplink ProcessPlatformCanRunELF(): bool
System.Process's CanRunELF on linux64: an ELF runs natively
Returns: as CanRunELF returns it
ProcessPlatformOpenURL
func cpplink ProcessPlatformOpenURL(const AURL: string): bool
System.Process's OpenURL: xdg-open (freedesktop's opener) found on PATH, given the URL and waited for (it hands the URL to the handler and ends); false when there is none on PATH or it fails
Parameters
AURL: asOpenURLtakes it
Returns: as OpenURL returns it
System.Process.Win64
System.Process's platform unit for x86_64-windows-gnu, over System.Windows.
Import it with import System.Process.Win64;.
Types
ProcessPlatformRun
type ProcessPlatformRun = object
One captured run. Its handles are closed by Close or at its end
Members
method Prepare(const ATerminal: bool; const ACols: int32; const ARows: int32; const AHasHost: bool; const AStdin: uint64): bool: The output channel and standard input made. ATerminal: a pseudo console of ACols x ARows (0 x 0: this process's console window's size, else 120 x 30); else pipes. Standard input: AStdin (a host's handle, copied inheritable: the host's own need not be) when not 0; else NUL, except a terminal run with a host (AHasHost): its pseudo console's (the keys the host types). False when Windows refuses (nothing left open) Parameters:ATerminaltrue for a terminal run, false for pipes;AColsthe terminal's columns (0 with ARows 0: this process's size);ARowsthe terminal's lines;AHasHosttrue when a host types the keys;AStdinthe host's standard input, or 0. Returns: false when the system refusesmethod Launch(const AExe: string; const AArgs: StringArray; const AWorkDir: string): bool: AExe (named in full, no PATH search) started with AArgs in AWorkDir ("" = this process's folder) on what Prepare made, hidden for a pipes run. False when it does not start Parameters:AExethe program, its full path;AArgsits arguments;AWorkDirthe folder it runs in; "" for this process's. Returns: false when it does not startmethod Next(var ABytes: string): bool: The program's output appended to ABytes as it comes (pipes: one read, waiting for it; terminal: what came within one wait, maybe nothing). False once all of it was handed over Parameters:ABytesgets the output appended. Returns: false once all of it was handed overmethod Exited(): bool: A terminal run's program has ended (its last output may still come from Next) Returns: true once the program has endedmethod WriteKeys(const AText: string): bool: AText typed into a terminal run's program. False for a pipes run or when it is gone Parameters:ATextthe keys, UTF-8. Returns: false for a pipes run or when it is gonemethod Resize(const ACols: int32; const ARows: int32): bool: A terminal run's new size. False for a pipes run or when refused Parameters:AColsthe columns;ARowsthe lines. Returns: false for a pipes run or when refusedmethod ExitCode(var ACode: uint32): bool: Waits for the program and takes its exit code into ACode. False when it never started or its exit code cannot be read Parameters:ACodereceives the exit code. Returns: false when it never started or its exit code cannot be readmethod Close(): Every handle closed (a pseudo console still open closed with its last output dropped); it may be prepared againdone: Closes whatever the run still holds open (as Close).
Routines
ProcessPlatformRunProcess
func cpplink ProcessPlatformRunProcess(const AExe: string; const AArgs: StringArray; const AWorkDir: string; var AOutput: string; var AExitCode: uint32): bool
System.Process's RunProcess: System.Windows' Win* routine of the same job
Parameters
AExe: asRunProcesstakes itAArgs: asRunProcesstakes itAWorkDir: asRunProcesstakes itAOutput: asRunProcesstakes itAExitCode: asRunProcesstakes it
Returns: as RunProcess returns it
ProcessPlatformRunAttached
func cpplink ProcessPlatformRunAttached(const AExe: string; const AArgs: StringArray; const AWorkDir: string; var AExitCode: uint32): bool
System.Process's RunAttached: System.Windows' Win* routine of the same job
Parameters
AExe: asRunAttachedtakes itAArgs: asRunAttachedtakes itAWorkDir: asRunAttachedtakes itAExitCode: asRunAttachedtakes it
Returns: as RunAttached returns it
ProcessPlatformRunPE
func cpplink ProcessPlatformRunPE(const AExe: string; const AArgs: StringArray; const AWorkDir: string; const AWait: bool; var AExitCode: uint32): bool
System.Process's RunPE (the launch form): System.Windows' Win* routine of the same job, shown normally
Parameters
AExe: asRunPEtakes itAArgs: asRunPEtakes itAWorkDir: asRunPEtakes itAWait: asRunPEtakes itAExitCode: asRunPEtakes it
Returns: as RunPE returns it
ProcessPlatformCanRunPE
func cpplink ProcessPlatformCanRunPE(): bool
True: a PE runs here (System.Process' RunPE forms)
Returns: true, always
ProcessPlatformDecodeLine
func cpplink ProcessPlatformDecodeLine(const ABytes: string): string
One output line's bytes as text: as they are when they are UTF-8, else read as the OEM code page (a console tool that does not write UTF-8 writes that)
Parameters
ABytes: the line's bytes, its line end left out
Returns: the line as UTF-8 text
ProcessPlatformELFPath
func cpplink ProcessPlatformELFPath(const APath: string): string
System.Process's ELFPath on win64: APath's resolved drive path, plain ('\'), as WSL names it; "" for a share (a long UNC spelling) or a path with no drive
Parameters
APath: asELFPathtakes it
Returns: as ELFPath returns it
ProcessPlatformELFCommand
func cpplink ProcessPlatformELFCommand(const AELF: string; const AArgs: StringArray; const AWorkDir: string; const APipes: bool; var AExe: string; var AArgsOut: StringArray): bool
RunELF's launch on win64 : AExe and AArgsOut start AELF with AArgs through WSL (APipes: stderr joined to stdout in Linux). False when there is no WSL, AELF is no file or has no drive path WSL can name (a share), or chmod +x fails
Parameters
AELF: asELFCommandtakes itAArgs: asELFCommandtakes itAWorkDir: asELFCommandtakes itAPipes: asELFCommand's AJoinErrorsAExe: asELFCommandtakes itAArgsOut: asELFCommandtakes it
Returns: as ELFCommand returns it
ProcessPlatformCanRunELF
func cpplink ProcessPlatformCanRunELF(): bool
System.Process's CanRunELF on win64 : WSL's launcher runs true with exit 0; asked once, the answer kept
Returns: as CanRunELF returns it
ProcessPlatformOpenURL
func cpplink ProcessPlatformOpenURL(const AURL: string): bool
System.Process's OpenURL: System.Windows' Win* routine of the same job (the scheme checked)
Parameters
AURL: asOpenURLtakes it
Returns: as OpenURL returns it
System.Raven.Ext
Raven (https://github.com/oscar-soirey/Raven, v0.3.0, Apache-2.0), a GUI library in C11 (widgets, layout panels, themes, XML-described windows, text input, menus, dialogs), as Adam objects over its C API. import System.Raven.C, System.Raven.Ext; builds user interfaces with it; the .C unit stays usable beside the objects.
Import it with import System.Raven.Ext;.
Types
UIBackend
type UIBackend = choices(
The renderer Raven draws with (R_BACKEND_*): Null renders nothing (headless runs, tests).
Members
UIBackend.Default: The renderer of the platform: WebGL in browser builds, Metal on macOS and iOS when it is compiled, Vulkan otherwise. C: R_BACKEND_DEFAULTUIBackend.Vulkan: Built-in Vulkan renderer. C: R_BACKEND_VULKANUIBackend.Null: Renders nothing. Used for headless runs and unit tests. C: R_BACKEND_NULLUIBackend.Custom: Backend supplied with Rbackend_register (see raven_backend.h). C: R_BACKEND_CUSTOMUIBackend.WebGL: Browser renderer (Emscripten, WebGL 2). C: R_BACKEND_WEBGLUIBackend.Metal: Built-in Metal renderer (macOS, iOS). C: R_BACKEND_METAL
UIErrorCode
type UIErrorCode = choices(
An error Raven reports (R_NO_ERROR, R_ERROR_*).
Members
UIErrorCode.None: No error. C: R_NO_ERRORUIErrorCode.InvalidId: The invalid id error. C: R_ERROR_INVALID_IDUIErrorCode.InvalidEnum: The invalid enum error. C: R_ERROR_INVALID_ENUMUIErrorCode.InvalidValue: The invalid value error. C: R_ERROR_INVALID_VALUEUIErrorCode.InvalidOperation: The invalid operation error. C: R_ERROR_INVALID_OPERATIONUIErrorCode.Backend: The backend error. C: R_ERROR_BACKENDUIErrorCode.Platform: The platform error. C: R_ERROR_PLATFORMUIErrorCode.OutOfMemory: The out of memory error. C: R_ERROR_OUT_OF_MEMORYUIErrorCode.InvalidFileFormat: The invalid file format error. C: R_ERROR_INVALID_FILE_FORMATUIErrorCode.FileNotFound: The file not found error. C: R_ERROR_FILE_NOT_FOUNDUIErrorCode.XML: The XML error. C: R_ERROR_XMLUIErrorCode.WrongThread: The wrong thread error. C: R_ERROR_WRONG_THREADUIErrorCode.Script: A diagnostic of Raven Script (raven_script.h): the text is the whole message, "error[RS102]: ...". C: R_ERROR_SCRIPT
UISeverity
type UISeverity = choices(
How bad a reported error is (R_SEVERITY_*).
Members
UISeverity.WeakWarning: Weak warning. C: R_SEVERITY_WEAK_WARNINGUISeverity.Warning: Warning. C: R_SEVERITY_WARNINGUISeverity.Error: Error. C: R_SEVERITY_ERRORUISeverity.Fatal: Fatal. C: R_SEVERITY_FATAL
UIAppEvent
type UIAppEvent = choices(
A life-cycle event of the application (R_APP_*).
Members
UIAppEvent.WillPause: The application is about to leave the front (home, app switcher, a call). Save the state now. C: R_APP_WILL_PAUSEUIAppEvent.DidPause: The application is in the background: Raven has stopped drawing, and waited until the GPU was idle. C: R_APP_DID_PAUSEUIAppEvent.WillResume: The application is coming back to the front: Raven draws again. C: R_APP_WILL_RESUMEUIAppEvent.DidResume: The application is in front and takes input again. C: R_APP_DID_RESUMEUIAppEvent.LowMemory: The system is low on memory: free what can be made again. Raven then drops its own caches and trims its heap. C: R_APP_LOW_MEMORYUIAppEvent.WillTerminate: The application is about to end (Android: the activity is finishing; its window is closed right after). C: R_APP_WILL_TERMINATE
UIWindowFlag
type UIWindowFlag = choices(
A window's creation flag (R_WINDOW_*; none is Raven's R_WINDOW_DEFAULT). A member's value is its bit number in Raven's flags (a set of them casts to them).
Members
UIWindowFlag.NoResize: The user cannot resize it. C: R_WINDOW_NO_RESIZEUIWindowFlag.Hidden: Made hidden. C: R_WINDOW_HIDDENUIWindowFlag.Borderless: No system frame or title bar. C: R_WINDOW_BORDERLESSUIWindowFlag.Maximized: Made maximized. C: R_WINDOW_MAXIMIZEDUIWindowFlag.CustomHeader: No title bar from the OS: the content covers the whole window and draws its own header, with a R_WIDGET_HEADER_BAR (raven_shell.h) or with any widget given to Rwidget_set_window_drag. The window is still moved, resized, snapped and maximized by the OS, as it does for its own title bars. C: R_WINDOW_CUSTOM_HEADERUIWindowFlag.Transparent: The window can be seen through: where the application draws nothing opaque, what is behind the window on the screen shows (the desktop, the other applications), not a color of the application. Glass then looks at the screen itself. What the OS does to what shows through is chosen with Rwindow_set_backdrop. See RBackdrop for what each window system can do. C: R_WINDOW_TRANSPARENTUIWindowFlag.SplashScreen: A splash screen: shown while the application starts. No frame (it implies R_WINDOW_BORDERLESS and R_WINDOW_NO_RESIZE, and cancels R_WINDOW_MAXIMIZED and R_WINDOW_CUSTOM_HEADER), centered on the screen before it is first shown and again when its size changes, above the other windows, out of the taskbar and of Alt+Tab (Windows), of the Window menu and of Cmd+` (macOS), typed _NET_WM_WINDOW_TYPE_SPLASH on X11. Wayland gives it no place of its own: it is a window without frame there. The application destroys it once its main window is ready (creating the main window first keeps Ris_running true). C: R_WINDOW_SPLASH_SCREEN
UIWindowFlags
type UIWindowFlags = set of UIWindowFlag
A set of UIWindowFlag (Raven's RWindowFlags).
UIWindowSystem
type UIWindowSystem = choices(
The OS windowing system a window runs on (R_WINDOW_SYSTEM_*).
Members
UIWindowSystem.None: None. C: R_WINDOW_SYSTEM_NONEUIWindowSystem.Win32: Win32. C: R_WINDOW_SYSTEM_WIN32UIWindowSystem.X11: X11. C: R_WINDOW_SYSTEM_X11UIWindowSystem.Wayland: Wayland. C: R_WINDOW_SYSTEM_WAYLANDUIWindowSystem.Cocoa: Cocoa (macOS). C: R_WINDOW_SYSTEM_COCOAUIWindowSystem.Emscripten: Emscripten. C: R_WINDOW_SYSTEM_EMSCRIPTENUIWindowSystem.Android: Android. C: R_WINDOW_SYSTEM_ANDROIDUIWindowSystem.UIKit: UIKit (iOS). C: R_WINDOW_SYSTEM_UIKIT
UIPipCorner
type UIPipCorner = choices(
The screen corner a picture-in-picture window sits in (R_PIP_*).
Members
UIPipCorner.BottomRight: The bottom right corner. C: R_PIP_BOTTOM_RIGHTUIPipCorner.BottomLeft: The bottom left corner. C: R_PIP_BOTTOM_LEFTUIPipCorner.TopRight: The top right corner. C: R_PIP_TOP_RIGHTUIPipCorner.TopLeft: The top left corner. C: R_PIP_TOP_LEFT
UIBackdrop
type UIBackdrop = choices(
What shows behind a window (R_BACKDROP_*).
Members
UIBackdrop.None: Opaque: the window color, or the wallpaper of the theme. C: R_BACKDROP_NONEUIBackdrop.Transparent: The screen behind the window, as it is. C: R_BACKDROP_TRANSPARENTUIBackdrop.Blur: The screen behind the window, blurred by the OS. C: R_BACKDROP_BLURUIBackdrop.Acrylic: Blurred, tinted and grained by the OS (the acrylic of Windows). C: R_BACKDROP_ACRYLICUIBackdrop.Mica: A soft tint taken from the wallpaper of the desktop (the mica of Windows 11). C: R_BACKDROP_MICA
UIInputType
type UIInputType = choices(
The kind of text a text input takes, for on-screen keyboards (R_TEXT_INPUT_TYPE_*).
Members
UIInputType.Text: Plain text. C: R_TEXT_INPUT_TYPE_TEXTUIInputType.Email: An email address. C: R_TEXT_INPUT_TYPE_EMAILUIInputType.Number: Digits. C: R_TEXT_INPUT_TYPE_NUMBERUIInputType.Decimal: Digits and a decimal separator. C: R_TEXT_INPUT_TYPE_DECIMALUIInputType.Phone: A phone number. C: R_TEXT_INPUT_TYPE_PHONEUIInputType.URL: A URL. C: R_TEXT_INPUT_TYPE_URLUIInputType.Search: A search. C: R_TEXT_INPUT_TYPE_SEARCH
UITextAlign
type UITextAlign = choices(
How text lines up in its box (R_TEXT_ALIGN_*).
Members
UITextAlign.Left: Lined up on the left. C: R_TEXT_ALIGN_LEFTUITextAlign.Center: Centred. C: R_TEXT_ALIGN_CENTERUITextAlign.Right: Lined up on the right. C: R_TEXT_ALIGN_RIGHT
UIReturnKey
type UIReturnKey = choices(
The label of an on-screen keyboard's return key (R_RETURN_KEY_*).
Members
UIReturnKey.Default: The system's own label. C: R_RETURN_KEY_DEFAULTUIReturnKey.Done: The return key reads "Done". C: R_RETURN_KEY_DONEUIReturnKey.Go: The return key reads "Go". C: R_RETURN_KEY_GOUIReturnKey.Next: The return key reads "Next". C: R_RETURN_KEY_NEXTUIReturnKey.Search: The return key reads "Search". C: R_RETURN_KEY_SEARCHUIReturnKey.Send: The return key reads "Send". C: R_RETURN_KEY_SEND
UIEdge
type UIEdge = choices(
A window edge or corner, for resizing (R_EDGE_*).
Members
UIEdge.Left: The left edge. C: R_EDGE_LEFTUIEdge.Right: The right edge. C: R_EDGE_RIGHTUIEdge.Top: The top edge. C: R_EDGE_TOPUIEdge.Bottom: The bottom edge. C: R_EDGE_BOTTOMUIEdge.TopLeft: The top-left corner. C: R_EDGE_TOP_LEFTUIEdge.TopRight: The top-right corner. C: R_EDGE_TOP_RIGHTUIEdge.BottomLeft: The bottom-left corner. C: R_EDGE_BOTTOM_LEFTUIEdge.BottomRight: The bottom-right corner. C: R_EDGE_BOTTOM_RIGHT
UIPointerButton
type UIPointerButton = choices(
A mouse button (R_MOUSE_*).
Members
UIPointerButton.Left: The left mouse button. C: R_MOUSE_LEFTUIPointerButton.Right: The right mouse button. C: R_MOUSE_RIGHTUIPointerButton.Middle: The middle mouse button. C: R_MOUSE_MIDDLEUIPointerButton.X1: The X1 mouse button. C: R_MOUSE_X1UIPointerButton.X2: The X2 mouse button. C: R_MOUSE_X2
UIModifier
type UIModifier = choices(
A modifier key held with an input (R_MOD_*). A member's value is its bit number in Raven's flags (a set of them casts to them).
Members
UIModifier.Shift: The Shift key. C: R_MOD_SHIFTUIModifier.Ctrl: The Ctrl key. C: R_MOD_CTRLUIModifier.Alt: The Alt key. C: R_MOD_ALTUIModifier.Super: The Super key. C: R_MOD_SUPER
UIModifiers
type UIModifiers = set of UIModifier
A set of UIModifier (Raven's RModifier).
UICursor
type UICursor = choices(
A mouse cursor shape (R_CURSOR_*).
Members
UICursor.Arrow: The arrow cursor. C: R_CURSOR_ARROWUICursor.IBeam: The I-beam (text) cursor. C: R_CURSOR_IBEAMUICursor.Hand: The hand cursor. C: R_CURSOR_HANDUICursor.Crosshair: The crosshair cursor. C: R_CURSOR_CROSSHAIRUICursor.ResizeH: The left-right resize cursor. C: R_CURSOR_RESIZE_HUICursor.ResizeV: The up-down resize cursor. C: R_CURSOR_RESIZE_VUICursor.ResizeNWSE: The top-left to bottom-right resize cursor. C: R_CURSOR_RESIZE_NWSEUICursor.ResizeNESW: The top-right to bottom-left resize cursor. C: R_CURSOR_RESIZE_NESWUICursor.Move: The move cursor. C: R_CURSOR_MOVEUICursor.NotAllowed: The not allowed cursor. C: R_CURSOR_NOT_ALLOWEDUICursor.None: No pointer at all (a game that hides it). Windows; elsewhere the arrow. C: R_CURSOR_NONE
UIKey
type UIKey = choices(
A keyboard key (R_KEY_*; the digit keys Key0 .. Key9).
Members
UIKey.Unknown: The unknown key. C: R_KEY_UNKNOWNUIKey.Space: The space key. C: R_KEY_SPACEUIKey.Apostrophe: The apostrophe key. C: R_KEY_APOSTROPHEUIKey.Comma: The comma key. C: R_KEY_COMMAUIKey.Minus: The minus key. C: R_KEY_MINUSUIKey.Period: The period key. C: R_KEY_PERIODUIKey.Slash: The slash key. C: R_KEY_SLASHUIKey.Key0: The 0 key. C: R_KEY_0UIKey.Key1: The 1 key. C: R_KEY_1UIKey.Key2: The 2 key. C: R_KEY_2UIKey.Key3: The 3 key. C: R_KEY_3UIKey.Key4: The 4 key. C: R_KEY_4UIKey.Key5: The 5 key. C: R_KEY_5UIKey.Key6: The 6 key. C: R_KEY_6UIKey.Key7: The 7 key. C: R_KEY_7UIKey.Key8: The 8 key. C: R_KEY_8UIKey.Key9: The 9 key. C: R_KEY_9UIKey.Semicolon: The semicolon key. C: R_KEY_SEMICOLONUIKey.Equal: The equal key. C: R_KEY_EQUALUIKey.A: The A key. C: R_KEY_AUIKey.B: The B key. C: R_KEY_BUIKey.C: The C key. C: R_KEY_CUIKey.D: The D key. C: R_KEY_DUIKey.E: The E key. C: R_KEY_EUIKey.F: The F key. C: R_KEY_FUIKey.G: The G key. C: R_KEY_GUIKey.H: The H key. C: R_KEY_HUIKey.I: The I key. C: R_KEY_IUIKey.J: The J key. C: R_KEY_JUIKey.K: The K key. C: R_KEY_KUIKey.L: The L key. C: R_KEY_LUIKey.M: The M key. C: R_KEY_MUIKey.N: The N key. C: R_KEY_NUIKey.O: The O key. C: R_KEY_OUIKey.P: The P key. C: R_KEY_PUIKey.Q: The Q key. C: R_KEY_QUIKey.R: The R key. C: R_KEY_RUIKey.S: The S key. C: R_KEY_SUIKey.T: The T key. C: R_KEY_TUIKey.U: The U key. C: R_KEY_UUIKey.V: The V key. C: R_KEY_VUIKey.W: The W key. C: R_KEY_WUIKey.X: The X key. C: R_KEY_XUIKey.Y: The Y key. C: R_KEY_YUIKey.Z: The Z key. C: R_KEY_ZUIKey.LeftBracket: The left bracket key. C: R_KEY_LEFT_BRACKETUIKey.Backslash: The backslash key. C: R_KEY_BACKSLASHUIKey.RightBracket: The right bracket key. C: R_KEY_RIGHT_BRACKETUIKey.Grave: The grave key. C: R_KEY_GRAVEUIKey.Escape: The escape key. C: R_KEY_ESCAPEUIKey.Enter: The enter key. C: R_KEY_ENTERUIKey.Tab: The tab key. C: R_KEY_TABUIKey.Backspace: The backspace key. C: R_KEY_BACKSPACEUIKey.Insert: The insert key. C: R_KEY_INSERTUIKey.Delete: The delete key. C: R_KEY_DELETEUIKey.Right: The right key. C: R_KEY_RIGHTUIKey.Left: The left key. C: R_KEY_LEFTUIKey.Down: The down key. C: R_KEY_DOWNUIKey.Up: The up key. C: R_KEY_UPUIKey.PageUp: The page up key. C: R_KEY_PAGE_UPUIKey.PageDown: The page down key. C: R_KEY_PAGE_DOWNUIKey.Home: The home key. C: R_KEY_HOMEUIKey.End: The end key. C: R_KEY_ENDUIKey.CapsLock: The caps lock key. C: R_KEY_CAPS_LOCKUIKey.PrintScreen: The print screen key. C: R_KEY_PRINT_SCREENUIKey.Pause: The pause key. C: R_KEY_PAUSEUIKey.F1: The F1 key. C: R_KEY_F1UIKey.F2: The F2 key. C: R_KEY_F2UIKey.F3: The F3 key. C: R_KEY_F3UIKey.F4: The F4 key. C: R_KEY_F4UIKey.F5: The F5 key. C: R_KEY_F5UIKey.F6: The F6 key. C: R_KEY_F6UIKey.F7: The F7 key. C: R_KEY_F7UIKey.F8: The F8 key. C: R_KEY_F8UIKey.F9: The F9 key. C: R_KEY_F9UIKey.F10: The F10 key. C: R_KEY_F10UIKey.F11: The F11 key. C: R_KEY_F11UIKey.F12: The F12 key. C: R_KEY_F12UIKey.Kp0: The keypad 0 key. C: R_KEY_KP_0UIKey.Kp1: The keypad 1 key. C: R_KEY_KP_1UIKey.Kp2: The keypad 2 key. C: R_KEY_KP_2UIKey.Kp3: The keypad 3 key. C: R_KEY_KP_3UIKey.Kp4: The keypad 4 key. C: R_KEY_KP_4UIKey.Kp5: The keypad 5 key. C: R_KEY_KP_5UIKey.Kp6: The keypad 6 key. C: R_KEY_KP_6UIKey.Kp7: The keypad 7 key. C: R_KEY_KP_7UIKey.Kp8: The keypad 8 key. C: R_KEY_KP_8UIKey.Kp9: The keypad 9 key. C: R_KEY_KP_9UIKey.KpDecimal: The keypad decimal key. C: R_KEY_KP_DECIMALUIKey.KpDivide: The keypad divide key. C: R_KEY_KP_DIVIDEUIKey.KpMultiply: The keypad multiply key. C: R_KEY_KP_MULTIPLYUIKey.KpSubtract: The keypad subtract key. C: R_KEY_KP_SUBTRACTUIKey.KpAdd: The keypad add key. C: R_KEY_KP_ADDUIKey.KpEnter: The keypad enter key. C: R_KEY_KP_ENTERUIKey.LeftShift: The left shift key. C: R_KEY_LEFT_SHIFTUIKey.LeftCtrl: The left Ctrl key. C: R_KEY_LEFT_CTRLUIKey.LeftAlt: The left alt key. C: R_KEY_LEFT_ALTUIKey.LeftSuper: The left super key. C: R_KEY_LEFT_SUPERUIKey.RightShift: The right shift key. C: R_KEY_RIGHT_SHIFTUIKey.RightCtrl: The right Ctrl key. C: R_KEY_RIGHT_CTRLUIKey.RightAlt: The right alt key. C: R_KEY_RIGHT_ALTUIKey.RightSuper: The right super key. C: R_KEY_RIGHT_SUPERUIKey.Menu: The menu key. C: R_KEY_MENU
UIEventKind
type UIEventKind = choices(
The kind of a widget input event (R_EVENT_*).
Members
UIEventKind.None: No event. C: R_EVENT_NONEUIEventKind.MouseMove: A mouse move event. C: R_EVENT_MOUSE_MOVEUIEventKind.MouseDown: A mouse down event. C: R_EVENT_MOUSE_DOWNUIEventKind.MouseUp: A mouse up event. C: R_EVENT_MOUSE_UPUIEventKind.MouseWheel: A mouse wheel event. C: R_EVENT_MOUSE_WHEELUIEventKind.MouseEnter: A mouse enter event. C: R_EVENT_MOUSE_ENTERUIEventKind.MouseLeave: A mouse leave event. C: R_EVENT_MOUSE_LEAVEUIEventKind.KeyDown: A key down event. C: R_EVENT_KEY_DOWNUIEventKind.KeyUp: A key up event. C: R_EVENT_KEY_UPUIEventKind.Text: A character was typed.codepointholds the Unicode scalar value. C: R_EVENT_TEXTUIEventKind.FocusGained: A focus gained event. C: R_EVENT_FOCUS_GAINEDUIEventKind.FocusLost: A focus lost event. C: R_EVENT_FOCUS_LOST
UIDropPhase
type UIDropPhase = choices(
The stage of a drag and drop over a widget (R_DROP_*).
Members
UIDropPhase.Enter: The pointer came over the target. C: R_DROP_ENTERUIDropPhase.Move: It moves over the target. C: R_DROP_MOVEUIDropPhase.Leave: It left the target without dropping. C: R_DROP_LEAVEUIDropPhase.Dropped: The user dropped:pathsandtexthold what was dropped. C: R_DROP_DROPPED
UITouchMode
type UITouchMode = choices(
How a widget takes touch input (R_TOUCH_MODE_*).
Members
UITouchMode.Auto: The finger scrolls what scrolls under it, and is a mouse elsewhere (default). C: R_TOUCH_MODE_AUTOUITouchMode.Scroll: A finger moving on the widget always scrolls what contains it, even over a control that drags. C: R_TOUCH_MODE_SCROLLUITouchMode.Mouse: The finger is a mouse on the widget: pressing presses at once, moving drags, nothing scrolls. C: R_TOUCH_MODE_MOUSEUITouchMode.None: Fingers are ignored on the widget (only its touch callback sees them): a surface for the pen. C: R_TOUCH_MODE_NONE
UITouchPhase
type UITouchPhase = choices(
The stage of a touch (R_TOUCH_*).
Members
UITouchPhase.Down: A finger came down. C: R_TOUCH_DOWNUITouchPhase.Move: The touch moved. C: R_TOUCH_MOVEUITouchPhase.Up: The finger was lifted. C: R_TOUCH_UPUITouchPhase.Cancel: The system took the finger away (a gesture of its own, the window lost it): nothing must happen as for a lift. C: R_TOUCH_CANCEL
UIPenPhase
type UIPenPhase = choices(
The stage of a pen (stylus) input (R_PEN_*).
Members
UIPenPhase.Down: The tip touched the screen. C: R_PEN_DOWNUIPenPhase.Move: The pen moves while touching. C: R_PEN_MOVEUIPenPhase.Up: The tip left the screen. C: R_PEN_UPUIPenPhase.Hover: The pen moves near the screen without touching it. C: R_PEN_HOVERUIPenPhase.Leave: The pen went out of reach. C: R_PEN_LEAVE
UIPenButton
type UIPenButton = choices(
A pen's barrel button (R_PEN_BUTTON_*). A member's value is its bit number in Raven's flags (a set of them casts to them).
Members
UIPenButton.Barrel: The pen's barrel button. C: R_PEN_BUTTON_BARRELUIPenButton.Barrel2: The pen's second barrel button. C: R_PEN_BUTTON_BARREL2
UIPenButtons
type UIPenButtons = set of UIPenButton
A set of UIPenButton (Raven's RPenButton).
UIGesturePhase
type UIGesturePhase = choices(
The stage of a gesture (R_GESTURE_BEGIN ..).
Members
UIGesturePhase.Begin: A second finger came down (a touch screen), or the system recognized a gesture (a trackpad). C: R_GESTURE_BEGINUIGesturePhase.Update: The gesture went on. C: R_GESTURE_UPDATEUIGesturePhase.End: Fewer than two fingers remain, or the fingers left the trackpad (RGestureEvent::cancelled: the system took the gesture back). C: R_GESTURE_END
UIGestureKind
type UIGestureKind = choices(
The kind of a gesture (R_GESTURE_PINCH, R_GESTURE_SWIPE).
Members
UIGestureKind.Pinch: Two fingers that pinch, turn and move together: scale, rotation and pan. C: R_GESTURE_PINCHUIGestureKind.Swipe: Three or more fingers that move together on a trackpad: only the pan (scale stays 1). By default, a swipe across goes back or forward. C: R_GESTURE_SWIPE
UIGestureDevice
type UIGestureDevice = choices(
The device a gesture comes from (R_GESTURE_DEVICE_*).
Members
UIGestureDevice.Touchscreen: On the screen: the library recognized the gesture. C: R_GESTURE_DEVICE_TOUCHSCREENUIGestureDevice.Trackpad: On a trackpad: the system recognized the gesture; the fingers are not on the window (x, y is the pointer). C: R_GESTURE_DEVICE_TRACKPAD
UILook
type UILook = choices(
A built-in look: a theme and its materials together (R_LOOK_*).
Members
UILook.RavenDark: Raven, flat and dense, for tools. The look at start. C: R_LOOK_RAVEN_DARKUILook.RavenLight: The light variant ofRavenDark. C: R_LOOK_RAVEN_LIGHTUILook.RavenGlassDark: Raven in glass: controls are capsules of translucent glass that refract and blur what is behind them, catch the light on their rim and react to the pointer with short animations. Windows get a soft colored background unless they have their own (Rwindow_set_background, Rwindow_set_clear_color). C: R_LOOK_RAVEN_GLASS_DARKUILook.RavenGlassLight: The light variant ofRavenGlassDark. C: R_LOOK_RAVEN_GLASS_LIGHTUILook.RavenHighContrastDark: High contrast, for low vision: pure black and white, yellow (or blue) focus and selection, thick borders, larger text (raven_accessibility.h, Raccessibility_set_high_contrast). C: R_LOOK_RAVEN_HIGH_CONTRAST_DARKUILook.RavenHighContrastLight: The light variant ofRavenHighContrastDark. C: R_LOOK_RAVEN_HIGH_CONTRAST_LIGHTUILook.WindowsDark: Windows 11 (Fluent): its controls, its colors, the accent color the user chose (on Windows), the Segoe UI font when the system has it, and motion without bounce. C: R_LOOK_WINDOWS_DARKUILook.WindowsLight: The light variant ofWindowsDark. C: R_LOOK_WINDOWS_LIGHTUILook.MacosDark: MacOS (Sequoia, Aqua): its controls, its colors, the accent color the user chose (on macOS), the San Francisco font when the system has it, no change under the pointer, and selections in the accent color. C: R_LOOK_MACOS_DARKUILook.MacosLight: The light variant ofMacosDark. C: R_LOOK_MACOS_LIGHTUILook.GnomeDark: GNOME (libadwaita), the desktop of most Linux distributions: flat rounded controls, the accent and the font of the desktop (on Linux). C: R_LOOK_GNOME_DARKUILook.GnomeLight: The light variant ofGnomeDark. C: R_LOOK_GNOME_LIGHTUILook.NativeDark: The look of the platform the application runs on: Windows on Windows, macOS on macOS (macOS Glass from macOS 26 on), GNOME on Linux and the other systems. C: R_LOOK_NATIVE_DARKUILook.NativeLight: The light variant ofNativeDark. C: R_LOOK_NATIVE_LIGHTUILook.MacosGlassDark: MacOS 26 (Tahoe, Liquid Glass): the controls of macOS, larger and rounder, and glass where the system puts it, on what floats above the content: header bars and their buttons, menus, drop-down lists, tooltips, sheets; the knobs of sliders and switches turn into a lens of clear glass while they are held. The content itself (fields, lists, text) stays opaque. The accent color and the font of the system, on macOS. C: R_LOOK_MACOS_GLASS_DARKUILook.MacosGlassLight: The light variant ofMacosGlassDark. C: R_LOOK_MACOS_GLASS_LIGHT
UIThemeKind
type UIThemeKind = choices(
A built-in theme (R_THEME_*).
Members
UIThemeKind.Dark: Flat, dense themes for tools. C: R_THEME_DARKUIThemeKind.Light: The light variant ofDark. C: R_THEME_LIGHTUIThemeKind.GlassDark: Glass themes: controls are capsules of translucent glass that refract and blur what is behind them, catch the light on their rim and react to the pointer with short animations. Windows get a soft colored background unless they have their own (Rwindow_set_background, Rwindow_set_clear_color). C: R_THEME_GLASS_DARKUIThemeKind.GlassLight: The light variant ofGlassDark. C: R_THEME_GLASS_LIGHTUIThemeKind.HighContrastDark: High contrast, for low vision: pure black and white, yellow (or blue) focus and selection, thick borders, larger text (raven_accessibility.h, Raccessibility_set_high_contrast). C: R_THEME_HIGH_CONTRAST_DARKUIThemeKind.HighContrastLight: The light variant ofHighContrastDark. C: R_THEME_HIGH_CONTRAST_LIGHT
UIMaterial
type UIMaterial = choices(
The surface a widget is drawn with (R_MATERIAL_*).
Members
UIMaterial.Solid: Opaque: filled with the colors of the theme. The material of R_THEME_DARK and R_THEME_LIGHT. C: R_MATERIAL_SOLIDUIMaterial.Glass: Clear glass: what is behind stays sharp enough to be recognized, strongly bent at the rim. C: R_MATERIAL_GLASSUIMaterial.FrostedGlass: Frosted glass: what is behind is blurred into soft colors. The material of the glass themes. C: R_MATERIAL_FROSTED_GLASSUIMaterial.TintedGlass: Frosted glass colored by the accent color of the theme (or of the widget): for what must stand out. C: R_MATERIAL_TINTED_GLASSUIMaterial.Default: Not a material: "the one of the theme". Removes the material given to a widget. C: R_MATERIAL_DEFAULT
UIColorRole
type UIColorRole = choices(
A theme colour's role (R_COLOR_*).
Members
UIColorRole.Window: Window clear color. C: R_COLOR_WINDOWUIColorRole.Panel: Border background. C: R_COLOR_PANELUIColorRole.Border: Border outline, list and input outlines. C: R_COLOR_BORDERUIColorRole.Text: Text. Inherited by the children of the widget it is set on. C: R_COLOR_TEXTUIColorRole.TextDisabled:Texton a disabled widget. C: R_COLOR_TEXT_DISABLEDUIColorRole.TextPlaceholder: The text placeholder colour. C: R_COLOR_TEXT_PLACEHOLDERUIColorRole.Accent: Primary buttons, checked boxes, slider fill, progress fill. C: R_COLOR_ACCENTUIColorRole.AccentHovered:Accentwhile hovered. C: R_COLOR_ACCENT_HOVEREDUIColorRole.AccentPressed:Accentwhile pressed. C: R_COLOR_ACCENT_PRESSEDUIColorRole.AccentText: Text and marks drawn on top of the accent color. C: R_COLOR_ACCENT_TEXTUIColorRole.Control: Button, combo box, check box background. C: R_COLOR_CONTROLUIColorRole.ControlHovered:Controlwhile hovered. C: R_COLOR_CONTROL_HOVEREDUIColorRole.ControlPressed:Controlwhile pressed. C: R_COLOR_CONTROL_PRESSEDUIColorRole.ControlBorder:Controlas its border. C: R_COLOR_CONTROL_BORDERUIColorRole.Input: Text input, spin box, list and tree background. C: R_COLOR_INPUTUIColorRole.Focus: Keyboard focus outline. C: R_COLOR_FOCUSUIColorRole.Selection: Selected rows and selected text. C: R_COLOR_SELECTIONUIColorRole.RowHovered: The row hovered colour. C: R_COLOR_ROW_HOVEREDUIColorRole.Track: Slider track, progress background, scrollbar track. C: R_COLOR_TRACKUIColorRole.Handle: Scrollbar thumb, slider handle. C: R_COLOR_HANDLEUIColorRole.HandleHovered:Handlewhile hovered. C: R_COLOR_HANDLE_HOVEREDUIColorRole.Separator: The separator colour. C: R_COLOR_SEPARATORUIColorRole.Header: Menu bar, tab bar, expander header. C: R_COLOR_HEADERUIColorRole.HeaderHovered:Headerwhile hovered. C: R_COLOR_HEADER_HOVEREDUIColorRole.TabActive: Active tab. C: R_COLOR_TAB_ACTIVEUIColorRole.Popup: Menus, combo box lists. C: R_COLOR_POPUPUIColorRole.PopupBorder:Popupas its border. C: R_COLOR_POPUP_BORDERUIColorRole.Shadow: The shadow colour. C: R_COLOR_SHADOWUIColorRole.Tooltip: The tooltip colour. C: R_COLOR_TOOLTIPUIColorRole.TooltipText: The tooltip text colour. C: R_COLOR_TOOLTIP_TEXTUIColorRole.Switch: Track of a switch that is on. C: R_COLOR_SWITCHUIColorRole.Success: What went well, what needs attention, what is wrong or destroys something (markers, badges, classes). C: R_COLOR_SUCCESSUIColorRole.Warning: The warning colour. C: R_COLOR_WARNINGUIColorRole.Danger: The danger colour. C: R_COLOR_DANGERUIColorRole.Link: Links of formatted text. C: R_COLOR_LINKUIColorRole.Code: Background of code in formatted text. C: R_COLOR_CODE
UIColorFilter
type UIColorFilter = choices(
A colour filter over the whole output, for accessibility (R_COLOR_FILTER_*).
Members
UIColorFilter.None: No filter. C: R_COLOR_FILTER_NONEUIColorFilter.Protanopia: Red is weak. C: R_COLOR_FILTER_PROTANOPIAUIColorFilter.Deuteranopia: Green is weak (the most frequent). C: R_COLOR_FILTER_DEUTERANOPIAUIColorFilter.Tritanopia: Blue is weak. C: R_COLOR_FILTER_TRITANOPIAUIColorFilter.Grayscale: Grayscale. C: R_COLOR_FILTER_GRAYSCALEUIColorFilter.Invert: The colours inverted. C: R_COLOR_FILTER_INVERTUIColorFilter.SimulateProtanopia: Simulations, to see an interface as the color blind see it. C: R_COLOR_FILTER_SIMULATE_PROTANOPIAUIColorFilter.SimulateDeuteranopia: Shows the output as a person with deuteranopia sees it. C: R_COLOR_FILTER_SIMULATE_DEUTERANOPIAUIColorFilter.SimulateTritanopia: Shows the output as a person with tritanopia sees it. C: R_COLOR_FILTER_SIMULATE_TRITANOPIAUIColorFilter.SimulateAchromatopsia: Shows the output as a person with achromatopsia sees it. C: R_COLOR_FILTER_SIMULATE_ACHROMATOPSIA
UIMetric
type UIMetric = choices(
A theme size's role (R_METRIC_*).
Members
UIMetric.FontSize: The font size. C: R_METRIC_FONT_SIZEUIMetric.CornerRadius: The corner radius. C: R_METRIC_CORNER_RADIUSUIMetric.BorderWidth: The border width. C: R_METRIC_BORDER_WIDTHUIMetric.ControlHeight: Height of buttons, inputs, combo boxes, tabs, menu bars. C: R_METRIC_CONTROL_HEIGHTUIMetric.PaddingX: Horizontal / vertical padding inside controls. C: R_METRIC_PADDING_XUIMetric.PaddingY: The vertical padding. C: R_METRIC_PADDING_YUIMetric.Spacing: Gap between an icon or a check mark and its text. C: R_METRIC_SPACINGUIMetric.ScrollbarSize: The scrollbar size. C: R_METRIC_SCROLLBAR_SIZEUIMetric.RowHeight: Height of list, tree and menu rows. C: R_METRIC_ROW_HEIGHTUIMetric.Indent: Indentation per tree level. C: R_METRIC_INDENTUIMetric.SplitterSize: The splitter size. C: R_METRIC_SPLITTER_SIZEUIMetric.CheckSize: The check size. C: R_METRIC_CHECK_SIZEUIMetric.SliderHandleSize: The slider handle size. C: R_METRIC_SLIDER_HANDLE_SIZEUIMetric.PopupRadius: Corner radius of menus, drop-down lists and tooltips. C: R_METRIC_POPUP_RADIUSUIMetric.GlassFrost: The glass of the theme: each one multiplies what the material gives, 1 = unchanged. Frost (how much is blurred), refraction (how far the rim bends what is behind), saturation (of what is seen through), rim (the light it catches) and shadow (the one it drops). C: R_METRIC_GLASS_FROSTUIMetric.GlassRefraction: The glass refraction. C: R_METRIC_GLASS_REFRACTIONUIMetric.GlassSaturation: The glass saturation. C: R_METRIC_GLASS_SATURATIONUIMetric.GlassRim: The glass rim. C: R_METRIC_GLASS_RIMUIMetric.GlassShadow: The glass shadow. C: R_METRIC_GLASS_SHADOWUIMetric.BlurRadius: Radius of the blur of a BackgroundBlur that was not given one. C: R_METRIC_BLUR_RADIUS
UIFontStyle
type UIFontStyle = choices(
A font's style (R_FONT_*).
Members
UIFontStyle.Regular: Regular. C: R_FONT_REGULARUIFontStyle.Bold: Bold. C: R_FONT_BOLDUIFontStyle.Italic: Italic. C: R_FONT_ITALICUIFontStyle.BoldItalic: Bold italic. C: R_FONT_BOLD_ITALIC
UIFilter
type UIFilter = choices(
How a texture is sampled when scaled (R_FILTER_*).
Members
UIFilter.Linear: Linear smoothing. C: R_FILTER_LINEARUIFilter.Nearest: No smoothing: keeps pixel art sharp. C: R_FILTER_NEARESTUIFilter.Mipmap: Smooth, with mipmaps: an image shown much smaller than its size stays clean instead of shimmering, for a third more GPU memory. The default of the textures made from image files (Rtexture_create...). Backends without mipmaps treat it as R_FILTER_LINEAR. C: R_FILTER_MIPMAP
UITextureFormat
type UITextureFormat = choices(
A texture's pixel format (R_TEXTURE_*).
Members
UITextureFormat.RGBA8: 4 bytes per pixel: R, G, B, A. C: R_TEXTURE_RGBA8UITextureFormat.Alpha8: 1 byte per pixel, sampled as (1, 1, 1, value). Used by the glyph atlas. C: R_TEXTURE_ALPHA8
UIWidgetKind
type UIWidgetKind = choices(
The kind of a widget (R_WIDGET_*).
Members
UIWidgetKind.VBox: Stacks children top to bottom. C: R_WIDGET_VBOXUIWidgetKind.HBox: Stacks children left to right. C: R_WIDGET_HBOXUIWidgetKind.Grid: Rows and columns with spans and fill coefficients. C: R_WIDGET_GRIDUIWidgetKind.UniformGrid: Grid whose cells all have the same size. C: R_WIDGET_UNIFORM_GRIDUIWidgetKind.Overlay: Draws children on top of each other. C: R_WIDGET_OVERLAYUIWidgetKind.Border: One child with a background, an outline and inner padding. C: R_WIDGET_BORDERUIWidgetKind.SizeBox: One child with size constraints or a fixed aspect ratio. C: R_WIDGET_SIZE_BOXUIWidgetKind.Spacer: Empty space. C: R_WIDGET_SPACERUIWidgetKind.ScrollBox: Scrollable stack of children. C: R_WIDGET_SCROLL_BOXUIWidgetKind.Splitter: Children separated by draggable handles. C: R_WIDGET_SPLITTERUIWidgetKind.WrapBox: Flows children and wraps to the next line. C: R_WIDGET_WRAP_BOXUIWidgetKind.Canvas: Children placed with anchors and offsets. C: R_WIDGET_CANVASUIWidgetKind.Switcher: Shows one child at a time. C: R_WIDGET_SWITCHERUIWidgetKind.TabView: Tab bar + one page per child. C: R_WIDGET_TAB_VIEWUIWidgetKind.Expander: Collapsible header + one child. C: R_WIDGET_EXPANDERUIWidgetKind.Label: ---- controls (raven_controls.h) ----. C: R_WIDGET_LABELUIWidgetKind.Button: A button. C: R_WIDGET_BUTTONUIWidgetKind.CheckBox: A check box. C: R_WIDGET_CHECKBOXUIWidgetKind.Slider: A slider. C: R_WIDGET_SLIDERUIWidgetKind.ProgressBar: A progress bar. C: R_WIDGET_PROGRESSBARUIWidgetKind.Image: An image. C: R_WIDGET_IMAGEUIWidgetKind.TextInput: A text input. C: R_WIDGET_TEXT_INPUTUIWidgetKind.SpinBox: A spin box. C: R_WIDGET_SPIN_BOXUIWidgetKind.ComboBox: A combo box. C: R_WIDGET_COMBO_BOXUIWidgetKind.Separator: A separator. C: R_WIDGET_SEPARATORUIWidgetKind.ListView: A list view. C: R_WIDGET_LIST_VIEWUIWidgetKind.TreeView: A tree view. C: R_WIDGET_TREE_VIEWUIWidgetKind.MenuBar: A menu bar. C: R_WIDGET_MENU_BARUIWidgetKind.Menu: A menu. C: R_WIDGET_MENUUIWidgetKind.MenuItem: A menu item. C: R_WIDGET_MENU_ITEMUIWidgetKind.Viewport: Area showing content rendered by the application. C: R_WIDGET_VIEWPORTUIWidgetKind.Custom: Widget painted and measured by application callbacks. C: R_WIDGET_CUSTOMUIWidgetKind.TextEditor: Multi-line text editor. C: R_WIDGET_TEXT_EDITORUIWidgetKind.HeaderBar: Title bar of a window with a custom header, holding any widget. C: R_WIDGET_HEADER_BARUIWidgetKind.DockArea: Panels docked side by side or behind tabs, that the user rearranges. C: R_WIDGET_DOCK_AREAUIWidgetKind.Island: A capsule that unfolds into a panel, at the top of a window. C: R_WIDGET_ISLANDUIWidgetKind.FileBrowser: Explorer of the files of the computer. C: R_WIDGET_FILE_BROWSERUIWidgetKind.BackgroundBlur: One child over a blurred view of what is behind it. C: R_WIDGET_BACKGROUND_BLURUIWidgetKind.ColorPicker: Chooses a color: hue, saturation, value, opacity, by hand or by numbers. C: R_WIDGET_COLOR_PICKERUIWidgetKind.Timeline: Tracks of clips and keys along a time ruler. C: R_WIDGET_TIMELINEUIWidgetKind.NodeGraph: Nodes linked by wires, on a canvas that pans and zooms. C: R_WIDGET_NODE_GRAPHUIWidgetKind.TileView: Grid of tiles (an icon over a name), virtualized. C: R_WIDGET_TILE_VIEWUIWidgetKind.BlockEditor: Blocks that snap into each other, in the style of Scratch. C: R_WIDGET_BLOCK_EDITORUIWidgetKind.Table: Rows of cells under columns that can be resized and sorted, virtualized. C: R_WIDGET_TABLEUIWidgetKind.DatePicker: A date, chosen in a calendar that drops down. C: R_WIDGET_DATE_PICKERUIWidgetKind.TimePicker: A time of the day: hours, minutes, optionally seconds. C: R_WIDGET_TIME_PICKERUIWidgetKind.Toast: A short message that rises for a few seconds, with an optional action ("Undo"). C: R_WIDGET_TOASTUIWidgetKind.Breadcrumb: The path to the current place: links separated by chevrons. C: R_WIDGET_BREADCRUMBUIWidgetKind.Rating: A score shown and chosen with stars. C: R_WIDGET_RATINGUIWidgetKind.Pagination: Page numbers with previous and next. C: R_WIDGET_PAGINATIONUIWidgetKind.Plot: Curves of X / Y data: legend, line styles, markers, log axes, a second X and Y axis, pan and zoom. C: R_WIDGET_PLOTUIWidgetKind.PDFView: The pages of a PDF document, scrolled and zoomed (drawn by PDFium, loaded at run time). C: R_WIDGET_PDF_VIEWUIWidgetKind.Chart: The charts of dashboards: pie, donut, gauge, heatmap, sparkline (RChartKind). C: R_WIDGET_CHARTUIWidgetKind.MapView: A map of slippy-map tiles given by the application (or read from files): panned, zoomed, with markers. C: R_WIDGET_MAP_VIEWUIWidgetKind.Carousel: Pages shown one at a time and swiped (a page view), with dots and arrows. C: R_WIDGET_CAROUSEL
UIWidgetKinds
type UIWidgetKinds = set of UIWidgetKind
A set of UIWidgetKind (the kinds a widget type views: UIWidget.Kinds).
UIHAlign
type UIHAlign = choices(
How a widget lines up across its slot (R_HALIGN_*).
Members
UIHAlign.Fill: Fills the slot across. C: R_HALIGN_FILLUIHAlign.Left: At the left. C: R_HALIGN_LEFTUIHAlign.Center: Centred across the slot. C: R_HALIGN_CENTERUIHAlign.Right: At the right. C: R_HALIGN_RIGHT
UIVAlign
type UIVAlign = choices(
How a widget lines up down its slot (R_VALIGN_*).
Members
UIVAlign.Fill: Fills the slot down. C: R_VALIGN_FILLUIVAlign.Top: At the top. C: R_VALIGN_TOPUIVAlign.Center: Centred down the slot. C: R_VALIGN_CENTERUIVAlign.Bottom: At the bottom. C: R_VALIGN_BOTTOM
UIVisibility
type UIVisibility = choices(
Whether a widget shows and takes room (R_VISIBLE, R_HIDDEN, R_COLLAPSED).
Members
UIVisibility.Visible: Drawn and laid out. C: R_VISIBLEUIVisibility.Hidden: Not drawn, but still takes its space in the layout. C: R_HIDDENUIVisibility.Collapsed: Not drawn and takes no space. C: R_COLLAPSED
UIOrientation
type UIOrientation = choices(
A direction of layout (R_HORIZONTAL, R_VERTICAL).
Members
UIOrientation.Horizontal: Horizontal. C: R_HORIZONTALUIOrientation.Vertical: Vertical. C: R_VERTICAL
UITransition
type UITransition = choices(
How a widget's content changes over (R_TRANSITION_*).
Members
UITransition.None: No transition. C: R_TRANSITION_NONEUITransition.Fade: Becomes opaque. C: R_TRANSITION_FADEUITransition.Pop: Grows from a smaller size and bounces a little past its own. C: R_TRANSITION_POPUITransition.Zoom: Shrinks from a larger size. C: R_TRANSITION_ZOOMUITransition.FlyUp: Flies in from below / above / the right / the left, and settles with a bounce. C: R_TRANSITION_FLY_UPUITransition.FlyDown: The new content flies in downwards. C: R_TRANSITION_FLY_DOWNUITransition.FlyLeft: The new content flies in to the left. C: R_TRANSITION_FLY_LEFTUITransition.FlyRight: The new content flies in to the right. C: R_TRANSITION_FLY_RIGHTUITransition.Drop: Falls from above, squashes on landing and wobbles. C: R_TRANSITION_DROPUITransition.SlideLeft: Short slide from the right / from the left, without bounce: pages that replace one another. C: R_TRANSITION_SLIDE_LEFTUITransition.SlideRight: The new content slides in to the right. C: R_TRANSITION_SLIDE_RIGHT
UIBlurStyle
type UIBlurStyle = choices(
A background blur's style (R_BLUR_*).
Members
UIBlurStyle.Plain: What is behind, out of focus, and nothing else (a Gaussian blur). C: R_BLUR_PLAINUIBlurStyle.Frosted: Frosted: blurred, its colors a little stronger, under a veil of the panel color of the theme, a fine grain and a hairline. The default. C: R_BLUR_FROSTEDUIBlurStyle.Glass: Glass: a slab that bends what is behind at its rim and catches the light, as the glass materials do (RMaterial); the radius says how frosted it is. C: R_BLUR_GLASSUIBlurStyle.Native: Native: the widget opens the window there, and what shows is what the OS puts behind the window (Rwindow_set_backdrop: the blurred desktop, acrylic, mica), under a light veil. It needs a window created with R_WINDOW_TRANSPARENT that the OS could make see-through; anywhere else it is drawn as R_BLUR_FROSTED. The radius is the one of the OS. C: R_BLUR_NATIVE
UIDirection
type UIDirection = choices(
The layout direction: left to right or right to left (R_DIRECTION_*).
Members
UIDirection.Inherit: A widget: the direction of its parent (the default). C: R_DIRECTION_INHERITUIDirection.LTR: Left to right. C: R_DIRECTION_LTRUIDirection.RTL: Right to left. C: R_DIRECTION_RTLUIDirection.Auto: The windows: the direction of the language. C: R_DIRECTION_AUTO
UIToastKind
type UIToastKind = choices(
A toast's kind (R_TOAST_INFO ..).
Members
UIToastKind.Info: A neutral message (the accent of the theme). C: R_TOAST_INFOUIToastKind.Success: A success toast. C: R_TOAST_SUCCESSUIToastKind.Warning: A warning toast. C: R_TOAST_WARNINGUIToastKind.Error: An error toast. C: R_TOAST_ERROR
UIToastQueue
type UIToastQueue = choices(
How a new toast meets the shown one (R_TOAST_REPLACE ..).
Members
UIToastQueue.Replace: The new message takes the place of the one shown (the default). C: R_TOAST_REPLACEUIToastQueue.Sequence: The messages are shown one after the other, each for its own time. C: R_TOAST_SEQUENCEUIToastQueue.Stack: Up to Rtoast_set_max_visible messages are shown at once, one above the other; the others wait. C: R_TOAST_STACK
UIButtonStyle
type UIButtonStyle = choices(
A button's style (R_BUTTON_*).
Members
UIButtonStyle.Default: Filled with R_COLOR_CONTROL. C: R_BUTTON_DEFAULTUIButtonStyle.Primary: Filled with R_COLOR_ACCENT. C: R_BUTTON_PRIMARYUIButtonStyle.Flat: No background until hovered (toolbars). C: R_BUTTON_FLAT
UICheckStyle
type UICheckStyle = choices(
A check box's style (R_CHECKBOX_*).
Members
UICheckStyle.Check: A check box. C: R_CHECKBOX_CHECKUICheckStyle.Radio: Round mark. Checking one unchecks the other radio boxes of the same parent. C: R_CHECKBOX_RADIOUICheckStyle.Switch: On / off switch. C: R_CHECKBOX_SWITCH
UIStretch
type UIStretch = choices(
How content fills its box (R_STRETCH_*).
Members
UIStretch.Fill: Stretches the image to the widget, ignoring its aspect ratio. C: R_STRETCH_FILLUIStretch.Fit: Largest size that fits entirely, keeping the aspect ratio. C: R_STRETCH_FITUIStretch.Cover: Smallest size that covers the widget, keeping the aspect ratio (cropped). C: R_STRETCH_COVERUIStretch.None: Original size, centered. C: R_STRETCH_NONE
UIAxis
type UIAxis = choices(
A plot axis (R_PLOT_X ..).
Members
UIAxis.X: The horizontal axis under the data. C: R_PLOT_XUIAxis.Y: The vertical axis on the left. C: R_PLOT_YUIAxis.X2: A second horizontal axis, over the data: shown when a series or a drag line uses it. C: R_PLOT_X2UIAxis.Y2: A second vertical axis, on the right: shown when a series or a drag line uses it. C: R_PLOT_Y2
UIAxisScale
type UIAxisScale = choices(
A plot axis's scale (R_PLOT_SCALE_*).
Members
UIAxisScale.Linear: A linear scale. C: R_PLOT_SCALE_LINEARUIAxisScale.Log: Powers of ten at even distances; only values above zero are shown. C: R_PLOT_SCALE_LOGUIAxisScale.Symlog: Symmetric logarithm: linear between -t and t (Rplot_set_axis_linear_threshold, 1 by default), logarithmic beyond on both sides: shows zero and the negative values a logarithm cannot. C: R_PLOT_SCALE_SYMLOG
UILineStyle
type UILineStyle = choices(
A plot line's style (R_PLOT_LINE_*).
Members
UILineStyle.Solid: Solid lines. C: R_PLOT_LINE_SOLIDUILineStyle.Dashed: Dashed lines. C: R_PLOT_LINE_DASHEDUILineStyle.Dotted: Dotted lines. C: R_PLOT_LINE_DOTTEDUILineStyle.DashDot: Dash-dot lines. C: R_PLOT_LINE_DASH_DOTUILineStyle.None: No line: only the markers (a scatter plot). C: R_PLOT_LINE_NONE
UIMarkerShape
type UIMarkerShape = choices(
A plot point's marker (R_PLOT_MARKER_*).
Members
UIMarkerShape.None: No marker. C: R_PLOT_MARKER_NONEUIMarkerShape.Circle: A circle marker. C: R_PLOT_MARKER_CIRCLEUIMarkerShape.Square: A square marker. C: R_PLOT_MARKER_SQUAREUIMarkerShape.Diamond: A diamond marker. C: R_PLOT_MARKER_DIAMONDUIMarkerShape.TriangleUp: A triangle up marker. C: R_PLOT_MARKER_TRIANGLE_UPUIMarkerShape.TriangleDown: A triangle down marker. C: R_PLOT_MARKER_TRIANGLE_DOWNUIMarkerShape.Cross: A cross marker. C: R_PLOT_MARKER_CROSSUIMarkerShape.Plus: A plus marker. C: R_PLOT_MARKER_PLUSUIMarkerShape.Asterisk: An asterisk marker. C: R_PLOT_MARKER_ASTERISK
UILegendPlace
type UILegendPlace = choices(
Where a plot's legend goes (R_PLOT_LEGEND_*).
Members
UILegendPlace.Hidden: No legend. C: R_PLOT_LEGEND_HIDDENUILegendPlace.TopLeft: At the top left. C: R_PLOT_LEGEND_TOP_LEFTUILegendPlace.Top: At the top. C: R_PLOT_LEGEND_TOPUILegendPlace.TopRight: At the top right. C: R_PLOT_LEGEND_TOP_RIGHTUILegendPlace.Right: At the right. C: R_PLOT_LEGEND_RIGHTUILegendPlace.BottomRight: At the bottom right. C: R_PLOT_LEGEND_BOTTOM_RIGHTUILegendPlace.Bottom: At the bottom. C: R_PLOT_LEGEND_BOTTOMUILegendPlace.BottomLeft: At the bottom left. C: R_PLOT_LEGEND_BOTTOM_LEFTUILegendPlace.Left: At the left. C: R_PLOT_LEGEND_LEFTUILegendPlace.Outside: To the right of the data, outside it. C: R_PLOT_LEGEND_OUTSIDE
UIPDFFit
type UIPDFFit = choices(
How a PDF page fits its view (R_PDF_FIT_*).
Members
UIPDFFit.Width: The widest page fills the width of the view (default). C: R_PDF_FIT_WIDTHUIPDFFit.Page: The largest page fits whole in the view. C: R_PDF_FIT_PAGEUIPDFFit.None: The zoom of Rpdf_view_set_zoom; zooming with the wheel or the keys switches to it. C: R_PDF_FIT_NONE
UIPDFStatus
type UIPDFStatus = choices(
A PDF view's state (R_PDF_EMPTY ..).
Members
UIPDFStatus.Empty: No document. C: R_PDF_EMPTYUIPDFStatus.Loaded: A document is shown. C: R_PDF_LOADEDUIPDFStatus.NeedsPassword: The document needs a password, or the one given is wrong: load it again with one. C: R_PDF_NEEDS_PASSWORDUIPDFStatus.Error: The file could not be read, or is not a PDF document. C: R_PDF_ERRORUIPDFStatus.Unavailable: The PDFium library was not found (see Rpdf_is_available). C: R_PDF_UNAVAILABLE
UIPDFFont
type UIPDFFont = choices(
A font PDF drawing writes with (R_PDF_FONT_*).
Members
UIPDFFont.Sans: Roboto, the font of the interface of Raven. C: R_PDF_FONT_SANSUIPDFFont.Mono: Roboto Mono. C: R_PDF_FONT_MONO
UIPDFPaint
type UIPDFPaint = choices(
How a PDF shape is painted (R_PDF_FILL, R_PDF_STROKE). A member's value is its bit number in Raven's flags (a set of them casts to them).
Members
UIPDFPaint.Fill: Filled with the fill color. C: R_PDF_FILLUIPDFPaint.Stroke: Outlined with the stroke color and the line width. C: R_PDF_STROKE
UIPDFPaints
type UIPDFPaints = set of UIPDFPaint
A set of UIPDFPaint (Raven's RPdfPaint).
UIPDFText
type UIPDFText = choices(
A PDF text style (R_PDF_TEXT_*). A member's value is its bit number in Raven's flags (a set of them casts to them).
Members
UIPDFText.Bold: Bold. C: R_PDF_TEXT_BOLDUIPDFText.Italic: Italic. C: R_PDF_TEXT_ITALICUIPDFText.Underline: Underline. C: R_PDF_TEXT_UNDERLINE
UIPDFTexts
type UIPDFTexts = set of UIPDFText
A set of UIPDFText (Raven's RPdfTextStyle).
UIPrintFlag
type UIPrintFlag = choices(
A printing option (R_PDF_PRINT_*). A member's value is its bit number in Raven's flags (a set of them casts to them).
Members
UIPrintFlag.NoDialog: No dialog: printed at once on the printer named, else the default one. C: R_PDF_PRINT_NO_DIALOG
UIPrintFlags
type UIPrintFlags = set of UIPrintFlag
A set of UIPrintFlag (Raven's RPdfPrintFlags).
UITileState
type UITileState = choices(
A map tile's state (R_MAP_TILE_*).
Members
UITileState.None: Not in the view's cache: never asked for, no longer wanted, or evicted. C: R_MAP_TILE_NONEUITileState.Pending: Asked for (the tile callback was called, or the file is being read): waiting for its pixels. C: R_MAP_TILE_PENDINGUITileState.Loaded: Its pixels are in the cache. C: R_MAP_TILE_LOADEDUITileState.Failed: The application said it has none (Rmap_view_set_tile_failed), or its file could not be read. C: R_MAP_TILE_FAILED
UIChartKind
type UIChartKind = choices(
A chart's kind (R_CHART_*).
Members
UIChartKind.Pie: Slices of a whole, as parts of a disc (the default). C: R_CHART_PIEUIChartKind.Donut: Slices of a whole, as parts of a ring; its middle shows the total, or the slice under the pointer. C: R_CHART_DONUTUIChartKind.Gauge: One value within a range, on an arc; bands color parts of the range. C: R_CHART_GAUGEUIChartKind.Heatmap: A grid of values, each cell colored from the low color to the high one. C: R_CHART_HEATMAPUIChartKind.Sparkline: A small line of values without axes, to sit in a tile or a cell of a table. C: R_CHART_SPARKLINE
UISyntax
type UISyntax = choices(
A text editor's built-in highlighting (R_SYNTAX_*).
Members
UISyntax.None: No highlighting. C: R_SYNTAX_NONEUISyntax.XML: XML highlighting. C: R_SYNTAX_XMLUISyntax.C: C highlighting. C: R_SYNTAX_C
UILanguageFlag
type UILanguageFlag = choices(
A syntax language's option (R_LANGUAGE_*). A member's value is its bit number in Raven's flags (a set of them casts to them).
Members
UILanguageFlag.Markup: Tags and attributes instead of code: XML, HTML. The words and the comments of the description are not used. C: R_LANGUAGE_MARKUPUILanguageFlag.StyleSheet: Selectors, properties and values: CSS. C: R_LANGUAGE_STYLE_SHEETUILanguageFlag.NestedComments: A block comment may hold another one (Rust). C: R_LANGUAGE_NESTED_COMMENTSUILanguageFlag.CharLiterals: Between single quotes there is one character; any other single quote is not a text (C, Java, Rust). C: R_LANGUAGE_CHAR_LITERALSUILanguageFlag.IndentOnColon: A line that ends with ':' indents the next one (Python). C: R_LANGUAGE_INDENT_ON_COLONUILanguageFlag.IgnoreCase: The words of the language are recognized whatever their case. C: R_LANGUAGE_IGNORE_CASEUILanguageFlag.Embeds: Markup that holds JavaScript in script elements and CSS in style elements (HTML). C: R_LANGUAGE_EMBEDSUILanguageFlag.FormattedText: Formatted text written in Markdown: titles, strong and emphasized text, code, links, lists. The editor shows the text as it is written, marks included, with strong text in bold, emphasized text in italic and titles in bold: what will be formatted is seen while typing. C: R_LANGUAGE_FORMATTED_TEXT
UILanguageFlags
type UILanguageFlags = set of UILanguageFlag
A set of UILanguageFlag (Raven's RLanguageFlags).
UITokenKind
type UITokenKind = choices(
A highlighted token's kind (R_TOKEN_*).
Members
UITokenKind.Text: Plain text. C: R_TOKEN_TEXTUITokenKind.Comment: A comment. C: R_TOKEN_COMMENTUITokenKind.String: A string. C: R_TOKEN_STRINGUITokenKind.Number: A number. C: R_TOKEN_NUMBERUITokenKind.Keyword: A keyword. C: R_TOKEN_KEYWORDUITokenKind.Type: A type, or a name that is always there. C: R_TOKEN_TYPEUITokenKind.Function: A name followed by an opening parenthesis. C: R_TOKEN_FUNCTIONUITokenKind.Tag: The name of an element, in markup and in the selectors of a style sheet. C: R_TOKEN_TAGUITokenKind.Attribute: The name of an attribute (markup), of a class or of a property (style sheets), of a key (JSON). C: R_TOKEN_ATTRIBUTEUITokenKind.Punctuation: Punctuation. C: R_TOKEN_PUNCTUATIONUITokenKind.Directive: A line for the preprocessor, an annotation, a declaration of a document. C: R_TOKEN_DIRECTIVEUITokenKind.Heading: Formatted text (the Markdown language): a title, strong text, emphasized text, a link. C: R_TOKEN_HEADINGUITokenKind.Strong: Strong (bold) text. C: R_TOKEN_STRONGUITokenKind.Emphasis: Emphasized (italic) text. C: R_TOKEN_EMPHASISUITokenKind.Link: A link. C: R_TOKEN_LINK
UIMarkKind
type UIMarkKind = choices(
A text editor line mark's kind (R_MARKER_*).
Members
UIMarkKind.Error: An error mark. C: R_MARKER_ERRORUIMarkKind.Warning: A warning mark. C: R_MARKER_WARNINGUIMarkKind.Info: An info mark. C: R_MARKER_INFO
UIHeaderButton
type UIHeaderButton = choices(
A header bar's window button (R_HEADER_*). A member's value is its bit number in Raven's flags (a set of them casts to them).
Members
UIHeaderButton.Close: The close button. C: R_HEADER_CLOSEUIHeaderButton.Minimize: The minimize button. C: R_HEADER_MINIMIZEUIHeaderButton.Maximize: The maximize button. C: R_HEADER_MAXIMIZE
UIHeaderButtons
type UIHeaderButtons = set of UIHeaderButton
A set of UIHeaderButton (Raven's RHeaderButtons).
UITaskbarProgress
type UITaskbarProgress = choices(
The state of a taskbar progress (R_TASKBAR_PROGRESS_*).
Members
UITaskbarProgress.None: No progress shown. C: R_TASKBAR_PROGRESS_NONEUITaskbarProgress.Normal: Progress shown as it goes. C: R_TASKBAR_PROGRESS_NORMALUITaskbarProgress.Paused: Shown as paused (yellow on Windows). C: R_TASKBAR_PROGRESS_PAUSEDUITaskbarProgress.Error: Shown as failed (red on Windows). C: R_TASKBAR_PROGRESS_ERRORUITaskbarProgress.Indeterminate: Something goes on, without knowing how far it is. C: R_TASKBAR_PROGRESS_INDETERMINATE
UIDockSide
type UIDockSide = choices(
Where a docked panel goes (R_DOCK_*).
Members
UIDockSide.Left: The left side. C: R_DOCK_LEFTUIDockSide.Right: The right side. C: R_DOCK_RIGHTUIDockSide.Top: The top side. C: R_DOCK_TOPUIDockSide.Bottom: The bottom side. C: R_DOCK_BOTTOMUIDockSide.Tab: Behind the same tabs as the other panel. C: R_DOCK_TAB
UIDockFloat
type UIDockFloat = choices(
Where an undocked panel floats (R_DOCK_FLOAT_*).
Members
UIDockFloat.Window: In a window of its own. C: R_DOCK_FLOAT_WINDOWUIDockFloat.InWindow: Inside the window. C: R_DOCK_FLOAT_IN_WINDOW
UIPreset
type UIPreset = choices(
A node graph's or timeline's visual preset (R_PRESET_*).
Members
UIPreset.Auto: The look of the theme of the window: its platform, dark or light. C: R_PRESET_AUTOUIPreset.Modern: Cards with soft shadows, few lines (follows dark or light). C: R_PRESET_MODERNUIPreset.Blueprint: Headers in gradients, a grid of lines, thick links that glow; pins of the type "exec" are arrows. C: R_PRESET_BLUEPRINTUIPreset.Blender: Compact nodes, flat headers in muted colors, thin links. C: R_PRESET_BLENDERUIPreset.Neon: Almost black, outlines and links of light. C: R_PRESET_NEON
UITimelineItemKind
type UITimelineItemKind = choices(
A timeline item's kind (R_TIMELINE_*).
Members
UITimelineItemKind.None: No item. C: R_TIMELINE_NONEUITimelineItemKind.Clip: A clip. C: R_TIMELINE_CLIPUITimelineItemKind.Key: A key. C: R_TIMELINE_KEYUITimelineItemKind.Marker: A marker. C: R_TIMELINE_MARKER
UIBlockShape
type UIBlockShape = choices(
A block editor block's shape (R_BLOCK_STATEMENT ..).
Members
UIBlockShape.Statement: A step: snaps under another one, others snap under it. C: R_BLOCK_STATEMENTUIBlockShape.Hat: Starts a script ("when the game starts"): nothing goes above it. C: R_BLOCK_HATUIBlockShape.Cap: Ends a script ("stop"): nothing goes under it. C: R_BLOCK_CAPUIBlockShape.C: Wraps stacks in its mouths ("repeat", "if ... else"). C: R_BLOCK_CUIBlockShape.Reporter: A rounded value that goes into a slot. C: R_BLOCK_REPORTERUIBlockShape.Boolean: A hexagonal condition that goes into a %b slot (or a %r one). C: R_BLOCK_BOOLEAN
UIBlockPart
type UIBlockPart = choices(
Where a block joins another (R_BLOCK_NEXT ..).
Members
UIBlockPart.Next: After it, as the next block. C: R_BLOCK_NEXTUIBlockPart.Body: Inside its body. C: R_BLOCK_BODYUIBlockPart.Input: In one of its inputs. C: R_BLOCK_INPUT
UIUrgency
type UIUrgency = choices(
A notification's urgency (R_NOTIFICATION_*).
Members
UIUrgency.Low: No sound; may only go to the list of notifications. C: R_NOTIFICATION_LOWUIUrgency.Normal: Normal urgency. C: R_NOTIFICATION_NORMALUIUrgency.Critical: Stays until the user dismisses it, where the system allows it. C: R_NOTIFICATION_CRITICAL
UIFileDialogFlag
type UIFileDialogFlag = choices(
A file dialog option (R_FILE_DIALOG_*). A member's value is its bit number in Raven's flags (a set of them casts to them).
Members
UIFileDialogFlag.Multiple: Several files can be chosen (Rfile_dialog_open): see Rfile_dialog_get_result. C: R_FILE_DIALOG_MULTIPLEUIFileDialogFlag.Raven: Never the dialog of the OS: the file browser of Raven, in a dialog of the parent window. C: R_FILE_DIALOG_RAVENUIFileDialogFlag.ShowHidden: Hidden files shown. C: R_FILE_DIALOG_SHOW_HIDDEN
UIFileDialogFlags
type UIFileDialogFlags = set of UIFileDialogFlag
A set of UIFileDialogFlag (Raven's RFileDialogFlags).
UIBrowserMode
type UIBrowserMode = choices(
A file browser's mode (R_FILE_BROWSER_*).
Members
UIBrowserMode.Open: Choose an existing file. C: R_FILE_BROWSER_OPENUIBrowserMode.Save: Choose where to save: a name is typed; an existing file must be confirmed. C: R_FILE_BROWSER_SAVEUIBrowserMode.Folder: Choose a folder. C: R_FILE_BROWSER_FOLDER
UIMessageButtons
type UIMessageButtons = choices(
The buttons of a message box (R_MESSAGE_OK ..).
Members
UIMessageButtons.Ok: An OK button. C: R_MESSAGE_OKUIMessageButtons.OkCancel: OK and Cancel. C: R_MESSAGE_OK_CANCELUIMessageButtons.YesNo: Yes and No. C: R_MESSAGE_YES_NOUIMessageButtons.YesNoCancel: Yes, No and Cancel. C: R_MESSAGE_YES_NO_CANCEL
UIMessageResult
type UIMessageResult = choices(
The button a message box was closed with (R_MESSAGE_RESULT_*).
Members
UIMessageResult.Cancel: Dismissed (Escape), or the Cancel button. C: R_MESSAGE_RESULT_CANCELUIMessageResult.Ok: OK. C: R_MESSAGE_RESULT_OKUIMessageResult.Yes: Yes. C: R_MESSAGE_RESULT_YESUIMessageResult.No: No. C: R_MESSAGE_RESULT_NO
UIMotion
type UIMotion = choices(
An animation's feel (R_MOTION_*).
Members
UIMotion.Snappy: Fast, no bounce: hover, highlights. C: R_MOTION_SNAPPYUIMotion.Smooth: Slower, no bounce: scrolling, fades, sizes. C: R_MOTION_SMOOTHUIMotion.Bouncy: Runs a little past the target and comes back: switches, popups, pressed buttons. C: R_MOTION_BOUNCYUIMotion.Wobbly: Swings several times around the target: things that fly in or get dropped. C: R_MOTION_WOBBLY
UIEffect
type UIEffect = choices(
A built-in shader effect (R_EFFECT_*).
Members
UIEffect.Aurora: Soft lights that drift slowly: color, color2; params: speed, scale, intensity, -. Animated. C: R_EFFECT_AURORAUIEffect.Shimmer: A band of light that sweeps across (loading placeholders): color = base, color2 = light; params: speed, width, angle, -. Animated. C: R_EFFECT_SHIMMERUIEffect.Neon: A glowing edge whose colors run around the shape: color, color2; params: speed, width, glow, -. Animated. C: R_EFFECT_NEONUIEffect.Ripple: Rings that ripple what is behind, like water (reads the backdrop): color = tint; params: speed, strength, density, center x (0..1). Animated. C: R_EFFECT_RIPPLEUIEffect.Plasma: Bands of color that flow into each other: color, color2; params: speed, scale, contrast, -. Animated. C: R_EFFECT_PLASMAUIEffect.Grain: A gradient with the fine grain of film: color (top left) to color2 (bottom right); params: grain, angle, -, -. Animated grain. C: R_EFFECT_GRAINUIEffect.Spotlight: A soft light that follows a point: color = light, color2 = background; params: x, y (0..1), radius (0..1), -. C: R_EFFECT_SPOTLIGHTUIEffect.Mesh: Four colors blended across the surface, slowly moving: color, color2 and their mix; params: speed, -, -, -. Animated. C: R_EFFECT_MESH
UIShaderFlag
type UIShaderFlag = choices(
A shader option (R_SHADER_*). A member's value is its bit number in Raven's flags (a set of them casts to them).
Members
UIShaderFlag.Backdrop: The effect reads what is drawn behind it (raven_backdrop, raven_backdrop_blur). C: R_SHADER_BACKDROPUIShaderFlag.Animated: The effect changes with time: the window keeps drawing frames while it is shown. C: R_SHADER_ANIMATED
UIShaderFlags
type UIShaderFlags = set of UIShaderFlag
A set of UIShaderFlag (Raven's RShaderFlags).
UIXMLAttrKind
type UIXMLAttrKind = choices(
The kind of value an XML attribute takes (R_XML_*).
Members
UIXMLAttrKind.Text: Text. C: R_XML_TEXTUIXMLAttrKind.Bool: "true" or "false". C: R_XML_BOOLUIXMLAttrKind.Number: A number. C: R_XML_NUMBERUIXMLAttrKind.Choice: One of the words ofchoices. C: R_XML_CHOICEUIXMLAttrKind.Color: "#RGB", "#RRGGBB", "#RRGGBBAA", or a name: white, black, red, transparent. C: R_XML_COLORUIXMLAttrKind.Action: The name of an action (Raction_bind). C: R_XML_ACTIONUIXMLAttrKind.File: The path of a file. C: R_XML_FILEUIXMLAttrKind.Numbers: Several numbers separated by commas: "8,4", "0,0,1,1". C: R_XML_NUMBERSUIXMLAttrKind.List: Texts separated by '|': "One|Two|Three". C: R_XML_LIST
UIRole
type UIRole = choices(
A widget's accessibility role (R_ROLE_*).
Members
UIRole.Auto: The role of the type of the widget (the default). C: R_ROLE_AUTOUIRole.None: Not exposed: its children are seen as the children of its parent. C: R_ROLE_NONEUIRole.Window: A window. C: R_ROLE_WINDOWUIRole.Group: A group. C: R_ROLE_GROUPUIRole.Text: Text. C: R_ROLE_TEXTUIRole.Heading: A heading. C: R_ROLE_HEADINGUIRole.Link: A link. C: R_ROLE_LINKUIRole.Button: A button. C: R_ROLE_BUTTONUIRole.ToggleButton: A toggle button. C: R_ROLE_TOGGLE_BUTTONUIRole.CheckBox: A check box. C: R_ROLE_CHECKBOXUIRole.RadioButton: A radio button. C: R_ROLE_RADIO_BUTTONUIRole.Slider: A slider. C: R_ROLE_SLIDERUIRole.ProgressBar: A progress bar. C: R_ROLE_PROGRESS_BARUIRole.SpinButton: A spin button. C: R_ROLE_SPIN_BUTTONUIRole.TextField: A text field. C: R_ROLE_TEXT_FIELDUIRole.Document: A document. C: R_ROLE_DOCUMENTUIRole.ComboBox: A combo box. C: R_ROLE_COMBO_BOXUIRole.List: A list. C: R_ROLE_LISTUIRole.ListItem: A list item. C: R_ROLE_LIST_ITEMUIRole.Tree: A tree. C: R_ROLE_TREEUIRole.TreeItem: A tree item. C: R_ROLE_TREE_ITEMUIRole.Table: A table. C: R_ROLE_TABLEUIRole.MenuBar: A menu bar. C: R_ROLE_MENU_BARUIRole.Menu: A menu. C: R_ROLE_MENUUIRole.MenuItem: A menu item. C: R_ROLE_MENU_ITEMUIRole.TabList: A tab list. C: R_ROLE_TAB_LISTUIRole.Tab: A tab. C: R_ROLE_TABUIRole.TabPanel: A tab panel. C: R_ROLE_TAB_PANELUIRole.Toolbar: A toolbar. C: R_ROLE_TOOLBARUIRole.StatusBar: A status bar. C: R_ROLE_STATUS_BARUIRole.Dialog: A dialog. C: R_ROLE_DIALOGUIRole.Alert: An alert. C: R_ROLE_ALERTUIRole.Image: An image. C: R_ROLE_IMAGEUIRole.Canvas: A canvas. C: R_ROLE_CANVASUIRole.Separator: A separator. C: R_ROLE_SEPARATORUIRole.ScrollBar: A scroll bar. C: R_ROLE_SCROLL_BARUIRole.Pane: A pane. C: R_ROLE_PANE
UIColor
type UIColor = record
A colour as Raven draws it: red, green, blue and alpha, each from 0 to 1 (Raven runs on its own, so it keeps its own float colour rather than raylib's bytes).
Members
r: float32: Red, 0 .. 1.g: float32: Green, 0 .. 1.b: float32: Blue, 0 .. 1.a: float32: Alpha (opacity), 0 .. 1.
Example: LAccent := UIColor.FromHex("#3a7bd5", UIColor.Black()).WithAlpha(0.8f);
UIPoint
type UIPoint = record
A point in logical units (Raven's coordinates: x to the right, y down).
Members
x: float32: The distance to the right.y: float32: The distance down.
UISize
type UISize = record
A size in logical units.
Members
w: float32: The width.h: float32: The height.
UIRect
type UIRect = record
A rectangle in logical units: its top-left corner and its size.
Members
x: float32: The left edge.y: float32: The top edge.w: float32: The width.h: float32: The height.
UIRange
type UIRange = record
A range a slider or a spin box reads back: its lowest and highest values and its step.
Members
Min: float64: The lowest value.Max: float64: The highest value.Step: float64: The step between values.
UIDate
type UIDate = record
A date a date picker reads back (Month 1 .. 12, Day 1 .. 31).
Members
Year: int32: The year.Month: int32: The month, 1 .. 12.Day: int32: The day of the month, 1 .. 31.
UITime
type UITime = record
A time a time picker reads back (Hour 0 .. 23).
Members
Hour: int32: The hour, 0 .. 23.Minute: int32: The minute, 0 .. 59.Second: int32: The second, 0 .. 59.
UIHSV
type UIHSV = record
A colour as hue (0 .. 360), saturation and value (0 .. 1), as a colour picker reads it back.
Members
h: float32: The hue, 0 .. 360.s: float32: The saturation, 0 .. 1.v: float32: The value (brightness), 0 .. 1.
UIJumpTask
type UIJumpTask = record
One task of a taskbar jump list (UIApp.JumpList): its title, the command-line arguments the program starts with when it is picked, and its tooltip.
Members
Title: string: The text the task shows in the jump list.Args: string: The command-line arguments the program starts with when the task is picked.Description: string: The task's tooltip.
UIRavenError
type UIRavenError = record
An error Raven reported (UIErrors.Last): its code, its severity and Raven's detail.
Members
Code: UIErrorCode: What went wrong.Severity: UISeverity: How serious it is.Detail: string: Raven's text about it.
UIFrameFunc
type UIFrameFunc = ref func(const ADelta: float64)
What UIApp.OnFrame runs each frame: the seconds since the frame before.
UIAppEventFunc
type UIAppEventFunc = ref func(const AEvent: UIAppEvent)
What UIApp.OnAppEvent runs on a life-cycle event.
UITaskFunc
type UITaskFunc = ref func()
A routine with no arguments: a posted task (UIApp.Post), UIApp.OnDeviceReset, UIApp.OnNotifyClicked.
UINotifyFunc
type UINotifyFunc = ref func(const ATitle: string; const ABody: string; const AUrgency: UIUrgency)
What UIApp.NotifyFallback runs for a notification the system cannot show: its title, body and urgency.
UIErrorFunc
type UIErrorFunc = ref func(const ACode: UIErrorCode; const ASeverity: UISeverity; const ADetail: string)
What UIErrors.OnError runs for each error Raven reports: its code, severity and detail.
UITimerFunc
type UITimerFunc = ref func(const ATimer: UITimerRes)
What a timer runs each time it fires (UITimerRes): the timer.
UIEventFunc
type UIEventFunc = ref func(const AEvent: REvent): bool
What UIWidget.OnEvent runs for each input event the widget gets: true when it handled the event.
UIDropFunc
type UIDropFunc = ref func(const AEvent: RDropEvent): bool
What UIWidget.OnDrop runs at each stage of a drag and drop over the widget: true when the widget takes the drop.
UITouchFunc
type UITouchFunc = ref func(const AEvent: RTouchEvent): bool
What UIWidget.OnTouch runs for each touch on the widget: true when it handled it.
UIPenFunc
type UIPenFunc = ref func(const AEvent: RPenEvent): bool
What UIWidget.OnPen runs for each pen event on the widget: true when it handled it.
UIGestureFunc
type UIGestureFunc = ref func(const AEvent: RGestureEvent): bool
What UIWidget.OnGesture runs for each gesture on the widget: true when it handled it.
UIAskFunc
type UIAskFunc = ref func(): bool
What UIWindow.OnBack / OnClose run: true when the back is handled / the window may close.
UIKeyboardFunc
type UIKeyboardFunc = ref func(const AVisible: bool; const AHeight: float32)
What UIWindow.OnKeyboard runs when the on-screen keyboard shows or hides: shown, and the height it covers.
UIResizeFunc
type UIResizeFunc = ref func(const AWidth: int32; const AHeight: int32)
What UIWindow.OnResize runs: the window's new size in logical units.
UIClosedFunc
type UIClosedFunc = ref func(const AResult: int32)
What a popup's or dialog's AOnClosed runs once when it closes: its result.
UIToggleFunc
type UIToggleFunc = ref func(const AOn: bool)
A control's on / off closure: a check box's checked state, an expander's expanded one.
UIIndexFunc
type UIIndexFunc = ref func(const AIndex: int32)
A control's index closure: the tab, item or page chosen.
UIValueFunc
type UIValueFunc = ref func(const AValue: float32)
A control's value closure: a slider's or a rating's value.
UIValue64Func
type UIValue64Func = ref func(const AValue: float64)
A spin box's value closure.
UITextFunc
type UITextFunc = ref func(const AText: string)
A control's text closure: a text input's text, a label link's URL.
UIDateFunc
type UIDateFunc = ref func(const AYear: int32; const AMonth: int32; const ADay: int32)
A date picker's closure: the date chosen.
UITimeFunc
type UITimeFunc = ref func(const AHour: int32; const AMinute: int32; const ASecond: int32)
A time picker's closure: the time chosen.
UIColorFunc
type UIColorFunc = ref func(const AColor: UIColor)
A colour picker's closure: the colour chosen.
UITabCloseFunc
type UITabCloseFunc = ref func(const ATab: UITab): bool
A tab view's close closure: the tab whose close button was pressed; true lets Raven delete its page, false keeps it (the program may ask, then destroy the page itself).
UIAppConfig
type UIAppConfig = object
How the app opens, built fluently: every method returns the config, Open opens the app. Start one with UIApp.Config(). Raven's defaults: the default backend, worker threads by the CPU count, a render thread, vsync on, no validation, OS windows, the system's UI scale.
Members
init(): Raven's defaults (see the type).method AppName(const AName: string): self: The application's name (the system's notifications, taskbar and settings show it). Parameters:ANamethe name. Returns: this object, so calls chainmethod WorkerThreads(const ACount: int32): self: The worker threads Raven runs (0: one a CPU core, the default). Parameters:ACounthow many. Returns: this object, so calls chainmethod NoRenderThread(const AOn: bool): self:trueto render on the UI thread rather than a render thread of its own. Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainmethod NoVsync(const AOn: bool): self:trueto draw frames without waiting for the display (vsync off). Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainmethod Validation(const AOn: bool): self:trueto turn the GPU driver's validation on (slower: finds rendering mistakes). Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainmethod Headless(const AOn: bool): self:truefor no OS window: windows draw off screen and take their input by injection (tools, tests). Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainmethod UIScale(const AScale: float32): self: The UI scale (0: the system's, the default; 2: everything twice as big). Parameters:AScalethe scale. Returns: this object, so calls chainmethod Backend(const ABackend: UIBackend): self: The renderer (UIBackend.Nullrenders nothing: headless runs and tests). Parameters:ABackendthe backend. Returns: this object, so calls chainconst method Open(): UIApp: Opens the app as configured. C: Rinit, Rinit_ex Returns: the app;IsValid()false when Raven did not open (its error reported toUIErrors) or an app is open already
Example: LApp := UIApp.Config().AppName("Notes").Backend(UIBackend.Vulkan).Open();
UIApp
type UIApp = object
The app: Raven itself, one per program. A shared handle: the last copy's release ends Raven (every <Name>Res still alive destroyed first). Open it with UIApp.Config()...Open() or UIApp(name); run it with Run() (a tool) or a loop of Frame() (a game or an engine).
Members
init(): An empty handle (holds no app:IsValid()false), as a variable declared with no arguments starts.init(const AName: string): Opens the app namedANamewith Raven's defaults: the short form ofUIApp.Config().AppName(AName).Open(). Parameters:ANamethe name.static method Config(): UIAppConfig: A config with Raven's defaults, to open the app with. Returns: a config with Raven's defaults, to open the app withstatic method Current(): UIApp: The app open now (an empty handle when none is). Returns: the app open now (an empty handle when none is)const method IsValid(): bool:truewhile this handle holds the open app. Returns:truewhile this handle holds the open appstatic method Shutdown(): Ends Raven now, before its last handle goes (a host ending its UI before its own device or window): every<Name>Resdestroyed, every closure let go; each copy of the app is then empty (IsValid()false). C: Rshutdownstatic method Initialized(): bool:truewhile Raven is open (any app). C: Ris_initialized Returns:truewhile Raven is open (any app)static method Version(): string: Raven's version, e.g."0.3.0". C: Rget_version Returns: raven's version, e.gconst method Running(): bool:trueuntilQuitis called or the last window is closed. C: Ris_running Returns:trueuntilQuitis called or the last window is closedconst method Paused(): bool:truewhile the system has the app paused (a phone's app in the background). C: Ris_app_paused Returns:truewhile the system has the app paused (a phone's app in the background)const method OnUIThread(): bool:truewhen called on the UI thread (the one that opened the app). C: Ris_ui_thread Returns:truewhen called on the UI thread (the one that opened the app)const method ExitCode(): int32: The exit codeQuitset (0 when none was). C: Rget_exit_code Returns: the exit codeQuitset (0 when none was)const method Delta(): float64: The seconds the last frame took. C: Rget_delta_time Returns: the seconds the last frame tookconst method Time(): float64: The seconds since the app opened. C: Rget_time Returns: the seconds since the app openedmethod Vsync(const AOn: bool): self: Waits for the display before each frame (true, the default) or not. C: Rset_vsync Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Vsync(): bool:truewhen frames wait for the display. C: Rget_vsync Returns:truewhen frames wait for the displaymethod UIScale(const AScale: float32): self: The UI scale (2: everything twice as big). C: Rset_ui_scale Parameters:AScalethe scale. Returns: this object, so calls chainconst method UIScale(): float32: The UI scale. C: Rget_ui_scale Returns: the UI scalemethod Direction(const ADirection: UIDirection): self: The layout direction of every window (right to left for Arabic or Hebrew). C: Rset_layout_direction Parameters:ADirectionthe direction. Returns: this object, so calls chainconst method Direction(): UIDirection: The layout direction. C: Rget_layout_direction Returns: the layout directionmethod Animations(const AOn: bool): self: Animations on (true, the default) or off. C: Rset_animations_enabled Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Animations(): bool:truewhen animations are on. C: Rget_animations_enabled Returns:truewhen animations are onmethod AnimationSpeed(const ASpeed: float32): self: How fast animations run (1: as designed, 0.5: half speed). C: Rset_animation_speed Parameters:ASpeedthe speed. Returns: this object, so calls chainconst method AnimationSpeed(): float32: How fast animations run. C: Rget_animation_speed Returns: how fast animations runmethod AnimationStep(const ASeconds: float64): self: Animations stepASecondseach frame rather than by the clock (0: by the clock), for frames that come out the same every run (recordings, tests). C: Rset_animation_time_step Parameters:ASecondsthe time, in seconds. Returns: this object, so calls chainconst method WorkerThreads(): int32: The worker threads Raven runs. C: Rget_worker_thread_count Returns: the worker threads Raven runsmethod Run(): int32: Runs the app untilQuitis called or the last window is closed, drawing a frame whenever something changed and sleeping between (a tool's loop). Returns: the exit codeQuitsetmethod Frame(): bool: Draws one frame of every window: processes the pending events, runs the posted tasks and timers, then lays out and paints what changed (a game's loop calls it each turn). C: Rdraw_frame Returns:falseonceQuitwas called or the last window is closedmethod WaitFrame(const ATimeout: float64): bool: Sleeps until something happens (an event, a task, a timer) orATimeoutseconds pass (a negative one: no limit), then draws a frame. C: Rwait_frame Parameters:ATimeoutthe timeout. Returns:falseonceQuitwas called or the last window is closedmethod WaitEvents(const ATimeout: float64): Sleeps until an event comes orATimeoutseconds pass, drawing nothing. C: Rwait_events Parameters:ATimeoutthe timeout.method PollEvents(): Takes the pending OS events, drawing nothing. C: Rpoll_eventsmethod Quit(): Ends the loop with exit code 0 (Runreturns,Framegivesfalse). Any thread. C: Rquitmethod Quit(const ACode: int32): Ends the loop with exit codeACode. Any thread. C: Rquit Parameters:ACodethe exit code.method WakeUp(): Wakes aWaitFrame/WaitEventssleeping on the UI thread. Any thread. C: Rwake_upmethod InjectAppEvent(const AEvent: UIAppEvent): Acts as if the system sent the life-cycle eventAEvent(tests). C: Rinject_app_event Parameters:AEventthe event.method OnFrame(const AFunc: UIFrameFunc): self: RunsAFuncat every frame with the seconds since the frame before (nil: none). C: Rset_frame_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainmethod OnAppEvent(const AFunc: UIAppEventFunc): self: RunsAFuncon each life-cycle event (nil: none). C: Rset_app_event_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainmethod OnDeviceReset(const AFunc: UITaskFunc): self: RunsAFuncafter the GPU device was lost and Raven made a new one, on the UI thread, to rebuild what the program made itself (nil: none). C: Rset_device_reset_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainmethod Post(const AFunc: UITaskFunc): RunsAFunconce on the UI thread, at the next frame. Any thread: the way a worker hands its result to the UI. C: Rtask_post Parameters:AFuncthe func it runs. Example:LApp.Post(func() begin LStatus.Text("done"); end);const method MemoryStats(): RMemoryStats: Raven's memory use. C: Rmemory_get_stats Returns: raven's memory useconst method MemoryCheck(): bool: Checks Raven's memory for damage (a debug aid). C: Rmemory_check Returns:truewhen it is soundmethod MemoryTrim(): Gives the memory Raven keeps for reuse back to the heap. C: Rmemory_trimstatic method ClipboardText(): string: The clipboard's text ("" when it holds none). C: Rclipboard_get_text Returns: the clipboard's text ("" when it holds none)static method ClipboardText(const AText: string): PutsATexton the clipboard. C: Rclipboard_set_text Parameters:ATextthe text.static method ClipboardHTML(const AText: string; const AHTML: string): PutsATexton the clipboard withAHTMLas its formatted form (pasted into a program that takes HTML). C: Rclipboard_set_html Parameters:ATextthe text;AHTMLthe HTML.static method Notify(const ATitle: string; const ABody: string): bool: Shows a system notification of normal urgency. C: Rnotification_show Parameters:ATitlethe title;ABodythe body. Returns:truewhen the system showed it (orNotifyFallback's routine took it)static method Notify(const ATitle: string; const ABody: string; const AUrgency: UIUrgency): bool: Shows a system notification of urgencyAUrgency. C: Rnotification_show Parameters:ATitlethe title;ABodythe body;AUrgencythe urgency. Returns:truewhen the system showed it (orNotifyFallback's routine took it)static method NotifySupported(): bool:truewhen the system shows notifications. C: Rnotification_is_supported Returns:truewhen the system shows notificationsmethod NotifyFallback(const AFunc: UINotifyFunc): self: RunsAFuncfor a notification the system cannot show, to show it another way (a toast in the window; nil: none). C: Rnotification_set_fallback Parameters:AFuncthe func it runs. Returns: this object, so calls chainmethod OnNotifyClicked(const AFunc: UITaskFunc): self: RunsAFuncwhen the user clicks a notification the app showed (nil: none). C: Rnotification_set_clicked_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainstatic method TaskbarBadge(const AText: string): bool: ShowsATextas the badge on the app's taskbar button ("" removes it). C: Rtaskbar_set_badge Parameters:ATextthe text. Returns:truewhen the system has taskbar badgesstatic method JumpList(const ATasks: array of UIJumpTask): bool: The tasks of the app's taskbar jump list, in order (none: it is cleared). C: Rtaskbar_set_jump_list Parameters:ATasksthe tasks. Returns:truewhen the system has jump lists
Example: LApp := UIApp("Notes"); LApp.OnFrame(func(const ADelta: float64) begin Tick(ADelta); end); return LApp.Run();
UIErrors
type UIErrors = object
Raven's errors: the last one, their texts, a routine run for each, the console report. Raven reports every error as it happens (a bad id, a missing file, a bad XML attribute ...); the program sees them through OnError or Report, or asks Last.
Members
static method Last(): UIRavenError: The error Raven reported last (UIErrorCode.Nonewhen none was). C: Rerror_get_last Returns: the error Raven reported last (UIErrorCode.Nonewhen none was)static method Text(const ACode: UIErrorCode): string: The name of the error codeACode, e.g."R_ERROR_INVALID_ID". C: Rerror_to_string Parameters:ACodethe error code. Returns: the name of the error codeACode, e.gstatic method Text(const ASeverity: UISeverity): string: The name of the severityASeverity. C: Rseverity_to_string Parameters:ASeveritythe severity. Returns: the name of the severityASeveritystatic method OnError(const AFunc: UIErrorFunc): RunsAFuncfor every error Raven reports, with its code, severity and detail, in place ofReport's console lines (nil: none). Set it before the app opens to see the errors of opening too. C: Rerror_set_callback Parameters:AFuncthe func it runs.static method Report(): Writes every error Raven reports on the console, one line each:[Raven] <code> (<severity>): <detail>, in place of anOnErrorroutine. Call it before the app opens so the errors of opening are seen too;OnError(nil)turns it off. Example:UIErrors.Report(); LApp := UIApp("Game");
UITimerRes
type UITimerRes = object
A timer: runs its routine every AInterval seconds (or once) on the UI thread, during a frame. A shared handle: the last copy destroys the timer, the app's end too. C: Rtimer_destroy (the last copy's release)
Members
init(): An empty handle (holds no timer:IsValid()false), as a variable declared with no arguments starts.init(const AInterval: float64; const ARepeat: bool; const AFunc: UITimerFunc): A timer runningAFuncafterAIntervalseconds, then again everyAIntervalseconds whenARepeatistrue(the app must be open). C: Rtimer_create Parameters:AIntervalthe interval;ARepeattrueto run again every interval;AFuncthe func it runs.const method IsValid(): bool:truewhile the timer runs (a one-shot timer that fired runs no more). C: Rtimer_is_valid Returns:truewhile the timer runs (a one-shot timer that fired runs no more)static method Of(const ATimer: Rid): UITimerRes: A handle to the timerATimerthis layer made (sharing its holder), as its routine is handed when it fires; an empty handle for any other Rid. Parameters:ATimerthe timer. Returns: a handle to the timerATimerthis layer made (sharing its holder), as its routine is handed when it fires; an empty handle for any other Ridconst method Id(): Rid: The timer's Rid, for .C calls (R_INVALID_IDwhen the handle holds none). Returns: the timer's Rid, for .C calls (R_INVALID_IDwhen the handle holds none)
Example: LTick := UITimerRes(1.0, true, func(const ATimer: UITimerRes) begin Refresh(); end);
UIPixels
type UIPixels = record
Decoded pixels: Width x Height, four bytes each (red, green, blue, alpha), rows from the top, tightly packed. UITextureRes.Decode gives them; textures, window and tray icons take them.
Members
Width: int32: The width in pixels.Height: int32: The height in pixels.RGBA: array of uint8: The pixels:Width * Height * 4bytes.
Example: LIcon := UITextureRes.Decode(LPNG); LWindow.Icon(LIcon);
UITextureRes
type UITextureRes = object
A picture on the GPU that images, icons, viewports, backgrounds and painters show: from an image file (PNG, JPEG, BMP, TGA, GIF, PSD, SVG), its bytes, an SVG text or pixels, decoded at once or on a worker thread (Load). A shared handle: the last copy destroys the texture (the app's end too); what shows it keeps a copy while it does. C: Rtexture_* (Rtexture_destroy: the last copy's release)
Members
init(): An empty handle (holds no texture:IsValid()false), as a variable declared with no arguments starts.init(const APath: string): The texture of the image file atAPath(through the program's IO hooks), decoded now (empty when it cannot be read; the app must be open). C: Rtexture_create_from_file Parameters:APaththe file's path.static method View(const ATexture: Rid): UITextureRes: A borrowed handle of the textureATexture(a Rid System.Raven.C gave): it never destroys it. Parameters:ATexturethe texture. Returns: a borrowed handle of the textureATexture(a Rid System.Raven.C gave): it never destroys itstatic method Adopt(const ATexture: Rid): UITextureRes: The handle owning the textureATexturea System.Raven.C call made (it destroys it with its last copy, the app's end too). Parameters:ATexturethe texture. Returns: the handle owning the textureATexturea System.Raven.C call made (it destroys it with its last copy, the app's end too)static method FromIO(const AIO: IO): UITextureRes: The texture of the image file read fromAIO(from where it stands to its end), decoded now (empty when it cannot be read). C: Rtexture_create Parameters:AIOthe IO. Returns: the texture of the image file read fromAIO(from where it stands to its end), decoded now (empty when it cannot be read)static method FromMemory(const AData: array of uint8): UITextureRes: The texture of the image file bytesAData, decoded now (Raven copies them). C: Rtexture_create Parameters:ADatathe bytes. Returns: the texture of the image file bytesAData, decoded now (Raven copies them)static method FromSVG(const ASVG: string; const AScale: float32): UITextureRes: The SVG textASVGdrawn into a texture atAScalepixels per SVG unit (widgets show it at the SVG's own size whatever the scale:Density). Paths, fills, strokes and gradients are drawn; text, filters and masks are not. C: Rtexture_create_from_svg Parameters:ASVGthe SVG;AScalethe scale. Returns: the SVG textASVGdrawn into a texture atAScalepixels per SVG unit (widgets show it at the SVG's own size whatever the scale:Density)static method FromPixels(const APixels: UIPixels): UITextureRes: A texture of the pixelsAPixels(empty when they hold fewer bytes than their size needs). C: Rtexture_create_from_pixels Parameters:APixelsthe pixels. Returns: a texture of the pixelsAPixels(empty when they hold fewer bytes than their size needs)static method Load(const APath: string): UITextureRes: The texture of the image file atAPath, decoded on a worker thread: the handle is usable at once, what shows it draws nothing until it isReady. C: Rtexture_create_from_file_async Parameters:APaththe file's path. Returns: the texture of the image file atAPath, decoded on a worker thread: the handle is usable at once, what shows it draws nothing until it isReadystatic method LoadMemory(const AData: array of uint8): UITextureRes: The texture of the image file bytesAData, decoded on a worker thread (Raven copies them), asLoad. C: Rtexture_create_async Parameters:ADatathe bytes. Returns: the texture of the image file bytesAData, decoded on a worker thread (Raven copies them), asLoadstatic method Decode(const AData: array of uint8): UIPixels: The image file bytesADatadecoded to pixels, on the calling thread (any thread), with no texture made: empty pixels (Width 0) when Raven cannot read them. C: Rimage_decode, Rpixels_free Parameters:ADatathe bytes. Returns: the image file bytesADatadecoded to pixels, on the calling thread (any thread), with no texture made: empty pixels (Width 0) when Raven cannot read themconst method IsValid(): bool:truewhile it holds a texture Raven still has. C: Rtexture_is_valid Returns:truewhile it holds a texture Raven still hasconst method Id(): Rid: The texture's Rid, for .C calls (R_INVALID_IDwhen the handle holds none or it is destroyed). Returns: the texture's Rid, for .C calls (R_INVALID_IDwhen the handle holds none or it is destroyed)const method Ready(): bool:trueonce it is decoded (always for one decoded at once). C: Rtexture_is_ready Returns:trueonce it is decoded (always for one decoded at once)const method Wait(): self: Waits until a texture decoding on a worker thread is ready. C: Rtexture_wait Returns: this object, so calls chainconst method Size(): UISize: Its size in pixels (0 x 0 while it is not ready). C: Rtexture_get_size Returns: its size in pixels (0 x 0 while it is not ready)const method Density(): float32: Its pixels per logical unit: an SVG's scale, 1 otherwise. C: Rtexture_get_density Returns: its pixels per logical unit: an SVG's scale, 1 otherwiseconst method Update(const APixels: UIPixels): self: Its pixels replaced byAPixels(their size may differ; nothing when they hold fewer bytes than their size needs). C: Rtexture_update Parameters:APixelsthe pixels. Returns: this object, so calls chainconst method Filter(const AFilter: UIFilter): self: How it is sampled when drawn at another size. C: Rtexture_set_filter Parameters:AFilterthe filter. Returns: this object, so calls chain
Example: LLogo := UITextureRes("$P:../../../../res/assets/ui/logo.png"); UIImage.Create().Texture(LLogo).Stretch(UIStretch.Fit);
UIFontRes
type UIFontRes = object
A font for text: a TrueType / OpenType file's bytes (copied; glyphs drawn at the exact size each window scale needs), or the built-in Roboto (Default) and its fixed-width companion (Monospace). A shared handle: the last copy destroys the font (the app's end too); what shows it keeps a copy while it does. C: Rfont_* (Rfont_destroy: the last copy's release)
Members
init(): An empty handle (holds no font:IsValid()false), as a variable declared with no arguments starts.init(const APath: string): The font file atAPath(through the program's IO hooks; empty when it cannot be read; the app must be open). C: Rfont_create_from_file Parameters:APaththe file's path.static method View(const AFont: Rid): UIFontRes: A borrowed handle of the fontAFont(a Rid System.Raven.C gave): it never destroys it. Parameters:AFontthe font. Returns: a borrowed handle of the fontAFont(a Rid System.Raven.C gave): it never destroys itstatic method FromIO(const AIO: IO): UIFontRes: The font file read fromAIO(from where it stands to its end; empty when it cannot be read). C: Rfont_create Parameters:AIOthe IO. Returns: the font file read fromAIO(from where it stands to its end; empty when it cannot be read)static method FromMemory(const AData: array of uint8): UIFontRes: The font file bytesAData(Raven copies them). C: Rfont_create Parameters:ADatathe bytes. Returns: the font file bytesAData(Raven copies them)static method Default(): UIFontRes: The font built into Raven (Roboto: Latin and Latin Extended-A), borrowed. C: Rfont_get_default Returns: the font built into Raven (Roboto: Latin and Latin Extended-A), borrowedstatic method Monospace(): UIFontRes: The fixed-width font built into Raven (code, the text editor with a language), borrowed. C: Rfont_get_monospace Returns: the fixed-width font built into Raven (code, the text editor with a language), borrowedconst method IsValid(): bool:truewhile it holds a font Raven still has. C: Rfont_is_valid Returns:truewhile it holds a font Raven still hasconst method Id(): Rid: The font's Rid, for .C calls (R_INVALID_IDwhen the handle holds none or it is destroyed). Returns: the font's Rid, for .C calls (R_INVALID_IDwhen the handle holds none or it is destroyed)const method Fallback(const AFallback: UIFontRes): self:AFallbackdraws the characters this font lacks (an empty handle: none); kept while this font lives. C: Rfont_set_fallback Parameters:AFallbackthe fallback. Returns: this object, so calls chainconst method Variant(const AStyle: UIFontStyle; const AVariant: UIFontRes): self:AVariantdrawn for the styleAStyleof this font (bold, italic ..; an empty handle: the one Raven derives, glyphs thickened or slanted); kept while this font lives. C: Rfont_set_variant Parameters:AStylethe style;AVariantthe variant. Returns: this object, so calls chainconst method Variant(const AStyle: UIFontStyle): UIFontRes: The font drawn for the styleAStyleof this one: the variant given, else the one Raven derives (it lives as long as this font), borrowed. C: Rfont_get_variant Parameters:AStylethe style. Returns: the font drawn for the styleAStyleof this one: the variant given, else the one Raven derives (it lives as long as this font), borrowedconst method Measure(const ASize: float32; const AText: string): UISize: The size ofAText(UTF-8,\nstarting lines) at the font sizeASize(0: the theme's), in logical units at scale 1; an empty handle measures with the theme's font. C: Rfont_measure_text Parameters:ASizethe size;ATextthe text. Returns: the size ofAText(UTF-8,\nstarting lines) at the font sizeASize(0: the theme's), in logical units at scale 1; an empty handle measures with the theme's font
Example: LFont := UIFontRes("$P:../../../../res/assets/fonts/Inter.ttf"); UITheme.Font(LFont);
UIShaderRes
type UIShaderRes = object
A GPU effect: a SPIR-V fragment shader (written against Raven's raven_effect.glsl) that borders and painters draw, or one of Raven's built-in effects (Effect, borrowed). A shared handle: the last copy destroys the shader (the app's end too); what shows it keeps a copy while it does. C: Rshader_, Reffect_ (Rshader_destroy: the last copy's release)
Members
init(): An empty handle (holds no shader:IsValid()false), as a variable declared with no arguments starts.init(const APath: string; const AFlags: UIShaderFlags): The SPIR-V file atAPath(a .spv; through the program's IO hooks), drawn asAFlagssay (empty when it cannot be read). C: Rshader_create_from_file Parameters:APaththe file's path;AFlagsthe flags.static method View(const AShader: Rid): UIShaderRes: A borrowed handle of the shaderAShader(a Rid System.Raven.C gave): it never destroys it. Parameters:AShaderthe shader. Returns: a borrowed handle of the shaderAShader(a Rid System.Raven.C gave): it never destroys itstatic method FromSPIRV(const ASPIRV: array of uint8; const AFlags: UIShaderFlags): UIShaderRes: The SPIR-V codeASPIRV(copied), drawn asAFlagssay: empty when the code is not SPIR-V (a backend that refuses it reports an error and draws a rectangle). C: Rshader_create Parameters:ASPIRVthe SPIRV;AFlagsthe flags. Returns: the SPIR-V codeASPIRV(copied), drawn asAFlagssay: empty when the code is not SPIR-V (a backend that refuses it reports an error and draws a rectangle)static method Effect(const AEffect: UIEffect): UIShaderRes: The built-in effectAEffect(made the first time it is asked for), borrowed. C: Reffect_get Parameters:AEffectthe effect. Returns: the built-in effectAEffect(made the first time it is asked for), borrowedstatic method Effect(const AName: string): UIShaderRes: The built-in effect namedAName("aurora", "shimmer", "neon", "ripple", "plasma", "grain", "spotlight", "mesh"), borrowed; empty for another name. C: Reffect_find Parameters:ANamethe name. Returns: the built-in effect namedAName("aurora", "shimmer", "neon", "ripple", "plasma", "grain", "spotlight", "mesh"), borrowed; empty for another namestatic method EffectName(const AEffect: UIEffect): string: The name of the built-in effectAEffect("aurora" ..). C: Reffect_get_name Parameters:AEffectthe effect. Returns: the name of the built-in effectAEffect("aurora" ..)static method EffectDefaults(const AEffect: UIEffect): RShaderLook: The look the built-in effectAEffectis drawn with when none is given. C: Reffect_get_defaults Parameters:AEffectthe effect. Returns: the look the built-in effectAEffectis drawn with when none is givenstatic method Look(): RShaderLook: A look with Raven's starting values (colours, parameters, radius, animation), to change and hand toUIBorder.EffectorUIPainter.Shader. C: Rshader_look_init Returns: a look with Raven's starting values (colours, parameters, radius, animation), to change and hand toUIBorder.EffectorUIPainter.Shaderconst method IsValid(): bool:truewhile it holds a shader Raven still has. C: Rshader_is_valid Returns:truewhile it holds a shader Raven still hasconst method Id(): Rid: The shader's Rid, for .C calls (R_INVALID_IDwhen the handle holds none or it is destroyed). Returns: the shader's Rid, for .C calls (R_INVALID_IDwhen the handle holds none or it is destroyed)const method Flags(): UIShaderFlags: How it is drawn (UIShaderFlag.Backdrop: it reads what is behind it;Animated: redrawn every frame). C: Rshader_get_flags Returns: how it is drawn (UIShaderFlag.Backdrop: it reads what is behind it;Animated: redrawn every frame)const method Defaults(): RShaderLook: The look it is drawn with when none is given (a built-in effect's own, elseUIShaderRes.Look()'s). C: Rshader_look_defaults Returns: the look it is drawn with when none is given (a built-in effect's own, elseUIShaderRes.Look()'s)
Example: LWave := UIShaderRes("$P:wave.spv", []); LBorder.Effect(LWave, LWave.Defaults());
UITheme
type UITheme = object
The app's theme: the look (Look), dark or light, the colours, sizes, material and font every widget takes unless it has its own, styles by widget kind and class, the text editor's token colours, and themes loaded from XML (laid over the built-in ones, kept through a look switch) and used by name. All static. C: Rtheme_, Rlook_
Members
static method Look(const ALook: UILook): The look (Raven's own or glass, dark or light): the sizes set withMetricstay; colours and styles set here are lost (put them in a loaded theme to keep them). C: Rlook_set Parameters:ALookthe look.static method Look(): UILook: The look in use. C: Rlook_get Returns: the look in usestatic method Dark(const AOn: bool): Dark (true) or light colours for the look in use. C: Rtheme_set_dark Parameters:AOntrueto turn it on,falseto turn it off.static method Dark(): bool:truewhile the colours are dark. C: Rtheme_is_dark Returns:truewhile the colours are darkstatic method FollowSystem(const AOn: bool): Dark or light following the system's setting as it changes (true). C: Rtheme_follow_system Parameters:AOntrueto turn it on,falseto turn it off.static method SystemDark(): bool:truewhen the system is set to dark. C: Rtheme_get_system_dark Returns:truewhen the system is set to darkstatic method Accent(const AColor: UIColor): The accent colour (its alpha unused): selections, focus, the default buttons. C: Rtheme_set_accent Parameters:AColorthe colour.static method Wallpaper(const ATexture: UITextureRes): The picture behind the windows with no background of their own (an empty handle: the window colour); kept while it is set. C: Rtheme_set_wallpaper Parameters:ATexturethe texture.static method Wallpaper(): UITextureRes: The wallpaper, borrowed (empty for none). C: Rtheme_get_wallpaper Returns: the wallpaper, borrowed (empty for none)static method Color(const ARole: UIColorRole; const AColor: UIColor): The colour ofARolefor every widget with none of its own. C: Rtheme_set_color Parameters:ARolethe role;AColorthe colour.static method Color(const ARole: UIColorRole): UIColor: The colour ofARole. C: Rtheme_get_color Parameters:ARolethe role. Returns: the colour ofARolestatic method Metric(const AMetric: UIMetric; const AValue: float32): The sizeAMetric(font size, corner radius, paddings ..) for every widget with none of its own; kept through a look switch. C: Rtheme_set_metric Parameters:AMetricthe metric;AValuethe value.static method Metric(const AMetric: UIMetric): float32: The sizeAMetric. C: Rtheme_get_metric Parameters:AMetricthe metric. Returns: the sizeAMetricstatic method Material(const AMaterial: UIMaterial): What the panels are made of (solid or a glass). C: Rtheme_set_material Parameters:AMaterialthe material.static method Material(): UIMaterial: The material in use. C: Rtheme_get_material Returns: the material in usestatic method Font(const AFont: UIFontRes): The font of every text with none of its own (an empty handle: Raven's own); kept while it is set. C: Rtheme_set_font Parameters:AFontthe font.static method Font(): UIFontRes: The theme's font, borrowed. C: Rtheme_get_font Returns: the theme's font, borrowedstatic method StyleColor(const AWidget: string; const AClass: string; const ARole: UIColorRole; const AColor: UIColor): The colour ofARolefor the widgets of the kindAWidget(its XML name: "Button" ..; "": every kind) with the style classAClass("": whatever their classes); a style naming a kind and a class wins over one naming a class, over one naming a kind. C: Rtheme_set_style_color Parameters:AWidgetthe widget;AClassthe class name;ARolethe role;AColorthe colour.static method StyleMetric(const AWidget: string; const AClass: string; const AMetric: UIMetric; const AValue: float32): The sizeAMetricfor the widgets of the kindAWidget("": every kind) with the style classAClass("": whatever their classes), asStyleColor. C: Rtheme_set_style_metric Parameters:AWidgetthe widget;AClassthe class name;AMetricthe metric;AValuethe value.static method StyleMaterial(const AWidget: string; const AClass: string; const AMaterial: UIMaterial): The material of the widgets of the kindAWidget("": every kind) with the style classAClass("": whatever their classes), asStyleColor. C: Rtheme_set_style_material Parameters:AWidgetthe widget;AClassthe class name;AMaterialthe material.static method ClearStyles(): Every style set by kind and class removed. C: Rtheme_clear_stylesstatic method TokenColor(const AToken: UITokenKind; const AColor: UIColor): The text editors' colour of the token kindAToken. C: Rtheme_set_token_color Parameters:ATokenthe token;AColorthe colour.static method TokenColor(const AToken: UITokenKind): UIColor: The text editors' colour of the token kindAToken. C: Rtheme_get_token_color Parameters:ATokenthe token. Returns: the text editors' colour of the token kindATokenstatic method ClearTokenColors(): The token colours back to the look's. C: Rtheme_clear_token_colorsstatic method Load(const APath: string): string: Loads the theme file (XML) atAPath, ready toUse; loading a theme of a name that is loaded already updates every widget using it. Parameters:APaththe file's path. Returns: The theme's name; "" (the error reported) when it cannot be loaded. C: Rtheme_loadstatic method LoadText(const AXML: string): string: Loads a theme from the XML textAXML, asLoad. C: Rtheme_load_from_memory Parameters:AXMLthe XML text. Returns: the theme's name; "" (the error reported) when it cannot be loadedstatic method Use(const AName: string): bool: The theme namedAName(a built-in one, "Dark" .., or one loaded) for the app. Parameters:ANamethe name. Returns:false(the error reported) when no theme has that name. C: Rtheme_usestatic method Name(): string: The name of the theme in use ("Dark" at the start). C: Rtheme_get_name Returns: the name of the theme in use ("Dark" at the start)static method Count(): int32: The number of themes known (built in and loaded). C: Rtheme_get_count Returns: the number of themes known (built in and loaded)static method NameAt(const AIndex: int32): string: The name of the themeAIndex(0 ..Count() - 1; "" outside). C: Rtheme_get_name_at Parameters:AIndexthe index, from 0. Returns: the name of the themeAIndex(0 .static method Save(const APath: string; const AName: string): bool: Saves the theme namedANameas an XML file atAPath. Parameters:APaththe file's path;ANamethe name. Returns:falsewhen it cannot be written or no theme has that name. C: Rtheme_save
Example: UITheme.Look(UILook.RavenGlassDark); UITheme.Accent(UIColor.FromHex("#3a7bd5", UIColor.Black())); UITheme.Metric(UIMetric.CornerRadius, 10.0f);
UILayoutPart
type UILayoutPart = choices(
The parts of a child's place in its parent a UILayout sets (the others keep Raven's defaults).
Members
UILayoutPart.Fill: The partUILayout.Fillsets.UILayoutPart.Auto: The partUILayout.Autosets.UILayoutPart.Margin: The partUILayout.Marginsets.UILayoutPart.HAlign: The partUILayout.HAlignsets.UILayoutPart.VAlign: The partUILayout.VAlignsets.UILayoutPart.MaxSize: The partUILayout.MaxSizesets.UILayoutPart.Cell: The partUILayout.Cellsets.UILayoutPart.Span: The partUILayout.Spansets.UILayoutPart.Anchors: The partUILayout.Anchorssets.UILayoutPart.At: The partUILayout.Atsets.UILayoutPart.Size: The partUILayout.Sizesets.UILayoutPart.Pivot: The partUILayout.Pivotsets.UILayoutPart.Title: The partUILayout.Titlesets.
UILayoutParts
type UILayoutParts = set of UILayoutPart
A set of UILayoutPart.
UILayout
type UILayout = object
How a child sits in its parent (Raven's slot), built fluently: each method returns a copy with one more part set, UIWidget.Add(W, L) places a child with it, W.Layout(L) moves a placed one. Which parts a parent reads depends on its kind: a box's Fill / Auto, Margin, HAlign / VAlign and MaxSize; a grid's Cell and Span; a canvas's Anchors, At, Size and Pivot; a tab view's or dock area's Title. The fields are the parts' values, Parts says which are set: set them through the methods.
Members
Parts: UILayoutParts: The parts set.FillShare: float32: Fill's share of the free room.MarginLeft: float32: Margin's room on the left.MarginTop: float32: Margin's room on the top.MarginRight: float32: Margin's room on the right.MarginBottom: float32: Margin's room on the bottom.Horizontal: UIHAlign: HAlign's alignment across the slot's width.Vertical: UIVAlign: VAlign's alignment across the slot's height.Largest: float32: MaxSize's largest size along the parent's direction.Column: int32: Cell's column.Row: int32: Cell's row.Columns: int32: Span's columns.Rows: int32: Span's rows.AnchorMinX: float32: Anchors' top-left corner: its x, as a fraction of the parent's width (0..1).AnchorMinY: float32: Anchors' top-left corner: its y, as a fraction of the parent's height (0..1).AnchorMaxX: float32: Anchors' bottom-right corner: its x, as a fraction of the parent's width (0..1).AnchorMaxY: float32: Anchors' bottom-right corner: its y, as a fraction of the parent's height (0..1).X: float32: At's x position.Y: float32: At's y position.Width: float32: Size's width.Height: float32: Size's height.PivotX: float32: Pivot's x, as a fraction of the child's width (0.5: its centre).PivotY: float32: Pivot's y, as a fraction of the child's height (0.5: its centre).Caption: string: Title's text.init(): No part set: Raven's defaults.const method Fill(const AShare: float32): UILayout: The child takesAShareof the room its parent has left (a box's children share it by their shares). C: Rslot_set_fill Parameters:ASharethe share. Returns: the child takesAShareof the room its parent has left (a box's children share it by their shares)const method Auto(): UILayout: The child takes the room its content wants (the default). C: Rslot_set_auto Returns: the child takes the room its content wants (the default)const method Margin(const AAll: float32): UILayout: The same roomAAllaround every side of the child. C: Rslot_set_padding Parameters:AAllthe room on every side. Returns: the same roomAAllaround every side of the childconst method Margin(const ALeft: float32; const ATop: float32; const ARight: float32; const ABottom: float32): UILayout: Room around the child: left, top, right, bottom. C: Rslot_set_padding Parameters:ALeftthe room on the left;ATopthe room above;ARightthe room on the right;ABottomthe room below. Returns: the layout with that room setconst method HAlign(const AAlign: UIHAlign): UILayout: How the child lines up across its slot's width. C: Rslot_set_halign Parameters:AAlignthe alignment. Returns: how the child lines up across its slot's widthconst method VAlign(const AAlign: UIVAlign): UILayout: How the child lines up across its slot's height. C: Rslot_set_valign Parameters:AAlignthe alignment. Returns: how the child lines up across its slot's heightconst method Align(const AHorizontal: UIHAlign; const AVertical: UIVAlign): UILayout: Both alignments at once. C: Rslot_set_halign, Rslot_set_valign Parameters:AHorizontalthe horizontal;AVerticalthe vertical. Returns: the layout with both alignments setconst method MaxSize(const ALargest: float32): UILayout: The largest size the child takes along its parent's direction. C: Rslot_set_max_size Parameters:ALargestthe largest. Returns: the largest size the child takes along its parent's directionconst method Cell(const AColumn: int32; const ARow: int32): UILayout: The grid cell the child sits in. C: Rslot_set_grid Parameters:AColumnthe column, from 0;ARowthe row, from 0. Returns: the grid cell the child sits inconst method Span(const AColumns: int32; const ARows: int32): UILayout: The grid columns and rows the child spans from its cell. C: Rslot_set_grid_span Parameters:AColumnsthe columns;ARowsthe rows. Returns: the grid columns and rows the child spans from its cellconst method Anchors(const AMinX: float32; const AMinY: float32; const AMaxX: float32; const AMaxY: float32): UILayout: The child's corners on a canvas as fractions of it (0, 0, 1, 1 stretches it over the whole canvas). C: Rslot_set_anchors Parameters:AMinXthe min X;AMinYthe min Y;AMaxXthe max X;AMaxYthe max Y. Returns: the child's corners on a canvas as fractions of it (0, 0, 1, 1 stretches it over the whole canvas)const method At(const AX: float32; const AY: float32): UILayout: The child's position on a canvas, from its anchors. C: Rslot_set_position Parameters:AXthe x coordinate;AYthe y coordinate. Returns: the child's position on a canvas, from its anchorsconst method Size(const AWidth: float32; const AHeight: float32): UILayout: The child's size on a canvas. C: Rslot_set_size Parameters:AWidththe width;AHeightthe height. Returns: the child's size on a canvasconst method Pivot(const AX: float32; const AY: float32): UILayout: The point of the child its canvas position names, as fractions of the child (0.5, 0.5 its centre). C: Rslot_set_alignment Parameters:AXthe x coordinate;AYthe y coordinate. Returns: the point of the child its canvas position names, as fractions of the child (0.5, 0.5 its centre)const method Title(const AText: string): UILayout: The title a tab view's tab or a dock area's panel shows for the child. C: Rslot_set_title Parameters:ATextthe text. Returns: the title a tab view's tab or a dock area's panel shows for the child
Example: LRow.Add(LButton, UILayout().Fill(1).Margin(4).VAlign(UIVAlign.Center));
UIWidget
type UIWidget = object
A widget: a handle to one Raven owns (copying copies the handle; Raven destroys the widget with its parent, its window or the app). The base of every widget type: Find<T> and As<T> give the typed view of a widget, checking its kind. Its setters return the widget, so a tree is built in one chain (Add a child, End() back to the parent); its events take closures, released when Raven destroys the widget. Id() is the Rid for System.Raven.C's calls; UIWidget.Wrap(Rid) the handle of a Rid.
Members
init(): An empty handle (names no widget:IsValid()false), as a variable declared with no arguments starts.static method Create(const AKind: UIWidgetKind): UIWidget: A new widget of the kindAKindwith Raven's defaults, in no parent yet (the widget types' ownCreategive their typed handle). C: Rwidget_create Parameters:AKindthe kind. Returns: a new widget of the kindAKindwith Raven's defaults, in no parent yet (the widget types' ownCreategive their typed handle)static method FromXML(const APath: string): UIWidget: A widget tree made from the XML layout fileAPath(IsValid()false when it does not load: its error reported toUIErrors). C: Rwidget_create_from_xml_file Parameters:APaththe file's path. Returns: a widget tree made from the XML layout fileAPath(IsValid()false when it does not load: its error reported toUIErrors)static method FromXMLText(const AXML: string): UIWidget: A widget tree made from the XML layout textAXML. C: Rwidget_create_from_xml Parameters:AXMLthe XML text. Returns: a widget tree made from the XML layout textAXMLstatic method Wrap(const AId: Rid): UIWidget: The handle of the widget System.Raven.C gave asAId(R_INVALID_ID: an empty one). Parameters:AIdthe id. Returns: the handle of the widget System.Raven.C gave asAId(R_INVALID_ID: an empty one)static method Kinds(): UIWidgetKinds: The kinds of widget this type views: every kind (each widget type restates it with its own;Find<T>/As<T>/Is<T>check a widget's kind againstT.Kinds()). Returns: the kinds of widget this type views: every kind (each widget type restates it with its own;Find<T>/As<T>/Is<T>check a widget's kind againstT.Kinds())const method Id(): Rid: The widget's Rid, for System.Raven.C's calls. Returns: the widget's Rid, for System.Raven.C's callsconst method IsValid(): bool:truewhile the handle names a widget (one Raven has not destroyed). C: Rwidget_is_valid Returns:truewhile the handle names a widget (one Raven has not destroyed)const method Kind(): UIWidgetKind: The widget's kind. C: Rwidget_get_type Returns: the widget's kindconst method Destroy(): Destroys the widget and everything inside it (each told by itsOnDestroy); the handles naming them are no longer valid. C: Rwidget_destroyconst method Add(const AChild: UIWidget): self: PlacesAChildlast inside this widget, with Raven's default layout. C: Rwidget_add_child Parameters:AChildthe child widget. Returns: this object, so calls chainconst method Add(const AChild: UIWidget; const ALayout: UILayout): self: PlacesAChildlast inside this widget, sitting asALayoutsays. C: Rwidget_add_child, Rslot_* Parameters:AChildthe child widget;ALayoutthe layout. Returns: this object, so calls chainconst method Insert(const AIndex: int32; const AChild: UIWidget): self: PlacesAChildatAIndexamong this widget's children. C: Rwidget_insert_child Parameters:AIndexthe index, from 0;AChildthe child widget. Returns: this object, so calls chainconst method Insert(const AIndex: int32; const AChild: UIWidget; const ALayout: UILayout): self: PlacesAChildatAIndexamong this widget's children, sitting asALayoutsays. C: Rwidget_insert_child, Rslot_* Parameters:AIndexthe index, from 0;AChildthe child widget;ALayoutthe layout. Returns: this object, so calls chainconst method Remove(const AChild: UIWidget): self: TakesAChildout of this widget (it is not destroyed: place it again, or destroy it). C: Rwidget_remove_child Parameters:AChildthe child widget. Returns: this object, so calls chainconst method Clear(): self: Destroys every child of this widget. C: Rwidget_clear_children Returns: this object, so calls chainconst method Layout(const ALayout: UILayout): self: How the widget sits in its parent, set toALayout's parts. C: Rslot_* Parameters:ALayoutthe layout. Returns: this object, so calls chainconst method Parent(): UIWidget: The widget this one is inside (an empty handle for a window's content or a widget in no parent). C: Rwidget_get_parent Returns: the widget this one is inside (an empty handle for a window's content or a widget in no parent)const method End(): UIWidget: The end of a child built in a chain: its parent, to go on adding there (the builder's close; theBegin<Kind>forms of the container types open one). Returns: the end of a child built in a chain: its parent, to go on adding there (the builder's close; theBegin<Kind>forms of the container types open one) Example:LPanel.Add(LTitle).Add(LRow.Add(LOk).Add(LCancel).End())const method ChildCount(): int32: The children this widget holds. C: Rwidget_get_child_count Returns: the children this widget holdsconst method Child(const AIndex: int32): UIWidget: The child atAIndex(0 .. ChildCount() - 1; an empty handle outside). C: Rwidget_get_child Parameters:AIndexthe index, from 0. Returns: the child atAIndex(0 .const method Name(const AName: string): self: The nameFindlooks for (an XML layout'sName). C: Rwidget_set_name Parameters:ANamethe name. Returns: this object, so calls chainconst method Name(): string: The widget's name ("" for none). C: Rwidget_get_name Returns: the widget's name ("" for none)const method Find<T>(const AName: string): T: The widget namedANameinside this one (searched as Raven searches: the name an XML layout orNamegave it), as the widget typeT. RaisesADAM_RAVEN_EXC_NOT_FOUNDwhen no widget has the name andADAM_RAVEN_EXC_KINDwhen it is of a kindTdoes not view (the message names the name and both kinds). C: Rwidget_find Parameters:ANamethe name. Returns: the widget namedANameinside this one (searched as Raven searches: the name an XML layout orNamegave it), as the widget typeTExample:LWindow.Content().Find<UISlider>("volume").OnChanged(func(const AValue: float32) begin .. end);const method Has<T>(const AName: string): bool:truewhen a widget namedANameis inside this one andTviews its kind. Parameters:ANamethe name. Returns:truewhen a widget namedANameis inside this one andTviews its kindconst method TryFind<T>(const AName: string; var AWidget: T): bool: The widget namedANameinside this one intoAWidgetasT:false(AWidgetunchanged) when none has the name orTdoes not view its kind. Parameters:ANamethe name;AWidgetthe widget. Returns:truewhen it was found and viewed asTconst method As<T>(): T: This widget as the widget typeT. RaisesADAM_RAVEN_EXC_NOT_FOUNDfor an empty or destroyed handle,ADAM_RAVEN_EXC_KINDwhenTdoes not view its kind. Returns: this widget as the widget typeTconst method Is<T>(): bool:truewhen the handle names a widget whose kindTviews. Returns:truewhen the handle names a widget whose kindTviewsconst method HitTest(const APoint: UIPoint): UIWidget: The innermost widget inside this one underAPoint(window units) that takes the pointer (an empty handle for none). C: Rwidget_hit_test Parameters:APointthe point. Returns: the innermost widget inside this one underAPoint(window units) that takes the pointer (an empty handle for none)const method Pick(const APoint: UIPoint): UIWidget: The innermost widget inside this one underAPoint, whether it takes the pointer or not. C: Rwidget_pick Parameters:APointthe point. Returns: the innermost widget inside this one underAPoint, whether it takes the pointer or notconst method Visibility(const AVisibility: UIVisibility): self: Shown, hidden (its room kept) or collapsed (no room). C: Rwidget_set_visibility Parameters:AVisibilitythe visibility. Returns: this object, so calls chainconst method Visibility(): UIVisibility: WhatVisibility(..)sets, read back. C: Rwidget_get_visibility Returns: whatVisibility(..)set lastconst method Show(): self:Visibility(UIVisibility.Visible). Returns: this object, so calls chainconst method Hide(): self:Visibility(UIVisibility.Hidden): not drawn, its room kept. Returns: this object, so calls chainconst method Collapse(): self:Visibility(UIVisibility.Collapsed): not drawn, no room. Returns: this object, so calls chainconst method Enabled(const AOn: bool): self:falsegreys the widget out and it takes no input (nor do its children). C: Rwidget_set_enabled Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Enabled(): bool: WhatEnabled(..)sets, read back. C: Rwidget_is_enabled Returns:truewhenEnabled(..)turned it onconst method HitTestable(const AOn: bool): self:falselets the pointer pass through the widget to what is under it. C: Rwidget_set_hit_testable Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Opacity(const AOpacity: float32): self: How opaque the widget and its children are drawn (0..1). C: Rwidget_set_opacity Parameters:AOpacitythe opacity. Returns: this object, so calls chainconst method Clipping(const AOn: bool): self:truecuts the children's drawing to the widget's rectangle. C: Rwidget_set_clipping Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Tooltip(const AText: string): self: The text shown when the pointer rests on the widget ("" for none). C: Rwidget_set_tooltip Parameters:ATextthe text. Returns: this object, so calls chainconst method Tooltip(): string: WhatTooltip(..)sets, read back. C: Rwidget_get_tooltip Returns: the text shown when the pointer rests on the widget ("" for none)const method Cursor(const ACursor: UICursor): self: The pointer's shape over the widget. C: Rwidget_set_cursor Parameters:ACursorthe cursor. Returns: this object, so calls chainconst method Direction(const ADirection: UIDirection): self: The widget's text and layout direction (UIDirection.Inherit: its parent's). C: Rwidget_set_direction Parameters:ADirectionthe direction. Returns: this object, so calls chainconst method Direction(): UIDirection: WhatDirection(..)sets, read back. C: Rwidget_get_direction Returns: the widget's text and layout direction (UIDirection.Inherit: its parent's)const method Size(const AWidth: float32; const AHeight: float32): self: The widget's own size (0 for a side: its content's). C: Rwidget_set_size Parameters:AWidththe width;AHeightthe height. Returns: this object, so calls chainconst method MinSize(const AWidth: float32; const AHeight: float32): self: The smallest size the widget is given. C: Rwidget_set_min_size Parameters:AWidththe width;AHeightthe height. Returns: this object, so calls chainconst method MaxSize(const AWidth: float32; const AHeight: float32): self: The largest size the widget is given. C: Rwidget_set_max_size Parameters:AWidththe width;AHeightthe height. Returns: this object, so calls chainconst method Rect(): UIRect: Where the widget was laid out, in window units. C: Rwidget_get_rect Returns: where the widget was laid out, in window unitsconst method DesiredSize(): UISize: The size the widget asks for. C: Rwidget_get_desired_size Returns: the size the widget asks forconst method Hovered(): bool:truewhile the pointer is over the widget. C: Rwidget_is_hovered Returns:truewhile the pointer is over the widgetconst method Focusable(const AOn: bool): self:truelets the widget take the keyboard focus. C: Rwidget_set_focusable Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Focus(): self: Gives the widget the keyboard focus. C: Rwidget_focus Returns: this object, so calls chainconst method Focused(): bool:truewhile the widget has the keyboard focus. C: Rwidget_is_focused Returns:truewhile the widget has the keyboard focusconst method ScrollIntoView(): self: Scrolls every scroll box the widget is in until it is shown. C: Rwidget_scroll_into_view Returns: this object, so calls chainconst method Invalidate(): self: Has the widget drawn again at the next frame. C: Rwidget_invalidate Returns: this object, so calls chainconst method Transition(const ATransition: UITransition): self: The animation the widget plays each time it is shown. C: Rwidget_set_transition Parameters:ATransitionthe transition. Returns: this object, so calls chainconst method Transition(const ATransition: UITransition; const ADelay: float32): self: The animation the widget plays each time it is shown,ADelayseconds after. C: Rwidget_set_transition Parameters:ATransitionthe transition;ADelaythe delay. Returns: this object, so calls chainconst method Play(const ATransition: UITransition): self: Plays the animationATransitionon the widget now. C: Rwidget_play_transition Parameters:ATransitionthe transition. Returns: this object, so calls chainconst method Play(const ATransition: UITransition; const ADelay: float32): self: Plays the animationATransitionon the widgetADelayseconds from now. C: Rwidget_play_transition Parameters:ATransitionthe transition;ADelaythe delay. Returns: this object, so calls chainconst method WindowDrag(const AOn: bool): self:truemakes dragging the widget move its window (a custom title bar). C: Rwidget_set_window_drag Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Action(const AAction: string): self: The action the widget runs when it is used (a button's click ..: the app's actions). C: Rwidget_set_action Parameters:AActionthe action. Returns: this object, so calls chainconst method Action(): string: WhatAction(..)sets, read back. C: Rwidget_get_action Returns: the action the widget runs when it is used (a button's click ..: the app's actions)const method UserHandle(const AHandle: ptr): self: A pointer of the program's own kept with the widget (Raven never reads it). C: Rwidget_set_user_handle Parameters:AHandlethe handle. Returns: this object, so calls chainconst method UserHandle(): ptr: WhatUserHandle(..)sets, read back. C: Rwidget_get_user_handle Returns: a pointer of the program's own kept with the widget (Raven never reads it)const method Color(const ARole: UIColorRole; const AColor: UIColor): self: The colour the widget and its children drawARolewith (over the theme's). C: Rwidget_set_color Parameters:ARolethe role;AColorthe colour. Returns: this object, so calls chainconst method Color(const ARole: UIColorRole): UIColor: The colour the widget drawsARolewith. C: Rwidget_get_color Parameters:ARolethe role. Returns: the colour the widget drawsARolewithconst method ClearColor(const ARole: UIColorRole): self:ARoleback to the theme's colour. C: Rwidget_clear_color Parameters:ARolethe role. Returns: this object, so calls chainconst method Metric(const AMetric: UIMetric; const AValue: float32): self: The sizeAMetricthe widget and its children use (over the theme's). C: Rwidget_set_metric Parameters:AMetricthe metric;AValuethe value. Returns: this object, so calls chainconst method Metric(const AMetric: UIMetric): float32: WhatMetric(..)sets, read back. C: Rwidget_get_metric Parameters:AMetricthe metric. Returns: the sizeAMetricthe widget and its children use (over the theme's)const method ClearMetric(const AMetric: UIMetric): self:AMetricback to the theme's. C: Rwidget_clear_metric Parameters:AMetricthe metric. Returns: this object, so calls chainconst method Material(const AMaterial: UIMaterial): self: What the widget's panels are drawn as (solid, glass ..). C: Rwidget_set_material Parameters:AMaterialthe material. Returns: this object, so calls chainconst method Material(): UIMaterial: WhatMaterial(..)sets, read back. C: Rwidget_get_material Returns: what the widget's panels are drawn as (solid, glass ..)const method Theme(const AName: string): bool: A theme of their own for the widget and everything inside it, by name ("Dark", a themeUIThemeloaded; "" follows the app's theme again). Parameters:ANamethe name. Returns:false(the error reported) when no theme has that name. C: Rwidget_set_themeconst method Theme(const AKind: UIThemeKind): self: One of Raven's built-in themes for the widget and everything inside it. C: Rwidget_set_theme Parameters:AKindthe kind. Returns: this object, so calls chainconst method Theme(): string: The name of the theme the widget is drawn with. C: Rwidget_get_theme Returns: the name of the theme the widget is drawn withconst method Class(const AClasses: string): self: The widget's style classes, a space between each (a theme's rules match them). C: Rwidget_set_class Parameters:AClassesthe classes. Returns: this object, so calls chainconst method Class(): string: WhatClass(..)sets, read back. C: Rwidget_get_class Returns: the widget's style classes, a space between each (a theme's rules match them)const method AddClass(const AClass: string): self: Adds the style classAClass. C: Rwidget_add_class Parameters:AClassthe class name. Returns: this object, so calls chainconst method RemoveClass(const AClass: string): self: Takes the style classAClassaway. C: Rwidget_remove_class Parameters:AClassthe class name. Returns: this object, so calls chainconst method HasClass(const AClass: string): bool:truewhen the widget has the style classAClass. C: Rwidget_has_class Parameters:AClassthe class name. Returns:truewhen the widget has the style classAClassconst method Attribute(const AName: string; const AValue: string): bool: Sets one attribute as an XML layout writes it: any attribute of the widget's tag, its slot's and colours' too ("Visibility","Color.Accent","Slot.Fill"..). Parameters:ANamethe name;AValuethe text. Returns:falsefor an attribute the tag lacks or a value it refuses. C: Rwidget_set_attributeconst method TextKey(const AAttribute: string; const AKey: string): self: The attributeAAttribute("Text", "Tooltip" ..) shows the text the locale's strings giveAKey, again whenever the language changes. C: Rwidget_set_text_key Parameters:AAttributethe attribute;AKeythe key. Returns: this object, so calls chainconst method Text(const AText: string): bool: Sets the text the widget shows (itsTextattribute: a label's, a button's, a check box's, a text input's, a text editor's ..). Parameters:ATextthe text. Returns:falsefor a widget with no text. C: Rwidget_set_attributeconst method Text(): string: The text the widget shows: a label's, a check box's, a text input's, a text editor's, a menu item's, a date picker's or a toast's; "" for another kind (a button's text has no reading form in Raven) or an empty handle. C: Rlabel_get_text, Rcheckbox_get_text, Rtext_input_get_text, Rtext_editor_get_text, Rmenu_item_get_text, Rdate_picker_get_text, Rtoast_get_text Returns: the text the widget shows: a label's, a check box's, a text input's, a text editor's, a menu item's, a date picker's or a toast's; "" for another kind (a button's text has no reading form in Raven) or an empty handleconst method OnEvent(const AFunc: UIEventFunc): self: RunsAFuncfor each input event the widget gets, before its own handling;AFuncreturnstruewhen it handled the event (the widget's own handling skipped). C: Rwidget_set_event_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnDestroy(const AFunc: UITaskFunc): self: RunsAFuncwhen Raven destroys the widget (Destroy, its parent's or window's end, the app's end); its handle is no longer valid then. C: Rwidget_set_destroy_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnDrop(const AFunc: UIDropFunc): self: RunsAFuncat each stage of a drag and drop over the widget (files, text, a drag of the app's own);AFuncreturnstruewhen the widget takes the drop. C: Rwidget_set_drop_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnTouch(const AFunc: UITouchFunc): self: RunsAFuncfor each touch on the widget;truewhen it handled it. C: Rwidget_set_touch_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnPen(const AFunc: UIPenFunc): self: RunsAFuncfor each pen event on the widget;truewhen it handled it. C: Rwidget_set_pen_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnGesture(const AFunc: UIGestureFunc): self: RunsAFuncfor each gesture on the widget (pinch, swipe ..);truewhen it handled it. C: Rwidget_set_gesture_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method TouchMode(const AMode: UITouchMode): self: How touches on the widget act (UITouchMode.Auto: by its kind). C: Rwidget_set_touch_mode Parameters:AModethe mode. Returns: this object, so calls chainconst method TouchMode(): UITouchMode: WhatTouchMode(..)sets, read back. C: Rwidget_get_touch_mode Returns: how touches on the widget act (UITouchMode.Auto: by its kind)const method TouchGestures(const AOn: bool): self:truehas the widget get gestures (OnGesture). C: Rwidget_set_touch_gestures Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method TouchGestures(): bool: WhatTouchGestures(..)sets, read back. C: Rwidget_get_touch_gestures Returns:truewhenTouchGestures(..)turned it onconst method PenMouse(const AOn: bool): self:truehas a pen act as the mouse on the widget too. C: Rwidget_set_pen_mouse Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method PenMouse(): bool: WhatPenMouse(..)sets, read back. C: Rwidget_get_pen_mouse Returns:truewhenPenMouse(..)turned it onconst method AccessibleName(const AName: string): self: The name a screen reader says for the widget. C: Rwidget_set_accessible_name Parameters:ANamethe name. Returns: this object, so calls chainconst method AccessibleName(): string: WhatAccessibleName(..)sets, read back. C: Rwidget_get_accessible_name Returns: the name a screen reader says for the widgetconst method AccessibleDescription(const ADescription: string): self: The longer description a screen reader gives. C: Rwidget_set_accessible_description Parameters:ADescriptionthe description. Returns: this object, so calls chainconst method AccessibleRole(const ARole: UIRole): self: What a screen reader says the widget is (UIRole.Auto: by its kind). C: Rwidget_set_accessible_role Parameters:ARolethe role. Returns: this object, so calls chainconst method AccessibleRole(): UIRole: WhatAccessibleRole(..)sets, read back. C: Rwidget_get_accessible_role Returns: what a screen reader says the widget is (UIRole.Auto: by its kind)const method AccessibleHidden(const AOn: bool): self:truehides the widget and its children from screen readers. C: Rwidget_set_accessible_hidden Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method AccessibleLabelledBy(const ALabel: UIWidget): self: The widget whose text names this one for a screen reader. C: Rwidget_set_accessible_labelled_by Parameters:ALabelthe label. Returns: this object, so calls chainconst method AccessibleChecked(const AOn: bool): self: The checked state a screen reader says (a custom toggle's). C: Rwidget_set_accessible_checked Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method OnAccessiblePress(const AFunc: UITaskFunc): self: RunsAFuncwhen a screen reader presses the widget (a custom control's action). C: Rwidget_set_accessible_action Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method Font(const AFont: UIFontRes): self: A font for the widget and everything inside it, for the texts with none of their own (a label's or text editor's own font wins; an empty handle: the theme's); kept while it is set. C: Rwidget_set_font Parameters:AFontthe font. Returns: this object, so calls chainconst method Font(): UIFontRes: The fontFontgave the widget, borrowed (empty for none). C: Rwidget_get_font Returns: the fontFontgave the widget, borrowed (empty for none)
Example: LName := LWindow.Content().Find<UIWidget>("name").Text();
UIWindow
type UIWindow = object
A top-level window: a handle naming a window Raven owns (copies name the same window). Opened by UIWindowConfig.Open (UIWindow.Config()), UIWindow.Create or from XML; its content is a widget tree (Content, Find<T>). Raven destroys it when it closes or with the app; its handles are then no longer valid (IsValid()).
Members
init(): An empty handle (names no window:IsValid()false), as a variable declared with no arguments starts.static method Config(): UIWindowConfig: A window opened in a chain (UIWindowConfig): title, size, flags and the rest, thenOpen(). Returns: a window opened in a chain (UIWindowConfig): title, size, flags and the rest, thenOpen()static method Create(const ATitle: string; const AWidth: int32; const AHeight: int32): UIWindow: Opens a window of the titleATitleand the sizeAWidthxAHeight(logical units), shown with Raven's defaults. C: Rwindow_create Parameters:ATitlethe title;AWidththe width;AHeightthe height. Returns: the newUIWindowstatic method FromXML(const APath: string): UIWindow: A window made from the XML window fileAPath(IsValid()false when it does not load: its error reported toUIErrors). C: Rwindow_create_from_xml_file Parameters:APaththe file's path. Returns: a window made from the XML window fileAPath(IsValid()false when it does not load: its error reported toUIErrors)static method FromXMLText(const AXML: string): UIWindow: A window made from the XML window textAXML. C: Rwindow_create_from_xml Parameters:AXMLthe XML text. Returns: a window made from the XML window textAXMLstatic method Wrap(const AId: Rid): UIWindow: The handle of the window System.Raven.C gave asAId(R_INVALID_ID: an empty one). Parameters:AIdthe id. Returns: the handle of the window System.Raven.C gave asAId(R_INVALID_ID: an empty one)const method Id(): Rid: The window's Rid, for System.Raven.C's calls. Returns: the window's Rid, for System.Raven.C's callsconst method IsValid(): bool:truewhile the handle names a window (one Raven has not destroyed). C: Rwindow_is_valid Returns:truewhile the handle names a window (one Raven has not destroyed)const method Close(): Asks the window to close, as its title bar's close does: itsOnClosemay refuse. C: Rwindow_closeconst method Destroy(): Closes the window at once (noOnCloseasked) and destroys its content; its handles are no longer valid and its closures are released. C: Rwindow_destroyconst method Content(const AWidget: UIWidget): self:AWidgetas the window's content (the root of what it shows). C: Rwindow_set_content Parameters:AWidgetthe widget. Returns: this object, so calls chainconst method Content(): UIWidget: The window's content (an empty handle when it has none). C: Rwindow_get_content Returns: the window's content (an empty handle when it has none)const method Find<T>(const AName: string): T: The widget namedANamein the window's content, viewed asT(UIWidget.Find<T>). Parameters:ANamethe name. Returns: the widget namedANamein the window's content, viewed asT(UIWidget.Find<T>) Raises:ADAM_RAVEN_EXC_NOT_FOUNDwhen none has the name,ADAM_RAVEN_EXC_KINDwhen it is of a kindTdoes not viewconst method Has<T>(const AName: string): bool:truewhen a widget of a kindTviews is namedANamein the window's content. Parameters:ANamethe name. Returns:truewhen a widget of a kindTviews is namedANamein the window's contentconst method Title(const ATitle: string): self: The title its title bar and the taskbar show. C: Rwindow_set_title Parameters:ATitlethe title. Returns: this object, so calls chainconst method Title(): string: WhatTitle(..)sets, read back. C: Rwindow_get_title Returns: the title its title bar and the taskbar showconst method Size(const AWidth: int32; const AHeight: int32): self: The client area's size in logical units. C: Rwindow_set_size Parameters:AWidththe width;AHeightthe height. Returns: this object, so calls chainconst method Size(): UISize: The client area's size in logical units. C: Rwindow_get_size Returns: the client area's size in logical unitsconst method MinSize(const AWidth: int32; const AHeight: int32): self: The smallest size the user can make it, in logical units. C: Rwindow_set_min_size Parameters:AWidththe width;AHeightthe height. Returns: this object, so calls chainconst method Position(const AX: int32; const AY: int32): self: Its top-left corner on the screen. C: Rwindow_set_position Parameters:AXthe x coordinate;AYthe y coordinate. Returns: this object, so calls chainconst method Position(): UIPoint: Its top-left corner on the screen. C: Rwindow_get_position Returns: its top-left corner on the screenconst method Center(): self: Centred on its screen. C: Rwindow_center Returns: this object, so calls chainconst method FramebufferSize(): UISize: The client area's size in pixels (its size x its scale). C: Rwindow_get_framebuffer_size Returns: the client area's size in pixels (its size x its scale)const method Scale(): float32: Pixels per logical unit on its screen (1.0 at 96 DPI). C: Rwindow_get_scale Returns: the pixels per logical unitconst method SafeArea(): RInsets: The edges system bars and notches cover (content laid out inside them). C: Rwindow_get_safe_area Returns: the edges system bars and notches cover (content laid out inside them)const method KeyboardArea(): RInsets: The edges the on-screen keyboard covers (zero while it is hidden). C: Rwindow_get_keyboard_area Returns: the edges the on-screen keyboard covers (zero while it is hidden)const method Show(): self: Shows the window. C: Rwindow_show Returns: this object, so calls chainconst method Hide(): self: Hides the window. C: Rwindow_hide Returns: this object, so calls chainconst method Focus(): self: Brings it forward as the window the user works in. C: Rwindow_focus Returns: this object, so calls chainconst method Maximize(): self: Maximizes the window. C: Rwindow_maximize Returns: this object, so calls chainconst method Minimize(): self: Minimizes the window. C: Rwindow_minimize Returns: this object, so calls chainconst method Restore(): self: Back from maximized or minimized. C: Rwindow_restore Returns: this object, so calls chainconst method Maximized(): bool: True while the window is maximized. C: Rwindow_is_maximized Returns:truewhen it is maximizedconst method Minimized(): bool: True while the window is minimized. C: Rwindow_is_minimized Returns:truewhen it is minimizedconst method Active(): bool:truewhile it is the window the user works in. C: Rwindow_is_active Returns:truewhile it is the window the user works inconst method BeginMove(): Starts the system's move of the window with the pointer (a custom header bar's drag). C: Rwindow_begin_moveconst method BeginResize(const AEdge: UIEdge): Starts the system's resize of the window from its edgeAEdge. C: Rwindow_begin_resize Parameters:AEdgethe edge.const method ClearColor(const AColor: UIColor): self: The colour the window is cleared to under its content. C: Rwindow_set_clear_color Parameters:AColorthe colour. Returns: this object, so calls chainconst method Backdrop(const ABackdrop: UIBackdrop): bool: What shows through behind its content (a transparent window's blur, acrylic, mica). Parameters:ABackdropthe backdrop. Returns:falsewhen the system cannot show it. C: Rwindow_set_backdropconst method Backdrop(): UIBackdrop: What shows through behind its content, asBackdrop(..)set it. C: Rwindow_get_backdrop Returns: the backdropconst method Theme(const AName: string): bool: A theme of its own, by name ("Dark", a themeUIThemeloaded; "" follows the app's). Parameters:ANamethe name. Returns:false(the error reported) when no theme has that name. C: Rwindow_set_themeconst method Theme(const AKind: UIThemeKind): self: One of Raven's built-in themes as its own. C: Rwindow_set_theme Parameters:AKindthe kind. Returns: this object, so calls chainconst method Theme(): string: The name of the theme it uses. C: Rwindow_get_theme Returns: the name of the theme it usesconst method HasOwnTheme(): bool:truewhen it has a theme of its own (not the app's). C: Rwindow_has_own_theme Returns:truewhen it has a theme of its own (not the app's)const method Opacity(const AOpacity: float32): bool: The whole window's opacity (0 clear .. 1 opaque). Parameters:AOpacitythe opacity. Returns:falsewhen the system cannot fade windows. C: Rwindow_set_opacityconst method Opacity(): float32: The whole window's opacity (0 clear .. 1 opaque). C: Rwindow_get_opacity Returns: the opacityconst method Topmost(const AOn: bool): bool:truekeeps it above the other windows. Parameters:AOntrueto turn it on,falseto turn it off. Returns:falsewhen the system cannot. C: Rwindow_set_topmostconst method Owner(const AOwner: UIWindow): bool: The window it belongs to: kept above it and minimized with it where the window system does it, destroyed with it everywhere (an empty handle: none). Parameters:AOwnerthe owner. Returns:falsewhen the window system cannot keep it with its owner (it is still destroyed with it), or nothing changed:AOwneris not valid or is owned by it. C: Rwindow_set_ownerconst method Owner(): UIWindow: The window it belongs to (an empty handle: none). C: Rwindow_get_owner Returns: the owner windowconst method PictureInPicture(const AOn: bool): bool:trueshows it as a small picture-in-picture window over the others. Parameters:AOntrueto turn it on,falseto turn it off. Returns:falsewhen the system cannot. C: Rwindow_set_picture_in_pictureconst method PictureInPicture(): bool: True while it shows as a picture-in-picture window. C: Rwindow_is_picture_in_picture Returns:truewhen it doesconst method PipLayout(const ACorner: UIPipCorner; const AWidth: int32; const AHeight: int32): self: Where the picture-in-picture window sits and its size. C: Rwindow_set_picture_in_picture_layout Parameters:ACornerthe corner;AWidththe width;AHeightthe height. Returns: this object, so calls chainconst method Inspector(const AOn: bool): self:trueshows Raven's widget inspector for it. C: Rwindow_set_inspector Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method InspectorShown(): bool: True while Raven's widget inspector is shown for it. C: Rwindow_is_inspector_shown Returns:truewhen it is shownconst method Inspector(): UIWindow: The inspector's own window (an empty handle while it is not shown). C: Rwindow_get_inspector Returns: the inspector's own window (an empty handle while it is not shown)const method SplashScreen(): bool:truefor the splash screen Raven showed at the start (destroyed once the app's main window is ready). C: Rwindow_is_splash_screen Returns:truefor the splash screen Raven showed at the start (destroyed once the app's main window is ready)const method Redraw(): Draws it again at the next frame. C: Rwindow_request_redrawconst method ContinuousRedraw(const AOn: bool): self:truedraws it every frame (games, live views), not only when something changed. C: Rwindow_set_continuous_redraw Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method UserHandle(const AHandle: ptr): self: A pointer of the program's own kept with the window. C: Rwindow_set_user_handle Parameters:AHandlethe handle. Returns: this object, so calls chainconst method UserHandle(): ptr: WhatUserHandle(..)sets, read back. C: Rwindow_get_user_handle Returns: a pointer of the program's own kept with the windowconst method NativeHandle(var ANative: RNativeWindow): bool: The system's own window (HWND, X11 Window, wl_surface ..) intoANative. Parameters:ANativereceives the native window. Returns:falsewhen the window has none (headless). C: Rwindow_get_native_handleconst method Capture(var AWidth: int32; var AHeight: int32): array of uint8: What the window shows, as RGBA bytes (AWidthxAHeightpixels, rows from the top); empty when it cannot be captured. Waits for the frame to be drawn. C: Rwindow_capture, Rpixels_free Parameters:AWidththe width;AHeightthe height. Returns: what the window shows, as RGBA bytes (AWidthxAHeightpixels, rows from the top); empty when it cannot be capturedconst method FrameStats(): RFrameStats: The last frame's timings and counts. C: Rwindow_get_frame_stats Returns: the last frame's timings and countsconst method FocusedWidget(): UIWidget: The widget keys go to (an empty handle: none). C: Rwindow_get_focused_widget Returns: the widget keys go to (an empty handle: none)const method HoveredWidget(): UIWidget: The widget under the pointer (an empty handle: none). C: Rwindow_get_hovered_widget Returns: the widget under the pointer (an empty handle: none)const method ClearFocus(): self: No widget has the keyboard focus. C: Rwindow_clear_focus Returns: this object, so calls chainconst method MousePosition(): UIPoint: The pointer in the window's logical units. C: Rwindow_get_mouse_position Returns: the pointer in the window's logical unitsconst method KeyDown(const AKey: UIKey): bool:truewhileAKeyis held down. C: Rwindow_is_key_down Parameters:AKeythe key. Returns:truewhileAKeyis held downconst method MouseDown(const AButton: UIPointerButton): bool:truewhileAButtonis held down. C: Rwindow_is_mouse_button_down Parameters:AButtonthe button. Returns:truewhileAButtonis held downconst method Mods(): UIModifiers: The modifier keys held down. C: Rwindow_get_modifiers Returns: the modifier keys held downconst method MouseInside(): bool:truewhile the pointer is over the window. C: Rwindow_is_mouse_inside Returns:truewhile the pointer is over the windowconst method TabNavigation(const AOn: bool): self:true(the default) moves the focus with Tab / Shift+Tab. C: Rwindow_set_tab_navigation Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Shortcut(const AKey: UIKey; const AMods: UIModifiers; const AAction: string): self:AKeywith the modifiersAModsruns the actionAAction(an actionUIActionsregistered). C: Rwindow_register_shortcut Parameters:AKeythe key;AModsthe modifier keys;AActionthe action. Returns: this object, so calls chainconst method RemoveShortcut(const AKey: UIKey; const AMods: UIModifiers): self: The shortcutAKeywithAModsremoved. C: Rwindow_unregister_shortcut Parameters:AKeythe key;AModsthe modifier keys. Returns: this object, so calls chainconst method WantsTextInput(): bool:truewhile a text field has the focus (the on-screen keyboard is wanted). C: Rwindow_wants_text_input Returns:truewhile a text field has the focus (the on-screen keyboard is wanted)const method TextInputInfo(var AInfo: RTextInputInfo): bool: The focused text field's keyboard settings intoAInfo. Parameters:AInfothe info. Returns:falsewhen no text field has the focus. C: Rwindow_get_text_input_infoconst method TextInputText(): string: The focused text field's text ("" when none has the focus). C: Rwindow_get_text_input_text Returns: the focused text field's text ("" when none has the focus)const method TextInputSelection(var AStart: int32; var AStop: int32): bool: The focused text field's selection intoAStart..AStop(byte offsets). Parameters:AStartthe start;AStopthe byte offset it ends at. Returns:falsewhen no text field has the focus. C: Rwindow_get_text_input_selectionconst method SelectTextInput(const AStart: int32; const AStop: int32): bool: The focused text field's selection set toAStart..AStop(byte offsets). Parameters:AStartthe start;AStopthe byte offset it ends at. Returns:falsewhen no text field has the focus. C: Rwindow_set_text_input_selectionconst method ReplaceTextInput(const AStart: int32; const AStop: int32; const AText: string): bool: The focused text field's bytesAStart..AStopreplaced byAText(an IME's commit). Parameters:AStartthe start;AStopthe byte offset it ends at;ATextthe text. Returns:falsewhen no text field has the focus. C: Rwindow_replace_text_inputconst method TextInputRect(): UIRect: Where the focused text field's caret is, for an IME's candidate window (zero when none has the focus). C: Rwindow_get_text_input_rect Returns: where the focused text field's caret is, for an IME's candidate window (zero when none has the focus)const method OnKeyboard(const AFunc: UIKeyboardFunc): self: RunsAFuncwhen the on-screen keyboard shows or hides (nil: none). C: Rwindow_set_keyboard_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnBack(const AFunc: UIAskFunc): self: RunsAFuncfor the system's back (Android's back, a mouse's back button):truewhen it handled it (nil: none). C: Rwindow_set_back_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method BackEnabled(const AOn: bool): self:truetells the system the window takes the back (itsOnBackruns). C: Rwindow_set_back_enabled Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method WantsBack(): bool: True while Back would be taken: a popup or dialog is open, orBackEnabled(true)said so. C: Rwindow_wants_back Returns:truewhen it wouldconst method OnClose(const AFunc: UIAskFunc): self: RunsAFuncwhen the user asks to close the window:truelets it close,falsekeeps it open (nil: it closes). C: Rwindow_set_close_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnResize(const AFunc: UIResizeFunc): self: RunsAFuncwith the new size (logical units) when the window is resized (nil: none). C: Rwindow_set_resize_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnDrop(const AFunc: UIDropFunc): self: RunsAFuncat each stage of a drag and drop over the window that no widget took:truewhen it takes the drop (nil: none). C: Rwindow_set_drop_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnEvent(const AFunc: UIEventFunc): self: RunsAFuncfor every input event before any widget gets it:truewhen it handled the event, so no widget gets it (nil: none). C: Rwindow_set_event_hook Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method HasPopup(): bool:truewhile a popup is open in the window. C: Rwindow_has_popup Returns:truewhile a popup is open in the windowconst method PopupCount(): int32: How many popups are open, the innermost last. C: Rwindow_get_popup_count Returns: how many popups are open, the innermost lastconst method Popup(const AIndex: int32): UIWidget: The content of the open popup atAIndex(0: the outermost). C: Rwindow_get_popup Parameters:AIndexthe index, from 0. Returns: the content of the open popup atAIndex(0: the outermost)const method ClosePopups(): self: Every open popup closed. C: Rwindow_close_popups Returns: this object, so calls chainconst method Popup(const AContent: UIWidget; const AAt: UIPoint; const AOnClosed: UIClosedFunc): OpensAContentas a popup atAAt(logical units);AOnClosedruns once with its result when it closes (nil: none). C: Rpopup_open Parameters:AContentthe content widget;AAtthe point;AOnClosedthe on closed.static method ClosePopup(const AContent: UIWidget; const AResult: int32): The popup whose content isAContentclosed with the resultAResult. C: Rpopup_close Parameters:AContentthe content widget;AResultthe result.static method PopupOpen(const AContent: UIWidget): bool:truewhileAContentis open as a popup. C: Rpopup_is_open Parameters:AContentthe content widget. Returns:truewhileAContentis open as a popupconst method Dialog(const AContent: UIWidget; const AOnClosed: UIClosedFunc): OpensAContentas a modal dialog over the window;AOnClosedruns once with its result when it closes (nil: none). C: Rdialog_open Parameters:AContentthe content widget;AOnClosedthe on closed.static method CloseDialog(const AContent: UIWidget; const AResult: int32): The dialog whose content isAContentclosed with the resultAResult. C: Rdialog_close Parameters:AContentthe content widget;AResultthe result.const method RunDialog(const AContent: UIWidget): int32: OpensAContentas a modal dialog and waits (the app's frames go on) until it closes. Parameters:AContentthe content widget. Returns: its result. C: Rdialog_runconst method HasDialog(): bool:truewhile a dialog is open over the window. C: Rwindow_has_dialog Returns:truewhile a dialog is open over the windowconst method Message(const ATitle: string; const AText: string; const AButtons: UIMessageButtons): UIMessageResult: Shows a message box over the window and waits for the user's answer. Parameters:ATitlethe title;ATextthe text;AButtonsthe buttons. Returns: the button pressed. C: Rmessage_box Example:if LWindow.Message("Quit", "Save first?", UIMessageButtons.YesNo) = UIMessageResult.Yes thenconst method TouchSettings(const ASettings: RTouchSettings): self: Its own touch and pen settings (over the app's,UITouch). C: Rwindow_set_touch_settings Parameters:ASettingsthe settings. Returns: this object, so calls chainconst method TouchSettings(): RTouchSettings: WhatTouchSettings(..)sets, read back. C: Rwindow_get_touch_settings Returns: its own touch and pen settings (over the app's,UITouch)const method TouchCount(): int32: How many fingers touch the window now. C: Rwindow_get_touch_count Returns: how many fingers touch the window nowconst method PenInRange(): bool:truewhile a pen hovers over or touches the window. C: Rwindow_is_pen_in_range Returns:truewhile a pen hovers over or touches the windowconst method TouchActive(): bool:truewhile a touch, its inertia or a gesture goes on. C: Rwindow_is_touch_active Returns:truewhile a touch, its inertia or a gesture goes onconst method AdvanceTouch(const ASeconds: float64): self: Moves the window's touch timing (long presses, inertia) on byASeconds(tests). C: Rwindow_advance_touch Parameters:ASecondsthe time, in seconds. Returns: this object, so calls chainconst method TaskbarProgress(const AState: UITaskbarProgress; const AValue: float32): bool: The progress its taskbar button shows (AValue0..1). Parameters:AStatethe state;AValuethe value. Returns:falsewhen the system shows none. C: Rwindow_set_taskbar_progressconst method RequestAttention(const ACritical: bool): bool: Flashes its taskbar button (ACritical: until the user looks, else once). Parameters:ACriticalthe critical. Returns:falsewhen the system cannot. C: Rwindow_request_attentionconst method InjectMove(const AAt: UIPoint): self: The pointer moved toAAt. C: Rwindow_inject_mouse_move Parameters:AAtthe point. Returns: this object, so calls chainconst method InjectButton(const AButton: UIPointerButton; const ADown: bool): self:AButtonpressed (ADown) or let go. C: Rwindow_inject_mouse_button Parameters:AButtonthe button;ADowntruefor pressed,falsefor let go. Returns: this object, so calls chainconst method InjectWheel(const ADelta: UIPoint): self: The wheel turned byADelta(x across, y up). C: Rwindow_inject_mouse_wheel Parameters:ADeltathe delta. Returns: this object, so calls chainconst method InjectKey(const AKey: UIKey; const ADown: bool; const AMods: UIModifiers): self:AKeypressed (ADown) or let go with the modifiersAMods. C: Rwindow_inject_key Parameters:AKeythe key;ADowntruefor pressed,falsefor let go;AModsthe modifier keys. Returns: this object, so calls chainconst method InjectText(const AText: string): self:ATexttyped (as a keyboard's text input). C: Rwindow_inject_text Parameters:ATextthe text. Returns: this object, so calls chainconst method InjectDrag(const AAt: UIPoint; const AInside: bool): bool: A drag from outside moved toAAt(AInsidefalse: it left the window). Parameters:AAtthe point;AInsidethe inside. Returns:truewhen something there takes it. C: Rwindow_inject_dragconst method InjectDrop(const AAt: UIPoint; const APaths: StringArray; const AText: string): bool: FilesAPathsand the textATextdropped from outside atAAt. Parameters:AAtthe point;APathsthe paths;ATextthe text. Returns:truewhen something there took the drop. C: Rwindow_inject_dropconst method InjectBack(): bool: The system's back pressed. Returns:truewhen the window handled it. C: Rwindow_inject_backconst method InjectTouch(const ATouchId: int32; const APhase: UITouchPhase; const AAt: UIPoint): self: The touchATouchIdat the stageAPhaseatAAt. C: Rwindow_inject_touch Parameters:ATouchIdthe touch id;APhasethe phase;AAtthe point. Returns: this object, so calls chainconst method InjectPen(const APhase: UIPenPhase; const AAt: UIPoint; const APressure: float32; const ATilt: UIPoint; const AButtons: UIPenButtons; const AEraser: bool): self: A pen at the stageAPhaseatAAt: its pressure (0..1), tilt (degrees), buttons held and eraser end. C: Rwindow_inject_pen Parameters:APhasethe phase;AAtthe point;APressurethe pressure;ATiltthe tilt;AButtonsthe buttons;AEraserthe eraser. Returns: this object, so calls chainconst method InjectGesture(const AKind: UIGestureKind; const APhase: UIGesturePhase; const AAt: UIPoint; const AScale: float32; const ARotation: float32; const APan: UIPoint; const AFingers: int32): self: A trackpad gestureAKindat the stageAPhaseatAAt: its scale and rotation changes, its pan and how many fingers. C: Rwindow_inject_trackpad_gesture Parameters:AKindthe kind;APhasethe phase;AAtthe point;AScalethe scale;ARotationthe rotation;APanthe pan movement;AFingersthe fingers. Returns: this object, so calls chainconst method InjectScroll(const ADelta: UIPoint): self: A trackpad's two-finger scroll byADelta. C: Rwindow_inject_trackpad_scroll Parameters:ADeltathe delta. Returns: this object, so calls chainconst method InjectScrollEnd(): self: The trackpad's scroll ended (its fingers lifted). C: Rwindow_inject_trackpad_scroll_end Returns: this object, so calls chainconst method Icon(const APixels: UIPixels): self: The window's icon (title bar, task bar) fromAPixels; empty pixels (Width 0) go back to the default (on Windows the executable's first icon). Windows and X11; nothing for pixels holding fewer bytes than their size needs. C: Rwindow_set_icon Parameters:APixelsthe pixels. Returns: this object, so calls chainconst method Background(const ATexture: UITextureRes): self: A picture behind the content, scaled to cover the window (what a glass theme's glass looks through; an empty handle removes it); kept while it is set. C: Rwindow_set_background Parameters:ATexturethe texture. Returns: this object, so calls chain
Example: LWindow := UIWindow.Config().Title("Notes").Size(800, 600).Center().Open();
UIWindowConfig
type UIWindowConfig = object
A window opened in a chain (UIWindow.Config()): each method sets one thing, Open() opens the window with them. Unset: an 800 x 600 window titled "", Raven's flags, place, theme and backdrop, no content.
Members
init(): The defaults (see the type).method Title(const ATitle: string): self: The title its title bar and the taskbar show. Parameters:ATitlethe title. Returns: this object, so calls chainmethod Size(const AWidth: int32; const AHeight: int32): self: The client area's size in logical units. Parameters:AWidththe width;AHeightthe height. Returns: this object, so calls chainmethod Flags(const AFlags: UIWindowFlags): self: How it opens (hidden, borderless, maximized, a custom header bar ..). Parameters:AFlagsthe flags. Returns: this object, so calls chainmethod MinSize(const AWidth: int32; const AHeight: int32): self: The smallest size the user can make it. Parameters:AWidththe width;AHeightthe height. Returns: this object, so calls chainmethod Position(const AX: int32; const AY: int32): self: Its top-left corner on the screen (not centred). Parameters:AXthe x coordinate;AYthe y coordinate. Returns: this object, so calls chainmethod Center(): self: Centred on its screen (no position). Returns: this object, so calls chainmethod Theme(const AKind: UIThemeKind): self: One of Raven's built-in themes as its own. Parameters:AKindthe kind. Returns: this object, so calls chainmethod Backdrop(const ABackdrop: UIBackdrop): self: What shows through behind its content (a transparent window's). Parameters:ABackdropthe backdrop. Returns: this object, so calls chainmethod Content(const AWidget: UIWidget): self:AWidgetas its content. Parameters:AWidgetthe widget. Returns: this object, so calls chainconst method Open(): UIWindow: Opens the window with the settings set (IsValid()false when Raven could not: the error reported toUIErrors). C: Rwindow_create Returns: the window (IsValid()false when Raven could not open it)
Example: LWindow := UIWindow.Config().Title("Notes").Size(800, 600).Content(LRoot).Open();
UITouch
type UITouch = object
The app's touch and pen settings (each window may have its own: UIWindow.TouchSettings).
Members
static method Settings(): RTouchSettings: The app's settings now. C: Rtouch_get_settings Returns: the app's settings nowstatic method Settings(const ASettings: RTouchSettings):ASettingsas the app's. C: Rtouch_set_settings Parameters:ASettingsthe settings.static method Defaults(): RTouchSettings: Raven's default settings. C: Rtouch_get_default_settings Returns: raven's default settings
UIDrag
type UIDrag = object
The app's own drag and drop: a drag started from a widget, carrying a type and data that the widget it is dropped on reads (UIWidget.OnDrop, RDropEvent).
Members
static method Begin(const ASource: UIWidget; const AType: string; const AData: string; const ALabel: string): bool: Starts a drag fromASource(the pointer held on it) carrying the dataADataof the typeAType(the program's own name for it), showingALabelby the pointer. Parameters:ASourcethe source;ATypethe type;ADatathe data;ALabelthe label. Returns:falsewhen a drag cannot start (one is on already). C: Rdrag_beginstatic method Active(const AWindow: UIWindow): bool:truewhile a drag of the app's own is on inAWindow. C: Rdrag_is_active Parameters:AWindowthe window. Returns:truewhile a drag of the app's own is on inAWindowstatic method DataType(const AWindow: UIWindow): string: The type of the drag on inAWindow("" when none). C: Rdrag_get_type Parameters:AWindowthe window. Returns: the type of the drag on inAWindow("" when none)static method Data(const AWindow: UIWindow): string: The data of the drag on inAWindow("" when none). C: Rdrag_get_data Parameters:AWindowthe window. Returns: the data of the drag on inAWindow("" when none)static method Cancel(const AWindow: UIWindow): The drag on inAWindowcancelled (nothing is dropped). C: Rdrag_cancel Parameters:AWindowthe window.static method Highlight(const ARect: UIRect): Where the drop would land, highlighted while the drag is over it (from anOnDropat its Enter / Move stage). C: Rdrop_set_highlight_rect Parameters:ARectthe rectangle.
UIPanel
type UIPanel = object(UIWidget)
A box laying its children out in a line: the base of UIVBox and UIHBox. C: Rpanel_*
Members
static method Kinds(): UIWidgetKinds: The kinds a panel views: VBox and HBox. Returns: the kinds a panel views: VBox and HBoxconst method Spacing(const ASpacing: float32): self: The gap between two children, in window units. C: Rpanel_set_spacing Parameters:ASpacingthe spacing. Returns: this object, so calls chainconst method Spacing(): float32: WhatSpacing(..)sets, read back. C: Rpanel_get_spacing Returns: the gap between two children, in window units
UIVBox
type UIVBox = object(UIPanel)
A box laying its children out top to bottom.
Members
static method Create(): UIVBox: A new, empty vertical box. C: Rwidget_create(R_WIDGET_VBOX) Returns: a new, empty vertical boxstatic method Kinds(): UIWidgetKinds: The kind a vertical box views. Returns: the kind a vertical box views
Example: LBox := UIVBox.Create().Spacing(8.0f).Add(UILabel.Create("Hi"));
UIHBox
type UIHBox = object(UIPanel)
A box laying its children out left to right (right to left in an RTL direction).
Members
static method Create(): UIHBox: A new, empty horizontal box. C: Rwidget_create(R_WIDGET_HBOX) Returns: a new, empty horizontal boxstatic method Kinds(): UIWidgetKinds: The kind a horizontal box views. Returns: the kind a horizontal box views
UIGrid
type UIGrid = object(UIWidget)
A grid: each child in the cell its layout names (UILayout.Cell, Span), the columns' and rows' shares of the room set by fill coefficients. C: Rgrid_*
Members
static method Create(): UIGrid: A new, empty grid. C: Rwidget_create(R_WIDGET_GRID) Returns: a new, empty gridstatic method Kinds(): UIWidgetKinds: The kind a grid views. Returns: the kind a grid viewsconst method ColumnFill(const AColumn: int32; const AFill: float32): self: The share of the spare width columnAColumntakes (0: as wide as its content). C: Rgrid_set_column_fill Parameters:AColumnthe column, from 0;AFillthe share of the room it takes. Returns: this object, so calls chainconst method RowFill(const ARow: int32; const AFill: float32): self: The share of the spare height rowARowtakes (0: as tall as its content). C: Rgrid_set_row_fill Parameters:ARowthe row, from 0;AFillthe share of the room it takes. Returns: this object, so calls chain
UIUniformGrid
type UIUniformGrid = object(UIWidget)
A grid of equal cells filled in order, Columns to a row. C: Runiform_grid_*
Members
static method Create(): UIUniformGrid: A new, empty uniform grid. C: Rwidget_create(R_WIDGET_UNIFORM_GRID) Returns: a new, empty uniform gridstatic method Kinds(): UIWidgetKinds: The kind a uniform grid views. Returns: the kind a uniform grid viewsconst method Columns(const AColumns: int32): self: The cells to a row (0: as many as fitMinCellSize). C: Runiform_grid_set_columns Parameters:AColumnsthe columns. Returns: this object, so calls chainconst method MinCellSize(const AWidth: float32; const AHeight: float32): self: The smallest a cell is. C: Runiform_grid_set_min_cell_size Parameters:AWidththe width;AHeightthe height. Returns: this object, so calls chain
UIOverlay
type UIOverlay = object(UIWidget)
Children stacked on one another, each filling the box (or placed by its layout's alignment), the last on top.
Members
static method Create(): UIOverlay: A new, empty overlay. C: Rwidget_create(R_WIDGET_OVERLAY) Returns: a new, empty overlaystatic method Kinds(): UIWidgetKinds: The kind an overlay views. Returns: the kind an overlay views
UIBorder
type UIBorder = object(UIWidget)
A frame around one child: padding, a background, an outline, rounded corners and a shadow. C: Rborder_*
Members
static method Create(): UIBorder: A new, empty border. C: Rwidget_create(R_WIDGET_BORDER) Returns: a new, empty borderstatic method Kinds(): UIWidgetKinds: The kind a border views. Returns: the kind a border viewsconst method Padding(const ALeft: float32; const ATop: float32; const ARight: float32; const ABottom: float32): self: The room between the frame and its child, side by side. C: Rborder_set_padding Parameters:ALeftthe room on the left;ATopthe room above;ARightthe room on the right;ABottomthe room below. Returns: this object, so calls chainconst method Padding(const AAll: float32): self: The same roomAAllon every side. C: Rborder_set_padding Parameters:AAllthe room on every side. Returns: this object, so calls chainconst method Background(const AColor: UIColor): self: The colour the frame is filled with. C: Rborder_set_background Parameters:AColorthe colour. Returns: this object, so calls chainconst method Outline(const AWidth: float32; const AColor: UIColor): self: An outlineAWidthwide inAColor(0 wide: none). C: Rborder_set_outline Parameters:AWidththe width;AColorthe colour. Returns: this object, so calls chainconst method CornerRadius(const ARadius: float32): self: Every corner rounded byARadius. C: Rborder_set_corner_radius Parameters:ARadiusthe radius. Returns: this object, so calls chainconst method CornerRadius(const ATopLeft: float32; const ATopRight: float32; const ABottomRight: float32; const ABottomLeft: float32): self: Each corner rounded by its own radius. C: Rborder_set_corner_radius Parameters:ATopLeftthe top-left corner's radius;ATopRightthe top-right corner's radius;ABottomRightthe bottom-right corner's radius;ABottomLeftthe bottom-left corner's radius. Returns: this object, so calls chainconst method Shadow(const ABlur: float32; const AOffset: UIPoint): self: A drop shadow blurred byABlur, moved byAOffset(0 blur: none). C: Rborder_set_shadow Parameters:ABlurthe blur radius;AOffsetthe offset. Returns: this object, so calls chainconst method Material(const AMaterial: UIMaterial): self: What the frame's own panel is drawn as (solid, glass ..). C: Rborder_set_material Parameters:AMaterialthe material. Returns: this object, so calls chainconst method Effect(const AShader: UIShaderRes; const ALook: RShaderLook): self:AShaderdrawn as the border's background (under its child), with the lookALook(colours, parameters, radius, animation; an empty handle removes it); kept while it is set. C: Rborder_set_effect Parameters:AShaderthe shader;ALookthe look. Returns: this object, so calls chainconst method Effect(const AShader: UIShaderRes): self:AShaderdrawn as the border's background with its own default look (AShader.Defaults()). C: Rborder_set_effect Parameters:AShaderthe shader. Returns: this object, so calls chainconst method Effect(): UIShaderRes: The effect drawn, borrowed (empty for none). C: Rborder_get_effect Returns: the effect drawn, borrowed (empty for none)
UISizeBox
type UISizeBox = object(UIWidget)
A box keeping its child at one width-to-height ratio. C: Rsize_box_*
Members
static method Create(): UISizeBox: A new, empty size box. C: Rwidget_create(R_WIDGET_SIZE_BOX) Returns: a new, empty size boxstatic method Kinds(): UIWidgetKinds: The kind a size box views. Returns: the kind a size box viewsconst method AspectRatio(const ARatio: float32): self: The child's width over its height (0: no ratio kept). C: Rsize_box_set_aspect_ratio Parameters:ARatiothe ratio. Returns: this object, so calls chain
UISpacer
type UISpacer = object(UIWidget)
Empty room of a given size between widgets. C: Rspacer_*
Members
static method Create(): UISpacer: A new spacer of no size (it takes what its layout gives it). C: Rwidget_create(R_WIDGET_SPACER) Returns: a new spacer of no size (it takes what its layout gives it)static method Create(const AWidth: float32; const AHeight: float32): UISpacer: A new spacerAWidthbyAHeight. C: Rwidget_create, Rspacer_set_size Parameters:AWidththe width;AHeightthe height. Returns: a new spacerAWidthbyAHeightstatic method Kinds(): UIWidgetKinds: The kind a spacer views. Returns: the kind a spacer viewsconst method Size(const AWidth: float32; const AHeight: float32): self: The room the spacer asks for. C: Rspacer_set_size Parameters:AWidththe width;AHeightthe height. Returns: this object, so calls chain
UIScrollBox
type UIScrollBox = object(UIWidget)
A view scrolling one child larger than itself. C: Rscroll_box_*
Members
static method Create(): UIScrollBox: A new, empty scroll box. C: Rwidget_create(R_WIDGET_SCROLL_BOX) Returns: a new, empty scroll boxstatic method Kinds(): UIWidgetKinds: The kind a scroll box views. Returns: the kind a scroll box viewsconst method Orientation(const AOrientation: UIOrientation): self: The direction it scrolls. C: Rscroll_box_set_orientation Parameters:AOrientationthe orientation. Returns: this object, so calls chainconst method ScrollBoth(const AOn: bool): self: Scrolls in both directions whenAOn. C: Rscroll_box_set_scroll_both Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Offset(const AOffset: UIPoint): self: Scrolls toAOffset(window units from the child's top left). C: Rscroll_box_set_offset Parameters:AOffsetthe offset. Returns: this object, so calls chainconst method Offset(): UIPoint: How far it is scrolled. C: Rscroll_box_get_offset Returns: how far it is scrolledconst method ScrollToEnd(): self: Scrolls to the child's end (a log's last line). C: Rscroll_box_scroll_to_end Returns: this object, so calls chain
UISplitter
type UISplitter = object(UIWidget)
Two panes side by side (or one above the other) with a bar between to drag. C: Rsplitter_*
Members
static method Create(): UISplitter: A new, empty splitter. C: Rwidget_create(R_WIDGET_SPLITTER) Returns: a new, empty splitterstatic method Kinds(): UIWidgetKinds: The kind a splitter views. Returns: the kind a splitter viewsconst method Orientation(const AOrientation: UIOrientation): self: Horizontal: panes side by side; vertical: one above the other. C: Rsplitter_set_orientation Parameters:AOrientationthe orientation. Returns: this object, so calls chainconst method MinPaneSize(const ASize: float32): self: The smallest a pane is dragged to. C: Rsplitter_set_min_pane_size Parameters:ASizethe size. Returns: this object, so calls chain
UIWrapBox
type UIWrapBox = object(UIWidget)
Children in a row, wrapping to a new row when it is full.
Members
static method Create(): UIWrapBox: A new, empty wrap box. C: Rwidget_create(R_WIDGET_WRAP_BOX) Returns: a new, empty wrap boxstatic method Kinds(): UIWidgetKinds: The kind a wrap box views. Returns: the kind a wrap box views
UICanvas
type UICanvas = object(UIWidget)
Children placed freely: each where its layout puts it (UILayout.At, Anchors, Size, Pivot).
Members
static method Create(): UICanvas: A new, empty canvas. C: Rwidget_create(R_WIDGET_CANVAS) Returns: a new, empty canvasstatic method Kinds(): UIWidgetKinds: The kind a canvas views. Returns: the kind a canvas views
UISwitcher
type UISwitcher = object(UIWidget)
Children shown one at a time (pages of a wizard, views of a tool). C: Rswitcher_*
Members
static method Create(): UISwitcher: A new, empty switcher. C: Rwidget_create(R_WIDGET_SWITCHER) Returns: a new, empty switcherstatic method Kinds(): UIWidgetKinds: The kind a switcher views. Returns: the kind a switcher viewsconst method Index(const AIndex: int32): self: Shows the child atAIndex. C: Rswitcher_set_index Parameters:AIndexthe index, from 0. Returns: this object, so calls chainconst method Index(): int32: The index of the child shown. C: Rswitcher_get_index Returns: the index of the child shown
UITabView
type UITabView = object(UIWidget)
Pages under a row of tabs, one page shown; each page is a child, its tab a UITab. C: Rtab_view_*
Members
static method Create(): UITabView: A new tab view with no pages. C: Rwidget_create(R_WIDGET_TAB_VIEW) Returns: a new tab view with no pagesstatic method Kinds(): UIWidgetKinds: The kind a tab view views. Returns: the kind a tab view viewsconst method AddTab(const ATitle: string; const AContent: UIWidget): UITab: A new pageAContentlast, under a tab titledATitle(an empty tab when Raven refuses it). C: Rtab_view_add_tab Parameters:ATitlethe title;AContentthe content widget. Returns: a new pageAContentlast, under a tab titledATitle(an empty tab when Raven refuses it)const method Active(const AIndex: int32): self: Shows the page atAIndex. C: Rtab_view_set_active Parameters:AIndexthe index, from 0. Returns: this object, so calls chainconst method Active(): int32: The index of the page shown (-1 for none). C: Rtab_view_get_active Returns: the index of the page shown (-1 for none)const method Documents(const AOn: bool): self: Document tabs whenAOn(an editor's: each with a close button, shrinking when they do not fit). C: Rtab_view_set_documents Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method TabCount(): int32: The pages the view holds. C: Rtab_view_get_tab_count Returns: the pages the view holdsconst method Tab(const AIndex: int32): UITab: The tab atAIndex(an empty one outside 0 .. TabCount() - 1). C: Rtab_view_get_tab Parameters:AIndexthe index, from 0. Returns: the tab atAIndex(an empty one outside 0 .const method FindTab(const AContent: UIWidget): UITab: The tab of the pageAContent(an empty one when it is no page here). C: Rtab_view_find_tab Parameters:AContentthe content widget. Returns: the tab of the pageAContent(an empty one when it is no page here)const method OnChanged(const AFunc: UIIndexFunc): self: RunsAFuncwith the index of the page shown when it changes. C: Rtab_view_set_changed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnClose(const AFunc: UITabCloseFunc): self: RunsAFuncwhen a tab's close button is pressed:truedeletes its page,falsekeeps it. C: Rtab_view_set_close_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
Example: LTabs := UITabView.Create(); LTabs.AddTab("General", LGeneral).Closable(false);
UITab
type UITab = object
One tab of a UITabView: a view of (the tab view, its page), copied freely; it names no tab once the page is gone. C: Rtab_view__tab_
Members
init(): An empty tab (names none).static method Wrap(const AView: Rid; const AContent: Rid): UITab: The tab of the pageAContentin the tab viewAView(both Rids). Parameters:AViewthe view;AContentthe content widget. Returns: the tab of the pageAContentin the tab viewAView(both Rids)const method IsValid(): bool:truewhile the tab's page is one of its tab view's. C: Rtab_view_find_tab Returns:truewhile the tab's page is one of its tab view'sconst method Index(): int32: The tab's place among its view's (-1 when it names none). C: Rtab_view_find_tab Returns: the tab's place among its view's (-1 when it names none)const method View(): UITabView: The tab view the tab is in. Returns: the tab view the tab is inconst method Content(): UIWidget: The page the tab shows. Returns: the page the tab showsconst method Title(const ATitle: string): self: The tab's title. C: Rtab_view_set_tab_title Parameters:ATitlethe title. Returns: this object, so calls chainconst method Closable(const AOn: bool): self: A close button on the tab whenAOn. C: Rtab_view_set_tab_closable Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Show(): self: Shows the tab's page. C: Rtab_view_show_tab Returns: this object, so calls chainconst method Icon(const ATexture: UITextureRes): self: The whole ofATextureas the icon before the title (an empty handle removes it), drawn in its own colours; kept while it is set. C: Rtab_view_set_tab_icon Parameters:ATexturethe texture. Returns: this object, so calls chainconst method Icon(const ATexture: UITextureRes; const AUVMin: UIPoint; const AUVMax: UIPoint; const ATint: bool): self: A part ofATextureas the icon before the title (an empty handle removes it); kept while it is set.AUVMin..AUVMax: the part of the texture shown, as texture coordinates (0 .. 1) of its corners;ATinttrue: the texture is a mask drawn in the text colour. C: Rtab_view_set_tab_icon Parameters:ATexturethe texture;AUVMinthe lowest texture coordinates (0 .. 1);AUVMaxthe highest texture coordinates (0 .. 1);ATintthe tint colour. Returns: this object, so calls chain
UIExpander
type UIExpander = object(UIWidget)
A titled header that opens and closes the content below it. C: Rexpander_*
Members
static method Create(const ATitle: string): UIExpander: A new, closed expander titledATitle. C: Rwidget_create(R_WIDGET_EXPANDER), Rexpander_set_title Parameters:ATitlethe title. Returns: a new, closed expander titledATitlestatic method Kinds(): UIWidgetKinds: The kind an expander views. Returns: the kind an expander viewsconst method Title(const ATitle: string): self: The header's title. C: Rexpander_set_title Parameters:ATitlethe title. Returns: this object, so calls chainconst method Title(): string: WhatTitle(..)sets, read back. C: Rexpander_get_title Returns: the header's titleconst method Expanded(const AOn: bool): self: Opens (true) or closes the content. C: Rexpander_set_expanded Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Expanded(): bool: WhatExpanded(..)sets, read back. C: Rexpander_is_expanded Returns:truewhenExpanded(..)turned it onconst method OnChanged(const AFunc: UIToggleFunc): self: RunsAFuncwith the new state when the expander opens or closes. C: Rexpander_set_changed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
UILabel
type UILabel = object(UIWidget)
A line or block of text, plain or Markdown (links run OnLink), optionally selectable. Its text is the base's Text. C: Rlabel_*
Members
static method Create(const AText: string): UILabel: A new label showingAText. C: Rlabel_create Parameters:ATextthe text. Returns: a new label showingATextstatic method Kinds(): UIWidgetKinds: The kind a label views. Returns: the kind a label viewsconst method TextSize(const ASize: float32): self: The text's size in window units. C: Rlabel_set_text_size Parameters:ASizethe size. Returns: this object, so calls chainconst method Align(const AAlign: UITextAlign): self: How each line sits across the label. C: Rlabel_set_text_align Parameters:AAlignthe alignment. Returns: this object, so calls chainconst method Wrap(const AOn: bool): self: Wraps long lines at the label's width whenAOn. C: Rlabel_set_wrap Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Color(const AColor: UIColor): self: The text's colour (the theme's text colour by default). C: Rlabel_set_color Parameters:AColorthe colour. Returns: this object, so calls chainconst method Markdown(const AOn: bool): self: The text read as Markdown whenAOn(headings, emphasis, lists, code, links). C: Rlabel_set_markdown Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Markdown(): bool: WhatMarkdown(..)sets, read back. C: Rlabel_get_markdown Returns:truewhenMarkdown(..)turned it onconst method PlainText(): string: The text as shown, Markdown's marks taken out. C: Rlabel_get_plain_text Returns: the text as shown, Markdown's marks taken outconst method Selectable(const AOn: bool): self: The text selectable (and copied) with the pointer whenAOn. C: Rlabel_set_selectable Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Selectable(): bool: WhatSelectable(..)sets, read back. C: Rlabel_get_selectable Returns:truewhenSelectable(..)turned it onconst method SelectedText(): string: The text selected ("" for none). C: Rlabel_get_selected_text Returns: the text selected ("" for none)const method SelectAll(): self: Selects the whole text. C: Rlabel_select_all Returns: this object, so calls chainconst method ClearSelection(): self: Selects nothing. C: Rlabel_clear_selection Returns: this object, so calls chainconst method OnLink(const AFunc: UITextFunc): self: RunsAFuncwith a Markdown link's URL when it is clicked (OpenURLit, or route it). C: Rlabel_set_link_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method Font(const AFont: UIFontRes): self: The label's own font (an empty handle: the widget's or the theme's); kept while it is set. C: Rlabel_set_font Parameters:AFontthe font. Returns: this object, so calls chain
Example: UILabel.Create("Ready").TextSize(18.0f).Color(UIColor.FromRGBA(80, 200, 120));
UIButton
type UIButton = object(UIWidget)
A push button. Its text is the base's Text. C: Rbutton_*
Members
static method Create(const AText: string): UIButton: A new button labelledAText. C: Rbutton_create Parameters:ATextthe text. Returns: a new button labelledATextstatic method Kinds(): UIWidgetKinds: The kind a button views. Returns: the kind a button viewsconst method Style(const AStyle: UIButtonStyle): self: How the button is drawn (default, primary, flat). C: Rbutton_set_style Parameters:AStylethe style. Returns: this object, so calls chainconst method OnClick(const AFunc: UITaskFunc): self: RunsAFuncwhen the button is clicked. C: Rbutton_set_clicked_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
Example: UIButton.Create("Save").Style(UIButtonStyle.Primary).OnClick(func() begin Save(); end);
UICheckBox
type UICheckBox = object(UIWidget)
A check box, radio button or switch with its text (Style). Its text is the base's Text. C: Rcheckbox_*
Members
static method Create(const AText: string): UICheckBox: A new, unchecked check box labelledAText. C: Rcheckbox_create Parameters:ATextthe text. Returns: a new, unchecked check box labelledATextstatic method Kinds(): UIWidgetKinds: The kind a check box views. Returns: the kind a check box viewsconst method Checked(const AOn: bool): self: Checks (true) or clears it. C: Rcheckbox_set_checked Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Checked(): bool: WhatChecked(..)sets, read back. C: Rcheckbox_is_checked Returns:truewhenChecked(..)turned it onconst method Style(const AStyle: UICheckStyle): self: Drawn as a check box, a radio button or a switch. C: Rcheckbox_set_style Parameters:AStylethe style. Returns: this object, so calls chainconst method OnChanged(const AFunc: UIToggleFunc): self: RunsAFuncwith the new state when it is checked or cleared. C: Rcheckbox_set_changed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
UISlider
type UISlider = object(UIWidget)
A bar with a thumb to drag between a range's ends. C: Rslider_*
Members
static method Create(): UISlider: A new slider over 0 .. 1. C: Rwidget_create(R_WIDGET_SLIDER) Returns: a new slider over 0 .static method Kinds(): UIWidgetKinds: The kind a slider views. Returns: the kind a slider viewsconst method Range(const AMin: float32; const AMax: float32): self: The values at its ends. C: Rslider_set_range Parameters:AMinthe lowest value;AMaxthe highest value. Returns: this object, so calls chainconst method Range(): UIRange: Its ends and its step. C: Rslider_get_range Returns: its ends and its stepconst method Value(const AValue: float32): self: Moves the thumb toAValue(kept in the range). C: Rslider_set_value Parameters:AValuethe value. Returns: this object, so calls chainconst method Value(): float32: WhatValue(..)sets, read back. C: Rslider_get_value Returns: whatValue(..)set lastconst method Step(const AStep: float32): self: The thumb moves in steps ofAStep(0: freely). C: Rslider_set_step Parameters:AStepthe step. Returns: this object, so calls chainconst method Orientation(const AOrientation: UIOrientation): self: Lies across (horizontal) or stands up (vertical). C: Rslider_set_orientation Parameters:AOrientationthe orientation. Returns: this object, so calls chainconst method OnChanged(const AFunc: UIValueFunc): self: RunsAFuncwith the value as the thumb moves. C: Rslider_set_changed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
UIProgressBar
type UIProgressBar = object(UIWidget)
A bar filled to show progress (0 .. 1). C: Rprogress_bar_*
Members
static method Create(): UIProgressBar: A new, empty progress bar. C: Rwidget_create(R_WIDGET_PROGRESS_BAR) Returns: a new, empty progress barstatic method Kinds(): UIWidgetKinds: The kind a progress bar views. Returns: the kind a progress bar viewsconst method Value(const AValue: float32): self: Fills it toAValue(0 .. 1). C: Rprogress_bar_set_value Parameters:AValuethe value. Returns: this object, so calls chainconst method Value(): float32: WhatValue(..)sets, read back. C: Rprogress_bar_get_value Returns: whatValue(..)set last
UIImage
type UIImage = object(UIWidget)
A picture: a texture's region, stretched, tinted and rounded. C: Rimage_*
Members
static method Create(): UIImage: A new image showing nothing yet. C: Rwidget_create(R_WIDGET_IMAGE) Returns: a new image showing nothing yetstatic method Kinds(): UIWidgetKinds: The kind an image views. Returns: the kind an image viewsconst method Tint(const AColor: UIColor): self: Multiplies the picture byAColor(an icon in a theme's colour). C: Rimage_set_tint_color Parameters:AColorthe colour. Returns: this object, so calls chainconst method TintText(const AOn: bool): self: Tinted with the theme's text colour whenAOn(follows light / dark). C: Rimage_set_tint_text Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Stretch(const AStretch: UIStretch): self: How the picture fits the widget (fill, fit, cover, none). C: Rimage_set_stretch Parameters:AStretchthe stretch. Returns: this object, so calls chainconst method Region(const AUVMin: UIPoint; const AUVMax: UIPoint): self: The part of the texture shown, as texture coordinates (0 .. 1) of its corners. C: Rimage_set_region Parameters:AUVMinthe lowest texture coordinates (0 .. 1);AUVMaxthe highest texture coordinates (0 .. 1). Returns: this object, so calls chainconst method CornerRadius(const ARadius: float32): self: The picture's corners rounded byARadius. C: Rimage_set_corner_radius Parameters:ARadiusthe radius. Returns: this object, so calls chainconst method Texture(const ATexture: UITextureRes): self: The texture it shows (an empty handle: nothing); kept while it is set. C: Rimage_set_texture Parameters:ATexturethe texture. Returns: this object, so calls chain
UITextInput
type UITextInput = object(UIWidget)
A one-line text field. Its text is the base's Text. C: Rtext_input_*
Members
static method Create(): UITextInput: A new, empty text field. C: Rwidget_create(R_WIDGET_TEXT_INPUT) Returns: a new, empty text fieldstatic method Kinds(): UIWidgetKinds: The kind a text input views. Returns: the kind a text input viewsconst method Placeholder(const AText: string): self: The hint shown while the field is empty. C: Rtext_input_set_placeholder Parameters:ATextthe text. Returns: this object, so calls chainconst method Password(const AOn: bool): self: The text hidden behind dots whenAOn. C: Rtext_input_set_password Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Password(): bool: WhatPassword(..)sets, read back. C: Rtext_input_is_password Returns:truewhenPassword(..)turned it onconst method ReadOnly(const AOn: bool): self: The text shown and selectable but not editable whenAOn. C: Rtext_input_set_read_only Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method ReadOnly(): bool: WhatReadOnly(..)sets, read back. C: Rtext_input_is_read_only Returns:truewhenReadOnly(..)turned it onconst method MaxLength(const ALength: int32): self: The most characters it takes (0: no limit). C: Rtext_input_set_max_length Parameters:ALengththe length. Returns: this object, so calls chainconst method SelectAll(): self: Selects the whole text. C: Rtext_input_select_all Returns: this object, so calls chainconst method InputType(const AType: UIInputType): self: What the text is (e-mail, number ..): the keyboard a touch device shows. C: Rtext_input_set_input_type Parameters:ATypethe type. Returns: this object, so calls chainconst method InputType(): UIInputType: WhatInputType(..)sets, read back. C: Rtext_input_get_input_type Returns: what the text is (e-mail, number ..): the keyboard a touch device showsconst method ReturnKey(const AKey: UIReturnKey): self: The label of a touch keyboard's return key. C: Rtext_input_set_return_key Parameters:AKeythe key. Returns: this object, so calls chainconst method ReturnKey(): UIReturnKey: WhatReturnKey(..)sets, read back. C: Rtext_input_get_return_key Returns: the label of a touch keyboard's return keyconst method OnChanged(const AFunc: UITextFunc): self: RunsAFuncwith the text at each change. C: Rtext_input_set_changed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnCommit(const AFunc: UITextFunc): self: RunsAFuncwith the text when it is committed (Enter, the return key). C: Rtext_input_set_committed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
Example: UITextInput.Create().Placeholder("Search").OnCommit(func(const S: string) begin Find(S); end);
UISpinBox
type UISpinBox = object(UIWidget)
A number field with steps (arrows, the wheel, dragging). C: Rspin_box_*
Members
static method Create(): UISpinBox: A new spin box. C: Rwidget_create(R_WIDGET_SPIN_BOX) Returns: a new spin boxstatic method Kinds(): UIWidgetKinds: The kind a spin box views. Returns: the kind a spin box viewsconst method Range(const AMin: float64; const AMax: float64): self: The lowest and highest values it takes. C: Rspin_box_set_range Parameters:AMinthe lowest value;AMaxthe highest value. Returns: this object, so calls chainconst method Range(): UIRange: Its range and its step. C: Rspin_box_get_range Returns: its range and its stepconst method Value(const AValue: float64): self: Sets the value (kept in the range). C: Rspin_box_set_value Parameters:AValuethe value. Returns: this object, so calls chainconst method Value(): float64: WhatValue(..)sets, read back. C: Rspin_box_get_value Returns: whatValue(..)set lastconst method Step(const AStep: float64): self: One step's size. C: Rspin_box_set_step Parameters:AStepthe step. Returns: this object, so calls chainconst method Decimals(const ADecimals: int32): self: The digits shown after the point. C: Rspin_box_set_decimals Parameters:ADecimalsthe decimals. Returns: this object, so calls chainconst method Buttons(const AOn: bool): self: Step buttons beside the number whenAOn(else drag to scrub, arrows / wheel to step). C: Rspin_box_set_buttons Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Buttons(): bool: WhatButtons(..)sets, read back. C: Rspin_box_get_buttons Returns:truewhenButtons(..)turned it onconst method OnChanged(const AFunc: UIValue64Func): self: RunsAFuncwith the value when it changes. C: Rspin_box_set_changed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
UIComboBox
type UIComboBox = object(UIWidget)
A drop-down list of text items, one chosen. C: Rcombo_box_*
Members
static method Create(): UIComboBox: A new combo box with no items. C: Rwidget_create(R_WIDGET_COMBO_BOX) Returns: a new combo box with no itemsstatic method Kinds(): UIWidgetKinds: The kind a combo box views. Returns: the kind a combo box viewsconst method AddItem(const AText: string): int32:ATextas the last item: its index. C: Rcombo_box_add_item Parameters:ATextthe text. Returns:ATextas the last item: its indexconst method ClearItems(): self: Every item removed. C: Rcombo_box_clear_items Returns: this object, so calls chainconst method ItemCount(): int32: The items it holds. C: Rcombo_box_get_item_count Returns: the items it holdsconst method Item(const AIndex: int32): string: The text of the item atAIndex("" outside). C: Rcombo_box_get_item_text Parameters:AIndexthe index, from 0. Returns: the text of the item atAIndex("" outside)const method Selected(const AIndex: int32): self: Chooses the item atAIndex(-1: none). C: Rcombo_box_set_selected Parameters:AIndexthe index, from 0. Returns: this object, so calls chainconst method Selected(): int32: The index of the item chosen (-1 for none). C: Rcombo_box_get_selected Returns: the index of the item chosen (-1 for none)const method OnChanged(const AFunc: UIIndexFunc): self: RunsAFuncwith the index chosen when it changes. C: Rcombo_box_set_changed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
UISeparator
type UISeparator = object(UIWidget)
A thin line between groups of widgets. C: Rseparator_*
Members
static method Create(): UISeparator: A new separator. C: Rwidget_create(R_WIDGET_SEPARATOR) Returns: a new separatorstatic method Kinds(): UIWidgetKinds: The kind a separator views. Returns: the kind a separator viewsconst method Orientation(const AOrientation: UIOrientation): self: A line across (horizontal) or up (vertical). C: Rseparator_set_orientation Parameters:AOrientationthe orientation. Returns: this object, so calls chain
UIRating
type UIRating = object(UIWidget)
A row of stars to rate with. C: Rrating_*
Members
static method Create(): UIRating: A new rating of 0 stars out of Raven's default. C: Rwidget_create(R_WIDGET_RATING) Returns: a new rating of 0 stars out of Raven's defaultstatic method Kinds(): UIWidgetKinds: The kind a rating views. Returns: the kind a rating viewsconst method Value(const AValue: float32): self: The stars lit (0 .. Max, halves with AllowHalf). C: Rrating_set_value Parameters:AValuethe value. Returns: this object, so calls chainconst method Value(): float32: WhatValue(..)sets, read back. C: Rrating_get_value Returns: the stars lit (0 .const method Max(const AMax: int32): self: The stars shown. C: Rrating_set_max Parameters:AMaxthe largest number. Returns: this object, so calls chainconst method Max(): int32: WhatMax(..)sets, read back. C: Rrating_get_max Returns: the stars shownconst method AllowHalf(const AOn: bool): self: Half stars allowed whenAOn. C: Rrating_set_allow_half Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method ReadOnly(const AOn: bool): self: Shown but not changeable whenAOn. C: Rrating_set_read_only Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method StarSize(const ASize: float32): self: A star's size in window units. C: Rrating_set_star_size Parameters:ASizethe size. Returns: this object, so calls chainconst method OnChanged(const AFunc: UIValueFunc): self: RunsAFuncwith the value when it is changed. C: Rrating_set_changed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
UIPagination
type UIPagination = object(UIWidget)
Page buttons (1 2 3 .. 9 >) for a paged list. C: Rpagination_*
Members
static method Create(): UIPagination: A new pagination. C: Rwidget_create(R_WIDGET_PAGINATION) Returns: a new paginationstatic method Kinds(): UIWidgetKinds: The kind a pagination views. Returns: the kind a pagination viewsconst method PageCount(const ACount: int32): self: The pages there are. C: Rpagination_set_page_count Parameters:ACounthow many. Returns: this object, so calls chainconst method PageCount(): int32: WhatPageCount(..)sets, read back. C: Rpagination_get_page_count Returns: the pages there areconst method Page(const APage: int32): self: Goes to pageAPage. C: Rpagination_set_page Parameters:APagethe page. Returns: this object, so calls chainconst method Page(): int32: The page shown. C: Rpagination_get_page Returns: the page shownconst method Siblings(const ACount: int32): self: The page buttons shown on each side of the current one. C: Rpagination_set_siblings Parameters:ACounthow many. Returns: this object, so calls chainconst method OnChanged(const AFunc: UIIndexFunc): self: RunsAFuncwith the page when it changes. C: Rpagination_set_changed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
UIBreadcrumb
type UIBreadcrumb = object(UIWidget)
A path of items (Home > Docs > Adam), each clickable. C: Rbreadcrumb_*
Members
static method Create(): UIBreadcrumb: A new, empty breadcrumb. C: Rwidget_create(R_WIDGET_BREADCRUMB) Returns: a new, empty breadcrumbstatic method Kinds(): UIWidgetKinds: The kind a breadcrumb views. Returns: the kind a breadcrumb viewsconst method Items(const AItems: array of string): self: Replaces the items withAItems(Raven separates them by '|', so no item holds one). C: Rbreadcrumb_set_items Parameters:AItemsthe items. Returns: this object, so calls chainconst method AddItem(const AText: string): int32:ATextas the last item: its index. C: Rbreadcrumb_add_item Parameters:ATextthe text. Returns:ATextas the last item: its indexconst method Truncate(const ACount: int32): self: Keeps the firstACountitems (Truncate(AIndex + 1)goes back to the item clicked). C: Rbreadcrumb_truncate Parameters:ACounthow many. Returns: this object, so calls chainconst method ItemCount(): int32: The items it holds. C: Rbreadcrumb_get_item_count Returns: the items it holdsconst method Item(const AIndex: int32): string: The text of the item atAIndex("" outside). C: Rbreadcrumb_get_item_text Parameters:AIndexthe index, from 0. Returns: the text of the item atAIndex("" outside)const method OnClick(const AFunc: UIIndexFunc): self: RunsAFuncwith the index of the item clicked. C: Rbreadcrumb_set_clicked_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
UIDatePicker
type UIDatePicker = object(UIWidget)
A date field with a calendar to pick from. Its text as shown is the base's Text(). C: Rdate_picker_*
Members
static method Create(): UIDatePicker: A new date picker. C: Rwidget_create(R_WIDGET_DATE_PICKER) Returns: a new date pickerstatic method Kinds(): UIWidgetKinds: The kind a date picker views. Returns: the kind a date picker viewsconst method Date(const AYear: int32; const AMonth: int32; const ADay: int32): self: Sets the date (AMonth1 .. 12). C: Rdate_picker_set_date Parameters:AYearthe year;AMonththe month;ADaythe day. Returns: this object, so calls chainconst method Date(): UIDate: The date chosen. C: Rdate_picker_get_date Returns: the date chosenconst method Range(const AMin: UIDate; const AMax: UIDate): self: The earliest and the latest dates that can be chosen (a 0 year leaves that side open). C: Rdate_picker_set_range Parameters:AMinthe earliest date;AMaxthe latest date. Returns: this object, so calls chainconst method FirstDayOfWeek(const ADay: int32): self: The calendar's first column: 0 Sunday (Raven's default), 1 Monday .. C: Rdate_picker_set_first_day_of_week Parameters:ADaythe day. Returns: this object, so calls chainconst method Format(const AFormat: string): self: How the field writes the date: YYYY, MM, M, DD, D, MMMM (the month's name), MMM, dddd (the day's name), ddd; anything else kept ("YYYY-MM-DD" by default). C: Rdate_picker_set_format Parameters:AFormatthe pixel format. Returns: this object, so calls chainconst method Open(const AOn: bool): self: Opens (true) or closes the calendar. C: Rdate_picker_set_open Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Open(): bool: WhatOpen(..)sets, read back. C: Rdate_picker_is_open Returns:truewhenOpen(..)turned it onconst method OnChanged(const AFunc: UIDateFunc): self: RunsAFuncwith the date when it is changed. C: Rdate_picker_set_changed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
UITimePicker
type UITimePicker = object(UIWidget)
A time field (hours, minutes, seconds). C: Rtime_picker_*
Members
static method Create(): UITimePicker: A new time picker. C: Rwidget_create(R_WIDGET_TIME_PICKER) Returns: a new time pickerstatic method Kinds(): UIWidgetKinds: The kind a time picker views. Returns: the kind a time picker viewsconst method Time(const AHour: int32; const AMinute: int32; const ASecond: int32): self: Sets the time (AHour0 .. 23). C: Rtime_picker_set_time Parameters:AHourthe hour;AMinutethe minute;ASecondthe second, 0 .. 59. Returns: this object, so calls chainconst method Time(): UITime: The time chosen. C: Rtime_picker_get_time Returns: the time chosenconst method SecondsVisible(const AOn: bool): self: The seconds shown (and chosen) whenAOn. C: Rtime_picker_set_seconds_visible Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method MinuteStep(const AStep: int32): self: The minutes move in steps ofAStep. C: Rtime_picker_set_minute_step Parameters:AStepthe step. Returns: this object, so calls chainconst method OnChanged(const AFunc: UITimeFunc): self: RunsAFuncwith the time when it is changed. C: Rtime_picker_set_changed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
UIColorPicker
type UIColorPicker = object(UIWidget)
A colour chooser: a hue / saturation / value field, opacity, hex text and swatches. C: Rcolor_picker_*
Members
static method Create(): UIColorPicker: A new colour picker. C: Rcolor_picker_create Returns: a new colour pickerstatic method Kinds(): UIWidgetKinds: The kind a colour picker views. Returns: the kind a colour picker viewsconst method Color(const AColor: UIColor): self: Sets the colour chosen. C: Rcolor_picker_set_color Parameters:AColorthe colour. Returns: this object, so calls chainconst method Color(): UIColor: The colour chosen. C: Rcolor_picker_get_color Returns: the colour chosenconst method HSV(const AH: float32; const AS: float32; const AV: float32): self: Sets the colour by hue (0 .. 360), saturation and value (0 .. 1), opacity kept. C: Rcolor_picker_set_hsv Parameters:AHthe hue, in degrees (0 to 360);ASthe saturation, 0 to 1;AVthe value (brightness), 0 to 1. Returns: this object, so calls chainconst method HSV(): UIHSV: The colour as hue, saturation and value (the hue kept for a grey). C: Rcolor_picker_get_hsv Returns: the colour as hue, saturation and value (the hue kept for a grey)const method Hex(const AHex: string): bool: Sets the colour from hex text ("#RRGGBB", "#RRGGBBAA"; one without opacity keeps it). Parameters:AHexthe hex. Returns:falsewhen the text is no colour (the colour unchanged). C: Rcolor_picker_set_hexconst method Hex(): string: The colour as "#RRGGBB" ("#RRGGBBAA" when opacity is shown and not full). C: Rcolor_picker_get_hex Returns: the colour as "#RRGGBB" ("#RRGGBBAA" when opacity is shown and not full)const method AlphaEnabled(const AOn: bool): self: The opacity shown and chosen whenAOn. C: Rcolor_picker_set_alpha_enabled Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method PreviousColor(const AColor: UIColor): self: The colour shown beside the new one (the one being replaced). C: Rcolor_picker_set_previous_color Parameters:AColorthe colour. Returns: this object, so calls chainconst method AddSwatch(const AColor: UIColor): self:AColoras the last swatch. C: Rcolor_picker_add_swatch Parameters:AColorthe colour. Returns: this object, so calls chainconst method ClearSwatches(): self: Every swatch removed. C: Rcolor_picker_clear_swatches Returns: this object, so calls chainconst method SwatchCount(): int32: The swatches it holds. C: Rcolor_picker_get_swatch_count Returns: the swatches it holdsconst method Popup(const AOn: bool): self: A button opening the picker in a popup whenAOn(else the picker itself). C: Rcolor_picker_set_popup Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Compact(const AOn: bool): self: The small form (no hex field, no swatches) whenAOn. C: Rcolor_picker_set_compact Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method OnChanged(const AFunc: UIColorFunc): self: RunsAFuncwith the colour as it is changed. C: Rcolor_picker_set_changed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
UIToast
type UIToast = object(UIWidget)
Short messages popping up over the content, then fading (info, success, warning, error), optionally with an action button ("Undo"). Its last text is the base's Text(). C: Rtoast_*
Members
static method Create(): UIToast: A new toast showing nothing. C: Rwidget_create(R_WIDGET_TOAST) Returns: a new toast showing nothingstatic method Kinds(): UIWidgetKinds: The kind a toast views. Returns: the kind a toast viewsconst method Show(const AText: string; const ASeconds: float64): self: ShowsATextforASeconds, of the kindKindset last. C: Rtoast_show Parameters:ATextthe text;ASecondsthe time, in seconds. Returns: this object, so calls chainconst method Show(const AText: string; const AKind: UIToastKind; const ASeconds: float64): self: ShowsATextof the kindAKindforASeconds. C: Rtoast_show_kind Parameters:ATextthe text;AKindthe kind;ASecondsthe time, in seconds. Returns: this object, so calls chainconst method Hide(): self: Hides the message shown (the next queued one shows). C: Rtoast_hide Returns: this object, so calls chainconst method Clear(): self: Hides the message shown and drops the queued ones. C: Rtoast_clear Returns: this object, so calls chainconst method Shown(): bool:truewhile a message is shown. C: Rtoast_is_shown Returns:truewhile a message is shownconst method Count(): int32: The messages shown and queued. C: Rtoast_get_count Returns: the messages shown and queuedconst method Queue(const AQueue: UIToastQueue): self: What a new message does to the ones shown (replace, queue after, stack). C: Rtoast_set_queue Parameters:AQueuethe queue. Returns: this object, so calls chainconst method Queue(): UIToastQueue: WhatQueue(..)sets, read back. C: Rtoast_get_queue Returns: what a new message does to the ones shown (replace, queue after, stack)const method MaxVisible(const ACount: int32): self: The most messages stacked at once. C: Rtoast_set_max_visible Parameters:ACounthow many. Returns: this object, so calls chainconst method Kind(const AKind: UIToastKind): self: The kind of the next messages (and of the one shown, when replacing): beside the base'sKind(), the widget's kind. C: Rtoast_set_kind Parameters:AKindthe kind. Returns: this object, so calls chainconst method ActionText(const AText: string): self: A button at the end of the next messages ("" removes it). C: Rtoast_set_action_text Parameters:ATextthe text. Returns: this object, so calls chainconst method OnAction(const AFunc: UITaskFunc): self: RunsAFuncwhen a message's action button is pressed (the message then hides). C: Rtoast_set_action_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
Example: LToast.ActionText("Undo").OnAction(func() begin Undo(); end).Show("Deleted", 3.0);
UITreeItem
type UITreeItem = object
One item of a UITreeView: a handle (Raven's Rid of the item), copied freely; it names no item once Raven deleted it (with its tree, an ancestor or Destroy). C: Rtree_item_*
Members
init(): An empty item handle (names none).static method Wrap(const AItem: Rid): UITreeItem: The handle of the tree item System.Raven.C gave asAItem. Parameters:AItemthe item. Returns: the handle of the tree item System.Raven.C gave asAItemconst method Id(): Rid: The item's Rid, for System.Raven.C's calls. Returns: the item's Rid, for System.Raven.C's callsconst method IsValid(): bool:truewhile the handle names an item of a tree. C: Rtree_item_is_valid Returns:truewhile the handle names an item of a treeconst method Destroy(): Deletes the item and its descendants, their icons let go. C: Rtree_item_destroyconst method Text(const AText: string): self: The item's text. C: Rtree_item_set_text Parameters:ATextthe text. Returns: this object, so calls chainconst method Text(): string: WhatText(..)sets, read back. C: Rtree_item_get_text Returns: the item's textconst method Expanded(const AOn: bool): self: Shows (true) or hides its children. C: Rtree_item_set_expanded Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Expanded(): bool: WhatExpanded(..)sets, read back. C: Rtree_item_is_expanded Returns:truewhenExpanded(..)turned it onconst method UserHandle(const AHandle: ptr): self: A pointer the program keeps with the item (Raven never reads it). C: Rtree_item_set_user_handle Parameters:AHandlethe handle. Returns: this object, so calls chainconst method UserHandle(): ptr: WhatUserHandle(..)sets, read back. C: Rtree_item_get_user_handle Returns: a pointer the program keeps with the item (Raven never reads it)const method Parent(): UITreeItem: The item it sits under (names none for a top-level item). C: Rtree_item_get_parent Returns: the item it sits under (names none for a top-level item)const method ChildCount(): int32: Its children. C: Rtree_item_get_child_count Returns: its childrenconst method Child(const AIndex: int32): UITreeItem: Its child atAIndex(names none outside). C: Rtree_item_get_child Parameters:AIndexthe index, from 0. Returns: its child atAIndex(names none outside)const method TextColor(const AColor: UIColor): self: The colour of its text (alpha 0: the theme's). C: Rtree_item_set_text_color Parameters:AColorthe colour. Returns: this object, so calls chainconst method Selected(const AOn: bool): self: Adds it to (true) or takes it from its tree's selection. C: Rtree_item_set_selected Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Selected(): bool: WhatSelected(..)sets, read back. C: Rtree_item_is_selected Returns:truewhenSelected(..)turned it onconst method Icon(const ATexture: UITextureRes): self: The whole ofATextureas the icon before the item's text (an empty handle removes it); kept while the item shows it, let go with the item, its tree or the tree'sClearItems. C: Rtree_item_set_icon Parameters:ATexturethe texture. Returns: this object, so calls chainconst method Icon(const ATexture: UITextureRes; const AUVMin: UIPoint; const AUVMax: UIPoint): self: A part ofATextureas the icon before the item's text, kept as the whole one is.AUVMin..AUVMax: the part of the texture shown, as texture coordinates (0 .. 1) of its corners. C: Rtree_item_set_icon Parameters:ATexturethe texture;AUVMinthe lowest texture coordinates (0 .. 1);AUVMaxthe highest texture coordinates (0 .. 1). Returns: this object, so calls chain
UITableColumn
type UITableColumn = object
One column of a UITable: a view of (the table, the column's index), copied freely. C: Rtable__column_
Members
init(): An empty column handle (names none).static method Wrap(const ATable: Rid; const AColumn: int32): UITableColumn: The columnAColumnof the tableATable(a Rid). Parameters:ATablethe table;AColumnthe column, from 0. Returns: the columnAColumnof the tableATable(a Rid)const method Index(): int32: The column's index (-1 when it names none). Returns: the column's index (-1 when it names none)const method IsValid(): bool:truewhile the index is one of its table's columns. C: Rtable_get_column_count Returns:truewhile the index is one of its table's columnsconst method Header(const AHeader: string): self: The column's header text. C: Rtable_set_column_header Parameters:AHeaderthe header. Returns: this object, so calls chainconst method Header(): string: WhatHeader(..)sets, read back. C: Rtable_get_column_header Returns: the column's header textconst method Width(const AWidth: float32): self: Its width in logical units. C: Rtable_set_column_width Parameters:AWidththe width. Returns: this object, so calls chainconst method Width(): float32: The width it has on screen (a filling column takes more). C: Rtable_get_column_width Returns: the width it has on screen (a filling column takes more)const method Fill(const AFill: float32): self: Above 0: the share of the room the other columns leave that it takes; 0: its width only. C: Rtable_set_column_fill Parameters:AFillthe share of the room it takes. Returns: this object, so calls chainconst method Sortable(const AOn: bool): self:false: a click on its header does not sort (on by default). C: Rtable_set_column_sortable Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Align(const AAlign: UITextAlign): self: Where its texts sit in their cells. C: Rtable_set_column_align Parameters:AAlignthe alignment. Returns: this object, so calls chain
UITableRow
type UITableRow = object
One row of a UITable: a view of (the table, the row's index in the order shown), copied freely; a sort or a removal before it moves the row the index names. C: Rtable__row_ / Rtable__cell
Members
init(): An empty row handle (names none).static method Wrap(const ATable: Rid; const ARow: int32): UITableRow: The rowARowof the tableATable(a Rid). Parameters:ATablethe table;ARowthe row, from 0. Returns: the rowARowof the tableATable(a Rid)const method Index(): int32: The row's index (-1 when it names none). Returns: the row's index (-1 when it names none)const method IsValid(): bool:truewhile the index is one of its table's rows. C: Rtable_get_row_count Returns:truewhile the index is one of its table's rowsconst method Selected(const AOn: bool): self: Adds it to (true) or takes it from the selection. C: Rtable_set_row_selected Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Selected(): bool: WhatSelected(..)sets, read back. C: Rtable_is_row_selected Returns:truewhenSelected(..)turned it onconst method Cell(const AColumn: int32; const AText: string): self: The text of its cell in the columnAColumn(a '|' in it stays). C: Rtable_set_cell Parameters:AColumnthe column, from 0;ATextthe text. Returns: this object, so calls chainconst method Cell(const AColumn: int32): string: WhatCell(..)sets, read back. C: Rtable_get_cell Parameters:AColumnthe column, from 0. Returns: the text of its cell in the columnAColumn(a '|' in it stays)const method TextColor(const AColor: UIColor): self: The colour of the row's texts (a cell's own colour wins; alpha 0: the inherited one). C: Rtable_set_cell_text_color (column -1) Parameters:AColorthe colour. Returns: this object, so calls chainconst method Remove(): Removes the row from its table (the rows after it move up). C: Rtable_remove_row
UITileSection
type UITileSection = object
One section of a UITileView: a view of (the tile view, the section's index), copied freely. C: Rtile_view__section
Members
init(): An empty section handle (names none).static method Wrap(const AView: Rid; const ASection: int32): UITileSection: The sectionASectionof the tile viewAView(a Rid). Parameters:AViewthe view;ASectionthe section. Returns: the sectionASectionof the tile viewAView(a Rid)const method Index(): int32: The section's index (-1 when it names none: a tile before the first section). Returns: the section's index (-1 when it names none: a tile before the first section)const method IsValid(): bool:truewhile the index is one of its tile view's sections. C: Rtile_view_get_section_count Returns:truewhile the index is one of its tile view's sectionsconst method Folded(const AOn: bool): self: Folds (true: its tiles neither drawn nor hit) or unfolds the section; the toggled closure is not run. C: Rtile_view_set_section_folded Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Folded(): bool: WhatFolded(..)sets, read back. C: Rtile_view_is_section_folded Returns:truewhenFolded(..)turned it on
UITile
type UITile = object
What a tile of a UITileView shows, filled by UITileView.Items' closure when the tile is drawn: its texts ("" for none), icon and colours (alpha 0: the theme's), starting from Raven's defaults (no icon, its whole texture, tint white).
Members
Icon: UITextureRes: The picture (an empty handle: none), kept until the tile is described again.IconUVMin: UIPoint: The top-left corner of the part ofIconshown, in texture coordinates (0 .. 1).IconUVMax: UIPoint: The bottom-right corner of the part ofIconshown, in texture coordinates (0 .. 1).Text: string: The name under the icon.Detail: string: A second, dimmer line.Badge: string: A small text at the tile's top right.Note: string: Rows layout: a third line under the detail.Tint: UIColor: The colour the icon is tinted with.IconRadius: float32: The radius of the icon's corners.TextColor: UIColor: The colour of the name.DetailColor: UIColor: The colour of the detail line.
UITileHeader
type UITileHeader = record
What a section header of a UITileView shows, filled by UITileView.Sections' closure: the index of the section's first tile (read when the sections are given), its title and a dimmer detail after it ("" for none).
Members
First: int32: The index of the section's first tile (read when the sections are given).Text: string: The section's title.Detail: string: A dimmer detail after the title ("" for none).
UITreeFunc
type UITreeFunc = ref func(const AItem: UITreeItem)
A tree view's item closure: the item selected or activated.
UITreeContextFunc
type UITreeContextFunc = ref func(const AItem: UITreeItem; const AAt: UIPoint)
A tree view's right-click closure: the item under the pointer (names none in the empty space) and the point in the window (for UIMenu.Open).
UIIndexContextFunc
type UIIndexContextFunc = ref func(const AIndex: int32; const AAt: UIPoint)
A tile view's right-click closure: the tile under the pointer (-1 in the empty space) and the point in the window.
UIItemTextFunc
type UIItemTextFunc = ref func(const AIndex: int32): string
A virtual list's text closure: the text of the row AIndex.
UIItemColorFunc
type UIItemColorFunc = ref func(const AIndex: int32; var AColor: UIColor): bool
A list's row colour closure: true with AColor set colours the row's text, false keeps the theme's.
UICellTextFunc
type UICellTextFunc = ref func(const ARow: int32; const AColumn: int32): string
A virtual table's text closure: the text of the cell (ARow in the order shown).
UICellColorFunc
type UICellColorFunc = ref func(const ARow: int32; const AColumn: int32; var AColor: UIColor): bool
A table's cell colour closure: true with AColor set colours the cell's text.
UISortFunc
type UISortFunc = ref func(const AColumn: int32; const ADescending: bool)
A table's sort closure: the column clicked and the order asked for.
UITileFunc
type UITileFunc = ref func(const AIndex: int32; var ATile: UITile)
A tile view's tile closure: fills ATile for the tile AIndex.
UITileHeaderFunc
type UITileHeaderFunc = ref func(const ASection: int32; var AHeader: UITileHeader)
A tile view's section closure: fills AHeader for the section ASection.
UITileSectionFunc
type UITileSectionFunc = ref func(const ASection: UITileSection)
A tile view's section closure: the section the user folded or unfolded.
UIDragDataFunc
type UIDragDataFunc = ref func(): string
A tile view's drag closure: the data of a drag of the selected tiles ("" keeps their indices).
UIListView
type UIListView = object(UIWidget)
A list of text rows, stored or virtual (the list asks for the rows it draws), one selected. C: Rlist_view_*
Members
static method Create(): UIListView: A new list with no rows. C: Rwidget_create(R_WIDGET_LIST_VIEW) Returns: a new list with no rowsstatic method Kinds(): UIWidgetKinds: The kind a list view views. Returns: the kind a list view viewsconst method AddItem(const AText: string): int32:ATextas the last row: its index. C: Rlist_view_add_item Parameters:ATextthe text. Returns:ATextas the last row: its indexconst method Item(const AIndex: int32; const AText: string): self: The text of the rowAIndex. C: Rlist_view_set_item_text Parameters:AIndexthe index, from 0;ATextthe text. Returns: this object, so calls chainconst method Item(const AIndex: int32): string: WhatItem(..)sets, read back. C: Rlist_view_get_item_text Parameters:AIndexthe index, from 0. Returns: the text of the rowAIndexconst method RemoveItem(const AIndex: int32): self: The rowAIndexremoved (the rows after it move up). C: Rlist_view_remove_item Parameters:AIndexthe index, from 0. Returns: this object, so calls chainconst method ClearItems(): self: Every row removed. C: Rlist_view_clear_items Returns: this object, so calls chainconst method ItemCount(): int32: The rows it has. C: Rlist_view_get_item_count Returns: the rows it hasconst method Virtual(const ACount: int32; const AFunc: UIItemTextFunc): self: Virtual mode, for large or computed data:ACountrows, the list storing none and runningAFuncfor the text of each row it draws. C: Rlist_view_set_virtual_items Parameters:ACounthow many;AFuncthe func it runs. Returns: this object, so calls chainconst method ItemColor(const AFunc: UIItemColorFunc): self: Colours the rows' texts: Raven runsAFuncfor each row it draws (stored or virtual); the colour stays on a selected or hovered row. C: Rlist_view_set_item_color_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method Selected(const AIndex: int32): self: Selects the rowAIndex(-1: none). C: Rlist_view_set_selected Parameters:AIndexthe index, from 0. Returns: this object, so calls chainconst method Selected(): int32: The row selected (-1 for none). C: Rlist_view_get_selected Returns: the row selected (-1 for none)const method ScrollTo(const AIndex: int32): self: Scrolls until the rowAIndexshows. C: Rlist_view_scroll_to_item Parameters:AIndexthe index, from 0. Returns: this object, so calls chainconst method OnSelect(const AFunc: UIIndexFunc): self: RunsAFuncwith the row selected when the selection changes. C: Rlist_view_set_selection_changed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnActivate(const AFunc: UIIndexFunc): self: RunsAFuncwith the row activated (double click, Enter; the widget's action runs too). C: Rlist_view_set_activated_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
Example: LList := UIListView.Create(); LList.AddItem("Ada"); LList.OnActivate(func(const AIndex: int32) begin Open(AIndex); end);
UITreeView
type UITreeView = object(UIWidget)
A tree of text items (virtualized), folding under their parents; one or several selected, draggable. C: Rtree_view_*
Members
static method Create(): UITreeView: A new tree with no items. C: Rwidget_create(R_WIDGET_TREE_VIEW) Returns: a new tree with no itemsstatic method Kinds(): UIWidgetKinds: The kind a tree view views. Returns: the kind a tree view viewsconst method AddItem(const AParent: UITreeItem; const AText: string): UITreeItem: A new itemATextas the last child ofAParent. C: Rtree_view_add_item Parameters:AParentthe parent;ATextthe text. Returns: a new itemATextas the last child ofAParentconst method AddItem(const AText: string): UITreeItem: A new top-level itemAText, the last one. C: Rtree_view_add_item Parameters:ATextthe text. Returns: a new top-level itemAText, the last oneconst method ClearItems(): self: Every item deleted. C: Rtree_view_clear_items Returns: this object, so calls chainconst method ItemCount(): int32: Its top-level items. C: Rtree_view_get_item_count Returns: its top-level itemsconst method Item(const AIndex: int32): UITreeItem: Its top-level item atAIndex(names none outside). C: Rtree_view_get_item Parameters:AIndexthe index, from 0. Returns: its top-level item atAIndex(names none outside)const method Selected(const AItem: UITreeItem): self: SelectsAItemalone (an empty handle: none). C: Rtree_view_set_selected_item Parameters:AItemthe item. Returns: this object, so calls chainconst method Selected(): UITreeItem: The item selected (the one clicked last in a multiple selection; names none for none). C: Rtree_view_get_selected_item Returns: the item selected (the one clicked last in a multiple selection; names none for none)const method MultiSelect(const AOn: bool): self: Several items selectable (Ctrl + click one more, Shift + click a range). C: Rtree_view_set_multi_select Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method ClearSelection(): self: Nothing selected. C: Rtree_view_clear_selection Returns: this object, so calls chainconst method SelectionCount(): int32: The items selected. C: Rtree_view_get_selection_count Returns: the items selectedconst method Selection(const AIndex: int32): UITreeItem: The selected item atAIndex, top to bottom. C: Rtree_view_get_selection Parameters:AIndexthe index, from 0. Returns: the selected item atAIndex, top to bottomconst method ScrollTo(const AItem: UITreeItem): self: Scrolls (unfolding its ancestors) untilAItemshows. C: Rtree_view_scroll_to_item Parameters:AItemthe item. Returns: this object, so calls chainconst method DragType(const AType: string): self: Items can be dragged: the selection goes to the drag with the typeATypeand, as data, the items' Rids in decimal separated by spaces ("": no drag, the default). C: Rtree_view_set_drag_type Parameters:ATypethe type. Returns: this object, so calls chainconst method ItemAt(const AAt: UIPoint): UITreeItem: The item atAAt, a point in the tree (a drop's local point; names none in the empty space). C: Rtree_view_get_item_at Parameters:AAtthe point. Returns: the item atAAt, a point in the tree (a drop's local point; names none in the empty space)const method DropHighlight(const AItem: UITreeItem; const AWholeTree: bool): self: Shows where a drop would go:AItem, or the whole tree whenAWholeTree(an empty handle andfalse: none). C: Rtree_view_set_drop_highlight Parameters:AItemthe item;AWholeTreethe whole tree. Returns: this object, so calls chainconst method OnSelect(const AFunc: UITreeFunc): self: RunsAFuncwith the item selected (the one clicked last) when the selection changes. C: Rtree_view_set_selection_changed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnActivate(const AFunc: UITreeFunc): self: RunsAFuncwith the item activated (double click, Enter; the widget's action runs too). C: Rtree_view_set_activated_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnContext(const AFunc: UITreeContextFunc): self: RunsAFuncon a right click: the item under the pointer (selected first; names none in the empty space) and the point in the window, forUIMenu.Open. C: Rtree_view_set_context_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
Example: LDocs := LTree.AddItem("Docs"); LTree.AddItem(LDocs, "README.md"); LDocs.Expanded(true);
UITable
type UITable = object(UIWidget)
Rows of cells under columns (virtualized): stored rows sort themselves when a header is clicked (numbers by value, texts aside case), a virtual table asks for the cells it draws and leaves the sort to OnSort. Row indices are always those of the order shown. C: Rtable_*
Members
static method Create(): UITable: A new table with no columns. C: Rwidget_create(R_WIDGET_TABLE) Returns: a new table with no columnsstatic method Kinds(): UIWidgetKinds: The kind a table views. Returns: the kind a table viewsconst method AddColumn(const AHeader: string; const AWidth: float32): UITableColumn: A new last column headedAHeader,AWidthwide (0 or less: Raven's 120); the stored rows get an empty cell in it. C: Rtable_add_column Parameters:AHeaderthe header;AWidththe width. Returns: a new last column headedAHeader,AWidthwide (0 or less: Raven's 120); the stored rows get an empty cell in itconst method ColumnCount(): int32: Its columns. C: Rtable_get_column_count Returns: its columnsconst method Column(const AIndex: int32): UITableColumn: Its column atAIndex. Parameters:AIndexthe index, from 0. Returns: its column atAIndexconst method ClearColumns(): self: Every column removed, with the stored rows. C: Rtable_clear_columns Returns: this object, so calls chainconst method AddRow(): UITableRow: A new empty last row (none in virtual mode, or with no column). C: Rtable_add_row Returns: a new empty last row (none in virtual mode, or with no column)const method AddRow(const ACells: array of string): UITableRow: A new last row with the cellsACells, in column order (a '|' in a text stays). C: Rtable_add_row + Rtable_set_cell Parameters:ACellsthe cells. Returns: a new last row with the cellsACells, in column order (a '|' in a text stays)const method Row(const AIndex: int32): UITableRow: Its row atAIndex(in the order shown). Parameters:AIndexthe index, from 0. Returns: its row atAIndex(in the order shown)const method RemoveRow(const AIndex: int32): self: The rowAIndexremoved (the rows after it move up). C: Rtable_remove_row Parameters:AIndexthe index, from 0. Returns: this object, so calls chainconst method ClearRows(): self: Every stored row removed. C: Rtable_clear_rows Returns: this object, so calls chainconst method RowCount(): int32: Its rows (stored or virtual). C: Rtable_get_row_count Returns: its rows (stored or virtual)const method Cell(const ARow: int32; const AColumn: int32; const AText: string): self: The text of the cell (ARow,AColumn) (a '|' in it stays). C: Rtable_set_cell Parameters:ARowthe row, from 0;AColumnthe column, from 0;ATextthe text. Returns: this object, so calls chainconst method Cell(const ARow: int32; const AColumn: int32): string: WhatCell(..)sets, read back. C: Rtable_get_cell Parameters:ARowthe row, from 0;AColumnthe column, from 0. Returns: the text of the cell (ARow,AColumn) (a '|' in it stays)const method Virtual(const ARows: int32; const AFunc: UICellTextFunc): self: Virtual mode, for large or computed data:ARowsrows, the table storing none and runningAFuncfor the text of each cell it draws. C: Rtable_set_virtual_rows Parameters:ARowsthe rows;AFuncthe func it runs. Returns: this object, so calls chainconst method CellColor(const AFunc: UICellColorFunc): self: Colours the cells' texts: Raven runsAFuncfor each cell it draws (it wins overCellTextColor). C: Rtable_set_cell_color_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method CellTextColor(const ARow: int32; const AColumn: int32; const AColor: UIColor): self: A stored cell's fixed text colour (AColumn-1: the whole row; alpha 0: the inherited one). C: Rtable_set_cell_text_color Parameters:ARowthe row, from 0;AColumnthe column, from 0;AColorthe colour. Returns: this object, so calls chainconst method MultiSelect(const AOn: bool): self: Several rows selectable (Ctrl + click one more, Shift + click a range). C: Rtable_set_multi_select Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Selected(const ARow: int32): self: The rowARowselected alone (-1: none). C: Rtable_set_selected Parameters:ARowthe row, from 0. Returns: this object, so calls chainconst method Selected(): int32: The row selected (-1 for none). C: Rtable_get_selected Returns: the row selected (-1 for none)const method ClearSelection(): self: Nothing selected. C: Rtable_clear_selection Returns: this object, so calls chainconst method SelectionCount(): int32: The rows selected. C: Rtable_get_selection_count Returns: the rows selectedconst method Selection(const AIndex: int32): int32: The selected row atAIndex, top to bottom (-1 outside). C: Rtable_get_selection Parameters:AIndexthe index, from 0. Returns: the selected row atAIndex, top to bottom (-1 outside)const method ScrollTo(const ARow: int32): self: Scrolls until the rowARowshows. C: Rtable_scroll_to_row Parameters:ARowthe row, from 0. Returns: this object, so calls chainconst method Sort(const AColumn: int32; const ADescending: bool): self: Sorts by the columnAColumn(stored rows move; -1 shows no sorted column). C: Rtable_sort Parameters:AColumnthe column, from 0;ADescendingthe descending. Returns: this object, so calls chainconst method SortColumn(): int32: The column sorted by (-1 for none). C: Rtable_get_sort_column Returns: the column sorted by (-1 for none)const method SortDescending(): bool:truewhen sorted from the highest down. C: Rtable_is_sort_descending Returns:truewhen sorted from the highest downconst method HeaderVisible(const AOn: bool): self: Shows (true) or hides the header row. C: Rtable_set_header_visible Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method GridLines(const AOn: bool): self: Lines between the cells. C: Rtable_set_grid_lines Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Striped(const AOn: bool): self: Every other row a little darker. C: Rtable_set_striped Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method OnSelect(const AFunc: UIIndexFunc): self: RunsAFuncwith the row selected when the selection changes. C: Rtable_set_selection_changed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnActivate(const AFunc: UIIndexFunc): self: RunsAFuncwith the row activated (double click, Enter). C: Rtable_set_activated_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnSort(const AFunc: UISortFunc): self: RunsAFuncwhen a header is clicked to sort: the column and the order (a virtual table orders its data there). C: Rtable_set_sort_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
Example: LTable.AddColumn("Name", 160.0f); LTable.AddColumn("Age", 60.0f).Align(UITextAlign.Right); LTable.AddRow(["Ada", "36"]);
UITileView
type UITileView = object(UIWidget)
A grid (or rows) of tiles, an icon over a name, virtualized: the program describes each tile Raven draws (Items), optionally cut into foldable sections under headers (Sections, given after the tiles). Several tiles selectable, draggable. C: Rtile_view_*
Members
static method Create(): UITileView: A new tile view with no tiles. C: Rwidget_create(R_WIDGET_TILE_VIEW) Returns: a new tile view with no tilesstatic method Kinds(): UIWidgetKinds: The kind a tile view views. Returns: the kind a tile view viewsconst method Items(const ACount: int32; const AFunc: UITileFunc): self:ACounttiles, each described byAFuncwhen it is drawn; the selection is cleared and the sections removed. C: Rtile_view_set_items Parameters:ACounthow many;AFuncthe func it runs. Returns: this object, so calls chainconst method Refresh(): self: Draws the tiles again (their description changed, not their number). C: Rtile_view_refresh Returns: this object, so calls chainconst method Count(): int32: Its tiles. C: Rtile_view_get_count Returns: its tilesconst method TileSize(const AWidth: float32; const AHeight: float32; const AIconSize: float32): self: The size of a tile (its name included) and of its icon (Raven's: 112 x 112, 64). C: Rtile_view_set_tile_size Parameters:AWidththe width;AHeightthe height;AIconSizethe icon size. Returns: this object, so calls chainconst method EmptyText(const AText: string): self: The text shown when there is no tile. C: Rtile_view_set_empty_text Parameters:ATextthe text. Returns: this object, so calls chainconst method IconWidth(const AWidth: float32): self: Rows layout: the width of the box an icon is drawn in (0: square, the default). C: Rtile_view_set_icon_width Parameters:AWidththe width. Returns: this object, so calls chainconst method Sections(const ACount: int32; const AFunc: UITileHeaderFunc): self:ACountsections, each header described byAFunc(itsFirstread now, its texts when drawn), all unfolded; give them after the tiles. C: Rtile_view_set_sections Parameters:ACounthow many;AFuncthe func it runs. Returns: this object, so calls chainconst method SectionCount(): int32: Its sections. C: Rtile_view_get_section_count Returns: its sectionsconst method Section(const AIndex: int32): UITileSection: The sectionAIndex. Parameters:AIndexthe index, from 0. Returns: the sectionAIndexconst method SectionOf(const AIndex: int32): UITileSection: The section of the tileAIndex(names none before the first section). C: Rtile_view_get_section_of Parameters:AIndexthe index, from 0. Returns: the section of the tileAIndex(names none before the first section)const method SectionAt(const AAt: UIPoint): UITileSection: The section whose header is atAAt, a point in the widget (names none elsewhere). C: Rtile_view_get_section_at Parameters:AAtthe point. Returns: the section whose header is atAAt, a point in the widget (names none elsewhere)const method Selected(const AIndex: int32; const AOn: bool): self: Adds the tileAIndexto (true) or takes it from the selection. C: Rtile_view_set_selected Parameters:AIndexthe index, from 0;AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Selected(const AIndex: int32): bool: WhatSelected(..)sets, read back. C: Rtile_view_is_selected Parameters:AIndexthe index, from 0. Returns:truewhenSelected(..)turned it onconst method ClearSelection(): self: Nothing selected. C: Rtile_view_clear_selection Returns: this object, so calls chainconst method SelectOnly(const AIndex: int32): self: The tileAIndexselected alone. C: Rtile_view_select_only Parameters:AIndexthe index, from 0. Returns: this object, so calls chainconst method Current(): int32: The tile clicked last (-1 for none). C: Rtile_view_get_current Returns: the tile clicked last (-1 for none)const method SelectionCount(): int32: The tiles selected. C: Rtile_view_get_selection_count Returns: the tiles selectedconst method Selection(const ANth: int32): int32: The index of theANthselected tile, in order. C: Rtile_view_get_selection Parameters:ANththe nth. Returns: the index of theANthselected tile, in orderconst method ScrollTo(const AIndex: int32): self: Scrolls until the tileAIndexshows. C: Rtile_view_scroll_to Parameters:AIndexthe index, from 0. Returns: this object, so calls chainconst method ItemAt(const AAt: UIPoint): int32: The tile atAAt, a point in the widget (a drop's local point; -1 elsewhere). C: Rtile_view_get_item_at Parameters:AAtthe point. Returns: the tile atAAt, a point in the widget (a drop's local point; -1 elsewhere)const method DropHighlight(const AIndex: int32): self: Shows the tile a drop would go to (-1: none). C: Rtile_view_set_drop_highlight Parameters:AIndexthe index, from 0. Returns: this object, so calls chainconst method DragType(const AType: string): self: Tiles can be dragged: the selected ones go to the drag with the typeATypeand, as data, their indices separated by spaces orDragData's text ("": no drag). C: Rtile_view_set_drag_type Parameters:ATypethe type. Returns: this object, so calls chainconst method DragData(const AFunc: UIDragDataFunc): self: The data of a drag, given byAFunc(paths of files ..) in place of the indices (its "" keeps them). C: Rtile_view_set_drag_data_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnSelect(const AFunc: UIIndexFunc): self: RunsAFuncwith the current tile (-1 for none) when the selection changes. C: Rtile_view_set_selection_changed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnActivate(const AFunc: UIIndexFunc): self: RunsAFuncwith the tile activated (double click, Enter). C: Rtile_view_set_activated_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnContext(const AFunc: UIIndexContextFunc): self: RunsAFuncon a right click: the tile under the pointer (selected first; -1 in the empty space) and the point in the window. C: Rtile_view_set_context_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnSectionToggled(const AFunc: UITileSectionFunc): self: RunsAFuncwith the section the user folded or unfolded. C: Rtile_view_set_section_toggled_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
Example: LTiles.Items(len(GFiles), func(const AIndex: int32; var ATile: UITile) begin ATile.Text := GFiles[AIndex]; end);
UIMenuItem
type UIMenuItem = object(UIWidget)
One item of a UIMenu: a widget, made by UIMenu.AddItem. Its text is the base's Text too. C: Rmenu_item_*
Members
static method Kinds(): UIWidgetKinds: The kind a menu item views. Returns: the kind a menu item viewsconst method Text(const AText: string): self: The item's text. C: Rmenu_item_set_text Parameters:ATextthe text. Returns: this object, so calls chainconst method Text(): string: WhatText(..)sets, read back. C: Rmenu_item_get_text Returns: the item's textconst method Shortcut(const AKey: UIKey; const AMods: UIModifiers): self: Shows the shortcutAKeywithAModsbeside the item, and runs the item when they are pressed in its menu bar's window. C: Rmenu_item_set_shortcut Parameters:AKeythe key;AModsthe modifier keys. Returns: this object, so calls chainconst method ShortcutText(const AText: string): self: A shortcut hint shown in place of the formatted shortcut, binding no key ("" hides it). C: Rmenu_item_set_shortcut_text Parameters:ATextthe text. Returns: this object, so calls chainconst method ResetShortcutText(): self: The formatted shortcut shown again in place ofShortcutText's. C: Rmenu_item_set_shortcut_text (NULL) Returns: this object, so calls chainconst method Checkable(const AOn: bool): self: The item shows a check mark that a click toggles. C: Rmenu_item_set_checkable Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Checked(const AOn: bool): self: Puts the check mark on (true) or off (a checkable item). C: Rmenu_item_set_checked Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Checked(): bool: True while the item is checked. C: Rmenu_item_is_checked Returns:truewhen it is checkedconst method OnClick(const AFunc: UITaskFunc): self: RunsAFuncwhen the item is clicked (or its shortcut pressed). C: Rmenu_item_set_clicked_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method Icon(const ATexture: UITextureRes): self: The whole ofATextureas the icon before the item's text (after the check mark column; an empty handle removes it), drawn in its own colours; kept while it is set. C: Rmenu_item_set_icon Parameters:ATexturethe texture. Returns: this object, so calls chainconst method Icon(const ATexture: UITextureRes; const AUVMin: UIPoint; const AUVMax: UIPoint; const ATint: bool): self: A part ofATextureas the item's icon (an empty handle removes it); kept while it is set.AUVMin..AUVMax: the part of the texture shown, as texture coordinates (0 .. 1) of its corners;ATinttrue: the texture is a mask drawn in the text colour. C: Rmenu_item_set_icon Parameters:ATexturethe texture;AUVMinthe lowest texture coordinates (0 .. 1);AUVMaxthe highest texture coordinates (0 .. 1);ATintthe tint colour. Returns: this object, so calls chain
UIMenu
type UIMenu = object(UIWidget)
A menu: items, separators, captions and sub-menus, in a menu bar or alone (a menu with no parent opens anywhere: Open, UIWidget.ContextMenu). C: Rmenu_*
Members
static method Create(): UIMenu: A new menu with no parent and no items. C: Rwidget_create(R_WIDGET_MENU) Returns: a new menu with no parent and no itemsstatic method Kinds(): UIWidgetKinds: The kind a menu views. Returns: the kind a menu viewsconst method Title(const ATitle: string): self: The menu's title (in its menu bar, or as a sub-menu's item). C: Rmenu_set_title Parameters:ATitlethe title. Returns: this object, so calls chainconst method TitleColor(const AColor: UIColor): self: The title's colour in an in-window bar (alpha 0: the theme's). C: Rmenu_set_title_color Parameters:AColorthe colour. Returns: this object, so calls chainconst method AddItem(const AText: string): UIMenuItem: A new last itemAText. C: Rmenu_add_item Parameters:ATextthe text. Returns: a new last itemATextconst method AddSeparator(): UIWidget: A separator line after the last item: its widget. C: Rmenu_add_separator Returns: a separator line after the last item: its widgetconst method AddHeader(const AText: string): UIWidget: A caption row keyboard navigation skips: its widget. C: Rmenu_add_header Parameters:ATextthe text. Returns: a caption row keyboard navigation skips: its widgetconst method AddMenu(const ATitle: string): UIMenu: A new last sub-menu titledATitle. C: Rmenu_add_menu Parameters:ATitlethe title. Returns: a new last sub-menu titledATitleconst method Open(const AWindow: UIWindow; const AAt: UIPoint): self: Opens the menu as a popup atAAtinAWindow(logical units). C: Rmenu_open Parameters:AWindowthe window;AAtthe point. Returns: this object, so calls chain
Example: LMenu := UIMenu.Create(); LMenu.AddItem("Rename").OnClick(func() begin Rename(); end); LList.ContextMenu(LMenu);
UIMenuBar
type UIMenuBar = object(UIWidget)
A window's menu bar: menus by title. On macOS the first one of the active window shows in the system's bar (Native, on by default); elsewhere it is drawn in the window. C: Rmenu_bar_*
Members
static method Create(): UIMenuBar: A new menu bar with no menus. C: Rwidget_create(R_WIDGET_MENU_BAR) Returns: a new menu bar with no menusstatic method Kinds(): UIWidgetKinds: The kind a menu bar views. Returns: the kind a menu bar viewsconst method Native(const AOn: bool): self:falsekeeps the bar in the window everywhere (macOS included). C: Rmenu_bar_set_native Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Native(): bool:truewhile the system shows the bar in place of the window. C: Rmenu_bar_is_native Returns:truewhile the system shows the bar in place of the windowconst method AddMenu(const ATitle: string): UIMenu: A new last menu titledATitle. C: Rmenu_add_menu Parameters:ATitlethe title. Returns: a new last menu titledATitleconst method AddDivider(): UIWidget: A divider after the last title of an in-window bar: its widget. C: Rmenu_bar_add_divider Returns: a divider after the last title of an in-window bar: its widget
Example: LFile := LBar.AddMenu("File"); LFile.AddItem("Quit").Shortcut(UIKey.Q, [UIModifier.Ctrl]);
UITextPos
type UITextPos = record
A place in a text editor's text: its line and its column, both from 0.
Members
Line: int32: The line, from 0.Column: int32: The column, from 0.
UITextSpan
type UITextSpan = record
A span of a text editor's text, from its first place up to its last.
Members
First: UITextPos: The span's first place.Last: UITextPos: The span's last place.
UIFileFilter
type UIFileFilter = record
One filter of a file browser's list: the name it shows ("Images") and its patterns, ;-separated (".png;.jpg"; "" for every file).
Members
Name: string: The name the filter shows ("Images").Patterns: string: Its patterns,;-separated (".png;.jpg"; "" for every file).
UIPainter
type UIPainter = object
The drawing a UICustom's paint closure gets, in the widget's own units from its top-left corner: valid during that call only (a painter kept past it draws nothing Raven shows). C: RPainter, Rdraw_*
Members
init(): An empty painter (draws nothing), as a variable declared with no arguments starts.static method Of(const APainter: ptr to RPainter): UIPainter: The painter of Raven'sAPainter(a paint callback's own, for System.Raven.C code). Parameters:APainterthe painter. Returns: the painter of Raven'sAPainter(a paint callback's own, for System.Raven.C code)const method IsValid(): bool:truewhen it names a painter (inside a paint closure). Returns:truewhen it names a painter (inside a paint closure)const method Rect(const ARect: UIRect; const AColor: UIColor; const ARadius: float32):ARectfilled withAColor, its corners rounded byARadius(0: square). C: Rdraw_rect Parameters:ARectthe rectangle;AColorthe colour;ARadiusthe radius.const method RectOutline(const ARect: UIRect; const AWidth: float32; const AColor: UIColor; const ARadius: float32):ARect's outline,AWidthwide, inAColor, its corners rounded byARadius. C: Rdraw_rect_outline Parameters:ARectthe rectangle;AWidththe width;AColorthe colour;ARadiusthe radius.const method Shadow(const ARect: UIRect; const ABlur: float32; const AColor: UIColor; const ARadius: float32): A soft shadow ofARect(corners rounded byARadius), blurred overABlurunits, inAColor. C: Rdraw_shadow Parameters:ARectthe rectangle;ABlurthe blur radius;AColorthe colour;ARadiusthe radius.const method Circle(const ACenter: UIPoint; const ARadius: float32; const AColor: UIColor): A filled circle aroundACenter. C: Rdraw_circle Parameters:ACenterthe centre;ARadiusthe radius;AColorthe colour.const method Line(const AFrom: UIPoint; const ATo: UIPoint; const AWidth: float32; const AColor: UIColor): A straight line fromAFromtoATo,AWidthwide. C: Rdraw_line Parameters:AFromthe start point;ATothe end point;AWidththe width;AColorthe colour.const method Curve(const AFrom: UIPoint; const AControl1: UIPoint; const AControl2: UIPoint; const ATo: UIPoint; const AWidth: float32; const AColor: UIColor): A cubic Bezier curve fromAFromtoATopulled byAControl1andAControl2,AWidthwide. C: Rdraw_curve Parameters:AFromthe start point;AControl1the first control point;AControl2the second control point;ATothe end point;AWidththe width;AColorthe colour.const method Triangle(const AFirst: UIPoint; const ASecond: UIPoint; const AThird: UIPoint; const AColor: UIColor): A filled triangle with the cornersAFirst,ASecondandAThird. C: Rdraw_triangle Parameters:AFirstthe first corner;ASecondthe second corner;AThirdthe third corner;AColorthe colour.const method Glass(const ARect: UIRect; const ARadius: float32; const AColor: UIColor):ARectas frosted glass over what is behind it, tintedAColor, its corners rounded byARadius. C: Rdraw_glass Parameters:ARectthe rectangle;ARadiusthe radius;AColorthe colour.const method Spring(var ASpring: RSpring; const ATarget: float32; const AMotion: UIMotion): float32:ASpringmoved one frame towardATargetasAMotioneases (the widget is drawn again while it moves). C: Rdraw_spring Parameters:ASpringthe spring;ATargetthe target;AMotionthe motion. Returns: the spring's value this frameconst method PushClip(const ARect: UIRect): What is drawn from now on clipped toARect(inside the clip already in place), untilPopClip. C: Rdraw_push_clip_rect Parameters:ARectthe rectangle.const method PopClip(): The clip before the lastPushClipback. C: Rdraw_pop_clip_rectconst method Image(const ATexture: UITextureRes; const ARect: UIRect; const ATint: UIColor):ATexturestretched toARect, multiplied byATint(white: its own colours). C: Rdraw_image Parameters:ATexturethe texture;ARectthe rectangle;ATintthe tint colour.const method Text(const AFont: UIFontRes; const ASize: float32; const AAt: UIPoint; const AColor: UIColor; const AText: string):AText(UTF-8) inAFont(an empty handle: the theme's) at the sizeASize(0: the theme's), the first line's top-left corner atAAt, inAColor. C: Rdraw_text Parameters:AFontthe font;ASizethe size;AAtthe point;AColorthe colour;ATextthe text.const method Shader(const AShader: UIShaderRes; const ARect: UIRect; const ALook: RShaderLook):AShaderdrawn overARectwith the lookALook. C: Rdraw_shader Parameters:AShaderthe shader;ARectthe rectangle;ALookthe look.
Example: LBox.OnPaint(func(const P: UIPainter; const AWidth: float32; const AHeight: float32) begin P.Rect(UIRect(x: 0.0f, y: 0.0f, w: AWidth, h: AHeight), UIColor.FromRGBA(40, 44, 52), 8.0f); end);
UIHoverFunc
type UIHoverFunc = ref func(const ALine: int32; const AColumn: int32): string
What a text editor's hover closure gets: the line and column under the pointer; it returns the tooltip shown there ("" for none).
UIViewportDrawFunc
type UIViewportDrawFunc = ref func(const AInfo: RViewportDrawInfo)
What a viewport's draw closure gets each frame: where to draw and the backend's handles.
UIPaintFunc
type UIPaintFunc = ref func(const APainter: UIPainter; const AWidth: float32; const AHeight: float32)
What a custom widget's paint closure gets: its painter and its size.
UIMeasureFunc
type UIMeasureFunc = ref func(var ASize: UISize)
What a custom widget's measure closure gets: the size it wants, to set (it starts at 0 x 0; the widget is never smaller than its children).
UITextEditor
type UITextEditor = object(UIWidget)
A text / code editor: lines, a cursor and a selection, undo, syntax colouring by a registered language, word completion, markers (errors, warnings) and tooltips. Its text is UIWidget.Text. C: Rtext_editor_*
Members
static method Create(const AText: string): UITextEditor: A new editor holdingAText("" for an empty one). C: Rtext_editor_create Parameters:ATextthe text. Returns: a new editor holdingAText("" for an empty one)static method Kinds(): UIWidgetKinds: The kind a text editor views. Returns: the kind a text editor viewsconst method Length(): int32: The text's length in bytes (UTF-8). C: Rtext_editor_get_length Returns: the text's length in bytes (UTF-8)const method LineCount(): int32: The lines it has (an empty text has one). C: Rtext_editor_get_line_count Returns: the lines it has (an empty text has one)const method Line(const ALine: int32): string: The text of the lineALine(from 0), with no line break ("" past the last). C: Rtext_editor_get_line Parameters:ALinethe line. Returns: the text of the lineALine(from 0), with no line break ("" past the last)const method Insert(const AText: string): self:ATexttyped in at the cursor (replacing the selection), as one undo step. C: Rtext_editor_insert_text Parameters:ATextthe text. Returns: this object, so calls chainconst method Cursor(const APos: UITextPos): self: The cursor put atAPos(kept inside the text), the selection gone. C: Rtext_editor_set_cursor Parameters:APosthe position. Returns: this object, so calls chainconst method Cursor(): UITextPos: Where the cursor is. C: Rtext_editor_get_cursor Returns: where the cursor isconst method Select(const ASpan: UITextSpan): self: The text fromASpan.Firstup toASpan.Lastselected (the cursor at its last place). C: Rtext_editor_select Parameters:ASpanthe span. Returns: this object, so calls chainconst method SelectAll(): self: The whole text selected. C: Rtext_editor_select_all Returns: this object, so calls chainconst method Selection(): UITextSpan: The selection, its first place before its last (both the cursor when nothing is selected:HasSelection). C: Rtext_editor_get_selection Returns: the selection, its first place before its last (both the cursor when nothing is selected:HasSelection)const method HasSelection(): bool:truewhen some text is selected. C: Rtext_editor_get_selection Returns:truewhen some text is selectedconst method SelectedText(): string: The selected text ("" for none). C: Rtext_editor_get_selected_text Returns: the selected text ("" for none)const method ScrollToLine(const ALine: int32): self: Scrolled so the lineALineshows. C: Rtext_editor_scroll_to_line Parameters:ALinethe line. Returns: this object, so calls chainconst method Undo(): self: The last edit taken back. C: Rtext_editor_undo Returns: this object, so calls chainconst method Redo(): self: The last edit taken back made again. C: Rtext_editor_redo Returns: this object, so calls chainconst method CanUndo(): bool:truewhen there is an edit to take back. C: Rtext_editor_can_undo Returns:truewhen there is an edit to take backconst method CanRedo(): bool:truewhen there is an undone edit to make again. C: Rtext_editor_can_redo Returns:truewhen there is an undone edit to make againconst method ReadOnly(const AOn: bool): self: The text can be read and selected but not changed by the user (AOn). C: Rtext_editor_set_read_only Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method WordWrap(const AOn: bool): self: Long lines wrap at the editor's width (AOn) rather than scroll across. C: Rtext_editor_set_word_wrap Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method LineNumbers(const AOn: bool): self: Line numbers shown in a gutter (AOn). C: Rtext_editor_set_line_numbers Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method TabSize(const ASpaces: int32): self: A tab isASpacescolumns wide. C: Rtext_editor_set_tab_size Parameters:ASpacesthe spaces. Returns: this object, so calls chainconst method TabSpaces(const AOn: bool): self: The Tab key types spaces up to the next tab stop (AOn) rather than a tab. C: Rtext_editor_set_tab_inserts_spaces Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Syntax(const ASyntax: UISyntax): self: Coloured by one of Raven's built-in syntaxes (Languagenames any registered one). C: Rtext_editor_set_syntax Parameters:ASyntaxthe syntax. Returns: this object, so calls chainconst method Language(const AName: string): self: Coloured as the registered languageAName("" or an unknown name: plain text). C: Rtext_editor_set_language Parameters:ANamethe name. Returns: this object, so calls chainconst method Language(): string: The language it is coloured as ("" for plain text). C: Rtext_editor_get_language Returns: the language it is coloured as ("" for plain text)const method Placeholder(const AText: string): self: The text shown, dimmed, while the editor is empty. C: Rtext_editor_set_placeholder Parameters:ATextthe text. Returns: this object, so calls chainconst method Zoom(const AZoom: float32): self: The text drawn atAZoomtimes its size (1: as the theme says). C: Rtext_editor_set_zoom Parameters:AZoomthe zoom. Returns: this object, so calls chainconst method Zoom(): float32: WhatZoom(..)sets, read back. C: Rtext_editor_get_zoom Returns: the text drawn atAZoomtimes its size (1: as the theme says)const method Zoomable(const AOn: bool): self: The user may zoom with Ctrl + the wheel or Ctrl +/- (AOn). C: Rtext_editor_set_zoomable Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Markdown(const AOn: bool): self: Markdown shown styled as it is typed (AOn): headings, strong, emphasis, links. C: Rtext_editor_set_markdown Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Markdown(): bool: WhatMarkdown(..)sets, read back. C: Rtext_editor_get_markdown Returns:truewhenMarkdown(..)turned it onconst method Token(const APos: UITextPos): UITokenKind: What the colouring found atAPos(a keyword, a string, a comment ..). C: Rtext_editor_get_token Parameters:APosthe position. Returns: what the colouring found atAPos(a keyword, a string, a comment ..)const method Completion(const AOn: bool): self: Completion offered as the user types (AOn): the wordsAddCompletiongave, those of the text (CompletionWords) and the language's keywords. C: Rtext_editor_set_completion Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method ShowCompletions(): self: The completion list opened at the cursor now. C: Rtext_editor_show_completions Returns: this object, so calls chainconst method Completing(): bool:truewhile the completion list is open. C: Rtext_editor_is_completing Returns:truewhile the completion list is openconst method AddCompletion(const AText: string; const ADetail: string): self:ATextoffered in the completion list,ADetailbeside it ("" for none); best added fromOnCompletion, which runs as the list opens. C: Rtext_editor_add_completion Parameters:ATextthe text;ADetailthe detail. Returns: this object, so calls chainconst method AddCompletion(const AText: string; const ADetail: string; const AInsert: string): self:ATextoffered in the completion list,ADetailbeside it,AInserttyped in when it is picked (a snippet). C: Rtext_editor_add_completion_insert Parameters:ATextthe text;ADetailthe detail;AInsertthe insert. Returns: this object, so calls chainconst method CompletionWords(const AOn: bool): self: The words of the text itself offered in the completion list (AOn). C: Rtext_editor_set_completion_words Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method AutoPairs(const AOn: bool): self: A bracket or quote typed gets its closing one (AOn). C: Rtext_editor_set_auto_pairs Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method AddMarker(const ALine: int32; const AFirst: int32; const ALast: int32; const AKind: UIMarkKind; const AText: string): self: A marker of the kindAKindunder the lineALinefrom the columnAFirstup toALast,ATextits tooltip. C: Rtext_editor_add_marker Parameters:ALinethe line;AFirstthe first column;ALastthe column it runs up to;AKindthe kind;ATextthe text. Returns: this object, so calls chainconst method ClearMarkers(): self: Every marker removed. C: Rtext_editor_clear_markers Returns: this object, so calls chainconst method MarkerCount(): int32: The markers it has. C: Rtext_editor_get_marker_count Returns: the markers it hasconst method OnZoom(const AFunc: UIValueFunc): self: RunsAFuncwith the zoom when the user zooms. C: Rtext_editor_set_zoom_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnCompletion(const AFunc: UITextFunc): self: RunsAFuncwith the word typed so far as the completion list opens: it adds the words to offer (AddCompletion). C: Rtext_editor_set_completion_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnHover(const AFunc: UIHoverFunc): self: RunsAFuncwith the line and column under the pointer resting on text with no marker: the text it returns is the tooltip ("" for none). C: Rtext_editor_set_hover_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnChanged(const AFunc: UITaskFunc): self: RunsAFuncwhenever the text changes (typed, pasted, undone or set). C: Rtext_editor_set_changed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method Font(const AFont: UIFontRes; const ASize: float32): self: The editor's own font at the sizeASize(0: the theme's font size); an empty handle: the theme's font, or the fixed-width one with a language. Kept while it is set. C: Rtext_editor_set_font Parameters:AFontthe font;ASizethe size. Returns: this object, so calls chain
Example: LCode := UITextEditor.Create("begin\nend.").Language("adam").LineNumbers(true);
UIFileBrowser
type UIFileBrowser = object(UIWidget)
A file picker inside a window: a folder's list with places, a path bar, a name field and the Open / Save / Cancel buttons (the system's own file dialog is apart). C: Rfile_browser_*
Members
static method Create(): UIFileBrowser: A new browser opening files in the working folder. C: Rfile_browser_create Returns: a new browser opening files in the working folderstatic method Kinds(): UIWidgetKinds: The kind a file browser views. Returns: the kind a file browser viewsconst method Mode(const AMode: UIBrowserMode): self: What it picks: a file to open, a file to save or a folder. C: Rfile_browser_set_mode Parameters:AModethe mode. Returns: this object, so calls chainconst method Directory(const APath: string): bool: Shows the folderAPath. Parameters:APaththe file's path. Returns:falsewhen it cannot be read (the browser stays where it was). C: Rfile_browser_set_directoryconst method Directory(): string: The folder it shows. C: Rfile_browser_get_directory Returns: the folder it showsconst method Refresh(): self: The folder read again (files added or removed outside). C: Rfile_browser_refresh Returns: this object, so calls chainconst method Filters(const AFilters: array of UIFileFilter): self: The filters its list offers, the first one active (none: every file). C: Rfile_browser_set_filters Parameters:AFiltersthe filters. Returns: this object, so calls chainconst method ShowHidden(const AOn: bool): self: Hidden files and folders listed (AOn). C: Rfile_browser_set_show_hidden Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Multiple(const AOn: bool): self: Several files may be picked at once (AOn; open mode). C: Rfile_browser_set_multiple Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method ControlsVisible(const AOn: bool): self: Its name field and buttons shown (AOn), or only the list (a browser inside a bigger form). C: Rfile_browser_set_controls_visible Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method PlacesVisible(const AOn: bool): self: Its places column (home, drives, recent folders) shown (AOn). C: Rfile_browser_set_places_visible Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method FileName(const AName: string): self: The name in its name field (save mode: the file to save). C: Rfile_browser_set_file_name Parameters:ANamethe name. Returns: this object, so calls chainconst method DefaultExtension(const AExtension: string): self: The extension a saved name with none gets ("txt"; "": the active filter's first). C: Rfile_browser_set_default_extension Parameters:AExtensionthe extension. Returns: this object, so calls chainconst method SelectionCount(): int32: The entries picked in its list. C: Rfile_browser_get_selection_count Returns: the entries picked in its listconst method Selection(const AIndex: int32): string: The full path of the picked entryAIndex("" past the last). C: Rfile_browser_get_selection Parameters:AIndexthe index, from 0. Returns: the full path of the picked entryAIndex("" past the last)const method Select(const AName: string): self: The entry namedANamein the folder shown picked (the others no longer). C: Rfile_browser_select Parameters:ANamethe name. Returns: this object, so calls chainconst method OnAccept(const AFunc: UITextFunc): self: RunsAFuncwith the full path when the user accepts (Open / Save, Enter, a double click; with several picked, once for each). C: Rfile_browser_set_accepted_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnCancel(const AFunc: UITaskFunc): self: RunsAFuncwhen the user cancels (Cancel, Escape). C: Rfile_browser_set_cancelled_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnSelect(const AFunc: UITextFunc): self: RunsAFuncwith the full path of the entry the user moves the selection to. C: Rfile_browser_set_selection_changed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
Example: LPick := UIFileBrowser.Create().Mode(UIBrowserMode.Open).OnAccept(func(const APath: string) begin Load(APath); end);
UIViewport
type UIViewport = object(UIWidget)
A rectangle the app's own renderer draws: a texture it rendered, its draw closure each frame with the backend's handles, or a native child window. C: Rviewport_*
Members
static method Create(): UIViewport: A new viewport showing nothing yet. C: Rwidget_create(R_WIDGET_VIEWPORT) Returns: a new viewport showing nothing yetstatic method Kinds(): UIWidgetKinds: The kind a viewport views. Returns: the kind a viewport viewsconst method Stretch(const AStretch: UIStretch): self: How its texture fits its rectangle. C: Rviewport_set_stretch Parameters:AStretchthe stretch. Returns: this object, so calls chainconst method FlipY(const AOn: bool): self: Its texture drawn upside down (AOn; a bottom-up render target). C: Rviewport_set_flip_y Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Realtime(const AOn: bool): self: The window drawn every frame while it shows (AOn; a game, a 3D view), not only when something changed. C: Rviewport_set_realtime Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Native(const AOn: bool): bool: A native child window in its rectangle (AOn), for a renderer that draws into a window of its own (NativeHandle). Parameters:AOntrueto turn it on,falseto turn it off. Returns:falsewhen the system or the backend has none (headless). C: Rviewport_set_nativeconst method NativeHandle(var ANative: RNativeWindow): bool: The native child window (HWND, X11 Window, wl_surface ..) intoANative. Parameters:ANativereceives the native window. Returns:falsewhen it has none (Nativeoff, headless). C: Rviewport_get_native_handleconst method PixelSize(): UISize: Its size in the window's pixels (its rectangle times the window's scale). C: Rviewport_get_pixel_size Returns: its size in the window's pixels (its rectangle times the window's scale)const method OnDraw(const AFunc: UIViewportDrawFunc): self: RunsAFunceach frame it is drawn, inside the window's render pass: where to draw and the backend's own handles (command buffer, render pass ..). C: Rviewport_set_draw_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnResize(const AFunc: UIResizeFunc): self: RunsAFuncwith its new size in pixels when it changes (a render target to remake). C: Rviewport_set_resize_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method Texture(const ATexture: UITextureRes): self: The texture it shows (mode 1: one the app renders into; an empty handle: nothing); kept while it is set. C: Rviewport_set_texture Parameters:ATexturethe texture. Returns: this object, so calls chain
Example: LView := UIViewport.Create().Realtime(true).OnResize(func(const AWidth: int32; const AHeight: int32) begin Resize(AWidth, AHeight); end);
UICustom
type UICustom = object(UIWidget)
A widget the app draws itself: its paint closure gets a UIPainter each time it is drawn, its measure closure says the size it wants; it may hold children too. C: Rwidget_create(R_WIDGET_CUSTOM), Rcustom_*
Members
static method Create(): UICustom: A new custom widget that draws nothing yet. C: Rwidget_create(R_WIDGET_CUSTOM) Returns: a new custom widget that draws nothing yetstatic method Kinds(): UIWidgetKinds: The kind a custom widget views. Returns: the kind a custom widget viewsconst method OnPaint(const AFunc: UIPaintFunc): self: RunsAFunceach time the widget is drawn, with its painter (valid in the call only) and its size. C: Rcustom_set_paint_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnMeasure(const AFunc: UIMeasureFunc): self: RunsAFuncwhen the layout asks the size the widget wants: it sets the size (it starts at 0 x 0; the widget is never smaller than its children). C: Rcustom_set_measure_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
Example: LDial := UICustom.Create().OnPaint(func(const P: UIPainter; const AWidth: float32; const AHeight: float32) begin P.Circle(UIPoint(x: AWidth / 2.0f, y: AHeight / 2.0f), 20.0f, UIColor.FromRGBA(58, 123, 213)); end);
UICarousel
type UICarousel = object(UIWidget)
Pages shown one at a time, sliding from one to the next: its children are the pages; arrows, dots, autoplay and looping as set. C: Rcarousel_*
Members
static method Create(): UICarousel: A new carousel with no pages. C: Rcarousel_create Returns: a new carousel with no pagesstatic method Kinds(): UIWidgetKinds: The kind a carousel views. Returns: the kind a carousel viewsconst method Page(const APage: int32; const AAnimated: bool): self: The pageAPage(from 0) shown, sliding there whenAAnimated. C: Rcarousel_set_page Parameters:APagethe page;AAnimatedthe animated. Returns: this object, so calls chainconst method Page(): int32: The page it shows. C: Rcarousel_get_page Returns: the page it showsconst method PageCount(): int32: The pages it has. C: Rcarousel_get_page_count Returns: the pages it hasconst method Next(): self: The next page shown (after the last: the first when it loops). C: Rcarousel_next Returns: this object, so calls chainconst method Prev(): self: The page before shown (before the first: the last when it loops). C: Rcarousel_prev Returns: this object, so calls chainconst method Loop(const AOn: bool): self: Going past the last page comes back to the first, and before the first to the last (AOn). C: Rcarousel_set_loop Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Loop(): bool: WhatLoop(..)sets, read back. C: Rcarousel_get_loop Returns:truewhenLoop(..)turned it onconst method Autoplay(const ASeconds: float64): self: The next page shown everyASeconds(0: never). C: Rcarousel_set_autoplay Parameters:ASecondsthe time, in seconds. Returns: this object, so calls chainconst method Autoplay(): float64: WhatAutoplay(..)sets, read back. C: Rcarousel_get_autoplay Returns: the next page shown everyASeconds(0: never)const method Indicators(const AOn: bool): self: A dot for each page shown (AOn). C: Rcarousel_set_indicators_visible Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Indicators(): bool: WhatIndicators(..)sets, read back. C: Rcarousel_get_indicators_visible Returns:truewhenIndicators(..)turned it onconst method Arrows(const AOn: bool): self: Previous / next arrows shown (AOn). C: Rcarousel_set_arrows_visible Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Arrows(): bool: WhatArrows(..)sets, read back. C: Rcarousel_get_arrows_visible Returns:truewhenArrows(..)turned it onconst method Orientation(const AOrientation: UIOrientation): self: The pages slide across (horizontal) or up and down (vertical). C: Rcarousel_set_orientation Parameters:AOrientationthe orientation. Returns: this object, so calls chainconst method Orientation(): UIOrientation: WhatOrientation(..)sets, read back. C: Rcarousel_get_orientation Returns: the pages slide across (horizontal) or up and down (vertical)const method OnChanged(const AFunc: UIIndexFunc): self: RunsAFuncwith the page shown each time it changes. C: Rcarousel_set_page_changed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
Example: LShow := UICarousel.Create().Add(LPage1).Add(LPage2).Loop(true).Autoplay(4.0);
UIPlotPoint
type UIPlotPoint = record
A point in a plot's data units.
Members
X: float64: The x value.Y: float64: The y value.
UILatLon
type UILatLon = record
A place on a map, in degrees: latitude (north positive) and longitude (east positive).
Members
Latitude: float64: Degrees north (south negative).Longitude: float64: Degrees east (west negative).
UIPrintDesc
type UIPrintDesc = record
How a PDF is printed (Raven's RPdfPrintDesc): the window the print dialog belongs to (its Id(); R_INVALID_ID: none), the job's title ("": the document's), the printer ("": the one chosen, else the default), the copies (0: one), the flags, a file the job is written to instead of a printer ("": none) and a protected document's password.
Members
Window: uint32: The window the print dialog belongs to (itsId();R_INVALID_ID: none).Title: string: The job's title ("": the document's).Printer: string: The printer ("": the one chosen, else the default).Copies: int32: The copies (0: one).Flags: UIPrintFlags: The print flags.Output: string: A file the job is written to instead of a printer ("": none).Password: string: A protected document's password.
UIPlotSeries
type UIPlotSeries = object
One series of a UIPlot: a view of (the plot, the series' index), copied freely. Removing a series moves the ones after it down by one. C: Rplot__series_
Members
init(): An empty series handle (names none).static method Wrap(const APlot: Rid; const ASeries: int32): UIPlotSeries: The seriesASeriesof the plotAPlot(a Rid). Parameters:APlotthe plot;ASeriesthe series. Returns: the seriesASeriesof the plotAPlot(a Rid)const method Index(): int32: The series' index (-1 when it names none). Returns: the series' index (-1 when it names none)const method IsValid(): bool:truewhile the index is one of its plot's series. C: Rplot_get_series_count Returns:truewhile the index is one of its plot's seriesconst method Name(const AName: string): self: The name the legend shows. C: Rplot_set_series_name Parameters:ANamethe name. Returns: this object, so calls chainconst method Name(): string: WhatName(..)sets, read back. C: Rplot_get_series_name Returns: the name the legend showsconst method Data(const AX: array of float64; const AY: array of float64): self: Its points: the pairs ofAXandAY(as many as the shorter has), replacing the ones it had (copied). C: Rplot_set_series_data Parameters:AXthe x coordinate;AYthe y coordinate. Returns: this object, so calls chainconst method Append(const AX: array of float64; const AY: array of float64): self: The pairs ofAXandAY(as many as the shorter has) added after its points (copied). C: Rplot_append_series_data Parameters:AXthe x coordinate;AYthe y coordinate. Returns: this object, so calls chainconst method Add(const AX: float64; const AY: float64): self: The point (AX,AY) added after its points. C: Rplot_add_point Parameters:AXthe x coordinate;AYthe y coordinate. Returns: this object, so calls chainconst method ClearData(): self: Every point removed. C: Rplot_clear_series_data Returns: this object, so calls chainconst method PointCount(): int32: The points it has. C: Rplot_get_point_count Returns: the points it hasconst method Point(const AIndex: int32): UIPlotPoint: Its pointAIndex(from 0; 0, 0 for one it does not have). C: Rplot_get_point Parameters:AIndexthe index, from 0. Returns: its pointAIndex(from 0; 0, 0 for one it does not have)const method MaxPoints(const AMax: int32): self: At mostAMaxpoints kept, the oldest leaving first (0: no limit): a live feed. C: Rplot_set_series_max_points Parameters:AMaxthe largest number. Returns: this object, so calls chainconst method Color(const AColor: UIColor): self: Its colour (the theme's own until set). C: Rplot_set_series_color Parameters:AColorthe colour. Returns: this object, so calls chainconst method Line(const AStyle: UILineStyle; const AWidth: float32): self: Its line's style and width in logical units. C: Rplot_set_series_line Parameters:AStylethe style;AWidththe width. Returns: this object, so calls chainconst method Marker(const AShape: UIMarkerShape; const ASize: float32): self: The marker drawn at each point and its size. C: Rplot_set_series_marker Parameters:AShapethe shape;ASizethe size. Returns: this object, so calls chainconst method MarkerFilled(const AOn: bool): self: Its markers filled (AOn) or outlined. C: Rplot_set_series_marker_filled Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Step(const AOn: bool): self: Its line drawn in steps (AOn) rather than straight from point to point. C: Rplot_set_series_step Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Fill(const AOpacity: float32): self: The area under its line filled atAOpacity(0: none, 1: solid). C: Rplot_set_series_fill Parameters:AOpacitythe opacity. Returns: this object, so calls chainconst method Axes(const AX: UIAxis; const AY: UIAxis): self: The axes it is drawn against (UIAxis.X/X2,UIAxis.Y/Y2). C: Rplot_set_series_axes Parameters:AXthe x coordinate;AYthe y coordinate. Returns: this object, so calls chainconst method Visible(const AOn: bool): self: Shown (AOn) or hidden (its legend entry stays). C: Rplot_set_series_visible Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Visible(): bool: WhatVisible(..)sets, read back. C: Rplot_is_series_visible Returns:truewhenVisible(..)turned it onconst method Remove(): The series removed from its plot (the ones after it move down by one). C: Rplot_remove_series
UIPlotAxis
type UIPlotAxis = object
One axis of a UIPlot: a view of (the plot, the axis), copied freely. C: Rplot__axis_
Members
init(): An empty axis handle (names no plot).static method Wrap(const APlot: Rid; const AAxis: UIAxis): UIPlotAxis: The axisAAxisof the plotAPlot(a Rid). Parameters:APlotthe plot;AAxisthe axis. Returns: the axisAAxisof the plotAPlot(a Rid)const method Axis(): UIAxis: Which axis it is. Returns: which axis it isconst method Label(const ALabel: string): self: The text written along it. C: Rplot_set_axis_label Parameters:ALabelthe label. Returns: this object, so calls chainconst method Label(): string: WhatLabel(..)sets, read back. C: Rplot_get_axis_label Returns: the text written along itconst method Scale(const AScale: UIAxisScale): self: Its scale: linear, logarithmic, or symmetric logarithmic (linear near 0). C: Rplot_set_axis_scale Parameters:AScalethe scale. Returns: this object, so calls chainconst method Scale(): UIAxisScale: WhatScale(..)sets, read back. C: Rplot_get_axis_scale Returns: its scale: linear, logarithmic, or symmetric logarithmic (linear near 0)const method LinearThreshold(const AThreshold: float64): self: Where a symmetric logarithmic scale is linear: from -AThresholdtoAThreshold. C: Rplot_set_axis_linear_threshold Parameters:AThresholdthe threshold. Returns: this object, so calls chainconst method Range(const AMin: float64; const AMax: float64): self: The values it shows, fromAMintoAMax(it stops fitting the data). C: Rplot_set_axis_range Parameters:AMinthe lowest value;AMaxthe highest value. Returns: this object, so calls chainconst method Range(): UIRange: The values it shows (Min, Max; Step 0). C: Rplot_get_axis_range Returns: the values it shows (Min, Max; Step 0)const method AutoFit(const AOn: bool): self: Its range follows the data (AOn). C: Rplot_set_axis_auto_fit Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method AutoFit(): bool: WhatAutoFit(..)sets, read back. C: Rplot_is_axis_auto_fit Returns:truewhenAutoFit(..)turned it onconst method Format(const AFormat: string): self: The C format its tick labels are written with ("%.1f"; "": Raven's own). C: Rplot_set_axis_format Parameters:AFormatthe pixel format. Returns: this object, so calls chainconst method Visible(const AOn: bool): self: Shown (AOn) or hidden. C: Rplot_set_axis_visible Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Grid(const AOn: bool): self: Grid lines drawn at its ticks (AOn). C: Rplot_set_axis_grid Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Inverted(const AOn: bool): self: Its values run the other way (AOn). C: Rplot_set_axis_inverted Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Locked(const AOn: bool): self: The user may not pan or zoom it (AOn). C: Rplot_set_axis_locked Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chain
UIDragLine
type UIDragLine = object
One drag line of a UIPlot (a line across it at a value, the user can drag): a view of (the plot, the line's index), copied freely. C: Rplot__drag_line_
Members
init(): An empty drag line handle (names none).static method Wrap(const APlot: Rid; const ALine: int32): UIDragLine: The drag lineALineof the plotAPlot(a Rid). Parameters:APlotthe plot;ALinethe line. Returns: the drag lineALineof the plotAPlot(a Rid)const method Index(): int32: The line's index (-1 when it names none). Returns: the line's index (-1 when it names none)const method IsValid(): bool:truewhile the index is one of its plot's drag lines. C: Rplot_get_drag_line_count Returns:truewhile the index is one of its plot's drag linesconst method Value(const AValue: float64): self: The value it stands at. C: Rplot_set_drag_line_value Parameters:AValuethe value. Returns: this object, so calls chainconst method Value(): float64: WhatValue(..)sets, read back. C: Rplot_get_drag_line_value Returns: the value it stands atconst method Color(const AColor: UIColor): self: Its colour. C: Rplot_set_drag_line_color Parameters:AColorthe colour. Returns: this object, so calls chainconst method Remove(): The line removed from its plot (the ones after it move down by one). C: Rplot_remove_drag_line
UIChartSlice
type UIChartSlice = object
One slice of a pie or donut UIChart: a view of (the chart, the slice's index), copied freely. Removing a slice moves the ones after it down by one. C: Rchart__slice_
Members
init(): An empty slice handle (names none).static method Wrap(const AChart: Rid; const ASlice: int32): UIChartSlice: The sliceASliceof the chartAChart(a Rid). Parameters:AChartthe chart;ASlicethe slice. Returns: the sliceASliceof the chartAChart(a Rid)const method Index(): int32: The slice's index (-1 when it names none). Returns: the slice's index (-1 when it names none)const method IsValid(): bool:truewhile the index is one of its chart's slices. C: Rchart_get_slice_count Returns:truewhile the index is one of its chart's slicesconst method Value(const AValue: float64): self: Its value (its share is its value over the chart's total). C: Rchart_set_slice_value Parameters:AValuethe value. Returns: this object, so calls chainconst method Value(): float64: WhatValue(..)sets, read back. C: Rchart_get_slice_value Returns: its value (its share is its value over the chart's total)const method Label(const ALabel: string): self: Its label. C: Rchart_set_slice_label Parameters:ALabelthe label. Returns: this object, so calls chainconst method Label(): string: WhatLabel(..)sets, read back. C: Rchart_get_slice_label Returns: its labelconst method Color(const AColor: UIColor): self: Its colour (the theme's own until set). C: Rchart_set_slice_color Parameters:AColorthe colour. Returns: this object, so calls chainconst method Remove(): The slice removed from its chart. C: Rchart_remove_slice
UIMapMarker
type UIMapMarker = object
One marker of a UIMapView: a view of (the map, the marker's id), copied freely; the id stays the marker's while others come and go. C: Rmap_view__marker_
Members
init(): An empty marker handle (names none).static method Wrap(const AMap: Rid; const AMarker: int32): UIMapMarker: The marker with the idAMarkeron the mapAMap(a Rid). Parameters:AMapthe map;AMarkerthe marker. Returns: the marker with the idAMarkeron the mapAMap(a Rid)const method Id(): int32: The marker's id (-1 when it names none). Returns: the marker's id (-1 when it names none)const method IsValid(): bool:truewhen it names a marker id (Raven gives -1 for a marker it could not add). Returns:truewhen it names a marker id (Raven gives -1 for a marker it could not add)const method Position(const ALatitude: float64; const ALongitude: float64): self: The place it stands at. C: Rmap_view_set_marker_position Parameters:ALatitudethe latitude;ALongitudethe longitude. Returns: this object, so calls chainconst method Label(const ALabel: string): self: The text shown beside it ("": none). C: Rmap_view_set_marker_label Parameters:ALabelthe label. Returns: this object, so calls chainconst method Color(const AColor: UIColor): self: Its colour (the theme's accent until set). C: Rmap_view_set_marker_color Parameters:AColorthe colour. Returns: this object, so calls chainconst method Remove(): The marker removed from its map. C: Rmap_view_remove_marker
UISeriesToggleFunc
type UISeriesToggleFunc = ref func(const ASeries: UIPlotSeries; const AVisible: bool)
What UIPlot.OnSeriesToggled runs when the user shows or hides a series from the legend: the series and whether it is shown now.
UIDragLineFunc
type UIDragLineFunc = ref func(const ALine: UIDragLine; const AValue: float64)
What UIPlot.OnDragLine runs while the user drags a line: the line and its value.
UISliceFunc
type UISliceFunc = ref func(const ASlice: UIChartSlice; const ASelected: bool)
What UIChart.OnSliceClick runs when the user clicks a slice: the slice and whether it is selected now.
UICellFunc
type UICellFunc = ref func(const ARow: int32; const AColumn: int32; const AValue: float32)
What UIChart.OnCellClick runs when the user clicks a heatmap cell: its row, column and value.
UIMapTileFunc
type UIMapTileFunc = ref func(const AZoom: int32; const AX: int32; const AY: int32)
What UIMapView.OnTile / OnTileCancel run: the tile's zoom level and its column and row at that level.
UIMarkerFunc
type UIMarkerFunc = ref func(const AMarker: UIMapMarker)
What UIMapView.OnMarkerClick runs when the user clicks a marker.
UIMapViewFunc
type UIMapViewFunc = ref func(const ALatitude: float64; const ALongitude: float64; const AZoom: float64)
What UIMapView.OnViewChanged runs when the user moves the map: its center and zoom.
UIPlot
type UIPlot = object(UIWidget)
A plot of series of points against axes (X / Y, and X2 / Y2 on the far sides): lines, markers, steps, fills; the user pans, zooms, toggles series in the legend and drags the drag lines. C: Rplot_*
Members
static method Create(): UIPlot: A new plot with no series. C: Rwidget_create (R_WIDGET_PLOT) Returns: a new plot with no seriesstatic method Kinds(): UIWidgetKinds: The kind a plot views. Returns: the kind a plot viewsconst method Title(const ATitle: string): self: The title written above it. C: Rplot_set_title Parameters:ATitlethe title. Returns: this object, so calls chainconst method Title(): string: WhatTitle(..)sets, read back. C: Rplot_get_title Returns: the title written above itconst method AddSeries(const AName: string): UIPlotSeries: A new series namedAName(the legend's text), with no points. C: Rplot_add_series Parameters:ANamethe name. Returns: a new series namedAName(the legend's text), with no pointsconst method RemoveSeries(const ASeries: UIPlotSeries): self:ASeriesremoved (the ones after it move down by one). C: Rplot_remove_series Parameters:ASeriesthe series. Returns: this object, so calls chainconst method Clear(): self: Every series and drag line removed. C: Rplot_clear Returns: this object, so calls chainconst method SeriesCount(): int32: The series it has. C: Rplot_get_series_count Returns: the series it hasconst method Series(const AIndex: int32): UIPlotSeries: Its seriesAIndex(from 0). Parameters:AIndexthe index, from 0. Returns: its seriesAIndex(from 0)const method Axis(const AAxis: UIAxis): UIPlotAxis: Its axisAAxis. Parameters:AAxisthe axis. Returns: its axisAAxisconst method Fit(): self: Every axis not locked fitted to the data, following it again. C: Rplot_fit Returns: this object, so calls chainconst method Legend(const APlace: UILegendPlace): self: Where the legend goes (UILegendPlace.Hidden: none). C: Rplot_set_legend Parameters:APlacethe place. Returns: this object, so calls chainconst method Crosshair(const AOn: bool): self: Lines across it under the pointer (AOn). C: Rplot_set_crosshair Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method MouseText(const AOn: bool): self: The pointer's place in data units written in a corner (AOn). C: Rplot_set_mouse_text Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Tooltips(const AOn: bool): self: The point nearest the pointer shown in a tooltip (AOn). C: Rplot_set_tooltips Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method MousePosition(var APoint: UIPlotPoint): bool: The pointer's place in data units inAPoint(X / Y axes). C: Rplot_get_mouse_position Parameters:APointthe point. Returns:truewhen the pointer is over the plot's areaconst method DataToPoint(const AX: float64; const AY: float64): UIPoint: Where the data point (AX,AY) is drawn, in the plot's own units from its top-left corner (after a layout). C: Rplot_data_to_point Parameters:AXthe x coordinate;AYthe y coordinate. Returns: where the data point (AX,AY) is drawn, in the plot's own units from its top-left corner (after a layout)const method PointToData(const APoint: UIPoint): UIPlotPoint: The data point drawn atAPoint(the plot's own units). C: Rplot_point_to_data Parameters:APointthe point. Returns: the data point drawn atAPoint(the plot's own units)const method AddDragLine(const AAxis: UIAxis; const AValue: float64; const ALabel: string): UIDragLine: A new drag line across the plot atAValueofAAxis, labelledALabel("": none). C: Rplot_add_drag_line Parameters:AAxisthe axis;AValuethe value;ALabelthe label. Returns: a new drag line across the plot atAValueofAAxis, labelledALabel("": none)const method DragLineCount(): int32: The drag lines it has. C: Rplot_get_drag_line_count Returns: the drag lines it hasconst method DragLine(const AIndex: int32): UIDragLine: Its drag lineAIndex(from 0). Parameters:AIndexthe index, from 0. Returns: its drag lineAIndex(from 0)const method OnViewChanged(const AFunc: UITaskFunc): self: RunsAFunceach time the user pans or zooms it. C: Rplot_set_view_changed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnDragLine(const AFunc: UIDragLineFunc): self: RunsAFuncwith the line and its value while the user drags a drag line. C: Rplot_set_drag_line_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnSeriesToggled(const AFunc: UISeriesToggleFunc): self: RunsAFuncwith the series and whether it is shown when the user toggles it in the legend. C: Rplot_set_series_toggled_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
Example: LPlot := UIPlot.Create().Title("Signal"); LPlot.AddSeries("sin").Data(LX, LY).Color(UIColor.FromRGBA(58, 123, 213));
UIChart
type UIChart = object(UIWidget)
A chart of one kind: pie or donut (slices), gauge (a value in a range, coloured bands), heatmap (a grid of cells, coloured along a scale) or sparkline (a small line of values). Each kind uses its own members; the kind may change. C: Rchart_*
Members
static method Create(const AKind: UIChartKind): UIChart: A new chart of the kindAKind, empty. C: Rchart_create Parameters:AKindthe kind. Returns: a new chart of the kindAKind, emptystatic method Kinds(): UIWidgetKinds: The kind a chart views. Returns: the kind a chart viewsconst method Kind(const AKind: UIChartKind): self: The chart's kind (what it keeps of the others stays for a change back). C: Rchart_set_kind Parameters:AKindthe kind. Returns: this object, so calls chainconst method ChartKind(): UIChartKind: Its chart kind (Kind()stays the widget's kind,UIWidgetKind.Chart). C: Rchart_get_kind Returns: its chart kind (Kind()stays the widget's kind,UIWidgetKind.Chart)const method Title(const ATitle: string): self: The title written above it. C: Rchart_set_title Parameters:ATitlethe title. Returns: this object, so calls chainconst method Title(): string: WhatTitle(..)sets, read back. C: Rchart_get_title Returns: the title written above itconst method Format(const AFormat: string): self: The C format its values are written with ("%.0f%%"; "": Raven's own). C: Rchart_set_format Parameters:AFormatthe pixel format. Returns: this object, so calls chainconst method Color(const AColor: UIColor): self: Its main colour (a gauge's arc, a sparkline's line). C: Rchart_set_color Parameters:AColorthe colour. Returns: this object, so calls chainconst method Legend(const AOn: bool): self: A legend shown (AOn). C: Rchart_set_legend Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Clear(): self: Every slice, band, cell and value removed. C: Rchart_clear Returns: this object, so calls chainconst method HoveredIndex(): int32: The slice or cell under the pointer (-1: none; a cell as row x columns + column). C: Rchart_get_hovered Returns: the slice or cell under the pointer (-1: none; a cell as row x columns + column)const method AddSlice(const ALabel: string; const AValue: float64): UIChartSlice: A new slice labelledALabelworthAValue(pie / donut). C: Rchart_add_slice Parameters:ALabelthe label;AValuethe value. Returns: a new slice labelledALabelworthAValue(pie / donut)const method SliceCount(): int32: The slices it has. C: Rchart_get_slice_count Returns: the slices it hasconst method Slice(const AIndex: int32): UIChartSlice: Its sliceAIndex(from 0). Parameters:AIndexthe index, from 0. Returns: its sliceAIndex(from 0)const method Total(): float64: The sum of its slices' values. C: Rchart_get_total Returns: the sum of its slices' valuesconst method Selected(const AIndex: int32): self: The sliceAIndexselected (pulled out; -1: none). C: Rchart_set_selected Parameters:AIndexthe index, from 0. Returns: this object, so calls chainconst method Selected(): int32: The selected slice (-1: none). C: Rchart_get_selected Returns: the selected slice (-1: none)const method Hole(const ARatio: float32): self: A donut's hole, as a share of its radius (0 .. 1). C: Rchart_set_hole Parameters:ARatiothe ratio. Returns: this object, so calls chainconst method CenterText(const AText: string; const ACaption: string): self: The text written in a donut's hole, a smaller caption under it ("": none). C: Rchart_set_center_text Parameters:ATextthe text;ACaptionthe caption. Returns: this object, so calls chainconst method OnSliceClick(const AFunc: UISliceFunc): self: RunsAFuncwith the slice and whether it is selected when the user clicks one. C: Rchart_set_slice_clicked_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method Range(const AMin: float64; const AMax: float64): self: A gauge's range, fromAMintoAMax. C: Rchart_set_range Parameters:AMinthe lowest value;AMaxthe highest value. Returns: this object, so calls chainconst method Range(): UIRange: A gauge's range (Min, Max; Step 0). C: Rchart_get_range Returns: a gauge's range (Min, Max; Step 0)const method Value(const AValue: float64): self: A gauge's value. C: Rchart_set_value Parameters:AValuethe value. Returns: this object, so calls chainconst method Value(): float64: WhatValue(..)sets, read back. C: Rchart_get_value Returns: a gauge's valueconst method AddBand(const AFrom: float64; const ATo: float64; const AColor: UIColor): self: A band of a gauge's arc fromAFromtoATocolouredAColor. C: Rchart_add_band Parameters:AFromthe band's start;ATothe band's end;AColorthe colour. Returns: this object, so calls chainconst method ClearBands(): self: Every band removed. C: Rchart_clear_bands Returns: this object, so calls chainconst method BandCount(): int32: The bands a gauge has. C: Rchart_get_band_count Returns: the bands a gauge hasconst method Grid(const ARows: int32; const AColumns: int32): self: A heatmap ofARowsxAColumnscells, every one 0. C: Rchart_set_grid Parameters:ARowsthe rows;AColumnsthe columns. Returns: this object, so calls chainconst method Grid(const ARows: int32; const AColumns: int32; const AValues: array of float32): self: A heatmap ofARowsxAColumnscells, their values row by row fromAValues(copied; one too short leaves every cell 0). C: Rchart_set_grid Parameters:ARowsthe rows;AColumnsthe columns;AValuesthe values. Returns: this object, so calls chainconst method RowCount(): int32: A heatmap's rows. C: Rchart_get_row_count Returns: a heatmap's rowsconst method ColumnCount(): int32: A heatmap's columns. C: Rchart_get_column_count Returns: a heatmap's columnsconst method Cell(const ARow: int32; const AColumn: int32; const AValue: float32): self: The value of a heatmap's cell atARow,AColumn. C: Rchart_set_cell Parameters:ARowthe row, from 0;AColumnthe column, from 0;AValuethe value. Returns: this object, so calls chainconst method Cell(const ARow: int32; const AColumn: int32): float32: WhatCell(..)sets, read back. C: Rchart_get_cell Parameters:ARowthe row, from 0;AColumnthe column, from 0. Returns: the value of a heatmap's cell atARow,AColumnconst method RowLabels(const ALabels: array of string): self: A heatmap's row labels, the first row's first (none: no labels). C: Rchart_set_row_labels Parameters:ALabelsthe labels. Returns: this object, so calls chainconst method ColumnLabels(const ALabels: array of string): self: A heatmap's column labels, the first column's first (none: no labels). C: Rchart_set_column_labels Parameters:ALabelsthe labels. Returns: this object, so calls chainconst method RowLabel(const AIndex: int32): string: The label of a heatmap's rowAIndex("": none). C: Rchart_get_row_label Parameters:AIndexthe index, from 0. Returns: the label of a heatmap's rowAIndex("": none)const method ColumnLabel(const AIndex: int32): string: The label of a heatmap's columnAIndex("": none). C: Rchart_get_column_label Parameters:AIndexthe index, from 0. Returns: the label of a heatmap's columnAIndex("": none)const method ColorScale(const ALow: UIColor; const AHigh: UIColor): self: A heatmap's colours:ALowfor its smallest value,AHighfor its largest. C: Rchart_set_color_scale Parameters:ALowthe colour for the smallest value;AHighthe colour for the largest value. Returns: this object, so calls chainconst method OnCellClick(const AFunc: UICellFunc): self: RunsAFuncwith the cell's row, column and value when the user clicks a heatmap cell. C: Rchart_set_cell_clicked_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method Values(const AValues: array of float32): self: A sparkline's values, replacing the ones it had (copied). C: Rchart_set_values Parameters:AValuesthe values. Returns: this object, so calls chainconst method Push(const AValue: float32; const AMaxCount: int32): self:AValueadded after a sparkline's values, the oldest leaving pastAMaxCount(0: no limit). C: Rchart_push_value Parameters:AValuethe value;AMaxCountthe max count. Returns: this object, so calls chainconst method ValueCount(): int32: The values a sparkline has. C: Rchart_get_value_count Returns: the values a sparkline hasconst method ValueAt(const AIndex: int32): float32: A sparkline's valueAIndex(from 0, the oldest). C: Rchart_get_value_at Parameters:AIndexthe index, from 0. Returns: a sparkline's valueAIndex(from 0, the oldest)const method Fill(const AOn: bool): self: The area under a sparkline filled (AOn). C: Rchart_set_fill Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Marker(const AOn: bool): self: A marker on a sparkline's last value (AOn). C: Rchart_set_marker Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chain
Example: LPie := UIChart.Create(UIChartKind.Donut).Title("Disk"); LPie.AddSlice("Used", 61.0); LPie.AddSlice("Free", 39.0);
UIPDFView
type UIPDFView = object(UIWidget)
A PDF document shown page under page, scrolled and zoomed by the user. Raven draws the pages with PDFium, opened at run time (RAVEN_PDFIUM, beside the program, or where the system looks): where it is not found the view says so and its status is UIPDFStatus.Unavailable. C: Rpdf_view_*
Members
static method Create(): UIPDFView: A new PDF view, empty. C: Rwidget_create (R_WIDGET_PDF_VIEW) Returns: a new PDF view, emptystatic method Kinds(): UIWidgetKinds: The kind a PDF view views. Returns: the kind a PDF view viewsstatic method Available(): bool:truewhen PDFium was found: PDF views can show documents and PDFs can be printed on Windows. C: Rpdf_is_available Returns:truewhen PDFium was found: PDF views can show documents and PDFs can be printed on Windowsconst method LoadFile(const APath: string): bool: The PDF fileAPathshown (read through Adam's streams). C: Rpdf_view_load_file Parameters:APaththe file's path. Returns:falsewhen it cannot be shown (seeStatus())const method LoadFile(const APath: string; const APassword: string): bool: The PDF fileAPath, protected byAPassword, shown. C: Rpdf_view_load_file Parameters:APaththe file's path;APasswordthe password. Returns:falsewhen it cannot be shown (seeStatus())const method LoadMemory(const AData: array of uint8): bool: The PDF inADatashown (copied). C: Rpdf_view_load_memory Parameters:ADatathe bytes. Returns:falsewhen it cannot be shown (seeStatus())const method LoadMemory(const AData: array of uint8; const APassword: string): bool: The PDF inAData, protected byAPassword, shown (copied). C: Rpdf_view_load_memory Parameters:ADatathe bytes;APasswordthe password. Returns:falsewhen it cannot be shown (seeStatus())const method Close(): self: The document closed: the view is empty. C: Rpdf_view_close Returns: this object, so calls chainconst method Status(): UIPDFStatus: What it shows: nothing, a document, or why it shows none. C: Rpdf_view_get_status Returns: what it shows: nothing, a document, or why it shows noneconst method PageCount(): int32: The pages of the document shown. C: Rpdf_view_get_page_count Returns: the pages of the document shownconst method PageSize(const APage: int32): UISize: The size of its pageAPage(from 0) in points (1/72 inch). C: Rpdf_view_get_page_size Parameters:APagethe page. Returns: the size of its pageAPage(from 0) in points (1/72 inch)const method Page(const APage: int32): self: Scrolled to its pageAPage(from 0). C: Rpdf_view_set_page Parameters:APagethe page. Returns: this object, so calls chainconst method Page(): int32: The page at the top of the view. C: Rpdf_view_get_page Returns: the page at the top of the viewconst method Zoom(const AZoom: float32): self: Its zoom (1: the pages at their size; it stops fitting). C: Rpdf_view_set_zoom Parameters:AZoomthe zoom. Returns: this object, so calls chainconst method Zoom(): float32: WhatZoom(..)sets, read back. C: Rpdf_view_get_zoom Returns: its zoom (1: the pages at their size; it stops fitting)const method Fit(const AFit: UIPDFFit): self: How the pages fit the view: its width, a whole page, or the zoom set. C: Rpdf_view_set_fit Parameters:AFitthe fit. Returns: this object, so calls chainconst method Fit(): UIPDFFit: WhatFit(..)sets, read back. C: Rpdf_view_get_fit Returns: how the pages fit the view: its width, a whole page, or the zoom setconst method Title(): string: The document's title ("": none). C: Rpdf_view_get_title Returns: the document's title ("": none)const method PageText(const APage: int32): string: The text of its pageAPage(from 0). C: Rpdf_view_get_page_text Parameters:APagethe page. Returns: the text of its pageAPage(from 0)const method Print(const ADesc: UIPrintDesc): bool: The document shown printed asADescsays (the job named after its title). Waits until the job is sent. C: Rpdf_view_print Parameters:ADescthe print settings. Returns:falsewhen cancelled or when it cannot printconst method OnPageChanged(const AFunc: UIIndexFunc): self: RunsAFuncwith the page at the top each time the user scrolls to another. C: Rpdf_view_set_page_changed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
Example: LDoc := UIPDFView.Create(); if not LDoc.LoadFile("manual.pdf") then println("{}", nameof(LDoc.Status())); end;
UIMapView
type UIMapView = object(UIWidget)
A slippy map of square tiles (Web Mercator, zoom 0 .. 24) the user drags and zooms, with markers. Raven fetches nothing from the network: the program hands it the tiles its tile closure asks for (Tile / TileData / TileFailed, from any thread), or names a folder of tile files (TilePath). C: Rmap_view_*
Members
static method Create(): UIMapView: A new map, centered on 0, 0 at zoom 0, with no tiles. C: Rmap_view_create Returns: a new map, centered on 0, 0 at zoom 0, with no tilesstatic method Kinds(): UIWidgetKinds: The kind a map views. Returns: the kind a map viewsconst method Center(const ALatitude: float64; const ALongitude: float64): self: The place at its center, at once. C: Rmap_view_set_center Parameters:ALatitudethe latitude;ALongitudethe longitude. Returns: this object, so calls chainconst method Center(): UILatLon: WhatCenter(..)sets, read back. C: Rmap_view_get_center Returns: the place at its center, at onceconst method Zoom(const AZoom: float64): self: Its zoom (0: the whole world in one tile; each step doubles the scale), at once, kept within its zoom range. C: Rmap_view_set_zoom Parameters:AZoomthe zoom. Returns: this object, so calls chainconst method Zoom(): float64: WhatZoom(..)sets, read back. C: Rmap_view_get_zoom Returns: its zoom (0: the whole world in one tile; each step doubles the scale), at once, kept within its zoom rangeconst method ZoomRange(const AMin: float64; const AMax: float64): self: The zooms the user may reach, fromAMintoAMax(within 0 .. 24). C: Rmap_view_set_zoom_range Parameters:AMinthe lowest value;AMaxthe highest value. Returns: this object, so calls chainconst method ZoomRange(): UIRange: Its zoom range (Min, Max; Step 0). C: Rmap_view_get_zoom_range Returns: its zoom range (Min, Max; Step 0)const method AnimateTo(const ALatitude: float64; const ALongitude: float64; const AZoom: float64): self: Flies to the place atAZoom(at once while animations are off). C: Rmap_view_animate_to Parameters:ALatitudethe latitude;ALongitudethe longitude;AZoomthe zoom. Returns: this object, so calls chainconst method ScreenToLatLon(const APoint: UIPoint): UILatLon: The place drawn atAPoint(the map's own units from its top-left corner). C: Rmap_view_screen_to_latlon Parameters:APointthe point. Returns: the place drawn atAPoint(the map's own units from its top-left corner)const method LatLonToScreen(const ALatitude: float64; const ALongitude: float64): UIPoint: Where the place is drawn, in the map's own units from its top-left corner. C: Rmap_view_latlon_to_screen Parameters:ALatitudethe latitude;ALongitudethe longitude. Returns: where the place is drawn, in the map's own units from its top-left cornerconst method OnTile(const AFunc: UIMapTileFunc): self: RunsAFuncwith a tile's zoom, column and row each time the map wants a tile it does not have (on the UI thread, while it paints); the program answers withTile,TileDataorTileFailed. C: Rmap_view_set_tile_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnTileCancel(const AFunc: UIMapTileFunc): self: RunsAFuncwith a tile asked for that the map no longer wants (moved away before it came). C: Rmap_view_set_tile_cancel_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method Tile(const AZoom: int32; const AX: int32; const AY: int32; const APixels: array of uint8; const AWidth: int32; const AHeight: int32): self: The tileAZoom/AX/AYasAWidthxAHeightRGBA pixels (rows from the top; copied; 1 .. 4096 on a side). C: Rmap_view_set_tile Parameters:AZoomthe zoom;AXthe x coordinate;AYthe y coordinate;APixelsthe pixels;AWidththe width;AHeightthe height. Returns: this object, so calls chainconst method TileData(const AZoom: int32; const AX: int32; const AY: int32; const AData: array of uint8): self: The tileAZoom/AX/AYfrom an image file's bytes (PNG, JPEG ..; decoded). C: Rmap_view_set_tile_data Parameters:AZoomthe zoom;AXthe x coordinate;AYthe y coordinate;ADatathe bytes. Returns: this object, so calls chainconst method TileFailed(const AZoom: int32; const AX: int32; const AY: int32): self: The tileAZoom/AX/AYcannot be had (the map draws a coarser one there). C: Rmap_view_set_tile_failed Parameters:AZoomthe zoom;AXthe x coordinate;AYthe y coordinate. Returns: this object, so calls chainconst method TilePath(const APath: string): self: A folder of tile files the map reads itself: a path with{z},{x}and{y}in it ("tiles/{z}/{x}/{y}.png"; local files only; "": none). C: Rmap_view_set_tile_path Parameters:APaththe file's path. Returns: this object, so calls chainconst method TilePath(): string: WhatTilePath(..)sets, read back. C: Rmap_view_get_tile_path Returns: a folder of tile files the map reads itself: a path with{z},{x}and{y}in it ("tiles/{z}/{x}/{y}.png"; local files only; "": none)const method TileSize(const ASize: int32): self: The size its tiles are drawn at, in logical units (16 .. 1024; 256 at first). C: Rmap_view_set_tile_size Parameters:ASizethe size. Returns: this object, so calls chainconst method TileSize(): int32: WhatTileSize(..)sets, read back. C: Rmap_view_get_tile_size Returns: the size its tiles are drawn at, in logical units (16 .const method CacheSize(const ABytes: int64): self: The bytes of tiles it keeps (64 MB at first), the least recently drawn leaving first. C: Rmap_view_set_cache_size Parameters:ABytesthe bytes. Returns: this object, so calls chainconst method CacheUsage(): int64: The bytes its tiles take now. C: Rmap_view_get_cache_usage Returns: the bytes its tiles take nowconst method ClearTiles(): self: Every tile it has dropped (asked for again as they are drawn). C: Rmap_view_clear_tiles Returns: this object, so calls chainconst method TileState(const AZoom: int32; const AX: int32; const AY: int32): UITileState: Where its tileAZoom/AX/AYstands. C: Rmap_view_get_tile_state Parameters:AZoomthe zoom;AXthe x coordinate;AYthe y coordinate. Returns: where its tileAZoom/AX/AYstandsconst method AddMarker(const ALatitude: float64; const ALongitude: float64; const ALabel: string): UIMapMarker: A new marker at the place, labelledALabel("": none). C: Rmap_view_add_marker Parameters:ALatitudethe latitude;ALongitudethe longitude;ALabelthe label. Returns: a new marker at the place, labelledALabel("": none)const method ClearMarkers(): self: Every marker removed. C: Rmap_view_clear_markers Returns: this object, so calls chainconst method MarkerCount(): int32: The markers it has. C: Rmap_view_get_marker_count Returns: the markers it hasconst method OnMarkerClick(const AFunc: UIMarkerFunc): self: RunsAFuncwith the marker the user clicks. C: Rmap_view_set_marker_clicked_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnViewChanged(const AFunc: UIMapViewFunc): self: RunsAFuncwith the map's center and zoom each time the user moves it or a move ends. C: Rmap_view_set_view_changed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method Attribution(const AText: string): self: The credit written in a corner (the tiles' source: "© OpenStreetMap"; "": none). C: Rmap_view_set_attribution Parameters:ATextthe text. Returns: this object, so calls chainconst method Attribution(): string: WhatAttribution(..)sets, read back. C: Rmap_view_get_attribution Returns: the credit written in a corner (the tiles' source: "© OpenStreetMap"; "": none)
Example: LMap := UIMapView.Create().TilePath("tiles/{z}/{x}/{y}.png").Center(48.8566, 2.3522).Zoom(12.0);
UIPDFDocRes
type UIPDFDocRes = object
A PDF the program writes: pages of a size in points (1/72 inch, from the top-left, y down; A4 595.28 x 841.89), drawn with shapes, text in an embedded font (Roboto, Roboto Mono, or a TrueType font added), pictures and windows; saved, kept in memory or printed. Drawing goes to the last page added (an A4 page is added when there is none). A shared handle: the last copy deletes the document, the app's end too. C: Rpdf_document_* (Rpdf_document_delete: the last copy's release)
Members
init(): An empty handle (holds no document:IsValid()false), as a variable declared with no arguments starts.init(const ATitle: string): A new document with no pages, titledATitle("": no title; the app must be open). C: Rpdf_document_create, Rpdf_document_set_title Parameters:ATitlethe title.const method IsValid(): bool:truewhile it holds a document. Returns:truewhile it holds a documentconst method Id(): Rid: The document's Rid, for .C calls (R_INVALID_IDwhen the handle holds none or it is deleted). Returns: the document's Rid, for .C calls (R_INVALID_IDwhen the handle holds none or it is deleted)const method Title(const ATitle: string): self: The title readers show. C: Rpdf_document_set_title Parameters:ATitlethe title. Returns: this object, so calls chainconst method Author(const AAuthor: string): self: The author readers show. C: Rpdf_document_set_author Parameters:AAuthorthe author. Returns: this object, so calls chainconst method Subject(const ASubject: string): self: The subject readers show. C: Rpdf_document_set_subject Parameters:ASubjectthe subject. Returns: this object, so calls chainconst method AddPage(const AWidth: float32; const AHeight: float32): self: A new pageAWidthxAHeightpoints; drawing goes to it. C: Rpdf_document_add_page Parameters:AWidththe width;AHeightthe height. Returns: this object, so calls chainconst method PageCount(): int32: The pages it has. C: Rpdf_document_get_page_count Returns: the pages it hasconst method FillColor(const AColor: UIColor): self: The colour shapes are filled and text is written with. C: Rpdf_document_set_fill_color Parameters:AColorthe colour. Returns: this object, so calls chainconst method StrokeColor(const AColor: UIColor): self: The colour of lines and outlines. C: Rpdf_document_set_stroke_color Parameters:AColorthe colour. Returns: this object, so calls chainconst method LineWidth(const AWidth: float32): self: The width of lines and outlines, in points (1 at first). C: Rpdf_document_set_line_width Parameters:AWidththe width. Returns: this object, so calls chainconst method Rect(const ARect: UIRect; const ARadius: float32; const APaint: UIPDFPaints): self:ARectfilled and / or outlined asAPaintsays, its corners rounded byARadius. C: Rpdf_document_draw_rect Parameters:ARectthe rectangle;ARadiusthe radius;APaintthe paint. Returns: this object, so calls chainconst method Ellipse(const ARect: UIRect; const APaint: UIPDFPaints): self: The ellipse insideARect, filled and / or outlined asAPaintsays. C: Rpdf_document_draw_ellipse Parameters:ARectthe rectangle;APaintthe paint. Returns: this object, so calls chainconst method Line(const AFrom: UIPoint; const ATo: UIPoint): self: A line fromAFromtoAToin the stroke colour. C: Rpdf_document_draw_line Parameters:AFromthe start point;ATothe end point. Returns: this object, so calls chainconst method AddFont(const AData: array of uint8): int32: A TrueType font fromAData(copied, embedded in the file). C: Rpdf_document_add_font Parameters:ADatathe bytes. Returns: its number forFont, -1 when it is not a TrueType fontconst method AddFontFile(const APath: string): int32: A TrueType font from the fileAPath(embedded in the document). C: Rpdf_document_add_font_from_file Parameters:APaththe file's path. Returns: its number forFont, -1 when it is not a TrueType fontconst method Font(const AFont: UIPDFFont; const ASize: float32; const AStyle: UIPDFTexts): self: The text written next set in one of Raven's fonts,ASizepoints, inAStyle. C: Rpdf_document_set_font Parameters:AFontthe font;ASizethe size;AStylethe style. Returns: this object, so calls chainconst method Font(const AFont: int32; const ASize: float32; const AStyle: UIPDFTexts): self: The text written next set in the fontAFontadded (AddFont),ASizepoints, inAStyle. C: Rpdf_document_set_font Parameters:AFontthe font;ASizethe size;AStylethe style. Returns: this object, so calls chainconst method LineHeight(): float32: The distance between two lines of text in the current font. C: Rpdf_document_get_line_height Returns: the distance between two lines of text in the current fontconst method Measure(const AText: string): float32: The width ofATextin the current font, in points (its widest line). C: Rpdf_document_measure_text Parameters:ATextthe text. Returns: the width ofATextin the current font, in points (its widest line)const method Text(const AAt: UIPoint; const AText: string): float32:ATextin the fill colour, the top of its first line atAAt("\n" starts a line below). C: Rpdf_document_draw_text Parameters:AAtthe point;ATextthe text. Returns: its widthconst method Paragraph(const AAt: UIPoint; const AWidth: float32; const AText: string; const AAlign: UIHAlign): float32:ATextwrapped at its spaces to fitAWidthfromAAt, each line placed byAAlign. C: Rpdf_document_draw_paragraph Parameters:AAtthe point;AWidththe width;ATextthe text;AAlignthe alignment. Returns: the height it tookconst method Image(const ARect: UIRect; const APixels: array of uint8; const AWidth: int32; const AHeight: int32): self: A picture ofAWidthxAHeightRGBA pixels (rows from the top) stretched overARect(a width or height of 0 keeps its proportions; both 0: 96 pixels per inch). C: Rpdf_document_draw_image Parameters:ARectthe rectangle;APixelsthe pixels;AWidththe width;AHeightthe height. Returns: this object, so calls chainconst method DrawWindow(const AWindow: UIWindow; const ARect: UIRect): bool: What the windowAWindowshows, as a picture overARect(a size of 0 x 0: its size on the screen). C: Rpdf_document_draw_window Parameters:AWindowthe window;ARectthe rectangle. Returns:falsewhen the window cannot be capturedconst method Save(const APath: string): bool: The document written to the fileAPath. C: Rpdf_document_save Parameters:APaththe file's path. Returns:falsewhen it cannot be writtenconst method ToMemory(): array of uint8: The document's file in memory (empty when it holds none). C: Rpdf_document_save_memory, Rmemory_free Returns: the document's file in memory (empty when it holds none)const method Print(const ADesc: UIPrintDesc): bool: The document printed asADescsays. Waits until the job is sent. C: Rpdf_document_print Parameters:ADescthe print settings. Returns:falsewhen cancelled or when it cannot printstatic method PrintMemory(const APDF: array of uint8; const ADesc: UIPrintDesc): bool: The PDF inAPDFprinted asADescsays (Windows: the pages drawn by PDFium; macOS: the print panel; elsewhere CUPS after Raven's printer dialog). Waits until the job is sent. C: Rpdf_print Parameters:APDFthe PDF;ADescthe print settings. Returns:falsewhen cancelled or when it cannot printstatic method PrintFile(const APath: string; const ADesc: UIPrintDesc): bool: The PDF fileAPathprinted asADescsays. Waits until the job is sent. C: Rpdf_print_file Parameters:APaththe file's path;ADescthe print settings. Returns:falsewhen cancelled or when it cannot print
Example: LDoc := UIPDFDocRes("Invoice"); LDoc.AddPage(595.28f, 841.89f).Font(UIPDFFont.Sans, 24.0f, [UIPDFText.Bold]).Text(UIPoint(x: 56.0f, y: 56.0f), "Invoice 2026-114"); LDoc.Save("invoice.pdf");
UITimeSpan
type UITimeSpan = record
A span of a timeline, in seconds: from First to Last.
Members
First: float64: Where the span starts, in seconds.Last: float64: Where the span ends, in seconds.
UICanvasView
type UICanvasView = record
Where a canvas view stands: the point it is at (a node graph's center, a block editor's scroll), in canvas units, and its zoom.
Members
Place: UIPoint: The point the view is at, in canvas units.Zoom: float32: The view's zoom.
UIBlockSpot
type UIBlockSpot = record
Where a block hangs on the block it hangs from (UIBlock.Parent): after it (Next), in one of its mouths (Body, Index the mouth) or in one of its slots (Input, Index the slot).
Members
Part: UIBlockPart: Which part of the parent it hangs in (Next, Body or Input).Index: int32: The mouth (Body) or the slot (Input) it hangs in.
UITrack
type UITrack = object
One track of a UITimeline: a view of (the timeline, the track's id), copied freely; the id stays the track's while others come and go. C: Rtimeline__track_
Members
init(): An empty track handle (names none).static method Wrap(const ATimeline: Rid; const ATrack: int32): UITrack: The track with the idATrackon the timelineATimeline(a Rid). Parameters:ATimelinethe timeline;ATrackthe track. Returns: the track with the idATrackon the timelineATimeline(a Rid)const method Id(): int32: The track's id (0 when it names none). Returns: the track's id (0 when it names none)const method IsValid(): bool:truewhen it names a track (Raven gives 0 for none). Returns:truewhen it names a track (Raven gives 0 for none)const method Name(const AName: string): self: The name shown in its header. C: Rtimeline_set_track_name Parameters:ANamethe name. Returns: this object, so calls chainconst method Name(): string: WhatName(..)sets, read back. C: Rtimeline_get_track_name Returns: the name shown in its headerconst method Color(const AColor: UIColor): self: The colour of its clips (AColor's alpha is not used). C: Rtimeline_set_track_color Parameters:AColorthe colour. Returns: this object, so calls chainconst method Height(const AHeight: float32): self: Its height in logical units (the timeline's default until set). C: Rtimeline_set_track_height Parameters:AHeightthe height. Returns: this object, so calls chainconst method Locked(const AOn: bool): self:true: the user cannot move, stretch or delete its items. C: Rtimeline_set_track_locked Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Muted(const AOn: bool): self:true: shown muted (its clips dimmed). C: Rtimeline_set_track_muted Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Muted(): bool: WhatMuted(..)sets, read back. C: Rtimeline_is_track_muted Returns:truewhenMuted(..)turned it onconst method Style(const AProperty: string; const AValue: string): bool: One style property of the track (as the theme's: "Clip.Radius" ..; "" or "Default" gives back the timeline's);falsewhen the name or the value is not one. C: Rtimeline_set_track_style Parameters:APropertythe property;AValuethe text. Returns:truewhen it was setconst method Remove(): The track removed with its items. C: Rtimeline_remove_track
UITimelineItem
type UITimelineItem = object
One item of a UITimeline (a clip, a key or a marker): a view of (the timeline, the item's id), copied freely. C: Rtimeline__item_
Members
init(): An empty item handle (names none).static method Wrap(const ATimeline: Rid; const AItem: int32): UITimelineItem: The item with the idAItemon the timelineATimeline(a Rid). Parameters:ATimelinethe timeline;AItemthe item. Returns: the item with the idAItemon the timelineATimeline(a Rid)const method Id(): int32: The item's id (0 when it names none). Returns: the item's id (0 when it names none)const method IsValid(): bool:truewhen it names an item (Raven gives 0 for none). Returns:truewhen it names an item (Raven gives 0 for none)const method ItemKind(): UITimelineItemKind: What it is: a clip, a key or a marker. C: Rtimeline_get_item_type Returns: what it is: a clip, a key or a markerconst method Track(): UITrack: The track it is on (none for a marker). C: Rtimeline_get_item_track Returns: the track it is on (none for a marker)const method Start(): float64: Where it starts, in seconds. C: Rtimeline_get_item_start Returns: where it starts, in secondsconst method Length(): float64: A clip's length in seconds (0 for a key or a marker). C: Rtimeline_get_item_length Returns: a clip's length in seconds (0 for a key or a marker)const method Move(const ATrack: UITrack; const AStart: float64; const ALength: float64): self: The item moved to the trackATrackfromAStartforALengthseconds (a key or a marker takes no length). C: Rtimeline_set_item Parameters:ATrackthe track;AStartthe start;ALengththe length. Returns: this object, so calls chainconst method Label(const ALabel: string): self: The text shown on it. C: Rtimeline_set_item_label Parameters:ALabelthe label. Returns: this object, so calls chainconst method Label(): string: WhatLabel(..)sets, read back. C: Rtimeline_get_item_label Returns: the text shown on itconst method Color(const AColor: UIColor): self: Its own colour (AColor's alpha is not used). C: Rtimeline_set_item_color Parameters:AColorthe colour. Returns: this object, so calls chainconst method Style(const AProperty: string; const AValue: string): bool: One style property of the item, asUITrack.Style. C: Rtimeline_set_item_style Parameters:APropertythe property;AValuethe text. Returns:truewhen it was setconst method Select(const AAdd: bool): self: The item selected;AAddkeeps the others selected. C: Rtimeline_select Parameters:AAddtrueto keep the others selected. Returns: this object, so calls chainconst method Selected(): bool: True while the item is selected. C: Rtimeline_is_selected Returns:truewhen it is selectedconst method Remove(): The item removed. C: Rtimeline_remove_item
UIGraphNode
type UIGraphNode = object
One node of a UINodeGraph: a view of (the graph, the node's id), copied freely. C: Rnode_graph__node_
Members
init(): An empty node handle (names none).static method Wrap(const AGraph: Rid; const ANode: int32): UIGraphNode: The node with the idANodeon the graphAGraph(a Rid). Parameters:AGraphthe graph;ANodethe node. Returns: the node with the idANodeon the graphAGraph(a Rid)const method Id(): int32: The node's id (0 when it names none). Returns: the node's id (0 when it names none)const method IsValid(): bool:truewhen it names a node (Raven gives 0 for none). Returns:truewhen it names a node (Raven gives 0 for none)const method Title(const ATitle: string): self: The text in its header. C: Rnode_graph_set_node_title Parameters:ATitlethe title. Returns: this object, so calls chainconst method Title(): string: WhatTitle(..)sets, read back. C: Rnode_graph_get_node_title Returns: the text in its headerconst method Position(const APosition: UIPoint): self: Where its top left stands, in canvas units. C: Rnode_graph_set_node_position Parameters:APositionthe position. Returns: this object, so calls chainconst method Position(): UIPoint: WhatPosition(..)sets, read back. C: Rnode_graph_get_node_position Returns: where its top left stands, in canvas unitsconst method Size(): UISize: Its size, in canvas units (from its pins and content). C: Rnode_graph_get_node_size Returns: its size, in canvas units (from its pins and content)const method Color(const AColor: UIColor): self: The colour of its header (AColor's alpha is not used). C: Rnode_graph_set_node_color Parameters:AColorthe colour. Returns: this object, so calls chainconst method Style(const AProperty: string; const AValue: string): bool: One style property of the node ("Header.Gradient", "Node.ShadowSize" ..; "" or "Default" gives back the graph's);falsewhen the name or the value is not one. C: Rnode_graph_set_node_style Parameters:APropertythe property;AValuethe text. Returns:truewhen it was setconst method Content(const AWidget: UIWidget): self: A widget shown in its body, under its pins (a value to edit, a preview). C: Rnode_graph_set_node_content Parameters:AWidgetthe widget. Returns: this object, so calls chainconst method Content(): UIWidget: WhatContent(..)sets, read back. C: Rnode_graph_get_node_content Returns: a widget shown in its body, under its pins (a value to edit, a preview)const method Name(const AName: string): self: The name it is found by (UINodeGraph.FindNode). C: Rnode_graph_set_node_name Parameters:ANamethe name. Returns: this object, so calls chainconst method Name(): string: WhatName(..)sets, read back. C: Rnode_graph_get_node_name Returns: the name it is found by (UINodeGraph.FindNode)const method UserData(const AData: ptr): self: A pointer of the program's kept with the node (Raven never reads it). C: Rnode_graph_set_node_user_data Parameters:ADatathe user data. Returns: this object, so calls chainconst method UserData(): ptr: WhatUserData(..)sets, read back. C: Rnode_graph_get_node_user_data Returns: a pointer of the program's kept with the node (Raven never reads it)const method Select(const AAdd: bool): self: The node selected;AAddkeeps the others selected. C: Rnode_graph_select_node Parameters:AAddtrueto keep the others selected. Returns: this object, so calls chainconst method Selected(): bool: True while the node is selected. C: Rnode_graph_is_node_selected Returns:truewhen it is selectedconst method Active(const AOn: bool): self:true: drawn as running (its outline lit). C: Rnode_graph_set_node_active Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method ActiveColor(const AColor: UIColor): self: The colour it is lit with while active (AColor's alpha is not used). C: Rnode_graph_set_node_active_color Parameters:AColorthe colour. Returns: this object, so calls chainconst method Deletable(const AOn: bool): self:false: the Delete key does not remove it (a graph's output, a tree's root). C: Rnode_graph_set_node_deletable Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method ShowAtOnce(): self: The node shown at once, without the pop-in a node added to a shown graph gets (a program rebuilding its graph). C: Rnode_graph_set_node_shown Returns: this object, so calls chainconst method Badge(const AText: string): self: A short text in a chip on its header ("": none). C: Rnode_graph_set_node_badge Parameters:ATextthe text. Returns: this object, so calls chainconst method BadgeColor(const AColor: UIColor): self: The colour of its badge (AColor's alpha is not used). C: Rnode_graph_set_node_badge_color Parameters:AColorthe colour. Returns: this object, so calls chainconst method Remove(): The node removed with its pins and links. C: Rnode_graph_remove_nodeconst method Icon(const ATexture: UITextureRes): self:ATextureas the icon before the node's title (an empty handle removes it); kept while it is set (the graph's, shared by any of its nodes). C: Rnode_graph_set_node_icon Parameters:ATexturethe texture. Returns: this object, so calls chain
UIGraphPin
type UIGraphPin = object
One pin of a UINodeGraph's node (an input or an output): a view of (the graph, the pin's id), copied freely. C: Rnode_graph__pin_
Members
init(): An empty pin handle (names none).static method Wrap(const AGraph: Rid; const APin: int32): UIGraphPin: The pin with the idAPinon the graphAGraph(a Rid). Parameters:AGraphthe graph;APinthe pin. Returns: the pin with the idAPinon the graphAGraph(a Rid)const method Id(): int32: The pin's id (0 when it names none). Returns: the pin's id (0 when it names none)const method IsValid(): bool:truewhen it names a pin (Raven gives 0 for none). Returns:truewhen it names a pin (Raven gives 0 for none)const method Node(): UIGraphNode: The node it belongs to. C: Rnode_graph_get_pin_node Returns: the node it belongs toconst method IsOutput(): bool:truefor an output pin. C: Rnode_graph_is_pin_output Returns:truefor an output pinconst method Label(): string: The text beside it. C: Rnode_graph_get_pin_label Returns: the text beside itconst method PinType(): string: The type it was added with ("": links to any type). C: Rnode_graph_get_pin_type Returns: the type it was added with ("": links to any type)const method Name(const AName: string): self: The name it is found by (UIGraphNode.FindPin; its label until set). C: Rnode_graph_set_pin_name Parameters:ANamethe name. Returns: this object, so calls chainconst method Position(): UIPoint: Where it is drawn, in canvas units. C: Rnode_graph_get_pin_position Returns: where it is drawn, in canvas unitsconst method Style(const AProperty: string; const AValue: string): bool: One style property of the pin, asUIGraphNode.Style. C: Rnode_graph_set_pin_style Parameters:APropertythe property;AValuethe text. Returns:truewhen it was setconst method Multiple(const AOn: bool): self:true: an input taking more than one link. C: Rnode_graph_set_pin_multiple Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Tag(const AText: string): self: A short text in a chip beside it ("": none;UINodeGraph.TagAtfinds it). C: Rnode_graph_set_pin_tag Parameters:ATextthe text. Returns: this object, so calls chainconst method TagLit(const AOn: bool): self:true: its tag drawn lit. C: Rnode_graph_set_pin_tag_lit Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Emphasis(const AEmphasis: int32): self: 1: drawn as the pin to go to, -1 stepped back, 0 as usual (linking in two clicks). C: Rnode_graph_set_pin_emphasis Parameters:AEmphasisthe emphasis. Returns: this object, so calls chainconst method Remove(): The pin removed with its links. C: Rnode_graph_remove_pin
UIGraphLink
type UIGraphLink = object
One link of a UINodeGraph (a wire from an output pin to an input pin): a view of (the graph, the link's id), copied freely. C: Rnode_graph__link_
Members
init(): An empty link handle (names none).static method Wrap(const AGraph: Rid; const ALink: int32): UIGraphLink: The link with the idALinkon the graphAGraph(a Rid). Parameters:AGraphthe graph;ALinkthe link. Returns: the link with the idALinkon the graphAGraph(a Rid)const method Id(): int32: The link's id (0 when it names none). Returns: the link's id (0 when it names none)const method IsValid(): bool:truewhen it names a link (Raven gives 0 for none: pins that cannot be linked). Returns:truewhen it names a link (Raven gives 0 for none: pins that cannot be linked)const method Output(): UIGraphPin: The output pin it leaves from. C: Rnode_graph_get_link_output Returns: the output pin it leaves fromconst method Input(): UIGraphPin: The input pin it arrives at. C: Rnode_graph_get_link_input Returns: the input pin it arrives atconst method ShowAtOnce(): self: The link shown at once, without the animation a new link gets. C: Rnode_graph_set_link_shown Returns: this object, so calls chainconst method Hidden(const AOn: bool): self:true: not drawn (and never under the pointer), still linking its pins. C: Rnode_graph_set_link_hidden Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Disconnect(): The link removed. C: Rnode_graph_disconnect
UIBlock
type UIBlock = object
One block of a UIBlockEditor: a view of (the editor, the block's id), copied freely. C: Rblock_editor_* (block)
Members
init(): An empty block handle (names none).static method Wrap(const AEditor: Rid; const ABlock: int32): UIBlock: The block with the idABlockin the editorAEditor(a Rid). Parameters:AEditorthe editor;ABlockthe block. Returns: the block with the idABlockin the editorAEditor(a Rid)const method Id(): int32: The block's id (0 when it names none). Returns: the block's id (0 when it names none)const method IsValid(): bool:truewhen it names a block (Raven gives 0 for none). Returns:truewhen it names a block (Raven gives 0 for none)const method BlockKind(): string: The name of its kind (UIBlockEditor.AddKind). C: Rblock_editor_get_kind Returns: the name of its kind (UIBlockEditor.AddKind)const method Next(): UIBlock: The block snapped under it (none at a script's end). C: Rblock_editor_get_next Returns: the block snapped under it (none at a script's end)const method MouthCount(): int32: How many mouths it has (a C block's). C: Rblock_editor_get_mouth_count Returns: how many mouths it has (a C block's)const method Body(const AMouth: int32): UIBlock: The first block in its mouthAMouth(none when empty). C: Rblock_editor_get_body Parameters:AMouththe mouth. Returns: the first block in its mouthAMouth(none when empty)const method SlotCount(): int32: How many slots its label has. C: Rblock_editor_get_slot_count Returns: how many slots its label hasconst method Input(const ASlot: int32): UIBlock: The value block in its slotASlot(none when the slot holds a typed value). C: Rblock_editor_get_input Parameters:ASlotthe slot. Returns: the value block in its slotASlot(none when the slot holds a typed value)const method Value(const ASlot: int32; const AValue: string): self: The typed value of its slotASlot. C: Rblock_editor_set_value Parameters:ASlotthe slot;AValuethe text. Returns: this object, so calls chainconst method Value(const ASlot: int32): string: WhatValue(..)sets, read back. C: Rblock_editor_get_value Parameters:ASlotthe slot. Returns: the typed value of its slotASlotconst method Parent(): UIBlock: The block it hangs from (none at a script's top);Spotsays where. C: Rblock_editor_get_parent Returns: the block it hangs from (none at a script's top);Spotsays whereconst method Spot(): UIBlockSpot: Where it hangs on its parent (Parent). C: Rblock_editor_get_parent Returns: where it hangs on its parent (Parent)const method Position(): UIPoint: Its top left, in canvas units. C: Rblock_editor_get_position Returns: its top left, in canvas unitsconst method Glow(const AOn: bool): self:true: drawn running (a halo breathes around it). C: Rblock_editor_set_block_glow Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Deletable(const AOn: bool): self:false: the user cannot delete it. C: Rblock_editor_set_block_deletable Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Select(const AAdd: bool): self: The block selected;AAddkeeps the others selected. C: Rblock_editor_select Parameters:AAddtrueto keep the others selected. Returns: this object, so calls chainconst method Attach(const ATarget: UIBlock; const APart: UIBlockPart; const AIndex: int32): bool: The block (with what hangs under it) put atAPart/AIndexofATarget;falsewhen it does not fit there. C: Rblock_editor_attach Parameters:ATargetthe target;APartthe part;AIndexthe index, from 0. Returns:truewhen it was attachedconst method Detach(const AAt: UIPoint): self: The block (with what hangs under it) taken out: a script of its own atAAt(canvas units). C: Rblock_editor_detach Parameters:AAtthe point. Returns: this object, so calls chainconst method Remove(): The block removed with what hangs under it. C: Rblock_editor_remove_block
UIDockPanel
type UIDockPanel = object
One panel of a UIDockArea: a view of (the area, the panel's widget), copied freely. C: Rdock_area__panel
Members
init(): An empty panel handle (names none).static method Wrap(const AArea: Rid; const APanel: Rid): UIDockPanel: The panelAPanel(its widget's Rid) of the areaAArea(a Rid). Parameters:AAreathe area;APanelthe panel. Returns: the panelAPanel(its widget's Rid) of the areaAArea(a Rid)const method IsValid(): bool:truewhen it names a panel. Returns:truewhen it names a panelconst method Panel(): UIWidget: The panel's widget (what was docked). Returns: the panel's widget (what was docked)const method Move(const ASide: UIDockSide; const ARelative: UIWidget; const ASize: float32): self: The panel moved to the sideASideofARelative(an emptyUIWidget(): of the whole area),ASizeits share (0 .. 1). C: Rdock_area_move_panel Parameters:ASidethe side;ARelativethe widget it docks beside;ASizethe size. Returns: this object, so calls chainconst method Title(const ATitle: string): self: The text of its tab. C: Rdock_area_set_panel_title Parameters:ATitlethe title. Returns: this object, so calls chainconst method Closable(const AOn: bool): self:false: its tab has no close button. C: Rdock_area_set_panel_closable Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Close(): The panel closed as the user's close button does (deleted, or hidden withUIDockArea.CloseHides). C: Rdock_area_close_panelconst method Hide(): self: The panel taken out of the layout, kept forOpen. C: Rdock_area_hide_panel Returns: this object, so calls chainconst method Open(): self: A hidden panel put back where it was. C: Rdock_area_open_panel Returns: this object, so calls chainconst method IsOpen(): bool:truewhile it is in the layout (not hidden). C: Rdock_area_is_panel_open Returns:truewhile it is in the layout (not hidden)const method Show(): self: Its tab brought to the front (opened first when hidden). C: Rdock_area_show_panel Returns: this object, so calls chainconst method Shown(): bool:truewhile its tab is the one in front. C: Rdock_area_is_panel_shown Returns:truewhile its tab is the one in frontconst method Float(const AX: int32; const AY: int32): UIWindow: The panel floated atAX,AY(native mode: the screen; in-window mode: the window, logical units); the window it is in now. C: Rdock_area_float_panel Parameters:AXthe x coordinate;AYthe y coordinate. Returns: the panel floated atAX,AY(native mode: the screen; in-window mode: the window, logical units); the window it is in nowconst method Dock(): self: A floating panel put back where it was in the area. C: Rdock_area_dock_panel Returns: this object, so calls chainconst method Window(): UIWindow: The window a floating panel is in (empty while docked). C: Rdock_area_get_panel_window Returns: the window a floating panel is in (empty while docked)const method Icon(const ATexture: UITextureRes): self: The whole ofATextureas the icon before the panel's title (an empty handle removes it), drawn in its own colours; kept while it is set. C: Rdock_area_set_panel_icon Parameters:ATexturethe texture. Returns: this object, so calls chainconst method Icon(const ATexture: UITextureRes; const AUVMin: UIPoint; const AUVMax: UIPoint; const ATint: bool): self: A part ofATextureas the panel's icon (an empty handle removes it); kept while it is set.AUVMin..AUVMax: the part of the texture shown, as texture coordinates (0 .. 1) of its corners;ATinttrue: the texture is a mask drawn in the text colour. C: Rdock_area_set_panel_icon Parameters:ATexturethe texture;AUVMinthe lowest texture coordinates (0 .. 1);AUVMaxthe highest texture coordinates (0 .. 1);ATintthe tint colour. Returns: this object, so calls chain
UIPlayheadFunc
type UIPlayheadFunc = ref func(const ASeconds: float64)
What UITimeline.OnTime runs when the playhead moves (scrubbed by the user, or playing): where it is, in seconds.
UITimelineItemFunc
type UITimelineItemFunc = ref func(const AItem: UITimelineItem)
What a UITimeline's item events run: the item (OnSelect: the item just clicked, or none).
UIGraphConnectFunc
type UIGraphConnectFunc = ref func(const AOutput: UIGraphPin; const AInput: UIGraphPin): bool
What UINodeGraph.OnConnect runs when the user is about to link two pins that may be linked: false refuses (a loop, a rule of the program).
UIGraphLinkFunc
type UIGraphLinkFunc = ref func(const ALink: UIGraphLink)
What UINodeGraph.OnLinked / OnUnlinked run: the link (an unlinked one's pins can still be read).
UIGraphNodeFunc
type UIGraphNodeFunc = ref func(const ANode: UIGraphNode)
What a UINodeGraph's node events run: the node (OnSelect: the node just clicked, or none).
UIGraphContextFunc
type UIGraphContextFunc = ref func(const ANode: UIGraphNode; const AAt: UIPoint)
What UINodeGraph.OnContext runs on a right click: the node under the pointer (none on the empty canvas) and the point, in the widget.
UIGraphPinFunc
type UIGraphPinFunc = ref func(const APin: UIGraphPin; const AAt: UIPoint)
What UINodeGraph.OnWireDropped / OnPinClick run: the pin and the point, in canvas units.
UICanvasPointFunc
type UICanvasPointFunc = ref func(const AAt: UIPoint)
What UINodeGraph.OnCanvasActivate runs on a double click on the empty canvas: the point, in canvas units.
UIBlockFunc
type UIBlockFunc = ref func(const ABlock: UIBlock)
What a UIBlockEditor's block events run: the block.
UIBlockContextFunc
type UIBlockContextFunc = ref func(const ABlock: UIBlock; const AAt: UIPoint)
What UIBlockEditor.OnContext runs on a right click: the block under the pointer (none on the empty canvas) and the point.
UIDockCloseFunc
type UIDockCloseFunc = ref func(const APanel: UIDockPanel): bool
What UIDockArea.OnClose runs when the user closes a panel, before it goes: false keeps it.
UIDockFloatFunc
type UIDockFloatFunc = ref func(const APanel: UIDockPanel; const AWindow: UIWindow;
What UIDockArea.FloatWindow runs when a panel leaves for a window of its own, once the window and its floating area are made: the window's content (a widget holding AFloating), or an empty UIWidget() for AFloating itself.
UITimeline
type UITimeline = object(UIWidget)
A timeline: tracks of clips and keys, markers and a playhead, scrubbed, zoomed and edited by the user (an animation, a video or a sequence editor).
Members
static method Create(): UITimeline: A new timeline, 0 seconds long, with no tracks. C: Rtimeline_create Returns: a new timeline, 0 seconds long, with no tracksstatic method Kinds(): UIWidgetKinds: The kind a timeline views. Returns: the kind a timeline viewsconst method Duration(const ASeconds: float64): self: How long it runs, in seconds. C: Rtimeline_set_duration Parameters:ASecondsthe time, in seconds. Returns: this object, so calls chainconst method Duration(): float64: WhatDuration(..)sets, read back. C: Rtimeline_get_duration Returns: how long it runs, in secondsconst method Time(const ASeconds: float64): self: Where the playhead stands, in seconds (no closure is told). C: Rtimeline_set_time Parameters:ASecondsthe time, in seconds. Returns: this object, so calls chainconst method Time(): float64: WhatTime(..)sets, read back. C: Rtimeline_get_time Returns: where the playhead stands, in seconds (no closure is told)const method FrameRate(const AFramesPerSecond: float64): self: The frames per second its ruler and snapping count in. C: Rtimeline_set_frame_rate Parameters:AFramesPerSecondthe frames per second. Returns: this object, so calls chainconst method FrameRate(): float64: WhatFrameRate(..)sets, read back. C: Rtimeline_get_frame_rate Returns: the frames per second its ruler and snapping count inconst method Snapping(const AOn: bool): self:false: items are placed anywhere, not on frames and other items' edges (Alt while dragging does it for one move). C: Rtimeline_set_snapping Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method View(const ASpan: UITimeSpan): self: The span shown, in seconds. C: Rtimeline_set_view Parameters:ASpanthe span. Returns: this object, so calls chainconst method View(): UITimeSpan: WhatView(..)sets, read back. C: Rtimeline_get_view Returns: the span shown, in secondsconst method Playing(const AOn: bool): self:true: the playhead runs by itself. C: Rtimeline_set_playing Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Playing(): bool: WhatPlaying(..)sets, read back. C: Rtimeline_is_playing Returns:truewhenPlaying(..)turned it onconst method Loop(const AOn: bool): self:true: playing goes back to the start at the end. C: Rtimeline_set_loop Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method HeaderWidth(const AWidth: float32): self: The width of the track-name column, in logical units. C: Rtimeline_set_header_width Parameters:AWidththe width. Returns: this object, so calls chainconst method HeaderWidth(): float32: The track-name column's width as laid out (0 until the timeline is laid out). C: Rtimeline_get_header_width Returns: the track-name column's width as laid out (0 until the timeline is laid out)const method RulerHeight(const AHeight: float32): self: The height of the time ruler, in logical units. C: Rtimeline_set_ruler_height Parameters:AHeightthe height. Returns: this object, so calls chainconst method RulerHeight(): float32: WhatRulerHeight(..)sets, read back. C: Rtimeline_get_ruler_height Returns: the height of the time ruler, in logical unitsconst method DefaultTrackHeight(const AHeight: float32): self: The height a track has until its own is set. C: Rtimeline_set_default_track_height Parameters:AHeightthe height. Returns: this object, so calls chainconst method DefaultTrackHeight(): float32: WhatDefaultTrackHeight(..)sets, read back. C: Rtimeline_get_default_track_height Returns: the height a track has until its own is setconst method Preset(const APreset: UIPreset): self: The look it is drawn with. C: Rtimeline_set_preset Parameters:APresetthe preset. Returns: this object, so calls chainconst method Preset(): UIPreset: WhatPreset(..)sets, read back. C: Rtimeline_get_preset Returns: the look it is drawn withconst method AddTrack(const AName: string): UITrack: A new track namedAName, under the others. C: Rtimeline_add_track Parameters:ANamethe name. Returns: a new track namedAName, under the othersconst method TrackCount(): int32: How many tracks it has. C: Rtimeline_get_track_count Returns: how many tracks it hasconst method Track(const AIndex: int32): UITrack: Its trackAIndexfrom the top (0 first). C: Rtimeline_get_track Parameters:AIndexthe index, from 0. Returns: its trackAIndexfrom the top (0 first)const method AddMarker(const ATime: float64; const ALabel: string): UITimelineItem: A new marker atATimeseconds, labelledALabel. C: Rtimeline_add_marker Parameters:ATimethe time;ALabelthe label. Returns: a new marker atATimeseconds, labelledALabelconst method ItemCount(): int32: How many items (clips, keys, markers) it has. C: Rtimeline_get_item_count Returns: how many items (clips, keys, markers) it hasconst method Item(const AIndex: int32): UITimelineItem: Its itemAIndex, in the order they were added (0 first). C: Rtimeline_get_item Parameters:AIndexthe index, from 0. Returns: its itemAIndex, in the order they were added (0 first)const method Clear(): self: Every track and item removed. C: Rtimeline_clear Returns: this object, so calls chainconst method ClearSelection(): self: No item selected. C: Rtimeline_clear_selection Returns: this object, so calls chainconst method SelectionCount(): int32: How many items are selected. C: Rtimeline_get_selection_count Returns: how many items are selectedconst method Selected(const AIndex: int32): UITimelineItem: Its selected itemAIndex(0 first). C: Rtimeline_get_selected Parameters:AIndexthe index, from 0. Returns: its selected itemAIndex(0 first)const method OnTime(const AFunc: UIPlayheadFunc): self: RunsAFuncwith the playhead's time as the user scrubs it or it plays. C: Rtimeline_set_time_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnChanged(const AFunc: UITimelineItemFunc): self: RunsAFuncwith each item the user moves, stretches or retimes, as it happens. C: Rtimeline_set_changed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnSelect(const AFunc: UITimelineItemFunc): self: RunsAFuncwhen the selection changes, with the item just clicked (or none). C: Rtimeline_set_selection_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnActivate(const AFunc: UITimelineItemFunc): self: RunsAFuncwith an item the user double-clicks. C: Rtimeline_set_activated_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnRemoved(const AFunc: UITimelineItemFunc): self: RunsAFuncwith an item the user deletes (the Delete key), before it goes; without it the Delete key does nothing. C: Rtimeline_set_removed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
Example: LTimeline := UITimeline.Create().Duration(10.0); LTrack := LTimeline.AddTrack("Video"); LTrack.AddClip(0.0, 4.0, "Intro");
UINodeGraph
type UINodeGraph = object(UIWidget)
A node graph: nodes with input and output pins the user links with wires, pans and zooms (a shader, a material or a data-flow editor).
Members
static method Create(): UINodeGraph: A new graph with no nodes. C: Rnode_graph_create Returns: a new graph with no nodesstatic method Kinds(): UIWidgetKinds: The kind a node graph views. Returns: the kind a node graph viewsconst method AddNode(const ATitle: string; const AAt: UIPoint): UIGraphNode: A new node titledATitlewith its top left atAAt(canvas units). C: Rnode_graph_add_node Parameters:ATitlethe title;AAtthe point. Returns: a new node titledATitlewith its top left atAAt(canvas units)const method Clear(): self: Every node and link removed. C: Rnode_graph_clear Returns: this object, so calls chainconst method NodeCount(): int32: How many nodes it has. C: Rnode_graph_get_node_count Returns: how many nodes it hasconst method Node(const AIndex: int32): UIGraphNode: Its nodeAIndex, in the order they were added (0 first). C: Rnode_graph_get_node Parameters:AIndexthe index, from 0. Returns: its nodeAIndex, in the order they were added (0 first)const method FindNode(const AName: string): UIGraphNode: Its node namedAName(none when it has no such node). C: Rnode_graph_find_node Parameters:ANamethe name. Returns: its node namedAName(none when it has no such node)const method TypeColor(const AType: string; const AColor: UIColor): self: The colour of the pins and wires of the typeAType(AColor's alpha is not used). C: Rnode_graph_set_type_color Parameters:ATypethe type;AColorthe colour. Returns: this object, so calls chainconst method TypeStyle(const AType: string; const AProperty: string; const AValue: string): bool: One style property of the pins and wires of the typeAType, asUIGraphNode.Style. C: Rnode_graph_set_type_style Parameters:ATypethe type;APropertythe property;AValuethe text. Returns:truewhen it was setconst method Connect(const AOutput: UIGraphPin; const AInput: UIGraphPin): UIGraphLink: A new link from the outputAOutputto the inputAInput(none when they cannot be linked: two inputs, types that differ; no closure is told). C: Rnode_graph_connect Parameters:AOutputthe output;AInputthe input. Returns: a new link from the outputAOutputto the inputAInput(none when they cannot be linked: two inputs, types that differ; no closure is told)const method LinkCount(): int32: How many links it has. C: Rnode_graph_get_link_count Returns: how many links it hasconst method Link(const AIndex: int32): UIGraphLink: Its linkAIndex(0 first). C: Rnode_graph_get_link Parameters:AIndexthe index, from 0. Returns: its linkAIndex(0 first)const method View(const AView: UICanvasView): self: The canvas point at its center and its zoom. C: Rnode_graph_set_view Parameters:AViewthe view. Returns: this object, so calls chainconst method View(): UICanvasView: WhatView(..)sets, read back. C: Rnode_graph_get_view Returns: the canvas point at its center and its zoomconst method ToCanvas(const APoint: UIPoint): UIPoint: The canvas point underAPointof the widget. C: Rnode_graph_to_canvas Parameters:APointthe point. Returns: the canvas point underAPointof the widgetconst method FromCanvas(const APoint: UIPoint): UIPoint: The point of the widget the canvas pointAPointis drawn at. C: Rnode_graph_from_canvas Parameters:APointthe point. Returns: the point of the widget the canvas pointAPointis drawn atconst method FrameAll(): self: The view moved and zoomed to show every node. C: Rnode_graph_frame_all Returns: this object, so calls chainconst method GridVisible(const AOn: bool): self:false: no grid drawn behind the nodes. C: Rnode_graph_set_grid_visible Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method FlowVisible(const AOn: bool): self:true: dots run along the wires (data flowing). C: Rnode_graph_set_flow_visible Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method ReadOnly(const AOn: bool): self:true: the user can pan, zoom and select, not move, link or delete. C: Rnode_graph_set_read_only Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Preset(const APreset: UIPreset): self: The look it is drawn with. C: Rnode_graph_set_preset Parameters:APresetthe preset. Returns: this object, so calls chainconst method Preset(): UIPreset: WhatPreset(..)sets, read back. C: Rnode_graph_get_preset Returns: the look it is drawn withconst method PinLabelWidth(const AWidth: float32): self: The width every pin label takes, in logical units (0: each its own). C: Rnode_graph_set_pin_label_width Parameters:AWidththe width. Returns: this object, so calls chainconst method PinLabelWidth(): float32: WhatPinLabelWidth(..)sets, read back. C: Rnode_graph_get_pin_label_width Returns: the width every pin label takes, in logical units (0: each its own)const method ClearSelection(): self: No node selected. C: Rnode_graph_clear_selection Returns: this object, so calls chainconst method SelectionCount(): int32: How many nodes are selected. C: Rnode_graph_get_selection_count Returns: how many nodes are selectedconst method SelectedNode(const AIndex: int32): UIGraphNode: Its selected nodeAIndex(0 first). C: Rnode_graph_get_selected_node Parameters:AIndexthe index, from 0. Returns: its selected nodeAIndex(0 first)const method NodeAt(const APoint: UIPoint): UIGraphNode: The node underAPointof the widget (none). C: Rnode_graph_get_node_at Parameters:APointthe point. Returns: the node underAPointof the widget (none)const method PinAt(const APoint: UIPoint): UIGraphPin: The pin nearAPointof the widget, or whose tag is under it (none). C: Rnode_graph_get_pin_at Parameters:APointthe point. Returns: the pin nearAPointof the widget, or whose tag is under it (none)const method LinkAt(const APoint: UIPoint): UIGraphLink: The link underAPointof the widget (none; a hidden link never is). C: Rnode_graph_get_link_at Parameters:APointthe point. Returns: the link underAPointof the widget (none; a hidden link never is)const method TagAt(const APoint: UIPoint): UIGraphPin: The pin whose tag chip is underAPointof the widget (none). C: Rnode_graph_get_tag_at Parameters:APointthe point. Returns: the pin whose tag chip is underAPointof the widget (none)const method OnConnect(const AFunc: UIGraphConnectFunc): self: RunsAFuncwhen the user is about to link two pins that may be linked:falserefuses. C: Rnode_graph_set_connect_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnLinked(const AFunc: UIGraphLinkFunc): self: RunsAFuncwith a link the user made. C: Rnode_graph_set_linked_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnUnlinked(const AFunc: UIGraphLinkFunc): self: RunsAFuncwith a link the user removes, before it goes. C: Rnode_graph_set_unlinked_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnMoved(const AFunc: UIGraphNodeFunc): self: RunsAFuncwith each node the user moved, when the button is released. C: Rnode_graph_set_moved_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnSelect(const AFunc: UIGraphNodeFunc): self: RunsAFuncwhen the selection changes, with the node just clicked (or none). C: Rnode_graph_set_selection_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnRemoved(const AFunc: UIGraphNodeFunc): self: RunsAFuncwith a node the user deletes (the Delete key), before it goes; without it the Delete key only removes links. C: Rnode_graph_set_removed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnActivate(const AFunc: UIGraphNodeFunc): self: RunsAFuncwith a node the user double-clicks. C: Rnode_graph_set_activated_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnContext(const AFunc: UIGraphContextFunc): self: RunsAFuncon a right click; without it the right button does nothing. C: Rnode_graph_set_context_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnCanvasActivate(const AFunc: UICanvasPointFunc): self: RunsAFuncon a double click on the empty canvas; without it that frames every node. C: Rnode_graph_set_canvas_activated_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnWireDropped(const AFunc: UIGraphPinFunc): self: RunsAFuncwhen a wire the user pulled from a pin is released on nothing: that pin and where (a node to connect it to). C: Rnode_graph_set_wire_dropped_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnPinClick(const AFunc: UIGraphPinFunc): self: RunsAFuncwith a pin clicked, not dragged (linking in two clicks); with it such a click neither detaches an input's wire nor drops a wire. C: Rnode_graph_set_pin_clicked_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
Example: LGraph := UINodeGraph.Create(); LOut := LGraph.AddNode("Source", LAt).AddOutput("Value", "float"); LIn := LGraph.AddNode("Sink", LAt2).AddInput("Value", "float"); LGraph.Connect(LOut, LIn);
UIBlockEditor
type UIBlockEditor = object(UIWidget)
A block editor: scripts of blocks the user snaps together from a palette, built from the kinds the program declares (a visual programming surface).
Members
static method Create(): UIBlockEditor: A new editor with no kinds and no scripts. C: Rblock_editor_create Returns: a new editor with no kinds and no scriptsstatic method Kinds(): UIWidgetKinds: The kind a block editor views. Returns: the kind a block editor viewsconst method AddKind(const AName: string; const ALabel: string; const AShape: UIBlockShape; const ACategory: string): int32: A new kind of block namedAName, with its block in the palette's categoryACategory;ALabelis its words and slots (%n a number, %s a text, %b a condition, %r any value, %m a choice:SlotOptions; {text} after a slot its default). Its index, -1 on an error. C: Rblock_editor_add_kind Parameters:ANamethe name;ALabelthe label;AShapethe shape;ACategorythe category. Returns: a new kind of block namedAName, with its block in the palette's categoryACategory;ALabelis its words and slots (%n a number, %s a text, %b a condition, %r any value, %m a choice:SlotOptions; {text} after a slot its default)const method CategoryColor(const ACategory: string; const AColor: UIColor): self: The colour of the blocks of the categoryACategory(AColor's alpha is not used). C: Rblock_editor_set_category_color Parameters:ACategorythe category;AColorthe colour. Returns: this object, so calls chainconst method PaletteVisible(const AOn: bool): self:false: no palette shown (the program adds every block). C: Rblock_editor_set_palette_visible Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method KindVisible(const AKind: string; const AOn: bool): self:false: the kindAKind's block left out of the palette. C: Rblock_editor_set_kind_visible Parameters:AKindthe kind;AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method KindLabel(const AKind: string; const ALabel: string): bool: A new label for the kindAKind(its blocks keep the values of the slots still there);falsewhen there is no such kind. C: Rblock_editor_set_kind_label Parameters:AKindthe kind;ALabelthe label. Returns:truewhen the label was setconst method SlotOptions(const AKind: string; const ASlot: int32; const AOptions: array of string): self: The choices of the %m slotASlotof the kindAKind(empty: the slot is typed in). C: Rblock_editor_set_slot_options Parameters:AKindthe kind;ASlotthe slot;AOptionsthe options. Returns: this object, so calls chainconst method AddBlock(const AKind: string; const AAt: UIPoint): UIBlock: A new block of the kindAKind, the top of a script of its own atAAt(canvas units); none on an error. C: Rblock_editor_add_block Parameters:AKindthe kind;AAtthe point. Returns: a new block of the kindAKind, the top of a script of its own atAAt(canvas units); none on an errorconst method Clear(): self: Every script removed. C: Rblock_editor_clear Returns: this object, so calls chainconst method ScriptCount(): int32: How many scripts it has. C: Rblock_editor_get_script_count Returns: how many scripts it hasconst method Script(const AIndex: int32): UIBlock: The top block of its scriptAIndex(0 first). C: Rblock_editor_get_script Parameters:AIndexthe index, from 0. Returns: the top block of its scriptAIndex(0 first)const method SelectionCount(): int32: How many blocks are selected. C: Rblock_editor_get_selection_count Returns: how many blocks are selectedconst method Selected(const AIndex: int32): UIBlock: Its selected blockAIndex(0 first). C: Rblock_editor_get_selected Parameters:AIndexthe index, from 0. Returns: its selected blockAIndex(0 first)const method View(const AView: UICanvasView): self: The canvas point its view stands at and its zoom. C: Rblock_editor_set_view Parameters:AViewthe view. Returns: this object, so calls chainconst method View(): UICanvasView: WhatView(..)sets, read back. C: Rblock_editor_get_view Returns: the canvas point its view stands at and its zoomconst method Save(): string: Every script as text (forLoad). C: Rblock_editor_save Returns: every script as text (forLoad)const method Load(const AText: string): bool: The scripts replaced by those ofAText(fromSave);falsewhen it is not such a text. C: Rblock_editor_load Parameters:ATextthe text. Returns:truewhen the scripts were loadedconst method OnChanged(const AFunc: UIBlockFunc): self: RunsAFunceach time the user changes a script, with the block changed. C: Rblock_editor_set_changed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnClick(const AFunc: UIBlockFunc): self: RunsAFuncwith a block the user clicks (to run its script). C: Rblock_editor_set_clicked_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnContext(const AFunc: UIBlockContextFunc): self: RunsAFuncon a right click. C: Rblock_editor_set_context_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
Example: LEditor := UIBlockEditor.Create(); LEditor.AddKind("say", "say %s", UIBlockShape.Statement, "Looks"); LEditor.AddBlock("say", LAt).Value(0, "Hello");
UIDockArea
type UIDockArea = object(UIWidget)
A dock area: panels docked beside each other, tabbed, rearranged and torn off into windows of their own by the user (an IDE's or a tool's workspace).
Members
static method Create(): UIDockArea: A new, empty dock area. C: Rdock_area_create Returns: a new, empty dock areastatic method Kinds(): UIWidgetKinds: The kind a dock area views. Returns: the kind a dock area viewsconst method AddPanel(const AWidget: UIWidget; const ATitle: string; const ASide: UIDockSide; const ARelative: UIWidget; const ASize: float32): UIDockPanel:AWidgetdocked as a panel titledATitleat the sideASideofARelative(an emptyUIWidget(): of the whole area; withUIDockSide.Tab, a tab beside it),ASizeits share (0 .. 1). C: Rdock_area_add_panel Parameters:AWidgetthe widget;ATitlethe title;ASidethe side;ARelativethe widget it docks beside;ASizethe size. Returns:AWidgetdocked as a panel titledATitleat the sideASideofARelative(an emptyUIWidget(): of the whole area; withUIDockSide.Tab, a tab beside it),ASizeits share (0 .const method Panel(const AWidget: UIWidget): UIDockPanel: The panelAWidget(one docked here). Parameters:AWidgetthe widget. Returns: the panelAWidget(one docked here)const method CloseHides(const AOn: bool): self:true: a tab's close button hides its panel (UIDockPanel.Openbrings it back) instead of deleting it. C: Rdock_area_set_close_hides Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Movable(const AOn: bool): self:false: the user cannot drag its panels elsewhere. C: Rdock_area_set_movable Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Tearable(const AOn: bool): self:true: a panel dragged out of the area floats. C: Rdock_area_set_tearable Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Tearable(): bool: WhatTearable(..)sets, read back. C: Rdock_area_is_tearable Returns:truewhenTearable(..)turned it onconst method FloatMode(const AMode: UIDockFloat): self: Where torn-off panels float: windows of their own, or cards inside this window. C: Rdock_area_set_float_mode Parameters:AModethe mode. Returns: this object, so calls chainconst method SaveLayout(): string: How its panels are arranged, as a short text to keep in a settings file (named by their widgets' names: unnamed panels are not in it). C: Rdock_area_save_layout Returns: how its panels are arranged, as a short text to keep in a settings file (named by their widgets' names: unnamed panels are not in it)const method LoadLayout(const ALayout: string): bool: The panels arranged asALayout(fromSaveLayout);falsewhen it is not such a text. C: Rdock_area_load_layout Parameters:ALayoutthe layout. Returns:truewhen the layout was appliedconst method OnClose(const AFunc: UIDockCloseFunc): self: RunsAFuncwhen the user closes a panel, before it goes:falsekeeps it. C: Rdock_area_set_close_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method OnChanged(const AFunc: UITaskFunc): self: RunsAFuncafter the user moves, resizes, shows or closes a panel. C: Rdock_area_set_changed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
Example: LDock := UIDockArea.Create(); LDock.AddPanel(LFiles, "Files", UIDockSide.Left, UIWidget(), 0.25f);
UIIsland
type UIIsland = object(UIWidget)
An island: a pill that unfolds to show more (a call, a timer, a download), on its own or as a window's island in the camera notch (UIWindow.Island).
Members
static method Create(): UIIsland: A new, folded island. C: Risland_create Returns: a new, folded islandstatic method Kinds(): UIWidgetKinds: The kind an island views. Returns: the kind an island viewsconst method Expanded(const AOn: bool): self: Unfolded (true) or folded (no closure is told). C: Risland_set_expanded Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Expanded(): bool: WhatExpanded(..)sets, read back. C: Risland_is_expanded Returns:truewhenExpanded(..)turned it onconst method ExpandFor(const ASeconds: float64): self: Unfolded forASeconds, then folded again. C: Risland_expand_for Parameters:ASecondsthe time, in seconds. Returns: this object, so calls chainconst method ExpandOnHover(const AOn: bool): self:true: it unfolds while the pointer is over it. C: Risland_set_expand_on_hover Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method ExpandOnClick(const AOn: bool): self:true: a click unfolds or folds it. C: Risland_set_expand_on_click Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Attached(const AOn: bool): self:true: drawn attached to the top edge of its window. C: Risland_set_attached Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Notch(const AOn: bool): self:true: it goes into the screen's camera housing when there is one. C: Risland_set_notch Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Notch(): bool: WhatNotch(..)sets, read back. C: Risland_get_notch Returns:truewhenNotch(..)turned it onconst method InNotch(): bool:truewhile it is in the screen's camera housing. C: Risland_is_in_notch Returns:truewhile it is in the screen's camera housingconst method OnChanged(const AFunc: UIToggleFunc): self: RunsAFuncwhen the user unfolds or folds it: whether it is unfolded now. C: Risland_set_changed_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
UIHeaderBar
type UIHeaderBar = object(UIWidget)
A header bar: a window's own title bar (with UIWindowFlag.CustomHeader), dragging the window and holding its buttons.
Members
static method Create(const ATitle: string): UIHeaderBar: A new header bar titledATitle, with every button. C: Rheader_bar_create Parameters:ATitlethe title. Returns: a new header bar titledATitle, with every buttonstatic method Kinds(): UIWidgetKinds: The kind a header bar views. Returns: the kind a header bar viewsconst method Title(const ATitle: string): self: Its title. C: Rheader_bar_set_title Parameters:ATitlethe title. Returns: this object, so calls chainconst method Buttons(const AButtons: UIHeaderButtons): self: The window buttons it shows. C: Rheader_bar_set_buttons Parameters:AButtonsthe buttons. Returns: this object, so calls chainconst method ButtonSide(const ASide: UIHAlign): self: The side its buttons sit on (left on macOS, right elsewhere until set). C: Rheader_bar_set_button_side Parameters:ASidethe side. Returns: this object, so calls chainconst method TitleAlign(const AAlign: UIHAlign): self: Where its title stands. C: Rheader_bar_set_title_align Parameters:AAlignthe alignment. Returns: this object, so calls chainconst method TitleNotch(const AOn: bool): self:true: its title kept clear of the screen's camera housing. C: Rheader_bar_set_title_notch Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainconst method Background(const AOn: bool): self:false: no background drawn (a bar floating above the content or in a glass panel). C: Rheader_bar_set_background Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chain
UIBackgroundBlur
type UIBackgroundBlur = object(UIWidget)
A background blur: a frosted, glass or native backdrop behind its child.
Members
static method Create(): UIBackgroundBlur: A new blur, in the theme's style. C: Rbackground_blur_create Returns: a new blur, in the theme's stylestatic method Kinds(): UIWidgetKinds: The kind a background blur views. Returns: the kind a background blur viewsconst method Style(const AStyle: UIBlurStyle): self: How it blurs. C: Rbackground_blur_set_style Parameters:AStylethe style. Returns: this object, so calls chainconst method Style(): UIBlurStyle: WhatStyle(..)sets, read back. C: Rbackground_blur_get_style Returns: how it blursconst method Radius(const ARadius: float32): self: The blur's radius, in logical units. C: Rbackground_blur_set_radius Parameters:ARadiusthe radius. Returns: this object, so calls chainconst method Radius(): float32: WhatRadius(..)sets, read back. C: Rbackground_blur_get_radius Returns: the blur's radius, in logical unitsconst method Tint(const AColor: UIColor): self: The colour laid over the blur. C: Rbackground_blur_set_tint Parameters:AColorthe colour. Returns: this object, so calls chainconst method ClearTint(): self: The style's own tint back. C: Rbackground_blur_clear_tint Returns: this object, so calls chainconst method Saturation(const ASaturation: float32): self: How saturated what shows through is (1: as it is). C: Rbackground_blur_set_saturation Parameters:ASaturationthe saturation. Returns: this object, so calls chainconst method Grain(const AGrain: float32): self: How much grain is laid over it (0: none). C: Rbackground_blur_set_grain Parameters:AGrainthe grain. Returns: this object, so calls chainconst method CornerRadius(const ATopLeft: float32; const ATopRight: float32; const ABottomRight: float32; const ABottomLeft: float32): self: The radius of each corner, in logical units. C: Rbackground_blur_set_corner_radius Parameters:ATopLeftthe top-left corner's radius;ATopRightthe top-right corner's radius;ABottomRightthe bottom-right corner's radius;ABottomLeftthe bottom-left corner's radius. Returns: this object, so calls chainconst method Padding(const ALeft: float32; const ATop: float32; const ARight: float32; const ABottom: float32): self: The space around its child, in logical units. C: Rbackground_blur_set_padding Parameters:ALeftthe room on the left;ATopthe room above;ARightthe room on the right;ABottomthe room below. Returns: this object, so calls chainconst method Shadow(const ABlur: float32): self: The blur of the shadow under it (0: none). C: Rbackground_blur_set_shadow Parameters:ABlurthe blur radius. Returns: this object, so calls chain
UIActionFunc
type UIActionFunc = ref func(const ASender: UIWidget)
The routine answering a bound action: ASender is the widget that fired it (an empty UIWidget for one fired by a script or with no sender).
UIActionPrefixFunc
type UIActionPrefixFunc = ref func(const ASender: UIWidget; const AArgument: string)
The routine answering every action named <prefix><argument>: AArgument is the rest of the name.
UIActionFallbackFunc
type UIActionFallbackFunc = ref func(const ASender: UIWidget; const AName: string)
The routine answering an action no binding and no prefix took: AName is its name.
UILocaleFunc
type UILocaleFunc = ref func(const ALanguage: string)
The language Raven's texts are in now (UILocale.OnChanged).
UIScriptLogFunc
type UIScriptLogFunc = ref func(const AText: string)
A line a script logged (UIScript.OnLog).
UIScriptDiagnosticFunc
type UIScriptDiagnosticFunc = ref func(const ASeverity: UISeverity; const ACode: string;
A script diagnostic: where (AFile, ALine, AColumn), its code and its text (UIScript.OnDiagnostic).
UITrayClickFunc
type UITrayClickFunc = ref func(const AButton: UIPointerButton)
A tray icon clicked with AButton (UITrayRes.OnClick).
UIActionContext
type UIActionContext = object
The call of an action bound with parameters: its sender, name and arguments, and its answer (Reply, or Fail). Valid during that call only. C: RActionContext, Raction_get_, Raction_return_, Raction_fail
Members
init(): An empty context (answers nothing), as a variable declared with no arguments starts.static method Of(const AContext: ptr to RActionContext): UIActionContext: The context Raven hands an action's callback asAContext(the layer's trampoline builds it). Parameters:AContextthe context. Returns: the context Raven hands an action's callback asAContext(the layer's trampoline builds it)const method Sender(): UIWidget: The widget that fired it (empty when a script called it). C: Raction_get_sender Returns: the widget that fired it (empty when a script called it)const method Name(): string: The action's name. C: Raction_get_name Returns: the action's nameconst method ArgCount(): int32: How many arguments it was given. C: Raction_get_argument_count Returns: how many arguments it was givenconst method Number(const AIndex: int32): float64: ArgumentAIndex(from 0) as a number. C: Raction_get_number Parameters:AIndexthe index, from 0. Returns: argumentAIndex(from 0) as a numberconst method Text(const AIndex: int32): string: ArgumentAIndex(from 0) as text. C: Raction_get_string Parameters:AIndexthe index, from 0. Returns: argumentAIndex(from 0) as textconst method Flag(const AIndex: int32): bool: ArgumentAIndex(from 0) astrue/false. C: Raction_get_bool Parameters:AIndexthe index, from 0. Returns: the argument as aboolconst method Reply(const AValue: float64): The number it gives back (a signature with: number). C: Raction_return_number Parameters:AValuethe value.const method Reply(const AText: string): The text it gives back (a signature with: string). C: Raction_return_string Parameters:ATextthe text.const method Reply(const AValue: bool): Thetrue/falseit gives back (a signature with: bool). C: Raction_return_bool Parameters:AValuethe value.const method Fail(const AMessage: string): The call failed withAMessage(a script sees an error). C: Raction_fail Parameters:AMessagethe message.
Example: UIActions.Bind("app.save", "(path: string): bool", func(const C: UIActionContext) begin C.Reply(Save(C.Text(0))); end);
UIActionCallFunc
type UIActionCallFunc = ref func(const AContext: UIActionContext)
The routine answering an action bound with parameters.
UIActions
type UIActions = object
Raven's actions answered by name: the name an XML layout gives a widget's OnClicked, OnChanged or Action, a script's call, or Fire. Bound by exact name, with typed parameters, or by a name's prefix; what nothing takes goes to the fallback. All static; every binding is let go when the app ends. C: Raction_*
Members
static method Bind(const AName: string; const AFunc: UIActionFunc):AFuncanswers the actionAName; binding a name again (either way) replaces it. C: Raction_bind Parameters:ANamethe name;AFuncthe func it runs.static method Bind(const AName: string; const ASignature: string; const AFunc: UIActionCallFunc): bool:AFuncanswers the actionANamewith typed parameters and a result, as itsASignaturesays ("(path: string): bool"); a widget firing it hands what its event gives (a slider's value, a check box's state ..). Parameters:ANamethe name;ASignaturethe signature;AFuncthe func it runs. Returns:false(the error reported) when the signature is not valid. C: Raction_bind_with_parametersstatic method BindPrefix(const APrefix: string; const AFunc: UIActionPrefixFunc):AFuncanswers every action whose name starts withAPrefixand has no binding of its own: the rest of the name is its argument ("theme.use."+"Ember"); prefixes are tried in the order bound, binding one again replaces its routine (nilremoves it). C: Raction_set_default_handler Parameters:APrefixthe prefix;AFuncthe func it runs.static method Fallback(const AFunc: UIActionFallbackFunc):AFuncanswers every action no binding and no prefix took (nil: none does). C: Raction_set_default_handler Parameters:AFuncthe func it runs.static method Unbind(const AName: string): The actionANameno longer answered by its binding. C: Raction_unbind Parameters:ANamethe name.static method Fire(const AName: string; const ASender: UIWidget): Runs the actionANameas ifASenderfired it (an emptyUIWidget(): no sender). C: Raction_fire Parameters:ANamethe name;ASenderthe sender.static method Builtins(const AOn: bool): Raven's built-in actions (app.quit,window.close..) on or off. C: Raction_set_builtins Parameters:AOntrueto turn it on,falseto turn it off.static method IsBuiltin(const AName: string): bool:truewhenANameis one of Raven's built-in actions. C: Raction_is_builtin Parameters:ANamethe name. Returns:truewhenANameis one of Raven's built-in actions
Example: UIActions.Bind("file.save", func(const S: UIWidget) begin Save(); end); UIActions.BindPrefix("theme.use.", func(const S: UIWidget; const AName: string) begin UITheme.Use(AName); end);
UILocale
type UILocale = object
The translation tables: texts by key in each language, loaded from CSV (a key column, then one column per language, the first the fallback), and the language in use. Raven's widgets show a key's text where an XML layout writes @key. All static. C: Rlocale_, Rtr
Members
static method LoadCSV(const APath: string): bool: Loads (adds) the tables of the CSV fileAPath. Parameters:APaththe file's path. Returns:false(the error reported) when it does not load. C: Rlocale_load_csvstatic method LoadCSVText(const ACSV: string): bool: Loads (adds) the tables of the CSV textACSV, asLoadCSV. C: Rlocale_load_csv_from_memory Parameters:ACSVthe CSV. Returns:false(the error reported) when it does not loadstatic method Clear(): Every table emptied. C: Rlocale_clearstatic method Text(const ALanguage: string; const AKey: string; const AText: string):ATextas the text ofAKeyinALanguage. C: Rlocale_set_text Parameters:ALanguagethe language;AKeythe key;ATextthe text.static method Tr(const AKey: string): string: The text ofAKeyin the language in use (the fallback language's, else the key). C: Rtr Parameters:AKeythe key. Returns: the text ofAKeyin the language in use (the fallback language's, else the key)static method Tr(const AKey: string; const AArgs: StringArray): string: The text ofAKeywith its{0}{1}.. replaced byAArgs. C: Rtr_format Parameters:AKeythe key;AArgsthe args. Returns: the text ofAKeywith its{0}{1}.static method Has(const AKey: string): bool:truewhenAKeyhas a text. C: Rtr_exists Parameters:AKeythe key. Returns:truewhenAKeyhas a textstatic method Plural(const AKey: string; const ACount: int32): string: The plural form ofAKeyforACount(the language's.one/.few/.other.. key),{n}replaced by the count. C: Rtr_plural Parameters:AKeythe key;ACounthow many. Returns: the plural form ofAKeyforACount(the language's.one/.few/.other.static method LanguageCount(): int32: How many languages the tables have. C: Rlocale_get_language_count Returns: how many languages the tables havestatic method LanguageAt(const AIndex: int32): string: The code of languageAIndex(from 0). C: Rlocale_get_language_at Parameters:AIndexthe index, from 0. Returns: the code of languageAIndex(from 0)static method Language(const ACode: string): bool:ACodeas the language in use; every widget's@keytext follows. Parameters:ACodethe language code. Returns:falsewhen the tables have no such language. C: Rlocale_set_languagestatic method Language(): string: The code of the language in use. C: Rlocale_get_language Returns: the code of the language in usestatic method SystemLanguage(): string: The system's language code. C: Rlocale_get_system_language Returns: the system's language codestatic method FallbackLanguage(const ACode: string):ACodeas the language a missing text comes from. C: Rlocale_set_fallback_language Parameters:ACodethe language code.static method RTL(): bool:truewhen the language in use is written right to left. C: Rlocale_is_rtl Returns:truewhen the language in use is written right to leftstatic method FormatNumber(const AValue: float64; const ADecimals: int32): string:AValuewithADecimalsdecimals, written the language's way. C: Rlocale_format_number Parameters:AValuethe value;ADecimalsthe decimals. Returns:AValuewithADecimalsdecimals, written the language's waystatic method OnChanged(const AFunc: UILocaleFunc):AFuncruns when the language in use changes (nil: none). C: Rlocale_set_changed_callback Parameters:AFuncthe func it runs.
Example: UILocale.LoadCSV("res/assets/ui/texts.csv"); UILocale.Language("fr"); LLabel.Text(UILocale.Tr("greeting"));
UIAccessibilitySettings
type UIAccessibilitySettings = record
The system's accessibility settings as Raven reads them.
Members
TextScale: float32: The text scale (1.0: none).HighContrast: bool: High contrast colours.ReduceMotion: bool: Less motion (animations shortened or left out).ScreenReader: bool: A screen reader running.
UIAccessibility
type UIAccessibility = object
Accessibility for every window: text scale, high contrast, an always visible focus, reduced motion, a colour filter, the system's settings, and what a screen reader says. All static. C: Raccessibility_*
Members
static method TextScale(const AScale: float32): Every text scaled byAScale. C: Raccessibility_set_text_scale Parameters:AScalethe scale.static method TextScale(): float32: The scale every text is drawn at. C: Raccessibility_get_text_scale Returns: the scalestatic method HighContrast(const AOn: bool): High contrast colours on or off. C: Raccessibility_set_high_contrast Parameters:AOntrueto turn it on,falseto turn it off.static method HighContrast(): bool: True while high contrast colours are on. C: Raccessibility_get_high_contrast Returns:truewhen they arestatic method FocusAlwaysVisible(const AOn: bool): The focus ring shown always (true), or only after a key. C: Raccessibility_set_focus_always_visible Parameters:AOntrueto turn it on,falseto turn it off.static method FocusAlwaysVisible(): bool: True when the focus ring is always shown (not only after a key). C: Raccessibility_get_focus_always_visible Returns:truewhen it isstatic method ReduceMotion(const AOn: bool): Animations shortened or left out (true). C: Raccessibility_set_reduce_motion Parameters:AOntrueto turn it on,falseto turn it off.static method ReduceMotion(): bool: True while animations are shortened or left out. C: Raccessibility_get_reduce_motion Returns:truewhen they arestatic method ColorFilter(const AFilter: UIColorFilter): The colour filter every window is drawn through. C: Raccessibility_set_color_filter Parameters:AFilterthe filter.static method ColorFilter(): UIColorFilter: The colour filter every window is drawn through. C: Raccessibility_get_color_filter Returns: the filterstatic method SystemSettings(): UIAccessibilitySettings: The system's own settings. C: Raccessibility_get_system_settings Returns: the system's own settingsstatic method FollowSystem(): The text scale, contrast and motion taken from the system's settings. C: Raccessibility_follow_systemstatic method Announce(const AText: string; const AAssertive: bool):ATextsaid by the screen reader: at once (AAssertive), or after what it says now. C: Raccessibility_announce Parameters:ATextthe text;AAssertivethe assertive.static method ScreenReader(): bool:truewhile a screen reader runs. C: Raccessibility_is_screen_reader_active Returns:truewhile a screen reader runs
Example: UIAccessibility.FollowSystem(); UIAccessibility.Announce("Saved", false);
UIScript
type UIScript = object
Raven's own script (the <script> of an XML layout, or loaded here): its functions answer actions; checked, formatted, limited, with its log and diagnostics. All static. C: Rscript_*
Members
static method Load(const ASource: string; const AName: string): bool: Installs the scriptASource, namedANamein diagnostics ("" for none). Parameters:ASourcethe source;ANamethe name. Returns:falsewhen it has an error (nothing of it installed). C: Rscript_loadstatic method LoadFile(const APath: string): bool: Installs the script fileAPath, asLoad. C: Rscript_load_file Parameters:APaththe file's path. Returns:falsewhen it has an error (nothing of it installed)static method Check(const ASource: string; const AName: string): int32: Checks the scriptASource(or an XML document's scripts: text starting with<) without running or installing anything; its diagnostics are reported. Parameters:ASourcethe source;ANamethe name. Returns: the number of errors (0: none). C: Rscript_checkstatic method CheckFile(const APath: string): int32: Checks the script fileAPath(a .rvs or an .xml), asCheck. Parameters:APaththe file's path. Returns: the number of errors (0: none), -1 when it cannot be read. C: Rscript_check_filestatic method Format(const ASource: string; const AIndent: string): string:ASourceformatted,AIndentone level of indentation ("": four spaces). C: Rscript_format Parameters:ASourcethe source;AIndentthe indent. Returns:ASourceformatted,AIndentone level of indentation ("": four spaces)static method Reset(): Every installed script removed. C: Rscript_resetstatic method HasFunction(const AName: string): bool:truewhen an installed script has the functionAName. C: Rscript_has_function Parameters:ANamethe name. Returns:truewhen an installed script has the functionANamestatic method Enabled(const AOn: bool): Scripts run (true) or are ignored. C: Rscript_set_enabled Parameters:AOntrueto turn it on,falseto turn it off.static method Enabled(): bool: True while scripts run. C: Rscript_is_enabled Returns:truewhen they runstatic method Limits(const AMaxInstructions: uint32; const AMaxDepth: int32; const AMaxMemory: uint64): The most a script call may run: instructions, call depth and memory in bytes. C: Rscript_set_limits Parameters:AMaxInstructionsthe max instructions;AMaxDepththe max depth;AMaxMemorythe max memory.static method OnLog(const AFunc: UIScriptLogFunc):AFuncgets what scripts log (nil: none). C: Rscript_set_log_callback Parameters:AFuncthe func it runs.static method OnDiagnostic(const AFunc: UIScriptDiagnosticFunc):AFuncgets every script diagnostic (nil: none). C: Rscript_set_diagnostic_callback Parameters:AFuncthe func it runs.
Example: UIScript.OnDiagnostic(DoReport); if not UIScript.Load(LSource, "main.rs") then return; end;
UILanguageDef
type UILanguageDef = record
A language the text editor colours: its name, file extensions and words, all space-separated; "" for what it lacks. C: RLanguageDesc
Members
Name: string: Its name (UITextEditor.Language).Extensions: string: Its file extensions ("adam").Keywords: string: Its keywords.Types: string: Its type names.Constants: string: Its constants ("true false nil").LineComment: string: What starts a comment to the line's end ("//").BlockCommentStart: string: What starts a block comment ("/*").BlockCommentEnd: string: What ends a block comment ("*/").StringQuotes: string: The characters quoting strings ("\"'").MultilineStrings: string: The quotes of strings that run over lines.Directive: string: What starts a directive line ("#").Annotation: string: What starts an annotation ("@").Flags: UILanguageFlags: How it is read.ScriptLanguage: string: The language of its embedded scripts ("" for none).
UISyntaxLanguage
type UISyntaxLanguage = object
The text editor's languages: declared or replaced (a built-in one too), read back, listed and found by a file's extension. All static. C: Rlanguage_*
Members
static method Register(const ADef: UILanguageDef): bool: DeclaresADef(replacing the language of that name); its texts are copied. Parameters:ADefthe language definition. Returns:false(the error reported) when it is not valid. C: Rlanguage_registerstatic method Find(const AName: string; var ADef: UILanguageDef): bool: The languageANameread intoADef. Parameters:ANamethe name;ADefthe language definition. Returns:false(ADef unchanged) when there is none. C: Rlanguage_getstatic method Count(): int32: How many languages there are. C: Rlanguage_get_count Returns: how many languages there arestatic method Name(const AIndex: int32): string: The name of languageAIndex(from 0). C: Rlanguage_get_name Parameters:AIndexthe index, from 0. Returns: the name of languageAIndex(from 0)static method ForFile(const APath: string): string: The language of the fileAPathby its extension ("" for none). C: Rlanguage_for_file Parameters:APaththe file's path. Returns: the language of the fileAPathby its extension ("" for none)
Example: LDef.Name := "adam"; LDef.Extensions := "adam"; LDef.Keywords := "module func begin end"; UISyntaxLanguage.Register(LDef);
UIFileDialog
type UIFileDialog = object
The system's file dialogs (Raven's own with UIFileDialogFlag.Raven), built fluently and shown by Open, Save or SelectFolder, which wait for the user. C: RFileDialogDesc, Rfile_dialog_*
Members
init(): No parent, title, folder, name or filters (every file); flags none.static method Create(): UIFileDialog: A dialog with the defaults (seeinit). Returns: a dialog with the defaults (seeinit)method Parent(const AWindow: UIWindow): self: The window it belongs to (shown over it). Parameters:AWindowthe window. Returns: this object, so calls chainmethod Title(const ATitle: string): self: Its title. Parameters:ATitlethe title. Returns: this object, so calls chainmethod Directory(const APath: string): self: The folder it opens in. Parameters:APaththe file's path. Returns: this object, so calls chainmethod FileName(const AName: string): self: The file name it offers. Parameters:ANamethe name. Returns: this object, so calls chainmethod Filter(const AName: string; const APatterns: string): self: One more filter: the name it shows ("Images") and its;-separated patterns ("*.png;*.jpg"); the first added is active. Parameters:ANamethe name;APatternsthe patterns. Returns: this object, so calls chainmethod DefaultExtension(const AExtension: string): self: The extension a saved name without one gets ("adam"). Parameters:AExtensionthe extension. Returns: this object, so calls chainmethod Flags(const AFlags: UIFileDialogFlags): self: How it opens (several files, Raven's own, hidden files shown). Parameters:AFlagsthe flags. Returns: this object, so calls chainconst method Open(): StringArray: The files to open the user chose (several withUIFileDialogFlag.Multiple; empty: cancelled). C: Rfile_dialog_open, Rfile_dialog_get_result_count, Rfile_dialog_get_result Returns: the files to open the user chose (several withUIFileDialogFlag.Multiple; empty: cancelled)const method Save(): string: The file to save the user chose ("": cancelled). C: Rfile_dialog_save Returns: the file to save the user chose ("": cancelled)const method SelectFolder(): string: The folder the user chose ("": cancelled). C: Rfile_dialog_select_folder Returns: the folder the user chose ("": cancelled)
Example: LFiles := UIFileDialog.Create().Title("Open").Filter("Adam", "*.adam").Open();
UITrayRes
type UITrayRes = object
An icon in the system tray (the notification area), with a tooltip, a title, a menu and a click closure. A shared handle: the last copy destroys it, the app's end too. C: Rtray_* (Rtray_destroy: the last copy's release)
Members
init(): An empty handle (holds no icon:IsValid()false), as a variable declared with no arguments starts.init(const AIcon: UIPixels; const ATooltip: string): A tray icon showingAIconwith the tooltipATooltip(empty when the system has no tray:Supported). C: Rtray_create Parameters:AIconthe icon;ATooltipthe tooltip.static method Supported(): bool:truewhen the system has a tray. C: Rtray_is_supported Returns:truewhen the system has a trayconst method IsValid(): bool:truewhile the handle holds a tray icon. C: Rtray_is_valid Returns:truewhile the handle holds a tray iconconst method Id(): Rid: The icon's Rid, for .C calls (R_INVALID_IDwhen the handle holds none). Returns: the icon's Rid, for .C calls (R_INVALID_IDwhen the handle holds none)const method Icon(const AIcon: UIPixels): self: The picture it shows (pixels asUIWindow.Icon's). C: Rtray_set_icon Parameters:AIconthe icon. Returns: this object, so calls chainconst method Tooltip(const AText: string): self: The text shown while the pointer rests on it. C: Rtray_set_tooltip Parameters:ATextthe text. Returns: this object, so calls chainconst method Title(const AText: string): self: The text beside it (where the system shows one). C: Rtray_set_title Parameters:ATextthe text. Returns: this object, so calls chainconst method Menu(const AMenu: UIMenu): self: The menu its click opens (an emptyUIMenu(): none). C: Rtray_set_menu Parameters:AMenuthe menu. Returns: this object, so calls chainconst method Rect(): UIRect: Where it is on the screen (an empty rect when the system does not tell). C: Rtray_get_rect Returns: where it is on the screen (an empty rect when the system does not tell)const method OnClick(const AFunc: UITrayClickFunc): self:AFuncruns when it is clicked (nil: none). C: Rtray_set_clicked_callback Parameters:AFuncthe func it runs. Returns: this object, so calls chain
Example: LTray := UITrayRes(LIcon, "Adam"); LTray.Menu(LMenu).OnClick(func(const B: UIPointerButton) begin LWindow.Show(); end);
UIFiles
type UIFiles = object
Files Raven opens by path (an XML layout, a theme, a font ..) kept in memory: a path registered here is read from its bytes, never the disk. All static. A program's own files go through System.IO. C: Rfile_register_memory, Rfile_unregister_memory, Rfile_is_memory
Members
static method Register(const APath: string; const AData: array of uint8): bool: The bytesAData(copied) as the fileAPath, replacing one registered there. Parameters:APaththe file's path;ADatathe bytes. Returns:false(the error reported) when Raven refuses it. C: Rfile_register_memorystatic method Unregister(const APath: string): The fileAPathno longer in memory. C: Rfile_unregister_memory Parameters:APaththe file's path.static method IsMemory(const APath: string): bool:truewhenAPathis a registered memory file. C: Rfile_is_memory Parameters:APaththe file's path. Returns:truewhenAPathis a registered memory file
Example: UIFiles.Register("ui/main.xml", LBytes); UITheme.Load("ui/main.xml");
UIXMLReloadFunc
type UIXMLReloadFunc = ref func(const APath: string; const AOk: bool)
The routine told a file was loaded again by live reload: APath as the interface was made from it, AOk false when the file could not be used (the interface unchanged).
UIXMLTagCreateFunc
type UIXMLTagCreateFunc = ref func(const ATag: string): UIWidget
The routine making the widget of a tag made by code (UIXML.Tag): ATag the tag as the document writes it.
UIXMLTagAttributeFunc
type UIXMLTagAttributeFunc = ref func(const AWidget: UIWidget; const AName: string;
The routine given each attribute of a tag made by code before Raven looks at it: true for one it understands, false to leave it to the widget.
UIXML
type UIXML = object
Raven's XML machinery, all static: where the files a document names are looked for (the document's folder and its subfolders, the base path, the current folder, PATH), auto-loading (the translation tables and <Widget> declarations found there), live reload (an interface made from a file follows the file while the app runs), the declared tags and the tags made by code, and what can be written (every tag and its attributes, for tools). C: Rxml_*
Members
static method BasePath(const APath: string): The folder looked into after the document's own, and the first one for documents given as text ("": none). C: Rxml_set_base_path Parameters:APaththe file's path.static method ResolvePath(const APath: string): string: WhereAPath, a file a document names, is found, looked for as Raven looks (the path it would have beside the document, else in the base path, when no place holds it). C: Rxml_resolve_path Parameters:APaththe file's path. Returns: whereAPath, a file a document names, is found, looked for as Raven looks (the path it would have beside the document, else in the base path, when no place holds it)static method AutoLoad(const AOn: bool): Auto-loading on (true, the default) or off: off, the register routines are the only way in. C: Rxml_set_auto_load Parameters:AOntrueto turn it on,falseto turn it off.static method AutoLoad(): bool: True while auto-loading is on. C: Rxml_get_auto_load Returns:truewhen it is onstatic method LiveReload(const AOn: bool): Live reload on (true, the default) or off: off, files are never looked at again. C: Rxml_set_live_reload Parameters:AOntrueto turn it on,falseto turn it off.static method LiveReload(): bool: True while live reload is on. C: Rxml_get_live_reload Returns:truewhen it is onstatic method CheckFiles(): int32: Looks at the files now (live reload looks five times a second), even with live reload off. Returns: the files found changed. C: Rxml_check_filesstatic method OnReload(const AFunc: UIXMLReloadFunc):AFuncruns each time a file was loaded again (nil: none): widgets built again have new handles, so it is the place to find them again. C: Rxml_set_reload_callback Parameters:AFuncthe func it runs.static method RegisterWidgets(const AXML: string): int32: Reads the<Widget Name="..">declarations of the XML textAXML(its root, or the children of a<Widgets>root), so the documents loaded afterwards can use their tags. Parameters:AXMLthe XML text. Returns: the tags declared. C: Rxml_register_widgetsstatic method RegisterWidgetsFile(const APath: string): int32: Reads the declarations of the fileAPath, asRegisterWidgets. Parameters:APaththe file's path. Returns: the tags declared. C: Rxml_register_widgets_from_filestatic method UnregisterWidget(const AName: string): The declared tagANameforgotten. C: Rxml_unregister_widget Parameters:ANamethe name.static method WidgetRegistered(const AName: string): bool:truewhenANameis a declared tag. C: Rxml_is_widget_registered Parameters:ANamethe name. Returns:truewhenANameis a declared tagstatic method RegisteredCount(): int32: The declared tags. C: Rxml_get_registered_widget_count Returns: the declared tagsstatic method RegisteredName(const AIndex: int32): string: The declared tag atAIndex(0 ..RegisteredCount() - 1). C: Rxml_get_registered_widget_name Parameters:AIndexthe index, from 0. Returns: the declared tag atAIndex(0 .static method Tag(const ATag: string; const ACreate: UIXMLTagCreateFunc; const AAttribute: UIXMLTagAttributeFunc): bool: A tag made by code: documents write<ATag ../>as they write<Button/>,ACreatemaking its widget andAAttribute(nil: none) given each attribute first. A tag registered again is replaced. Parameters:ATagthe tag;ACreatethe create;AAttributethe attribute. Returns:falsewhenATagis one of Raven's widgets or 64 tags are registered. C: Rxml_register_tagstatic method UnregisterTag(const ATag: string): The tag made by codeATagforgotten, its closures let go. C: Rxml_unregister_tag Parameters:ATagthe tag.static method TagRegistered(const ATag: string): bool:truewhenATagis a tag made by code. C: Rxml_is_tag_registered Parameters:ATagthe tag. Returns:truewhenATagis a tag made by codestatic method TagCount(): int32: Raven's tags,<Window>included (the declared ones:RegisteredName). C: Rxml_get_tag_count Returns: raven's tags,<Window>included (the declared ones:RegisteredName)static method TagName(const AIndex: int32): string: Raven's tag atAIndex(0 ..TagCount() - 1). C: Rxml_get_tag_name Parameters:AIndexthe index, from 0. Returns: raven's tag atAIndex(0 .static method TagDescription(const ATag: string): string: One line about the tagATag("" when there is nothing to say). C: Rxml_get_tag_description Parameters:ATagthe tag. Returns: the line ("" when there is nothing to say)static method TagChildren(const ATag: string): int32: The child widgetsATagtakes: 0 none, 1 a single one, 2 any number (a declared or unknown tag: 2). C: Rxml_get_tag_children Parameters:ATagthe tag. Returns: the child widgetsATagtakes: 0 none, 1 a single one, 2 any number (a declared or unknown tag: 2)static method AttributeCount(const ATag: string): int32: The attributesATagtakes: its own, then every widget's, then its place's in its parent. C: Rxml_get_attribute_count Parameters:ATagthe tag. Returns: the attributesATagtakes: its own, then every widget's, then its place's in its parentstatic method AttributeInfo(const ATag: string; const AIndex: int32; var AInfo: RXmlAttributeInfo): bool: The attribute ofATagatAIndex(0 ..AttributeCount(ATag) - 1) intoAInfo(its typed reads:RXmlAttributeInfo's extend). Parameters:ATagthe tag;AIndexthe index, from 0;AInfothe info. Returns:falsefor no such attribute. C: Rxml_get_attribute_info
Example: UIXML.BasePath("res/assets/ui"); UIXML.OnReload(func(const P: string; const AOk: bool) begin println("{} {}", P, AOk); end);
UIXMLDocRes
type UIXMLDocRes = object
An XML document as a tree of nodes, read, changed, built and written back (what an interface designer edits); comments are kept. What is built from it lives on after it. A shared handle: the last copy destroys the document and its nodes, the app's end too. C: Rxml_document_* (Rxml_document_destroy: the last copy's release)
Members
init(): An empty handle (holds no document:IsValid()false), as a variable declared with no arguments starts.init(const APath: string): The document of the XML fileAPath(the paths it names relative to its folder). C: Rxml_document_load Parameters:APaththe file's path.static method Create(const ARootTag: string): UIXMLDocRes: A new document of one element, the tagARootTag. C: Rxml_document_create Parameters:ARootTagthe root tag. Returns: a new document of one element, the tagARootTagstatic method Parse(const AXML: string): UIXMLDocRes: The document of the XML textAXML(IsValid()false when it does not read: its error reported toUIErrors). C: Rxml_document_parse Parameters:AXMLthe XML text. Returns: the document of the XML textAXML(IsValid()false when it does not read: its error reported toUIErrors)static method Parse(const AXML: string; var AError: RXmlError): UIXMLDocRes: The document of the XML textAXML; a mistake in it is described inAError(Message(), line, column) and not reported (IsValid()false). C: Rxml_document_parse Parameters:AXMLthe XML text;AErrorthe error. Returns: the document of the XML textAXML; a mistake in it is described inAError(Message(), line, column) and not reported (IsValid()false)static method View(const ADoc: Rid): UIXMLDocRes: The documentADocof System.Raven.C, borrowed (never destroyed by this handle). Parameters:ADocthe doc. Returns: the documentADocof System.Raven.C, borrowed (never destroyed by this handle)const method IsValid(): bool:truewhile it holds a document. C: Rxml_document_is_valid Returns:truewhile it holds a documentconst method Id(): Rid: The document's Rid, for .C calls (R_INVALID_IDwhen the handle holds none). Returns: the document's Rid, for .C calls (R_INVALID_IDwhen the handle holds none)const method Root(): UIXMLNode: Its root element. C: Rxml_document_get_root Returns: its root elementconst method ToString(): string: The document as text, one element a line, tab-indented (each node'sLine()then says where it was written). C: Rxml_document_to_string Returns: the document as text, one element a line, tab-indented (each node'sLine()then says where it was written)const method Save(const APath: string): bool: Writes the document to the fileAPath. Parameters:APaththe file's path. Returns:falsewhen it could not be written. C: Rxml_document_saveconst method CreateWidget(): UIWidget: The widgets it describes (for a<Window>root, what the window shows: an empty handle when it is empty). C: Rxml_document_create_widget Returns: the widgets it describes (for a<Window>root, what the window shows: an empty handle when it is empty)const method CreateWindow(): UIWindow: The window it describes. C: Rxml_document_create_window Returns: the window it describes
Example: LDoc := UIXMLDocRes.Create("VBox"); LDoc.Root().AddChild("Button").Attribute("Text", "Save"); LWidget := LDoc.CreateWidget();
UIXMLNode
type UIXMLNode = object
One node of a UIXMLDocRes, an element or a comment: a handle (Raven's Rid of the node), copied freely; it names no node once removed or its document destroyed. A new child goes at AIndex among its parent's children (-1: the end). C: Rxml_node_*
Members
init(): An empty node handle (names none).static method Wrap(const ANode: Rid): UIXMLNode: The handle of the node System.Raven.C gave asANode. Parameters:ANodethe node. Returns: the handle of the node System.Raven.C gave asANodeconst method Id(): Rid: The node's Rid, for System.Raven.C's calls. Returns: the node's Rid, for System.Raven.C's callsconst method IsValid(): bool:truewhile the handle names a node. C: Rxml_node_is_valid Returns:truewhile the handle names a nodeconst method IsComment(): bool:truefor a comment. C: Rxml_node_is_comment Returns:truefor a commentconst method Document(): UIXMLDocRes: The document it is in, borrowed (this handle never destroys it). C: Rxml_node_get_document Returns: the document it is in, borrowed (this handle never destroys it)const method Tag(const ATag: string): self: The element's tag. C: Rxml_node_set_tag Parameters:ATagthe tag. Returns: this object, so calls chainconst method Tag(): string: The element's tag ("" for a comment). C: Rxml_node_get_tag Returns: the element's tag ("" for a comment)const method Text(const AText: string): self: The text inside the element (<Label>this</Label>), or the comment's. C: Rxml_node_set_text Parameters:ATextthe text. Returns: this object, so calls chainconst method Text(): string: WhatText(..)sets, read back. C: Rxml_node_get_text Returns: the text inside the element (<Label>this</Label>), or the comment'sconst method Parent(): UIXMLNode: Its parent (an empty handle for the root). C: Rxml_node_get_parent Returns: its parent (an empty handle for the root)const method ChildCount(): int32: Its children. C: Rxml_node_get_child_count Returns: its childrenconst method Child(const AIndex: int32): UIXMLNode: Its child atAIndex(0 ..ChildCount() - 1). C: Rxml_node_get_child Parameters:AIndexthe index, from 0. Returns: its child atAIndex(0 .const method Index(): int32: Its place among its parent's children (0 for the root). C: Rxml_node_get_index Returns: its place among its parent's children (0 for the root)const method AddChild(const ATag: string): UIXMLNode: A new elementATag, its last child. C: Rxml_node_add_child Parameters:ATagthe tag. Returns: a new elementATag, its last childconst method AddChild(const ATag: string; const AIndex: int32): UIXMLNode: A new elementATag, its child atAIndex(-1: the end; an empty handle when it would be nested deeper than 256 levels). C: Rxml_node_add_child Parameters:ATagthe tag;AIndexthe index, from 0. Returns: a new elementATag, its child atAIndex(-1: the end; an empty handle when it would be nested deeper than 256 levels)const method AddComment(const AText: string): UIXMLNode: A new commentAText, its last child. C: Rxml_node_add_comment Parameters:ATextthe text. Returns: a new commentAText, its last childconst method AddComment(const AText: string; const AIndex: int32): UIXMLNode: A new commentAText, its child atAIndex(-1: the end). C: Rxml_node_add_comment Parameters:ATextthe text;AIndexthe index, from 0. Returns: a new commentAText, its child atAIndex(-1: the end)const method AddXML(const AXML: string): UIXMLNode: The element of the XML textAXML(one element and what it holds: a paste, a template), read and added as its last child. C: Rxml_node_add_xml Parameters:AXMLthe XML text. Returns: the element of the XML textAXML(one element and what it holds: a paste, a template), read and added as its last childconst method AddXML(const AXML: string; const AIndex: int32): UIXMLNode: The element ofAXMLadded as its child atAIndex(-1: the end). C: Rxml_node_add_xml Parameters:AXMLthe XML text;AIndexthe index, from 0. Returns: the element ofAXMLadded as its child atAIndex(-1: the end)const method Remove(): Removes the node and what it holds (the root stays). C: Rxml_node_removeconst method Move(const AParent: UIXMLNode; const AIndex: int32): bool: Moves the node, with what it holds, underAParentatAIndex(counted once it left its place; -1: the end). Parameters:AParentthe parent;AIndexthe index, from 0. Returns:falsewhen it cannot be (the root, a parent inside it, too deep). C: Rxml_node_moveconst method Duplicate(): UIXMLNode: A copy of the node and what it holds, right after it. C: Rxml_node_duplicate Returns: a copy of the node and what it holds, right after itconst method ToString(): string: The node as XML text. C: Rxml_node_to_string Returns: the node as XML textconst method AttributeCount(): int32: Its attributes. C: Rxml_node_get_attribute_count Returns: its attributesconst method AttributeName(const AIndex: int32): string: The name of its attribute atAIndex. C: Rxml_node_get_attribute_name Parameters:AIndexthe index, from 0. Returns: the name of its attribute atAIndexconst method AttributeValue(const AIndex: int32): string: The value of its attribute atAIndex. C: Rxml_node_get_attribute_value Parameters:AIndexthe index, from 0. Returns: the value of its attribute atAIndexconst method Attribute(const AName: string; const AValue: string): self: The attributeANameset toAValue(added after the others when new). C: Rxml_node_set_attribute Parameters:ANamethe name;AValuethe text. Returns: this object, so calls chainconst method Attribute(const AName: string): string: The value of the attributeAName(names compared without case; "" when it has none:HasAttribute). C: Rxml_node_get_attribute Parameters:ANamethe name. Returns: the value of the attributeAName(names compared without case; "" when it has none:HasAttribute)const method HasAttribute(const AName: string): bool:truewhen it has the attributeAName. C: Rxml_node_get_attribute Parameters:ANamethe name. Returns:truewhen it has the attributeANameconst method RemoveAttribute(const AName: string): self: The attributeANameremoved. C: Rxml_node_set_attribute Parameters:ANamethe name. Returns: this object, so calls chainconst method Line(): int32: Its line (from 1) in the text the document was read from or last written to (0 for a node added since). C: Rxml_node_get_line Returns: its line (from 1) in the text the document was read from or last written to (0 for a node added since)const method Widget(): UIWidget: The widget (the window, for a<Window>) it became the last time the document was built (an empty handle: never built, destroyed since, or no widget). C: Rxml_node_get_widget Returns: the widget (the window, for a<Window>) it became the last time the document was built (an empty handle: never built, destroyed since, or no widget)
UIHostCursorFunc
type UIHostCursorFunc = ref func(const AWindow: UIWindow; const ACursor: UICursor)
The routine giving Raven's window AWindow the cursor ACursor (UICursor.None: hidden).
UIHostClipboardSetFunc
type UIHostClipboardSetFunc = ref func(const AText: string)
The routine putting AText on the program's clipboard.
UIHostClipboardGetFunc
type UIHostClipboardGetFunc = ref func(): string
The routine giving the program's clipboard text ("" when it holds none).
UIHostWakeFunc
type UIHostWakeFunc = ref func()
The routine waking the program's loop (Raven has work: a post, a timer, an animation); it runs on any thread.
UIVulkanLockFunc
type UIVulkanLockFunc = ref func()
The routine taking (or giving back) the program's lock on the Vulkan queue Raven shares.
UIHostPlatform
type UIHostPlatform = object
What a program hosting Raven answers Raven's asks with (UIHost.Register): closures for the cursor, the clipboard both ways and waking the program's loop, each optional. A value, built fluently.
Members
init(): No closures: Raven keeps its cursor and clipboard to itself.method Cursor(const AFunc: UIHostCursorFunc): self: The cursor Raven wants over one of its windows. Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method Cursor(): UIHostCursorFunc: The cursor closure (nil: none). Returns: the cursor closure (nil: none)method ClipboardSet(const AFunc: UIHostClipboardSetFunc): self: Raven copies text to the clipboard. Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method ClipboardSet(): UIHostClipboardSetFunc: The clipboard-copy closure (nil: none). Returns: the clipboard-copy closure (nil: none)method ClipboardGet(const AFunc: UIHostClipboardGetFunc): self: Raven pastes the clipboard's text. Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method ClipboardGet(): UIHostClipboardGetFunc: The clipboard-paste closure (nil: none). Returns: the clipboard-paste closure (nil: none)method Wake(const AFunc: UIHostWakeFunc): self: Raven has work for the next frame (any thread). Parameters:AFuncthe func it runs. Returns: this object, so calls chainconst method Wake(): UIHostWakeFunc: The wake closure (nil: none). Returns: the wake closure (nil: none)
Example: UIHost.Register(UIHostPlatform().Cursor(func(const W: UIWindow; const C: UICursor) begin SetMyCursor(C); end));
UIHost
type UIHost = object
Raven inside the windows of another program (an editor's panels, an engine's screen), all static. Register before the app opens makes it run on the host platform: Raven opens no OS window and reads no OS events; the program tells each Raven window its size and scale (in its pixels) and gives it its input (Inject*), and draws it with a backend of its own (RegisterBackend, UIBackend.Custom) or Raven's. C: Rhost_, Rbackend_
Members
static method Register(const APlatform: UIHostPlatform): The next app opened runs on the host platform, answering Raven withAPlatform's closures. C: Rhost_platform_register Parameters:APlatformthe platform.static method Unregister(): The next app opened runs on the OS's own platform again (the default), the closures let go. C: Rhost_platform_registerstatic method Active(): bool:truewhile the open app runs on the host platform. C: Rhost_platform_is_active Returns:truewhile the open app runs on the host platformstatic method WindowSize(const AWindow: UIWindow; const AWidth: int32; const AHeight: int32; const AScale: float32):AWindow's size,AWidthxAHeightpixels, and its scale (pixels a UI unit). C: Rhost_window_set_size Parameters:AWindowthe window;AWidththe width;AHeightthe height;AScalethe scale.static method Insets(const AWindow: UIWindow; const ASafeArea: RInsets; const AKeyboardHeight: int32): The edges ofAWindowsystem bars and notches cover, and the height the on-screen keyboard covers (0: none). C: Rhost_window_set_insets Parameters:AWindowthe window;ASafeAreathe safe area;AKeyboardHeightthe keyboard height.static method SystemDark(const AOn: bool):truewhen the system's look is dark (themes following the system follow it). C: Rhost_set_system_dark Parameters:AOntrueto turn it on,falseto turn it off.static method InjectMove(const AWindow: UIWindow; const AX: int32; const AY: int32; const AMods: UIModifiers): The mouse moved to (AX,AY) pixels inAWindow. C: Rhost_inject_mouse_move Parameters:AWindowthe window;AXthe x coordinate;AYthe y coordinate;AModsthe modifier keys.static method InjectButton(const AWindow: UIWindow; const AX: int32; const AY: int32; const AButton: UIPointerButton; const APressed: bool; const AMods: UIModifiers): The mouse buttonAButtonwent down (APressed) or up at (AX,AY). C: Rhost_inject_mouse_button Parameters:AWindowthe window;AXthe x coordinate;AYthe y coordinate;AButtonthe button;APressedtruefor down,falsefor up;AModsthe modifier keys.static method InjectWheel(const AWindow: UIWindow; const AX: float32; const AY: float32; const AMods: UIModifiers): The wheel turned byAX,AYnotches. C: Rhost_inject_mouse_wheel Parameters:AWindowthe window;AXthe x coordinate;AYthe y coordinate;AModsthe modifier keys.static method InjectLeave(const AWindow: UIWindow): The mouse leftAWindow(hover ends). C: Rhost_inject_mouse_leave Parameters:AWindowthe window.static method InjectKey(const AWindow: UIWindow; const AKey: UIKey; const APressed: bool; const AMods: UIModifiers; const ARepeat: bool): The keyAKeywent down (APressed;ARepeatfor the system's auto-repeat) or up. C: Rhost_inject_key Parameters:AWindowthe window;AKeythe key;APressedtruefor down,falsefor up;AModsthe modifier keys;ARepeattruefor the system's auto-repeat.static method InjectText(const AWindow: UIWindow; const ACodepoint: uint32): The characterACodepoint(a Unicode code point) was typed. C: Rhost_inject_text Parameters:AWindowthe window;ACodepointthe codepoint.static method InjectFocus(const AWindow: UIWindow; const AOn: bool):AWindowtook (true) or lost the keyboard focus. C: Rhost_inject_focus Parameters:AWindowthe window;AOntrueto turn it on,falseto turn it off.static method InjectClose(const AWindow: UIWindow): The user asked to closeAWindow(its OnClose decides). C: Rhost_inject_close Parameters:AWindowthe window.static method RegisterBackend(const AVTable: RBackendVTable): The program's render backend, forUIBackend.Custom(before the app opens; Raven copies the table). C: Rbackend_register Parameters:AVTablethe V table.static method DeviceLost(): The program's backend lost its device (any thread): Raven makes its textures again. C: Rbackend_device_loststatic method CapturePixels(const ASize: uint64): ptr to uint8: A pixel buffer ofASizebytes Raven frees, for a backend's frame capture (RCapture.pixels); any thread. C: Rpixels_alloc Parameters:ASizethe size. Returns: a pixel buffer ofASizebytes Raven frees, for a backend's frame capture (RCapture.pixels); any thread
Example: UIHost.Register(LPlatform); LApp := UIApp.Config().AppName("Editor").Open(); UIHost.WindowSize(LPanel, 640, 480, 1.0f);
UIVulkan
type UIVulkan = object
Raven's Vulkan device shared with a Vulkan engine (Raven on UIBackend.Vulkan), all static: the extensions Raven needs, an engine's own device given to Raven (before the app opens), Raven's handles read, the queue's lock, and textures over the engine's image views or shared across processes. The handles are Vulkan's, as ptr (nil off Vulkan). C: Rvulkan_*
Members
static method RequiredInstanceExtensions(): StringArray: The instance extensions Raven needs enabled. C: Rvulkan_get_required_instance_extensions Returns: the instance extensions Raven needs enabledstatic method RequiredDeviceExtensions(): StringArray: The device extensions Raven needs enabled. C: Rvulkan_get_required_device_extensions Returns: the device extensions Raven needs enabledstatic method ExternalDevice(const AInstance: ptr; const APhysicalDevice: ptr; const ADevice: ptr; const AQueue: ptr; const AQueueFamily: uint32): Raven runs on the engine's device: itsVkInstance,VkPhysicalDevice,VkDevice, graphicsVkQueueand that queue's family (before the app opens). C: Rvulkan_set_external_device Parameters:AInstancethe instance;APhysicalDevicethe physical device;ADevicethe device;AQueuethe queue;AQueueFamilythe queue family.static method QueueLock(const ALock: UIVulkanLockFunc; const AUnlock: UIVulkanLockFunc):ALockandAUnlockrun around each of Raven's uses of a shared queue (nil,nil: none). Set it before the app opens: Raven refuses it while it runs; it stays until the app has shut down. C: Rvulkan_set_queue_lock_callbacks Parameters:ALockthe lock;AUnlockthe unlock.static method Instance(): ptr: Raven'sVkInstance. C: Rvulkan_get_instance Returns: raven'sVkInstancestatic method PhysicalDevice(): ptr: Raven'sVkPhysicalDevice. C: Rvulkan_get_physical_device Returns: raven'sVkPhysicalDevicestatic method Device(): ptr: Raven'sVkDevice. C: Rvulkan_get_device Returns: raven'sVkDevicestatic method GraphicsQueue(): ptr: Raven's graphicsVkQueue. C: Rvulkan_get_graphics_queue Returns: raven's graphicsVkQueuestatic method GraphicsQueueFamily(): uint32: The graphics queue's family. C: Rvulkan_get_graphics_queue_family Returns: the graphics queue's familystatic method SimulateDeviceLost(): Acts as if the device was lost (the recovery path, for tests). C: Rvulkan_simulate_device_loststatic method TextureFromImageView(const AImageView: uint64; const ASampler: uint64; const AWidth: int32; const AHeight: int32): UITextureRes: A texture showing the engine'sVkImageViewAImageViewthrough itsVkSamplerASampler,AWidthxAHeight(the engine keeps the image). C: Rvulkan_texture_create_from_image_view Parameters:AImageViewthe image view;ASamplerthe sampler;AWidththe width;AHeightthe height. Returns: a texture showing the engine'sVkImageViewAImageViewthrough itsVkSamplerASampler,AWidthxAHeight(the engine keeps the image)static method TextureImageView(const ATexture: UITextureRes; const AImageView: uint64; const ASampler: uint64; const AWidth: int32; const AHeight: int32):ATextureshows another image view of the engine's (after it made the image again). C: Rvulkan_texture_set_image_view Parameters:ATexturethe texture;AImageViewthe image view;ASamplerthe sampler;AWidththe width;AHeightthe height.static method SharedTexture(const AWidth: int32; const AHeight: int32): UITextureRes: A textureAWidthxAHeightwhose memory another process can open (SharedInfo). C: Rvulkan_texture_create_shared Parameters:AWidththe width;AHeightthe height. Returns: a textureAWidthxAHeightwhose memory another process can open (SharedInfo)static method SharedInfo(const ATexture: UITextureRes; var AInfo: RSharedTextureInfo): bool: The OS handle and size of a shared texture's memory intoAInfo. Parameters:ATexturethe texture;AInfothe info. Returns:falsewhenATextureis no shared texture. C: Rvulkan_texture_get_shared_info
Example: LExtensions := UIVulkan.RequiredInstanceExtensions(); UIVulkan.ExternalDevice(LInstance, LGpu, LDevice, LQueue, LFamily);
Extends
extend UIColor
extend UIColor
Members
static method White(): UIColor: Opaque white (1, 1, 1, 1). Returns: the newUIColorstatic method Black(): UIColor: Opaque black (0, 0, 0, 1). Returns: the newUIColorstatic method Transparent(): UIColor: Fully transparent black (0, 0, 0, 0). Returns: the newUIColorstatic method FromRGBA(const AR: uint8; const AG: uint8; const AB: uint8): UIColor: The opaque colour of the bytesAR,AG,AB(0..255 each). Parameters:ARthe red byte;AGthe green byte;ABthe blue byte. Returns: the opaque colour of the bytesAR,AG,AB(0..255 each) Example:UIColor.FromRGBA(58, 123, 213)static method FromRGBA(const AR: uint8; const AG: uint8; const AB: uint8; const AA: uint8): UIColor: The colour of the bytesAR,AG,AB,AA(0..255 each). Parameters:ARthe red byte;AGthe green byte;ABthe blue byte;AAthe alpha byte. Returns: the colour of the bytesAR,AG,AB,AA(0..255 each)static method FromHex(const AText: string; const ADefault: UIColor): UIColor: The colour the hex textATextnames (#RGB,#RGBA,#RRGGBB,#RRGGBBAA, the#optional:TryHexToRGBA), orADefaultfor any other text. Parameters:ATextthe text;ADefaultthe default. Returns: the colour the hex textATextnames (#RGB,#RGBA,#RRGGBB,#RRGGBBAA, the#optional:TryHexToRGBA), orADefaultfor any other text Example:UIColor.FromHex("#3a7bd5", UIColor.Black())static method FromHSV(const AH: float32; const AS: float32; const AV: float32): UIColor: The opaque colour of hueAH(0..360), saturationASand valueAV(0..1). C: Rcolor_hsv_to_rgb Parameters:AHthe hue, in degrees (0 to 360);ASthe saturation, 0 to 1;AVthe value (brightness), 0 to 1. Returns: the opaque colour of hueAH(0..360), saturationASand valueAV(0..1)static method FromHSV(const AH: float32; const AS: float32; const AV: float32; const AA: float32): UIColor: The colour of hueAH(0..360), saturationAS, valueAVand alphaAA(0..1). C: Rcolor_hsv_to_rgb Parameters:AHthe hue, in degrees (0 to 360);ASthe saturation, 0 to 1;AVthe value (brightness), 0 to 1;AAthe alpha (0..1). Returns: the colour of hueAH(0..360), saturationAS, valueAVand alphaAA(0..1)const method ToHSV(var AH: float32; var AS: float32; var AV: float32): The colour's hue (0..360), saturation and value (0..1). C: Rcolor_rgb_to_hsv Parameters:AHthe hue, in degrees (0 to 360);ASthe saturation, 0 to 1;AVthe value (brightness), 0 to 1.const method Hex(): string: The colour as hex text, uppercase:#RRGGBBwhen it is opaque, else#RRGGBBAA(each channel rounded to its nearest byte;FromHexreads it back). Returns: the colour as hex text, uppercase:#RRGGBBwhen it is opaque, else#RRGGBBAA(each channel rounded to its nearest byte;FromHexreads it back)const method WithAlpha(const AA: float32): UIColor: The colour with its alpha set toAA(0..1). Parameters:AAthe new alpha (0..1). Returns: the colour with its alpha set toAA(0..1)const method Lerp(const AB: UIColor; const AT: float32): UIColor: The colourATof the way from this one toAB(0: this one, 1:AB), each channel mixed in a straight line. Parameters:ABthe colour it mixes towards;AThow far along, 0 to 1. Returns: the colourATof the way from this one toAB(0: this one, 1:AB), each channel mixed in a straight lineoperator =(const A: UIColor; const B: UIColor): bool: The same colour: every channel equal. Parameters:Athe left operand;Bthe right operand. Returns:truewhen every channel is equal
extend UIPoint
extend UIPoint
Members
operator +(const A: UIPoint; const B: UIPoint): UIPoint: The sum of two points (a point moved by an offset). Parameters:Athe left operand;Bthe right operand. Returns: the sum of two points (a point moved by an offset)operator -(const A: UIPoint; const B: UIPoint): UIPoint: The offset fromBtoA. Parameters:Athe left operand;Bthe right operand. Returns: the offset fromBtoAoperator *(const A: UIPoint; const S: float32): UIPoint: The point scaled byS. Parameters:Athe left operand;Sthe right operand. Returns: the point scaled bySoperator =(const A: UIPoint; const B: UIPoint): bool: The same point. Parameters:Athe left operand;Bthe right operand. Returns:truewhen both coordinates are equal
extend UIRect
extend UIRect
Members
const method Contains(const AP: UIPoint): bool:truewhenAPlies inside the rectangle (its left and top edges in, its right and bottom edges out). Parameters:APthe point tested. Returns:truewhenAPlies inside the rectangle (its left and top edges in, its right and bottom edges out)const method Center(): UIPoint: The rectangle's centre. Returns: the rectangle's centre
extend REvent
extend REvent
Members
const method Kind(): UIEventKind: The event's kind. Returns: the event's kindconst method Position(): UIPoint: Where it happened, in the window's logical units. Returns: where it happened, in the window's logical unitsconst method Local(): UIPoint: Where it happened, in the widget's own logical units. Returns: where it happened, in the widget's own logical unitsconst method Delta(): UIPoint: How far the pointer moved since the event before. Returns: how far the pointer moved since the event beforeconst method Wheel(): UIPoint: How far the wheel turned (y: up / down, x: left / right). Returns: how far the wheel turned (y: up / down, x: left / right)const method Button(): UIPointerButton: The mouse button of a button event. Returns: the mouse button of a button eventconst method Key(): UIKey: The key of a key event. Returns: the key of a key eventconst method Mods(): UIModifiers: The modifier keys held. Returns: the modifier keys heldconst method Repeat(): bool:truefor a key event the key's auto-repeat made. Returns:truefor a key event the key's auto-repeat madeconst method Char(): string: The character a text event typed, as a string ("" for no character). Returns: the character a text event typed, as a string ("" for no character)const method Precise(): bool:truewhen the wheel's amounts are precise (a trackpad's), not whole notches. Returns:truewhen the wheel's amounts are precise (a trackpad's), not whole notchesconst method Target(): UIWidget: The widget the event happened on. Returns: the widget the event happened onconst method Window(): UIWindow: The window the event happened in. Returns: the window the event happened in
extend RDropEvent
extend RDropEvent
Members
const method Phase(): UIDropPhase: The drop's stage. Returns: the drop's stageconst method Position(): UIPoint: Where the pointer is, in the window's logical units. Returns: where the pointer is, in the window's logical unitsconst method Local(): UIPoint: Where the pointer is, in the widget's own logical units. Returns: where the pointer is, in the widget's own logical unitsconst method Paths(): array of string: The files dropped (none for a text drop). Returns: the files dropped (none for a text drop)const method Text(): string: The text dropped ("" for none). Returns: the text dropped ("" for none)const method DragType(): string: The type a drag inside the program named ("" for none). Returns: the type a drag inside the program named ("" for none)const method Source(): UIWidget: The widget a drag of the app's own started from (an empty handle for files or text from outside). Returns: the widget a drag of the app's own started from (an empty handle for files or text from outside)const method Window(): UIWindow: The window the drag is over. Returns: the window the drag is over
extend RTouchEvent
extend RTouchEvent
Members
const method Phase(): UITouchPhase: The touch's stage. Returns: the touch's stageconst method Position(): UIPoint: Where the finger is, in the window's logical units. Returns: where the finger is, in the window's logical unitsconst method Local(): UIPoint: Where the finger is, in the widget's own logical units. Returns: where the finger is, in the widget's own logical unitsconst method Mods(): UIModifiers: The modifier keys held. Returns: the modifier keys heldconst method Target(): UIWidget: The widget the touch is on. Returns: the widget the touch is onconst method Window(): UIWindow: The window the touch is in. Returns: the window the touch is in
extend RPenEvent
extend RPenEvent
Members
const method Phase(): UIPenPhase: The input's stage. Returns: the input's stageconst method Position(): UIPoint: Where the pen is, in the window's logical units. Returns: where the pen is, in the window's logical unitsconst method Local(): UIPoint: Where the pen is, in the widget's own logical units. Returns: where the pen is, in the widget's own logical unitsconst method Tilt(): UIPoint: The pen's tilt (x and y, in degrees). Returns: the pen's tilt (x and y, in degrees)const method Eraser(): bool:truewhen the pen's eraser end is used. Returns:truewhen the pen's eraser end is usedconst method Buttons(): UIPenButtons: The barrel buttons held. Returns: the barrel buttons heldconst method Mods(): UIModifiers: The modifier keys held. Returns: the modifier keys heldconst method Target(): UIWidget: The widget the pen is on. Returns: the widget the pen is onconst method Window(): UIWindow: The window the pen is in. Returns: the window the pen is in
extend RGestureEvent
extend RGestureEvent
Members
const method Phase(): UIGesturePhase: The gesture's stage. Returns: the gesture's stageconst method Kind(): UIGestureKind: The gesture's kind. Returns: the gesture's kindconst method Device(): UIGestureDevice: The device it comes from. Returns: the device it comes fromconst method Position(): UIPoint: Where it is, in the window's logical units. Returns: where it is, in the window's logical unitsconst method Local(): UIPoint: Where it is, in the widget's own logical units. Returns: where it is, in the widget's own logical unitsconst method Pan(): UIPoint: How far it panned since the event before. Returns: how far it panned since the event beforeconst method Total(): UIPoint: How far it panned since it began. Returns: how far it panned since it beganconst method Cancelled(): bool:truewhen the system cancelled it. Returns:truewhen the system cancelled itconst method Target(): UIWidget: The widget the gesture is on. Returns: the widget the gesture is onconst method Window(): UIWindow: The window the gesture is in. Returns: the window the gesture is in
extend RTextInputInfo
extend RTextInputInfo
Members
const method Kind(): UIInputType: The kind of text it takes. Returns: the kind of text it takesconst method ReturnKey(): UIReturnKey: The label of the on-screen keyboard's return key. Returns: the label of the on-screen keyboard's return keyconst method Password(): bool:truefor a password input (its text hidden). Returns:truefor a password input (its text hidden)const method ReadOnly(): bool:truewhen its text cannot be edited. Returns:truewhen its text cannot be edited
extend RAccessibilitySettings
extend RAccessibilitySettings
Members
const method HighContrast(): bool:truewhen high contrast is on. Returns:truewhen high contrast is onconst method ReduceMotion(): bool:truewhen the user asks for less motion. Returns:truewhen the user asks for less motionconst method ScreenReader(): bool:truewhen a screen reader runs. Returns:truewhen a screen reader runs
extend RTouchSettings
extend RTouchSettings
Members
const method MouseEmulation(): bool:truewhen a touch also acts as the mouse. Returns:truewhen a touch also acts as the mouseconst method Inertia(): bool:truewhen a fling keeps scrolling. Returns:truewhen a fling keeps scrollingconst method Gestures(): bool:truewhen pinch and swipe gestures are recognized. Returns:truewhen pinch and swipe gestures are recognizedconst method PenMouseEmulation(): bool:truewhen a pen also acts as the mouse. Returns:truewhen a pen also acts as the mouseconst method PalmRejection(): bool:truewhen a palm resting on the screen is ignored while a pen is used. Returns:truewhen a palm resting on the screen is ignored while a pen is usedconst method TrackpadGestures(): bool:truewhen a trackpad's gestures are recognized. Returns:truewhen a trackpad's gestures are recognizedconst method SwipeNavigation(): bool:truewhen a swipe from the edge goes back. Returns:truewhen a swipe from the edge goes back
extend RXmlError
extend RXmlError
Members
const method Message(): string: What is wrong at its line and column. Returns: what is wrong at its line and column
extend RXmlAttributeInfo
extend RXmlAttributeInfo
Members
const method Name(): string: The attribute's name. Returns: the attribute's nameconst method Kind(): UIXMLAttrKind: The kind of value it takes. Returns: the kind of value it takesconst method Choices(): string: The values a choice attribute takes, as Raven lists them ("" for another kind). Returns: the values a choice attribute takes, as Raven lists them ("" for another kind)const method Group(): string: The group the attribute belongs to ("" for none). Returns: the group the attribute belongs to ("" for none)const method Description(): string: What the attribute does. Returns: what the attribute does
extend RTileSection
extend RTileSection
Members
const method Text(): string: The section's title. Returns: the section's titleconst method Detail(): string: The section's second line ("" for none). Returns: the section's second line ("" for none)
extend RTileItem
extend RTileItem
Members
const method Text(): string: The tile's title. Returns: the tile's titleconst method Detail(): string: The tile's second line ("" for none). Returns: the tile's second line ("" for none)const method Badge(): string: The tile's badge ("" for none). Returns: the tile's badge ("" for none)const method Note(): string: The tile's note ("" for none). Returns: the tile's note ("" for none)const method Tint(): UIColor: The colour the tile's icon is tinted with. Returns: the colour the tile's icon is tinted withconst method TextColor(): UIColor: The colour of the tile's title. Returns: the colour of the tile's titleconst method DetailColor(): UIColor: The colour of the tile's second line. Returns: the colour of the tile's second line
extend RShaderLook
extend RShaderLook
Members
const method Color(): UIColor: The look's first colour. Returns: the look's first colourconst method Color2(): UIColor: The look's second colour. Returns: the look's second colourconst method Animate(): bool:truewhen the shader animates (it is drawn every frame). Returns:truewhen the shader animates (it is drawn every frame)const method Pointer(): bool:truewhen the shader follows the pointer. Returns:truewhen the shader follows the pointer
extend RSpring
extend RSpring
Members
method Kick(const AVelocity: float32): Gives the spring a push ofAVelocity(units a second). C: Rspring_kick Parameters:AVelocitythe velocity.method Set(const AValue: float32): Puts the spring atAValueat once, at rest. C: Rspring_set Parameters:AValuethe value.
extend UIWidget
extend UIWidget
Members
const method Window(): UIWindow: The window the widget is in (an empty handle when it is in none). C: Rwidget_get_window Returns: the window the widget is in (an empty handle when it is in none)const method ContextMenu(const AMenu: UIMenu): self: The menu a right click on the widget opens (an empty handle: none). C: Rwidget_set_context_menu Parameters:AMenuthe menu. Returns: this object, so calls chainconst method Begin<T>(): T: A newT(a widget type with aCreate(): UIVBox, UIGrid, UIBorder ..) placed last inside this widget, to fill in the chain; itsEnd()comes back to this widget. Returns: a newT(a widget type with aCreate(): UIVBox, UIGrid, UIBorder ..) placed last inside this widget, to fill in the chain; itsEnd()comes back to this widget Example:LRoot.Begin<UIHBox>().Add(LOk).Add(LCancel).End().Add(LStatus);const method Begin<T>(const ALayout: UILayout): T: A newTplaced last inside this widget, sitting asALayoutsays. Parameters:ALayoutthe layout. Returns: a newTplaced last inside this widget, sitting asALayoutsaysconst method XMLNode(): UIXMLNode: The node of a document the widget was built from (an empty handle: not built from a document, or it is gone). C: Rwidget_get_xml_node Returns: the node of a document the widget was built from (an empty handle: not built from a document, or it is gone)
extend UITableColumn
extend UITableColumn
Members
const method Table(): UITable: The table the column is in. Returns: the table the column is in
extend UITableRow
extend UITableRow
Members
const method Table(): UITable: The table the row is in. Returns: the table the row is in
extend UITileSection
extend UITileSection
Members
const method View(): UITileView: The tile view the section is in. Returns: the tile view the section is in
extend UIApp
extend UIApp
Members
static method TaskbarMenu(const AMenu: UIMenu): bool:AMenu, a menu with no parent (UIMenu.Create), as the menu of the app's taskbar button (an empty handle removes it). C: Rtaskbar_set_menu Parameters:AMenuthe menu. Returns:truewhen the system has taskbar menus (falsetoo for a menu in a bar or in another menu)
extend UITrack
extend UITrack
Members
const method AddClip(const AStart: float64; const ALength: float64; const ALabel: string): UITimelineItem: A new clip on the track fromAStartforALengthseconds, labelledALabel. C: Rtimeline_add_clip Parameters:AStartthe start;ALengththe length;ALabelthe label. Returns: a new clip on the track fromAStartforALengthseconds, labelledALabelconst method AddKey(const ATime: float64): UITimelineItem: A new key on the track atATimeseconds. C: Rtimeline_add_key Parameters:ATimethe time. Returns: a new key on the track atATimeseconds
extend UIGraphNode
extend UIGraphNode
Members
const method AddInput(const ALabel: string; const AType: string): UIGraphPin: A new input pin labelledALabelof the typeAType("": links to any type). C: Rnode_graph_add_input Parameters:ALabelthe label;ATypethe type. Returns: a new input pin labelledALabelof the typeAType("": links to any type)const method AddOutput(const ALabel: string; const AType: string): UIGraphPin: A new output pin labelledALabelof the typeAType("": links to any type). C: Rnode_graph_add_output Parameters:ALabelthe label;ATypethe type. Returns: a new output pin labelledALabelof the typeAType("": links to any type)const method Input(const AIndex: int32): UIGraphPin: Its inputAIndex(from the top, 0 first). C: Rnode_graph_get_input Parameters:AIndexthe index, from 0. Returns: its inputAIndex(from the top, 0 first)const method Output(const AIndex: int32): UIGraphPin: Its outputAIndex(from the top, 0 first). C: Rnode_graph_get_output Parameters:AIndexthe index, from 0. Returns: its outputAIndex(from the top, 0 first)const method FindPin(const AName: string): UIGraphPin: Its pin named (or labelled)AName(none when it has no such pin). C: Rnode_graph_find_pin Parameters:ANamethe name. Returns: its pin named (or labelled)AName(none when it has no such pin)
extend UIGraphPin
extend UIGraphPin
Members
const method InputLink(): UIGraphLink: The link arriving at this input (none when unlinked). C: Rnode_graph_get_input_link Returns: the link arriving at this input (none when unlinked)
extend UIDockArea
extend UIDockArea
Members
const method FloatWindow(const AFlags: UIWindowFlags; const AFunc: UIDockFloatFunc): self: How the windows of torn-off panels are made: the window flagsAFlags(NoResize, Borderless, CustomHeader and Transparent count) andAFuncmaking each one's content (nil: the floating area is the whole window). C: Rdock_area_set_float_window Parameters:AFlagsthe flags;AFuncthe func it runs. Returns: this object, so calls chain
extend UIDockPanel
extend UIDockPanel
Members
const method Area(): UIDockArea: The area it belongs to (its home). Returns: the area it belongs to (its home)
extend UIWindow
extend UIWindow
Members
const method Island(const AIsland: UIIsland): self: The window's island, in its title area or the screen's camera housing (an emptyUIIsland(): none). C: Rwindow_set_island Parameters:AIslandthe island. Returns: this object, so calls chainconst method Island(): UIIsland: WhatIsland(..)sets, read back. C: Rwindow_get_island Returns: the window's island, in its title area or the screen's camera housing (an emptyUIIsland(): none)
Constants
| Name | Declaration | Description |
|---|---|---|
ADAM_RAVEN_EXC_NOT_FOUND | const ADAM_RAVEN_EXC_NOT_FOUND: int32 = 1 | The code UIWidget.Find<T> / As<T> raise with when there is no widget: no widget has the name searched for, or the handle names none. |
ADAM_RAVEN_EXC_KIND | const ADAM_RAVEN_EXC_KIND: int32 = 13 | The code UIWidget.Find<T> / As<T> raise with when the widget is of a kind T does not view (the runtime's invalid cast's code). |
System.Raven.Raylib
a Raven user interface inside a raylib program: raylib keeps the window, the loop, audio and the game's drawing; Raven builds and lays out its widgets (System.Raven.Ext's objects, XML windows and themes included) and draws them in the raylib frame, over the game. RaylibHost is all of it:
Import it with import System.Raven.Raylib;.
Types
RaylibHost
type RaylibHost = object
Raven inside a raylib program: raylib keeps the window, the loop, audio and the game's drawing; Raven (System.Raven.Ext's objects, XML windows and themes included) lays out its windows and draws them in the raylib frame, over the game, on this unit's rlgl backend. One per program, made after the raylib Window opens. A shared handle: the last copy (or Close) ends Raven, then lets go of the window it keeps, so Raven is always down before raylib's window closes. C: Rinit_ex (its init), Rhost_platform_register, Rhost_window_set_size, Rhost_inject_* (Update), Rdraw_frame, Rshutdown (Close)
Members
init(): An empty handle (Raven not started:IsValid()false), as a variable declared with no arguments starts.init(const AWindow: Window; const AAppName: string): Starts Raven in the raylib windowAWindow(open:Ready()),AAppNamethe application's name; then make its UI window (UIWindow.CreateorUIWindow.FromXML: any size, it follows raylib's window).IsValid()false when the window is not open, Raven runs already, or Raven could not start (its error reported toUIErrors). Parameters:AWindowthe open raylib window Raven runs in;AAppNamethe application's name.const method IsValid(): bool:truewhile Raven runs in the raylib window. Returns:truewhile Raven runs in the raylib windowconst method App(): UIApp: The app Raven runs as (System.Raven.Ext's UIApp: its frame closure, actions, theme ..). Returns: the app (an empty one when Raven is not running)const method Update(const AWindow: UIWindow): bool: Runs one Raven frame forAWindow, before the raylib frame is drawn: the window takes raylib's window size in pixels (or the frame's base size inside the frame window) and its UI scale, then raylib's input this frame (focus, keys with modifiers and repeats, the mouse, the wheel, typed text), then Raven lays out and paints what changed and runs its closures, timers and tasks. Raven's cursor and clipboard are raylib's. Parameters:AWindowthe Raven window the frame is run for. Returns:falseonceUIApp.Quitwas called, the last Raven window is closed, or Raven is not runningconst method Draw(const AWindow: UIWindow): DrawsAWindow's last Raven frame over what the program drew: in raylib's window units, or with the frame window open between itsBeginFrameandEndFrame(base units, scaled and letterboxed with the frame). It draws through whatever raylib has bound, so a render texture or a camera takes it too. Nothing before the window's firstUpdate. Parameters:AWindowthe Raven window drawn.const method Texture(const ATexture: TextureRes): UITextureRes: A Raven texture showing the raylib textureATextureas it is in every frame (no copy) in an Image or a Viewport; it keepsATexturealive while it shows it. Empty when Raven is not running orATextureholds no texture. Parameters:ATexturethe raylib texture shown. Returns: the Raven texture (empty when Raven is not running orATextureholds none)const method Texture(const ATarget: RenderTextureRes): UITextureRes: A Raven texture showing the render textureATarget(what the program draws into it shows at once: a 3D view in a Viewport,FlipY(true): a render texture is bottom-up); it keepsATargetalive while it shows it. Parameters:ATargetthe render texture shown. Returns: the Raven texture (empty when Raven is not running orATargetholds none)const method Retarget(const ARaven: UITextureRes; const ATexture: TextureRes): bool: PointsARaven, a textureTexturemade, at the raylib textureATexture(a texture made again at a new size: the widget showing it keeps its Raven texture). Parameters:ARaventhe Raven textureTexturemade;ATexturethe raylib texture it shows from now on. Returns:falsewhen Raven is not running,ATextureholds no texture, orARavenis not oneTexturemadeconst method Retarget(const ARaven: UITextureRes; const ATarget: RenderTextureRes): bool: PointsARavenat the render textureATarget, asRetargetfor a texture. Parameters:ARaventhe Raven textureTexturemade;ATargetthe render texture it shows from now on. Returns:falsewhen Raven is not running,ATargetholds no texture, orARavenis not oneTexturemademethod Close(): Ends Raven now (every copy of the host then empty), before the last copy goes.
Example: LHost := RaylibHost(LWin, "Game"); LUI := UIWindow.FromXML("res/assets/ui/hud.xml"); while LWin.Running() and LHost.Update(LUI) do LWin.BeginFrame(); DrawGame(); LHost.Draw(LUI); LWin.EndFrame(); end;
Extends
extend Color
extend Color
Members
const method ToRaven(): UIColor: The colour as System.Raven.Ext'sUIColor(0..1 a channel). Returns: theUIColor
extend UIColor
extend UIColor
Members
const method ToRaylib(): Color: The colour as raylib'sColor(a byte a channel, rounded; out of 0..1 clamped). Returns: theColor
System.Raylib.Ext
raylib as Adam objects, over System.Raylib.C (the .C unit stays usable beside it; a program imports both, AD.5b). Every routine of System.Raylib.C has its home here (a member's C: tag names the raylib routines it covers) or in the std unit already doing its job (files, text, hashes, compression: System.IO, System.SysUtils, System.Hash, System.Base64, System.Zlib.Ext); the row raylib\raylib_coverage proves it.
Import it with import System.Raylib.Ext;.
Types
VideoStatus
type VideoStatus = choices(
Where a video stands: VideoStopped (at its start, no frame shown until it plays), VideoPlaying, or VideoPaused (where it was, its frame still drawn). A video starts stopped; one that does not loop is stopped again at its end.
Members
VideoStatus.VideoStopped: Stopped: at its start (or its end, when it does not loop), no frame shown until it plays.VideoStatus.VideoPlaying: Playing.VideoStatus.VideoPaused: Paused where it was, its frame still drawn.
Since: 0.1
See also: GetVideoStatus
Example: if GetVideoStatus(LIntro) = VideoStatus.VideoStopped then PlayVideo(LIntro); end;
VideoStatusCallback
type VideoStatusCallback = func(const AStatus: VideoStatus; const AName: ptr to const char)
Called on every change of a video's status: by PlayVideo, PauseVideo and StopVideo when they change it, and by UpdateVideo at the end of a video that does not loop (VideoStopped). A call that changes nothing (PlayVideo on a playing video) calls nothing, and neither does UnloadVideo.
Since: 0.1
See also: SetVideoStatusCallback
Example: func OnVideo(const AStatus: VideoStatus; const AName: ptr to const char); begin ... end;
Video
type Video = record
An MPEG-1 video (pl_mpeg) with its MP2 audio, used as raylib's Music is: load it with LoadVideo, LoadVideoIO or LoadVideoZip, PlayVideo it, call UpdateVideo once a frame and DrawVideo it, then UnloadVideo it. The record is a handle: copies name the same video. Every routine takes a video that did not load (ctxData nil) and does nothing with it, giving 0, false or VideoStopped.
Members
ctxData: ptr: The player; nil when the video did not load (IsVideoValid)width: int32: The frame width in pixels; 0 when the video did not loadheight: int32: The frame height in pixels; 0 when the video did not load
Since: 0.1
See also: LoadVideo
Example: LIntro := LoadVideoZip("$P:assets.zip", "res/assets/videos/intro.mpg", ""); PlayVideo(LIntro);
Key
type Key = choices(
A keyboard key, raylib's KeyboardKey values (KEY_A is Key.A).
Members
Key.Null: No key, for none pressed. C: KEY_NULLKey.Space: The space key. C: KEY_SPACEKey.Apostrophe: The apostrophe key. C: KEY_APOSTROPHEKey.Comma: The comma key. C: KEY_COMMAKey.Minus: The minus key. C: KEY_MINUSKey.Period: The period key. C: KEY_PERIODKey.Slash: The slash key. C: KEY_SLASHKey.Zero: The 0 key. C: KEY_ZEROKey.One: The 1 key. C: KEY_ONEKey.Two: The 2 key. C: KEY_TWOKey.Three: The 3 key. C: KEY_THREEKey.Four: The 4 key. C: KEY_FOURKey.Five: The 5 key. C: KEY_FIVEKey.Six: The 6 key. C: KEY_SIXKey.Seven: The 7 key. C: KEY_SEVENKey.Eight: The 8 key. C: KEY_EIGHTKey.Nine: The 9 key. C: KEY_NINEKey.Semicolon: The semicolon key. C: KEY_SEMICOLONKey.Equal: The equal key. C: KEY_EQUALKey.A: The A key. C: KEY_AKey.B: The B key. C: KEY_BKey.C: The C key. C: KEY_CKey.D: The D key. C: KEY_DKey.E: The E key. C: KEY_EKey.F: The F key. C: KEY_FKey.G: The G key. C: KEY_GKey.H: The H key. C: KEY_HKey.I: The I key. C: KEY_IKey.J: The J key. C: KEY_JKey.K: The K key. C: KEY_KKey.L: The L key. C: KEY_LKey.M: The M key. C: KEY_MKey.N: The N key. C: KEY_NKey.O: The O key. C: KEY_OKey.P: The P key. C: KEY_PKey.Q: The Q key. C: KEY_QKey.R: The R key. C: KEY_RKey.S: The S key. C: KEY_SKey.T: The T key. C: KEY_TKey.U: The U key. C: KEY_UKey.V: The V key. C: KEY_VKey.W: The W key. C: KEY_WKey.X: The X key. C: KEY_XKey.Y: The Y key. C: KEY_YKey.Z: The Z key. C: KEY_ZKey.LeftBracket: The left bracket key. C: KEY_LEFT_BRACKETKey.Backslash: The backslash key. C: KEY_BACKSLASHKey.RightBracket: The right bracket key. C: KEY_RIGHT_BRACKETKey.Grave: The grave key. C: KEY_GRAVEKey.Escape: The escape key. C: KEY_ESCAPEKey.Enter: The enter key. C: KEY_ENTERKey.Tab: The tab key. C: KEY_TABKey.Backspace: The backspace key. C: KEY_BACKSPACEKey.Insert: The insert key. C: KEY_INSERTKey.Delete: The delete key. C: KEY_DELETEKey.Right: The right key. C: KEY_RIGHTKey.Left: The left key. C: KEY_LEFTKey.Down: The down key. C: KEY_DOWNKey.Up: The up key. C: KEY_UPKey.PageUp: The page up key. C: KEY_PAGE_UPKey.PageDown: The page down key. C: KEY_PAGE_DOWNKey.Home: The home key. C: KEY_HOMEKey.End: The end key. C: KEY_ENDKey.CapsLock: The caps lock key. C: KEY_CAPS_LOCKKey.ScrollLock: The scroll lock key. C: KEY_SCROLL_LOCKKey.NumLock: The num lock key. C: KEY_NUM_LOCKKey.PrintScreen: The print screen key. C: KEY_PRINT_SCREENKey.Pause: The pause key. C: KEY_PAUSEKey.F1: The F1 key. C: KEY_F1Key.F2: The F2 key. C: KEY_F2Key.F3: The F3 key. C: KEY_F3Key.F4: The F4 key. C: KEY_F4Key.F5: The F5 key. C: KEY_F5Key.F6: The F6 key. C: KEY_F6Key.F7: The F7 key. C: KEY_F7Key.F8: The F8 key. C: KEY_F8Key.F9: The F9 key. C: KEY_F9Key.F10: The F10 key. C: KEY_F10Key.F11: The F11 key. C: KEY_F11Key.F12: The F12 key. C: KEY_F12Key.Kp0: The keypad 0 key. C: KEY_KP_0Key.Kp1: The keypad 1 key. C: KEY_KP_1Key.Kp2: The keypad 2 key. C: KEY_KP_2Key.Kp3: The keypad 3 key. C: KEY_KP_3Key.Kp4: The keypad 4 key. C: KEY_KP_4Key.Kp5: The keypad 5 key. C: KEY_KP_5Key.Kp6: The keypad 6 key. C: KEY_KP_6Key.Kp7: The keypad 7 key. C: KEY_KP_7Key.Kp8: The keypad 8 key. C: KEY_KP_8Key.Kp9: The keypad 9 key. C: KEY_KP_9Key.KpDecimal: The keypad decimal key. C: KEY_KP_DECIMALKey.KpDivide: The keypad divide key. C: KEY_KP_DIVIDEKey.KpMultiply: The keypad multiply key. C: KEY_KP_MULTIPLYKey.KpSubtract: The keypad subtract key. C: KEY_KP_SUBTRACTKey.KpAdd: The keypad add key. C: KEY_KP_ADDKey.KpEnter: The keypad enter key. C: KEY_KP_ENTERKey.KpEqual: The keypad equal key. C: KEY_KP_EQUALKey.LeftShift: The left shift key. C: KEY_LEFT_SHIFTKey.LeftControl: The left control key. C: KEY_LEFT_CONTROLKey.LeftAlt: The left alt key. C: KEY_LEFT_ALTKey.LeftSuper: The left super key. C: KEY_LEFT_SUPERKey.RightShift: The right shift key. C: KEY_RIGHT_SHIFTKey.RightControl: The right control key. C: KEY_RIGHT_CONTROLKey.RightAlt: The right alt key. C: KEY_RIGHT_ALTKey.RightSuper: The right super key. C: KEY_RIGHT_SUPERKey.KbMenu: The keyboard menu key. C: KEY_KB_MENUKey.Back: The back key. C: KEY_BACKKey.Menu: The menu key. C: KEY_MENUKey.VolumeUp: The volume up key. C: KEY_VOLUME_UPKey.VolumeDown: The volume down key. C: KEY_VOLUME_DOWN
Example: if IsKeyPressed(int32(Key.Space)) then Jump(); end;
Button
type Button = choices(
A mouse button, raylib's MouseButton values.
Members
Button.Left: The left mouse button. C: MOUSE_BUTTON_LEFTButton.Right: The right mouse button. C: MOUSE_BUTTON_RIGHTButton.Middle: The middle mouse button. C: MOUSE_BUTTON_MIDDLEButton.Side: The side mouse button. C: MOUSE_BUTTON_SIDEButton.Extra: The extra mouse button. C: MOUSE_BUTTON_EXTRAButton.Forward: The forward mouse button. C: MOUSE_BUTTON_FORWARDButton.Back: The back mouse button. C: MOUSE_BUTTON_BACK
Cursor
type Cursor = choices(
A mouse cursor shape, raylib's MouseCursor values.
Members
Cursor.Default: Default pointer shape. C: MOUSE_CURSOR_DEFAULTCursor.Arrow: Arrow shape. C: MOUSE_CURSOR_ARROWCursor.IBeam: Text writing cursor shape. C: MOUSE_CURSOR_IBEAMCursor.Crosshair: Cross shape. C: MOUSE_CURSOR_CROSSHAIRCursor.PointingHand: Pointing hand cursor. C: MOUSE_CURSOR_POINTING_HANDCursor.ResizeEW: Horizontal resize/move arrow shape. C: MOUSE_CURSOR_RESIZE_EWCursor.ResizeNS: Vertical resize/move arrow shape. C: MOUSE_CURSOR_RESIZE_NSCursor.ResizeNWSE: Top-left to bottom-right diagonal resize/move arrow shape. C: MOUSE_CURSOR_RESIZE_NWSECursor.ResizeNESW: The top-right to bottom-left diagonal resize/move arrow shape. C: MOUSE_CURSOR_RESIZE_NESWCursor.ResizeAll: The omnidirectional resize/move cursor shape. C: MOUSE_CURSOR_RESIZE_ALLCursor.NotAllowed: The operation-not-allowed shape. C: MOUSE_CURSOR_NOT_ALLOWED
PadButton
type PadButton = choices(
A gamepad button, raylib's GamepadButton values.
Members
PadButton.Unknown: Unknown button, for error checking. C: GAMEPAD_BUTTON_UNKNOWNPadButton.LeftFaceUp: Gamepad left DPAD up button. C: GAMEPAD_BUTTON_LEFT_FACE_UPPadButton.LeftFaceRight: Gamepad left DPAD right button. C: GAMEPAD_BUTTON_LEFT_FACE_RIGHTPadButton.LeftFaceDown: Gamepad left DPAD down button. C: GAMEPAD_BUTTON_LEFT_FACE_DOWNPadButton.LeftFaceLeft: Gamepad left DPAD left button. C: GAMEPAD_BUTTON_LEFT_FACE_LEFTPadButton.RightFaceUp: Gamepad right button up (i.e. PS3: Triangle, Xbox: Y). C: GAMEPAD_BUTTON_RIGHT_FACE_UPPadButton.RightFaceRight: Gamepad right button right (i.e. PS3: Circle, Xbox: B). C: GAMEPAD_BUTTON_RIGHT_FACE_RIGHTPadButton.RightFaceDown: Gamepad right button down (i.e. PS3: Cross, Xbox: A). C: GAMEPAD_BUTTON_RIGHT_FACE_DOWNPadButton.RightFaceLeft: Gamepad right button left (i.e. PS3: Square, Xbox: X). C: GAMEPAD_BUTTON_RIGHT_FACE_LEFTPadButton.LeftTrigger1: Gamepad top/back trigger left (first), it could be a trailing button. C: GAMEPAD_BUTTON_LEFT_TRIGGER_1PadButton.LeftTrigger2: Gamepad top/back trigger left (second), it could be a trailing button. C: GAMEPAD_BUTTON_LEFT_TRIGGER_2PadButton.RightTrigger1: Gamepad top/back trigger right (first), it could be a trailing button. C: GAMEPAD_BUTTON_RIGHT_TRIGGER_1PadButton.RightTrigger2: Gamepad top/back trigger right (second), it could be a trailing button. C: GAMEPAD_BUTTON_RIGHT_TRIGGER_2PadButton.MiddleLeft: Gamepad center buttons, left one (i.e. PS3: Select). C: GAMEPAD_BUTTON_MIDDLE_LEFTPadButton.Middle: Gamepad center buttons, middle one (i.e. PS3: PS, Xbox: XBOX). C: GAMEPAD_BUTTON_MIDDLEPadButton.MiddleRight: Gamepad center buttons, right one (i.e. PS3: Start). C: GAMEPAD_BUTTON_MIDDLE_RIGHTPadButton.LeftThumb: Gamepad joystick pressed button left. C: GAMEPAD_BUTTON_LEFT_THUMBPadButton.RightThumb: Gamepad joystick pressed button right. C: GAMEPAD_BUTTON_RIGHT_THUMB
PadAxis
type PadAxis = choices(
A gamepad axis, raylib's GamepadAxis values.
Members
PadAxis.LeftX: Gamepad left stick X axis. C: GAMEPAD_AXIS_LEFT_XPadAxis.LeftY: Gamepad left stick Y axis. C: GAMEPAD_AXIS_LEFT_YPadAxis.RightX: Gamepad right stick X axis. C: GAMEPAD_AXIS_RIGHT_XPadAxis.RightY: Gamepad right stick Y axis. C: GAMEPAD_AXIS_RIGHT_YPadAxis.LeftTrigger: Gamepad back trigger left, pressure level: [1..-1]. C: GAMEPAD_AXIS_LEFT_TRIGGERPadAxis.RightTrigger: Gamepad back trigger right, pressure level: [1..-1]. C: GAMEPAD_AXIS_RIGHT_TRIGGER
WindowFlag
type WindowFlag = choices(
A window flag; its value is the bit of raylib's ConfigFlags mask (FLAG_VSYNC_HINT = 64 = bit 6 = WindowFlag.VSyncHint).
Members
WindowFlag.FullscreenMode: Set to run program in fullscreen. C: FLAG_FULLSCREEN_MODEWindowFlag.Resizable: Set to allow resizable window. C: FLAG_WINDOW_RESIZABLEWindowFlag.Undecorated: Set to disable window decoration (frame and buttons). C: FLAG_WINDOW_UNDECORATEDWindowFlag.Transparent: Set to allow transparent framebuffer. C: FLAG_WINDOW_TRANSPARENTWindowFlag.Msaa4xHint: Set to try enabling MSAA 4X. C: FLAG_MSAA_4X_HINTWindowFlag.VSyncHint: Set to try enabling V-Sync on GPU. C: FLAG_VSYNC_HINTWindowFlag.Hidden: Set to hide window. C: FLAG_WINDOW_HIDDENWindowFlag.AlwaysRun: Set to allow windows running while minimized. C: FLAG_WINDOW_ALWAYS_RUNWindowFlag.Minimized: Set to minimize window (iconify). C: FLAG_WINDOW_MINIMIZEDWindowFlag.Maximized: Set to maximize window (expanded to monitor). C: FLAG_WINDOW_MAXIMIZEDWindowFlag.Unfocused: Set to window non focused. C: FLAG_WINDOW_UNFOCUSEDWindowFlag.Topmost: Set to window always on top. C: FLAG_WINDOW_TOPMOSTWindowFlag.HighDPI: Set to support HighDPI. C: FLAG_WINDOW_HIGHDPIWindowFlag.MousePassthrough: Set to support mouse passthrough, only supported when FLAG_WINDOW_UNDECORATED. C: FLAG_WINDOW_MOUSE_PASSTHROUGHWindowFlag.BorderlessWindowed: Set to run program in borderless windowed mode. C: FLAG_BORDERLESS_WINDOWED_MODEWindowFlag.InterlacedHint: Set to try enabling interlaced video format (for V3D). C: FLAG_INTERLACED_HINT
WindowFlags
type WindowFlags = set of WindowFlag
A set of window flags: uint32(LFlags) is raylib's ConfigFlags mask, WindowFlags(N) the set a mask holds.
Example: SetConfigFlags(uint32([WindowFlag.Resizable, WindowFlag.VSyncHint]));
LogLevel
type LogLevel = choices(
A trace log level, raylib's TraceLogLevel values.
Members
LogLevel.All: Display all logs. C: LOG_ALLLogLevel.Trace: Trace logging, intended for internal use only. C: LOG_TRACELogLevel.Debug: Debug logging, used for internal debugging, it should be disabled on release builds. C: LOG_DEBUGLogLevel.Info: Info logging, used for program execution info. C: LOG_INFOLogLevel.Warning: Warning logging, used on recoverable failures. C: LOG_WARNINGLogLevel.Error: Error logging, used on unrecoverable failures. C: LOG_ERRORLogLevel.Fatal: Fatal logging, used to abort program: exit(EXIT_FAILURE). C: LOG_FATALLogLevel.None: Disable logging. C: LOG_NONE
Pixel
type Pixel = choices(
A pixel format, raylib's PixelFormat values.
Members
Pixel.Gray: 8 bit per pixel (no alpha). C: PIXELFORMAT_UNCOMPRESSED_GRAYSCALEPixel.GrayAlpha: 8*2 bpp (2 channels). C: PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHAPixel.R5G6B5: 16 bpp. C: PIXELFORMAT_UNCOMPRESSED_R5G6B5Pixel.R8G8B8: 24 bpp. C: PIXELFORMAT_UNCOMPRESSED_R8G8B8Pixel.R5G5B5A1: 16 bpp (1 bit alpha). C: PIXELFORMAT_UNCOMPRESSED_R5G5B5A1Pixel.R4G4B4A4: 16 bpp (4 bit alpha). C: PIXELFORMAT_UNCOMPRESSED_R4G4B4A4Pixel.R8G8B8A8: 32 bpp. C: PIXELFORMAT_UNCOMPRESSED_R8G8B8A8Pixel.R32: 32 bpp (1 channel - float). C: PIXELFORMAT_UNCOMPRESSED_R32Pixel.R32G32B32: 32*3 bpp (3 channels - float). C: PIXELFORMAT_UNCOMPRESSED_R32G32B32Pixel.R32G32B32A32: 32*4 bpp (4 channels - float). C: PIXELFORMAT_UNCOMPRESSED_R32G32B32A32Pixel.R16: 16 bpp (1 channel - half float). C: PIXELFORMAT_UNCOMPRESSED_R16Pixel.R16G16B16: 16*3 bpp (3 channels - half float). C: PIXELFORMAT_UNCOMPRESSED_R16G16B16Pixel.R16G16B16A16: 16*4 bpp (4 channels - half float). C: PIXELFORMAT_UNCOMPRESSED_R16G16B16A16Pixel.Dxt1RGB: 4 bpp (no alpha). C: PIXELFORMAT_COMPRESSED_DXT1_RGBPixel.Dxt1RGBA: 4 bpp (1 bit alpha). C: PIXELFORMAT_COMPRESSED_DXT1_RGBAPixel.Dxt3RGBA: 8 bpp. C: PIXELFORMAT_COMPRESSED_DXT3_RGBAPixel.Dxt5RGBA: 8 bpp. C: PIXELFORMAT_COMPRESSED_DXT5_RGBAPixel.Etc1RGB: 4 bpp. C: PIXELFORMAT_COMPRESSED_ETC1_RGBPixel.Etc2RGB: 4 bpp. C: PIXELFORMAT_COMPRESSED_ETC2_RGBPixel.Etc2EacRGBA: 8 bpp. C: PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBAPixel.PvrtRGB: 4 bpp. C: PIXELFORMAT_COMPRESSED_PVRT_RGBPixel.PvrtRGBA: 4 bpp. C: PIXELFORMAT_COMPRESSED_PVRT_RGBAPixel.Astc4x4RGBA: Astc4x4RGBA pixels. C: PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBAPixel.Astc8x8RGBA: Astc8x8RGBA pixels. C: PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA
Filter
type Filter = choices(
A texture filter, raylib's TextureFilter values.
Members
Filter.Point: No filter, pixel approximation. C: TEXTURE_FILTER_POINTFilter.Bilinear: Linear filtering. C: TEXTURE_FILTER_BILINEARFilter.Trilinear: Trilinear filtering (linear with mipmaps). C: TEXTURE_FILTER_TRILINEARFilter.Anisotropic4x: Anisotropic filtering 4x. C: TEXTURE_FILTER_ANISOTROPIC_4XFilter.Anisotropic8x: Anisotropic filtering 8x. C: TEXTURE_FILTER_ANISOTROPIC_8XFilter.Anisotropic16x: Anisotropic filtering 16x. C: TEXTURE_FILTER_ANISOTROPIC_16X
WrapMode
type WrapMode = choices(
A texture wrap mode, raylib's TextureWrap values.
Members
WrapMode.Repeat: Repeats texture in tiled mode. C: TEXTURE_WRAP_REPEATWrapMode.Clamp: Clamps texture to edge pixel in tiled mode. C: TEXTURE_WRAP_CLAMPWrapMode.MirrorRepeat: Mirrors and repeats the texture in tiled mode. C: TEXTURE_WRAP_MIRROR_REPEATWrapMode.MirrorClamp: Mirrors and clamps to border the texture in tiled mode. C: TEXTURE_WRAP_MIRROR_CLAMP
CubeLayout
type CubeLayout = choices(
A cubemap layout, raylib's CubemapLayout values.
Members
CubeLayout.AutoDetect: Automatically detect layout type. C: CUBEMAP_LAYOUT_AUTO_DETECTCubeLayout.LineVertical: Layout is defined by a vertical line with faces. C: CUBEMAP_LAYOUT_LINE_VERTICALCubeLayout.LineHorizontal: Layout is defined by a horizontal line with faces. C: CUBEMAP_LAYOUT_LINE_HORIZONTALCubeLayout.CrossThreeByFour: Layout is defined by a 3x4 cross with cubemap faces. C: CUBEMAP_LAYOUT_CROSS_THREE_BY_FOURCubeLayout.CrossFourByThree: Layout is defined by a 4x3 cross with cubemap faces. C: CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE
FontKind
type FontKind = choices(
A font kind, raylib's FontType values.
Members
FontKind.Default: Default font generation, anti-aliased. C: FONT_DEFAULTFontKind.Bitmap: Bitmap font generation, no anti-aliasing. C: FONT_BITMAPFontKind.Sdf: SDF font generation, requires external shader. C: FONT_SDF
Blend
type Blend = choices(
A blend mode, raylib's BlendMode values.
Members
Blend.Alpha: Blend textures considering alpha (default). C: BLEND_ALPHABlend.Additive: Blend textures adding colors. C: BLEND_ADDITIVEBlend.Multiplied: Blend textures multiplying colors. C: BLEND_MULTIPLIEDBlend.AddColors: Blend textures adding colors (alternative). C: BLEND_ADD_COLORSBlend.SubtractColors: Blend textures subtracting colors (alternative). C: BLEND_SUBTRACT_COLORSBlend.AlphaPremultiply: Blend premultiplied textures considering alpha. C: BLEND_ALPHA_PREMULTIPLYBlend.Custom: Blend textures using custom src/dst factors (use rlSetBlendFactors()). C: BLEND_CUSTOMBlend.CustomSeparate: Blend textures using custom rgb/alpha separate src/dst factors (use rlSetBlendFactorsSeparate()). C: BLEND_CUSTOM_SEPARATE
TouchGesture
type TouchGesture = choices(
A touch gesture; its value is the bit of raylib's Gesture mask (GESTURE_TAP = 1 = bit 0).
Members
TouchGesture.Tap: Tap gesture. C: GESTURE_TAPTouchGesture.DoubleTap: Double tap gesture. C: GESTURE_DOUBLETAPTouchGesture.Hold: Hold gesture. C: GESTURE_HOLDTouchGesture.Drag: Drag gesture. C: GESTURE_DRAGTouchGesture.SwipeRight: Swipe right gesture. C: GESTURE_SWIPE_RIGHTTouchGesture.SwipeLeft: Swipe left gesture. C: GESTURE_SWIPE_LEFTTouchGesture.SwipeUp: Swipe up gesture. C: GESTURE_SWIPE_UPTouchGesture.SwipeDown: Swipe down gesture. C: GESTURE_SWIPE_DOWNTouchGesture.PinchIn: Pinch in gesture. C: GESTURE_PINCH_INTouchGesture.PinchOut: Pinch out gesture. C: GESTURE_PINCH_OUT
TouchGestures
type TouchGestures = set of TouchGesture
A set of touch gestures: uint32(LGestures) is raylib's mask, TouchGestures(N) the set a mask holds.
CameraStyle
type CameraStyle = choices(
A camera update style, raylib's CameraMode values.
Members
CameraStyle.Custom: Camera custom, controlled by user (UpdateCamera() does nothing). C: CAMERA_CUSTOMCameraStyle.Free: Camera free mode. C: CAMERA_FREECameraStyle.Orbital: Camera orbital, around target, zoom supported. C: CAMERA_ORBITALCameraStyle.FirstPerson: Camera first person. C: CAMERA_FIRST_PERSONCameraStyle.ThirdPerson: Camera third person. C: CAMERA_THIRD_PERSON
Projection
type Projection = choices(
A camera projection, raylib's CameraProjection values.
Members
Projection.Perspective: Perspective projection. C: CAMERA_PERSPECTIVEProjection.Orthographic: Orthographic projection. C: CAMERA_ORTHOGRAPHIC
NPatch
type NPatch = choices(
An n-patch layout, raylib's NPatchLayout values.
Members
NPatch.NinePatch: Npatch layout: 3x3 tiles. C: NPATCH_NINE_PATCHNPatch.ThreePatchVertical: Npatch layout: 1x3 tiles. C: NPATCH_THREE_PATCH_VERTICALNPatch.ThreePatchHorizontal: Npatch layout: 3x1 tiles. C: NPATCH_THREE_PATCH_HORIZONTAL
MapIndex
type MapIndex = choices(
A material map index, raylib's MaterialMapIndex values.
Members
MapIndex.Albedo: Albedo material (same as: MATERIAL_MAP_DIFFUSE). C: MATERIAL_MAP_ALBEDOMapIndex.Metalness: Metalness material (same as: MATERIAL_MAP_SPECULAR). C: MATERIAL_MAP_METALNESSMapIndex.Normal: Normal material. C: MATERIAL_MAP_NORMALMapIndex.Roughness: Roughness material. C: MATERIAL_MAP_ROUGHNESSMapIndex.Occlusion: Ambient occlusion material. C: MATERIAL_MAP_OCCLUSIONMapIndex.Emission: Emission material. C: MATERIAL_MAP_EMISSIONMapIndex.Height: Heightmap material. C: MATERIAL_MAP_HEIGHTMapIndex.Cubemap: Cubemap material (NOTE: Uses GL_TEXTURE_CUBE_MAP). C: MATERIAL_MAP_CUBEMAPMapIndex.Irradiance: Irradiance material (NOTE: Uses GL_TEXTURE_CUBE_MAP). C: MATERIAL_MAP_IRRADIANCEMapIndex.Prefilter: Prefilter material (NOTE: Uses GL_TEXTURE_CUBE_MAP). C: MATERIAL_MAP_PREFILTERMapIndex.Brdf: Brdf material. C: MATERIAL_MAP_BRDF
ShaderLoc
type ShaderLoc = choices(
A shader location index, raylib's ShaderLocationIndex values.
Members
ShaderLoc.VertexPosition: Shader location: vertex attribute: position. C: SHADER_LOC_VERTEX_POSITIONShaderLoc.VertexTexcoord01: Shader location: vertex attribute: texcoord01. C: SHADER_LOC_VERTEX_TEXCOORD01ShaderLoc.VertexTexcoord02: Shader location: vertex attribute: texcoord02. C: SHADER_LOC_VERTEX_TEXCOORD02ShaderLoc.VertexNormal: Shader location: vertex attribute: normal. C: SHADER_LOC_VERTEX_NORMALShaderLoc.VertexTangent: Shader location: vertex attribute: tangent. C: SHADER_LOC_VERTEX_TANGENTShaderLoc.VertexColor: Shader location: vertex attribute: color. C: SHADER_LOC_VERTEX_COLORShaderLoc.MatrixMvp: Shader location: matrix uniform: model-view-projection. C: SHADER_LOC_MATRIX_MVPShaderLoc.MatrixView: Shader location: matrix uniform: view (camera transform). C: SHADER_LOC_MATRIX_VIEWShaderLoc.MatrixProjection: Shader location: matrix uniform: projection. C: SHADER_LOC_MATRIX_PROJECTIONShaderLoc.MatrixModel: Shader location: matrix uniform: model (transform). C: SHADER_LOC_MATRIX_MODELShaderLoc.MatrixNormal: Shader location: matrix uniform: normal. C: SHADER_LOC_MATRIX_NORMALShaderLoc.VectorView: Shader location: vector uniform: view. C: SHADER_LOC_VECTOR_VIEWShaderLoc.ColorDiffuse: Shader location: vector uniform: diffuse color. C: SHADER_LOC_COLOR_DIFFUSEShaderLoc.ColorSpecular: Shader location: vector uniform: specular color. C: SHADER_LOC_COLOR_SPECULARShaderLoc.ColorAmbient: Shader location: vector uniform: ambient color. C: SHADER_LOC_COLOR_AMBIENTShaderLoc.MapAlbedo: Shader location: sampler2d texture: albedo (same as: SHADER_LOC_MAP_DIFFUSE). C: SHADER_LOC_MAP_ALBEDOShaderLoc.MapMetalness: Shader location: sampler2d texture: metalness (same as: SHADER_LOC_MAP_SPECULAR). C: SHADER_LOC_MAP_METALNESSShaderLoc.MapNormal: Shader location: sampler2d texture: normal. C: SHADER_LOC_MAP_NORMALShaderLoc.MapRoughness: Shader location: sampler2d texture: roughness. C: SHADER_LOC_MAP_ROUGHNESSShaderLoc.MapOcclusion: Shader location: sampler2d texture: occlusion. C: SHADER_LOC_MAP_OCCLUSIONShaderLoc.MapEmission: Shader location: sampler2d texture: emission. C: SHADER_LOC_MAP_EMISSIONShaderLoc.MapHeight: Shader location: sampler2d texture: heightmap. C: SHADER_LOC_MAP_HEIGHTShaderLoc.MapCubemap: Shader location: samplerCube texture: cubemap. C: SHADER_LOC_MAP_CUBEMAPShaderLoc.MapIrradiance: Shader location: samplerCube texture: irradiance. C: SHADER_LOC_MAP_IRRADIANCEShaderLoc.MapPrefilter: Shader location: samplerCube texture: prefilter. C: SHADER_LOC_MAP_PREFILTERShaderLoc.MapBrdf: Shader location: sampler2d texture: brdf. C: SHADER_LOC_MAP_BRDFShaderLoc.VertexBoneIds: Shader location: vertex attribute: bone indices. C: SHADER_LOC_VERTEX_BONEIDSShaderLoc.VertexBoneWeights: Shader location: vertex attribute: bone weights. C: SHADER_LOC_VERTEX_BONEWEIGHTSShaderLoc.BoneMatrices: Shader location: matrix attribute: bone transforms (animation). C: SHADER_LOC_MATRIX_BONETRANSFORMSShaderLoc.VertexInstanceTx: Shader location: vertex attribute: instance transforms. C: SHADER_LOC_VERTEX_INSTANCETRANSFORM
UniformType
type UniformType = choices(
A shader uniform data type, raylib's ShaderUniformDataType values.
Members
UniformType.Float: Shader uniform type: float. C: SHADER_UNIFORM_FLOATUniformType.Vec2: Shader uniform type: vec2 (2 float). C: SHADER_UNIFORM_VEC2UniformType.Vec3: Shader uniform type: vec3 (3 float). C: SHADER_UNIFORM_VEC3UniformType.Vec4: Shader uniform type: vec4 (4 float). C: SHADER_UNIFORM_VEC4UniformType.Int: Shader uniform type: int. C: SHADER_UNIFORM_INTUniformType.IVec2: Shader uniform type: ivec2 (2 int). C: SHADER_UNIFORM_IVEC2UniformType.IVec3: Shader uniform type: ivec3 (3 int). C: SHADER_UNIFORM_IVEC3UniformType.IVec4: Shader uniform type: ivec4 (4 int). C: SHADER_UNIFORM_IVEC4UniformType.UInt: Shader uniform type: unsigned int. C: SHADER_UNIFORM_UINTUniformType.UIVec2: Shader uniform type: uivec2 (2 unsigned int). C: SHADER_UNIFORM_UIVEC2UniformType.UIVec3: Shader uniform type: uivec3 (3 unsigned int). C: SHADER_UNIFORM_UIVEC3UniformType.UIVec4: Shader uniform type: uivec4 (4 unsigned int). C: SHADER_UNIFORM_UIVEC4UniformType.Sampler2D: Shader uniform type: sampler2d. C: SHADER_UNIFORM_SAMPLER2D
AttribType
type AttribType = choices(
A shader attribute data type, raylib's ShaderAttributeDataType values.
Members
AttribType.Float: Shader attribute type: float. C: SHADER_ATTRIB_FLOATAttribType.Vec2: Shader attribute type: vec2 (2 float). C: SHADER_ATTRIB_VEC2AttribType.Vec3: Shader attribute type: vec3 (3 float). C: SHADER_ATTRIB_VEC3AttribType.Vec4: Shader attribute type: vec4 (4 float). C: SHADER_ATTRIB_VEC4
AutomationKind
type AutomationKind = choices(
What an automation event records, raylib's AutomationEventType values (rcore's own: raylib.h keeps them out, so an AutomationEvent's type_ is one of these).
Members
AutomationKind.None: A none event.AutomationKind.KeyUp: A key up event.AutomationKind.KeyDown: A key down event.AutomationKind.KeyPressed: A key pressed event.AutomationKind.KeyReleased: A key released event.AutomationKind.MouseButtonUp: A mouse button up event.AutomationKind.MouseButtonDown: A mouse button down event.AutomationKind.MousePosition: A mouse position event.AutomationKind.MouseWheelMotion: A mouse wheel motion event.AutomationKind.GamepadConnect: A gamepad connect event.AutomationKind.GamepadDisconnect: A gamepad disconnect event.AutomationKind.GamepadButtonUp: A gamepad button up event.AutomationKind.GamepadButtonDown: A gamepad button down event.AutomationKind.GamepadAxisMotion: A gamepad axis motion event.AutomationKind.TouchUp: A touch up event.AutomationKind.TouchDown: A touch down event.AutomationKind.TouchPosition: A touch position event.AutomationKind.Gesture: A gesture event.AutomationKind.WindowClose: A window close event.AutomationKind.WindowMaximize: A window maximize event.AutomationKind.WindowMinimize: A window minimize event.AutomationKind.WindowResize: A window resize event.AutomationKind.TakeScreenshot: A take screenshot event.AutomationKind.SetTargetFPS: A set target FPS event.
Assets
type Assets = object
The source every resource path loads from: raylib's loads (images, textures, fonts, models, sounds, ...) read entries of it by their own names. The examples mount the shared assets. C: SetLoadFileDataCallback / SetSaveFileDataCallback / SetLoadFileTextCallback / SetSaveFileTextCallback (Mount sets all four)
Members
static method Mount(const AArchive: string; const APassword: string): bool: Mounts the zip archive atAArchive(its passwordAPassword, "" for none), closed again at Unmount or the program's end. A source mounted before goes first. Parameters:AArchivethe archive;APasswordthe password. Returns: false when the archive cannot be opened or used (nothing mounted then)static method Mount(const ASource: IOSource): bool: MountsASource(the program keeps it: Unmount never closes it). A source mounted before goes first. Parameters:ASourcethe source. Returns: false when it cannot be used (nil, no room): nothing mounted thenstatic method Unmount(): Paths load from the disk again; an archive Mount opened is closed.static method Mounted(): bool: True while a source is mounted. Returns:truewhile a source is mounted
Example: if not Assets.Mount("$P:../../../../assets.zip", "Adam") then return 1; end;
GlyphsRes
type GlyphsRes = object
A font's glyphs as raylib loads them from a font file's bytes (each with its own image), for ImageRes.FontAtlas: a shared handle, unloaded with the last copy. C: LoadFontData / UnloadFontData
Members
init(): An empty handle (holds nothing:IsValid()false, its changes do nothing), as a variable declared with no arguments starts.init(const AData: array of uint8; const ASize: int32; const ACodepoints: array of int32; const AKind: FontKind): The glyphs of the font fileADataatASizepixels: those ofACodepoints, or raylib's default 95 for none. C: LoadFontData Parameters:ADatathe bytes;ASizethe size;ACodepointsthe codepoints;AKindthe kind.const method IsValid(): bool: True when the glyphs loaded. Returns:truewhen the glyphs loadedconst method Count(): int32: How many glyphs there are (0 when none loaded). Returns: how many glyphs there are (0 when none loaded)const method Glyph(const AIndex: int32): GlyphInfo: GlyphAIndex(0 to Count() - 1; an empty one outside): its image is borrowed, alive while this handle is. Parameters:AIndexthe index, from 0. Returns: glyphAIndex(0 to Count() - 1; an empty one outside): its image is borrowed, alive while this handle isconst method Handle(): ptr to GlyphInfo: The C array (borrowed, for .C calls; nil when none loaded). Returns: the C array (borrowed, for .C calls; nil when none loaded)
Example: LGlyphs := GlyphsRes(LTTF, 32, [], FontKind.Default); LAtlas := ImageRes.FontAtlas(LGlyphs, LRecs, 32, 2, 0);
ImageRes
type ImageRes = object
An image in CPU memory: loaded, generated, changed in place and drawn on (each change returns the image, so they chain), then turned into a texture. A shared handle: a copy shares the pixels, Copy() makes new ones, the last copy unloads them. C: UnloadImage (the last copy's release)
Members
init(): An empty handle (holds nothing:IsValid()false, its changes do nothing), as a variable declared with no arguments starts.init(const APath: string): Loads the image file atAPath(from the mounted source). C: LoadImage Parameters:APaththe file's path.static method Adopt(const AImage: Image): ImageRes: Takes the .C imageAImageover: unloaded with the last copy. Parameters:AImagethe image. Returns: the newImageResstatic method FromIO(const AIO: IO; const AType: string): ImageRes: Loads an image of typeAType(".png" ...) fromAIO. Parameters:AIOthe IO;ATypethe type. Returns: the newImageResstatic method FromMemory(const AType: string; const AData: array of uint8): ImageRes: Loads an image of typeAType(".png" ...) from the file bytesAData. C: LoadImageFromMemory Parameters:ATypethe type;ADatathe bytes. Returns: the newImageResstatic method Raw(const APath: string; const AWidth: int32; const AHeight: int32; const AFormat: Pixel; const AHeaderSize: int32): ImageRes: Loads raw pixels ofAFormat(AWidthxAHeight, afterAHeaderSizebytes) fromAPath. C: LoadImageRaw Parameters:APaththe file's path;AWidththe width;AHeightthe height;AFormatthe pixel format;AHeaderSizethe header size. Returns: the newImageResstatic method Anim(const APath: string; var AFrames: int32): ImageRes: Loads every frame of the animated image atAPath(a GIF), stacked top to bottom. C: LoadImageAnim Parameters:AFramesset to the number of frames;APaththe file's path. Returns: the newImageResstatic method Anim(const AType: string; const AData: array of uint8; var AFrames: int32): ImageRes: Loads every frame of an animated image of typeATypefrom the file bytesAData. C: LoadImageAnimFromMemory Parameters:ATypethe type;ADatathe bytes;AFramesthe frames. Returns: the newImageResstatic method Color(const AWidth: int32; const AHeight: int32; const AColor: Color): ImageRes: AAWidthxAHeightimage filled withAColor. C: GenImageColor Parameters:AWidththe width;AHeightthe height;AColorthe colour. Returns: aAWidthxAHeightimage filled withAColorstatic method GradientLinear(const AWidth: int32; const AHeight: int32; const ADirection: int32; const AStart: Color; const AEnd: Color): ImageRes: A linear gradient fromAStarttoAEnd. C: GenImageGradientLinear Parameters:ADirectiondegrees: 0 left to right, 90 top to bottom;AWidththe width;AHeightthe height;AStartthe start;AEndthe end. Returns: a linear gradient fromAStarttoAEndstatic method GradientRadial(const AWidth: int32; const AHeight: int32; const ADensity: float32; const AInner: Color; const AOuter: Color): ImageRes: A radial gradient,AInnerat the center. C: GenImageGradientRadial Parameters:ADensity0 to 1: where the outer color starts;AWidththe width;AHeightthe height;AInnerthe colour at the centre;AOuterthe colour at the edge. Returns: a radial gradient,AInnerat the centerstatic method GradientSquare(const AWidth: int32; const AHeight: int32; const ADensity: float32; const AInner: Color; const AOuter: Color): ImageRes: A square gradient,AInnerat the center. C: GenImageGradientSquare Parameters:AWidththe width;AHeightthe height;ADensitythe density;AInnerthe colour at the centre;AOuterthe colour at the edge. Returns: a square gradient,AInnerat the centerstatic method Checked(const AWidth: int32; const AHeight: int32; const AChecksX: int32; const AChecksY: int32; const AColor1: Color; const AColor2: Color): ImageRes: A checkerboard ofAChecksXxAChecksYsquares in two colors. C: GenImageChecked Parameters:AWidththe width;AHeightthe height;AChecksXthe checks X;AChecksYthe checks Y;AColor1the color1;AColor2the color2. Returns: a checkerboard ofAChecksXxAChecksYsquares in two colorsstatic method WhiteNoise(const AWidth: int32; const AHeight: int32; const AFactor: float32): ImageRes: White noise (AFactor: the share of white pixels, 0 to 1). C: GenImageWhiteNoise Parameters:AWidththe width;AHeightthe height;AFactorthe factor. Returns: the newImageResstatic method PerlinNoise(const AWidth: int32; const AHeight: int32; const AOffsetX: int32; const AOffsetY: int32; const AScale: float32): ImageRes: Perlin noise from the offset (AOffsetX,AOffsetY) atAScale. C: GenImagePerlinNoise Parameters:AWidththe width;AHeightthe height;AOffsetXthe offset X;AOffsetYthe offset Y;AScalethe scale. Returns: the newImageResstatic method Cellular(const AWidth: int32; const AHeight: int32; const ATileSize: int32): ImageRes: Cellular (Worley) noise, one cell perATileSizepixels. C: GenImageCellular Parameters:AWidththe width;AHeightthe height;ATileSizethe tile size. Returns: the newImageResstatic method FontAtlas(const AGlyphs: GlyphsRes; var ARecs: array of Rectangle; const ASize: int32; const APadding: int32; const APacking: int32): ImageRes: A font atlas ofAGlyphsatASizepixels,APaddingaround each glyph. C: GenImageFontAtlas Parameters:ARecsset to each glyph's rectangle in the atlas;APacking0: raylib's default packing, 1: skyline;AGlyphsthe glyphs;ASizethe size;APaddingthe padding. Returns: a font atlas ofAGlyphsatASizepixels,APaddingaround each glyphconst method Copy(): ImageRes: A new image with these pixels (not a share). C: ImageCopy Returns: a new image with these pixels (not a share)const method Part(const ARect: Rectangle): ImageRes: A new image of the partARectof this one. C: ImageFromImage Parameters:ARectthe rectangle. Returns: a new image of the partARectof this oneconst method Channel(const AIndex: int32): ImageRes: A new grayscale image of channelAIndex(0 red .. 3 alpha). C: ImageFromChannel Parameters:AIndexthe index, from 0. Returns: a new grayscale image of channelAIndex(0 red .const method Handle(): Image: The .C image (borrowed, for .C calls; raylib's empty image when none is held). Returns: the .C image (borrowed, for .C calls; raylib's empty image when none is held)const method IsValid(): bool: True when the image holds pixels. C: IsImageValid Returns:truewhen the image holds pixelsconst method Width(): int32: The width in pixels. Returns: the width in pixelsconst method Height(): int32: The height in pixels. Returns: the height in pixelsconst method Mipmaps(): int32: The mipmap levels (1: the image alone). Returns: the mipmap levels (1: the image alone)const method Format(): Pixel: The pixel format. Returns: the pixel formatmethod ToFormat(const AFormat: Pixel): self: Converts the pixels toAFormat. C: ImageFormat Parameters:AFormatthe pixel format. Returns: this object, so calls chainmethod ToPot(const AFill: Color): self: Grows the image to power-of-two sides, the new pixelsAFill. C: ImageToPOT Parameters:AFillthe colour of the new pixels. Returns: this object, so calls chainmethod Crop(const ARect: Rectangle): self: Cuts the image toARect. C: ImageCrop Parameters:ARectthe rectangle. Returns: this object, so calls chainmethod AlphaCrop(const AThreshold: float32): self: Cuts the image to its pixels aboveAThresholdalpha (0 to 1). C: ImageAlphaCrop Parameters:AThresholdthe threshold. Returns: this object, so calls chainmethod AlphaClear(const AColor: Color; const AThreshold: float32): self: The pixels at or belowAThresholdalpha becomeAColor. C: ImageAlphaClear Parameters:AColorthe colour;AThresholdthe threshold. Returns: this object, so calls chainmethod AlphaMask(const AMask: ImageRes): self: The alpha channel becomesAMask's gray. C: ImageAlphaMask Parameters:AMaskthe mask. Returns: this object, so calls chainmethod AlphaPremultiply(): self: Multiplies the colors by their alpha. C: ImageAlphaPremultiply Returns: this object, so calls chainmethod BlurGaussian(const ASize: int32): self: A box blur approximating a Gaussian ofASizepixels. C: ImageBlurGaussian Parameters:ASizethe size. Returns: this object, so calls chainmethod Convolve(const AKernel: array of float32): self: Convolves the image with the square kernelAKernel(3 x 3: nine values, ...; an empty one does nothing). C: ImageKernelConvolution Parameters:AKernelthe kernel. Returns: this object, so calls chainmethod Resize(const AWidth: int32; const AHeight: int32): self: Scales the image toAWidthxAHeight(bicubic). C: ImageResize Parameters:AWidththe width;AHeightthe height. Returns: this object, so calls chainmethod ResizeNN(const AWidth: int32; const AHeight: int32): self: Scales the image toAWidthxAHeight(nearest neighbor: pixel art). C: ImageResizeNN Parameters:AWidththe width;AHeightthe height. Returns: this object, so calls chainmethod ResizeCanvas(const AWidth: int32; const AHeight: int32; const AOffsetX: int32; const AOffsetY: int32; const AFill: Color): self: Sets the canvas toAWidthxAHeight, the image at (AOffsetX,AOffsetY), the new pixelsAFill. C: ImageResizeCanvas Parameters:AWidththe width;AHeightthe height;AOffsetXthe offset X;AOffsetYthe offset Y;AFillthe colour of the new pixels. Returns: this object, so calls chainmethod GenMipmaps(): self: Adds every mipmap level. C: ImageMipmaps Returns: this object, so calls chainmethod Dither(const ARed: int32; const AGreen: int32; const ABlue: int32; const AAlpha: int32): self: Dithers to 16 bits per pixel or less (Floyd-Steinberg), the bits per channel given. C: ImageDither Parameters:ARedthe red;AGreenthe green;ABluethe blue;AAlphathe alpha. Returns: this object, so calls chainmethod FlipVertical(): self: Flips the image upside down. C: ImageFlipVertical Returns: this object, so calls chainmethod FlipHorizontal(): self: Mirrors the image left to right. C: ImageFlipHorizontal Returns: this object, so calls chainmethod Rotate(const ADegrees: int32): self: Rotates byADegrees(any angle, the canvas grown to hold it). C: ImageRotate Parameters:ADegreesthe degrees. Returns: this object, so calls chainmethod RotateCW(): self: Rotates 90 degrees clockwise. C: ImageRotateCW Returns: this object, so calls chainmethod RotateCCW(): self: Rotates 90 degrees counter-clockwise. C: ImageRotateCCW Returns: this object, so calls chainmethod Tint(const AColor: Color): self: Multiplies every pixel byAColor. C: ImageColorTint Parameters:AColorthe colour. Returns: this object, so calls chainmethod Invert(): self: Inverts every pixel's colour. C: ImageColorInvert Returns: this object, so calls chainmethod Grayscale(): self: Turns the image to grayscale. C: ImageColorGrayscale Returns: this object, so calls chainmethod Contrast(const AContrast: int32): self: Changes the contrast byAContrast(-100 to 100). C: ImageColorContrast Parameters:AContrastthe contrast. Returns: this object, so calls chainmethod Brightness(const ABrightness: int32): self: Changes the brightness byABrightness(-255 to 255). C: ImageColorBrightness Parameters:ABrightnessthe brightness. Returns: this object, so calls chainmethod Replace(const AFrom: Color; const ATo: Color): self: Every pixel ofAFrombecomesATo. C: ImageColorReplace Parameters:AFromthe colour replaced;ATothe colour put in its place. Returns: this object, so calls chainconst method Colors(): array of Color: Every pixel's color, row by row (none for an empty image). C: LoadImageColors / UnloadImageColors Returns: every pixel's color, row by row (none for an empty image)const method Palette(const AMaxSize: int32): array of Color: The distinct colors of the image,AMaxSizeat most. C: LoadImagePalette / UnloadImagePalette Parameters:AMaxSizethe max size. Returns: the distinct colors of the image,AMaxSizeat mostconst method AlphaBorder(const AThreshold: float32): Rectangle: The smallest rectangle holding every pixel aboveAThresholdalpha (0 to 1). C: GetImageAlphaBorder Parameters:AThresholdthe threshold. Returns: the smallest rectangle holding every pixel aboveAThresholdalpha (0 to 1)const method Pixel(const AX: int32; const AY: int32): Color: The color of the pixel (AX,AY). C: GetImageColor Parameters:AXthe x coordinate;AYthe y coordinate. Returns: the color of the pixel (AX,AY)method Clear(const AColor: Color): self: Fills the image withAColor. C: ImageClearBackground Parameters:AColorthe colour. Returns: this object, so calls chainmethod Pixel(const APos: Vector2; const AColor: Color): self: One pixel. C: ImageDrawPixel / ImageDrawPixelV Parameters:APosthe position;AColorthe colour. Returns: this object, so calls chainmethod Line(const AStart: Vector2; const AEnd: Vector2; const AColor: Color): self: A one-pixel line. C: ImageDrawLine / ImageDrawLineV Parameters:AStartthe start;AEndthe end;AColorthe colour. Returns: this object, so calls chainmethod Line(const AStart: Vector2; const AEnd: Vector2; const AThick: int32; const AColor: Color): self: A lineAThickpixels wide. C: ImageDrawLineEx Parameters:AStartthe start;AEndthe end;AThickthe line thickness;AColorthe colour. Returns: this object, so calls chainmethod LineStrip(const APoints: array of Vector2; const AColor: Color): self: Lines joiningAPointsin turn. C: ImageDrawLineStrip Parameters:APointsthe points;AColorthe colour. Returns: this object, so calls chainmethod Triangle(const AA: Vector2; const AB: Vector2; const AC: Vector2; const AColor: Color): self: A filled triangle (corners counter-clockwise). C: ImageDrawTriangle Parameters:AAthe first corner;ABthe second corner;ACthe third corner;AColorthe colour. Returns: this object, so calls chainmethod TriangleGradient(const AA: Vector2; const AB: Vector2; const AC: Vector2; const AColorA: Color; const AColorB: Color; const AColorC: Color): self: A triangle shaded between its corners' colors. C: ImageDrawTriangleGradient Parameters:AAthe first corner;ABthe second corner;ACthe third corner;AColorAthe color A;AColorBthe color B;AColorCthe color C. Returns: this object, so calls chainmethod TriangleLines(const AA: Vector2; const AB: Vector2; const AC: Vector2; const AColor: Color): self: A triangle's edges. C: ImageDrawTriangleLines Parameters:AAthe first corner;ABthe second corner;ACthe third corner;AColorthe colour. Returns: this object, so calls chainmethod TriangleFan(const APoints: array of Vector2; const AColor: Color): self: A triangle fan (the first point its center). C: ImageDrawTriangleFan Parameters:APointsthe points;AColorthe colour. Returns: this object, so calls chainmethod TriangleStrip(const APoints: array of Vector2; const AColor: Color): self: A triangle strip. C: ImageDrawTriangleStrip Parameters:APointsthe points;AColorthe colour. Returns: this object, so calls chainmethod Rect(const ARect: Rectangle; const AColor: Color): self: A filled rectangle. C: ImageDrawRectangle / ImageDrawRectangleV / ImageDrawRectangleRec Parameters:ARectthe rectangle;AColorthe colour. Returns: this object, so calls chainmethod Rect(const ARect: Rectangle; const AOrigin: Vector2; const ARotation: float32; const AColor: Color): self: A filled rectangle turnedARotationdegrees aboutAOrigin(from its corner). C: ImageDrawRectanglePro Parameters:ARectthe rectangle;AOriginthe origin;ARotationthe rotation;AColorthe colour. Returns: this object, so calls chainmethod RectLines(const ARect: Rectangle; const AColor: Color): self: A rectangle's one-pixel edges. C: ImageDrawRectangleLines Parameters:ARectthe rectangle;AColorthe colour. Returns: this object, so calls chainmethod RectLines(const ARect: Rectangle; const AThick: int32; const AColor: Color): self: A rectangle's edgesAThickpixels wide. C: ImageDrawRectangleLinesEx Parameters:ARectthe rectangle;AThickthe line thickness;AColorthe colour. Returns: this object, so calls chainmethod RectGradient(const ARect: Rectangle; const ATopLeft: Color; const ABottomLeft: Color; const ABottomRight: Color; const ATopRight: Color): self: A rectangle shaded between its corners' colors. C: ImageDrawRectangleGradientEx Parameters:ATopLeftthe top-left corner's color, then bottom-left, bottom-right, top-right;ARectthe rectangle;ABottomLeftthe bottom-left corner's colour;ABottomRightthe bottom-right corner's colour;ATopRightthe top-right corner's colour. Returns: this object, so calls chainmethod Circle(const ACenter: Vector2; const ARadius: int32; const AColor: Color): self: A filled circle. C: ImageDrawCircle / ImageDrawCircleV Parameters:ACenterthe centre;ARadiusthe radius;AColorthe colour. Returns: this object, so calls chainmethod CircleLines(const ACenter: Vector2; const ARadius: int32; const AColor: Color): self: A circle's outline. C: ImageDrawCircleLines / ImageDrawCircleLinesV Parameters:ACenterthe centre;ARadiusthe radius;AColorthe colour. Returns: this object, so calls chainmethod CircleGradient(const ACenter: Vector2; const ARadius: float32; const AInner: Color; const AOuter: Color): self: A circle shaded fromAInnerat its center toAOuter. C: ImageDrawCircleGradient Parameters:ACenterthe centre;ARadiusthe radius;AInnerthe colour at the centre;AOuterthe colour at the edge. Returns: this object, so calls chainmethod Image(const ASource: ImageRes; const APos: Vector2; const ATint: Color): self:ASourcedrawn atAPos, multiplied byATint. C: ImageDrawImage Parameters:ASourcethe source;APosthe position;ATintthe tint colour. Returns: this object, so calls chainmethod Image(const ASource: ImageRes; const APos: Vector2; const ARotation: float32; const AScale: float32; const ATint: Color): self:ASourceturnedARotationdegrees and scaled byAScaleatAPos. C: ImageDrawImageEx Parameters:ASourcethe source;APosthe position;ARotationthe rotation;AScalethe scale;ATintthe tint colour. Returns: this object, so calls chainmethod Image(const ASource: ImageRes; const ASourceRect: Rectangle; const APos: Vector2; const ATint: Color): self: The partASourceRectofASourceatAPos. C: ImageDrawImageRec Parameters:ASourcethe source;ASourceRectthe source rect;APosthe position;ATintthe tint colour. Returns: this object, so calls chainmethod Image(const ASource: ImageRes; const ASourceRect: Rectangle; const ADestRect: Rectangle; const ATint: Color): self: The partASourceRectofASourcescaled intoADestRect. C: ImageDrawImagePro Parameters:ASourcethe source;ASourceRectthe source rect;ADestRectthe dest rect;ATintthe tint colour. Returns: this object, so calls chainmethod Image(const ASource: ImageRes; const ASourceRect: Rectangle; const ADestRect: Rectangle; const AOrigin: Vector2; const ARotation: float32; const ATint: Color): self: The partASourceRectofASourcescaled intoADestRect, turnedARotationdegrees aboutAOrigin(from the destination's corner). C: ImageDrawImagePro Parameters:ASourcethe source;ASourceRectthe source rect;ADestRectthe dest rect;AOriginthe origin;ARotationthe rotation;ATintthe tint colour. Returns: this object, so calls chainconst method Export(const APath: string): bool: Saves the image atAPath(its extension the format: .png, .bmp, .qoi ...). C: ExportImage Parameters:APaththe file's path. Returns:truewhen the file was writtenconst method ExportToMemory(const AType: string): array of uint8: The image as the bytes of a file of typeAType(".png" ...; none when it cannot be written). C: ExportImageToMemory Parameters:ATypethe type. Returns: the image as the bytes of a file of typeAType(".png" ...; none when it cannot be written)const method ExportAsCode(const APath: string): bool: Saves the pixels as a C header atAPath. C: ExportImageAsCode Parameters:APaththe file's path. Returns:truewhen the file was written
Example: LImg: ImageRes("images/adam.png"); LImg.Resize(64, 64).FlipVertical(); LTex := LImg.ToTexture();
TextureRes
type TextureRes = object
A texture on the GPU (the window must be open): loaded, made from an image, drawn by Draw.Texture. A shared handle: the last copy unloads it, the window's close too. C: UnloadTexture (the last copy's release)
Members
init(): An empty handle (holds nothing:IsValid()false, its changes do nothing), as a variable declared with no arguments starts.init(const APath: string): Loads the image file atAPath(from the mounted source) as a texture. C: LoadTexture Parameters:APaththe file's path.static method Adopt(const ATexture: Texture2D): TextureRes: Takes the .C textureATextureover: unloaded with the last copy (or the window). Parameters:ATexturethe texture. Returns: the newTextureResstatic method View(const ATexture: Texture2D): TextureRes: A view ofATexture, which another owns: never unloaded through it, valid while its owner keeps it (a render texture's, a font's atlas, a .C texture of the program's). Parameters:ATexturethe texture. Returns: a view ofATexture, which another owns: never unloaded through it, valid while its owner keeps it (a render texture's, a font's atlas, a .C texture of the program's)static method FromIO(const AIO: IO; const AType: string): TextureRes: Loads an image of typeAType(".png" ...) fromAIOas a texture. Parameters:AIOthe IO;ATypethe type. Returns: the newTextureResstatic method FromImage(const AImage: ImageRes): TextureRes:AImage's pixels as a texture. C: LoadTextureFromImage Parameters:AImagethe image. Returns:AImage's pixels as a texturestatic method Cubemap(const AImage: ImageRes; const ALayout: CubeLayout): TextureRes: A cubemap fromAImage's six faces laid out asALayout. C: LoadTextureCubemap Parameters:AImagethe image;ALayoutthe layout. Returns: a cubemap fromAImage's six faces laid out asALayoutconst method Handle(): Texture2D: The .C texture (borrowed, for .C calls; raylib's empty texture when none is held). Returns: the .C texture (borrowed, for .C calls; raylib's empty texture when none is held)const method IsValid(): bool: True when the texture is on the GPU. C: IsTextureValid Returns:truewhen the texture is on the GPUconst method Width(): int32: The width in pixels. Returns: the width in pixelsconst method Height(): int32: The height in pixels. Returns: the height in pixelsconst method Size(): Vector2: The size in pixels. Returns: the size in pixelsconst method Mipmaps(): int32: The mipmap levels (1: the texture alone). Returns: the mipmap levels (1: the texture alone)const method Format(): Pixel: The pixel format. Returns: the pixel formatmethod Update(const APixels: ptr to const): Replaces every pixel withAPixels(the texture's size and format). C: UpdateTexture Parameters:APixelsthe pixels.method Update(const ARect: Rectangle; const APixels: ptr to const): Replaces the pixels ofARectwithAPixels. C: UpdateTextureRec Parameters:ARectthe rectangle;APixelsthe pixels.method GenMipmaps(): self: Adds every mipmap level. C: GenTextureMipmaps Returns: this object, so calls chainmethod SetFilter(const AFilter: Filter): self: How the texture is sampled when scaled. C: SetTextureFilter Parameters:AFilterthe filter. Returns: this object, so calls chainmethod SetWrap(const AWrap: WrapMode): self: How the texture repeats past its edges. C: SetTextureWrap Parameters:AWrapthe wrap mode. Returns: this object, so calls chainconst method ToImage(): ImageRes: The texture's pixels back as an image. C: LoadImageFromTexture Returns: the texture's pixels back as an image
Example: LTex: TextureRes("images/adam.png"); LTex.SetFilter(Filter.Bilinear); Draw.Texture(LTex, Vector2(x: 8, y: 8), WHITE);
RenderTextureRes
type RenderTextureRes = object
A texture drawn into (raylib's framebuffer object): drawing between Begin and End lands in it, in its own pixels, then Draw.Texture shows it the right way up. A shared handle: the last copy unloads it, the window's close too. C: UnloadRenderTexture (the last copy's release)
Members
init(): An empty handle (holds nothing:IsValid()false, its changes do nothing), as a variable declared with no arguments starts.init(const AWidth: int32; const AHeight: int32): AAWidthxAHeightrender texture (RGBA, with a depth buffer). C: LoadRenderTexture Parameters:AWidththe width;AHeightthe height.init(const AWidth: int32; const AHeight: int32; const AFormat: Pixel): AAWidthxAHeightrender texture of pixel formatAFormat. C: LoadRenderTextureEx Parameters:AWidththe width;AHeightthe height;AFormatthe pixel format.static method Adopt(const ATarget: RenderTexture2D): RenderTextureRes: Takes the .C render textureATargetover: unloaded with the last copy (or the window). Parameters:ATargetthe target. Returns: the newRenderTextureResconst method Handle(): RenderTexture2D: The .C render texture (borrowed, for .C calls; an empty one when none is held). Returns: the .C render texture (borrowed, for .C calls; an empty one when none is held)const method IsValid(): bool: True when the render texture is on the GPU. C: IsRenderTextureValid Returns:truewhen the render texture is on the GPUconst method Texture(): TextureRes: Its color texture (a view: valid while this render texture lives). Drawn as it is, it is upside down (OpenGL's rows):Draw.Textureof the render texture itself is not. Returns: its color texture (a view: valid while this render texture lives)const method Depth(): TextureRes: Its depth texture (a view, as Texture). Returns: its depth texture (a view, as Texture)const method Width(): int32: The width in pixels. Returns: the width in pixelsconst method Height(): int32: The height in pixels. Returns: the height in pixelsconst method Begin(): Drawing lands in this texture, in its pixels, until End (inside a frame too: the frame comes back at End). C: BeginTextureModestatic method End(): Ends Begin: drawing goes to the window (and the frame) again. C: EndTextureMode
Example: LCanvas: RenderTextureRes(160, 90); LCanvas.Begin(); Draw.Circle(Vector2(x: 80, y: 45), 20.0f, RED); RenderTextureRes.End();
FontRes
type FontRes = object
A font: its glyph atlas on the GPU (the window must be open), drawn by Draw.Text. A shared handle: the last copy unloads it, the window's close too; FontRes.Default() is raylib's own font (never unloaded). C: UnloadFont (the last copy's release)
Members
init(): An empty handle (holds nothing:IsValid()false, its changes do nothing), as a variable declared with no arguments starts.init(const APath: string): Loads the font file atAPath(from the mounted source) at its default size. C: LoadFont Parameters:APaththe file's path.init(const APath: string; const ASize: int32): Loads the font file atAPathatASizepixels, raylib's default 95 glyphs. C: LoadFontEx Parameters:APaththe file's path;ASizethe size.init(const APath: string; const ASize: int32; const ACodepoints: array of int32): Loads the font file atAPathatASizepixels, the glyphs ofACodepoints(none: raylib's default 95). C: LoadFontEx Parameters:APaththe file's path;ASizethe size;ACodepointsthe codepoints.static method Adopt(const AFont: Font): FontRes: Takes the .C fontAFontover: unloaded with the last copy (or the window; raylib's default font never is). Parameters:AFontthe font. Returns: the newFontResstatic method Default(): FontRes: raylib's default font (never unloaded). C: GetFontDefault Returns: raylib's default font (never unloaded)static method FromIO(const AIO: IO; const AType: string; const ASize: int32): FontRes: Loads a font of typeAType(".ttf" ...) fromAIOatASizepixels, raylib's default 95 glyphs. Parameters:AIOthe IO;ATypethe type;ASizethe size. Returns: the newFontResstatic method FromMemory(const AType: string; const AData: array of uint8; const ASize: int32; const ACodepoints: array of int32): FontRes: Loads a font of typeAType(".ttf" ...) from the file bytesADataatASizepixels, the glyphs ofACodepoints(none: raylib's default 95). C: LoadFontFromMemory Parameters:ATypethe type;ADatathe bytes;ASizethe size;ACodepointsthe codepoints. Returns: the newFontResstatic method FromImage(const AImage: ImageRes; const AKey: Color; const AFirstChar: int32): FontRes: A bitmap font fromAImage: glyphs in a row fromAFirstChar, parted by the key colorAKey. C: LoadFontFromImage Parameters:AImagethe image;AKeythe key;AFirstCharthe first char. Returns: a bitmap font fromAImage: glyphs in a row fromAFirstChar, parted by the key colorAKeystatic method Glyphs(const AData: array of uint8; const ASize: int32; const ACodepoints: array of int32; const AKind: FontKind): GlyphsRes: The glyphs of the font fileAData(for ImageRes.FontAtlas): GlyphsRes's own init. C: LoadFontData Parameters:ADatathe bytes;ASizethe size;ACodepointsthe codepoints;AKindthe kind. Returns: the glyphs of the font fileAData(for ImageRes.FontAtlas): GlyphsRes's own initconst method Handle(): Font: The .C font (borrowed, for .C calls; raylib's default font when none is held). Returns: the .C font (borrowed, for .C calls; raylib's default font when none is held)const method IsValid(): bool: True when the font holds glyphs and an atlas. C: IsFontValid Returns:truewhen the font holds glyphs and an atlasconst method BaseSize(): int32: The size the glyphs were made at. Returns: the size the glyphs were made atconst method GlyphCount(): int32: How many glyphs the font holds. Returns: how many glyphs the font holdsconst method GlyphPadding(): int32: The padding around each glyph in the atlas. Returns: the padding around each glyph in the atlasconst method Measure(const AText: string; const ASize: float32; const ASpacing: float32): Vector2: The sizeATexttakes atASize,ASpacingbetween glyphs. C: MeasureTextEx Parameters:ATextthe text;ASizethe size;ASpacingthe spacing. Returns: the sizeATexttakes atASize,ASpacingbetween glyphsconst method Measure(const AText: string; const ASize: int32): int32: The widthATexttakes atASizeby raylib's DrawText rules (10 the least, one unit of spacing per whole 10):Draw.Text's default-font form, measured. C: MeasureText Parameters:ATextthe text;ASizethe size. Returns: the widthATexttakes atASizeby raylib's DrawText rules (10 the least, one unit of spacing per whole 10):Draw.Text's default-font form, measured Example:LW := FontRes.Default().Measure("Game Over", 20);const method Measure(const ACodepoints: array of int32; const ASize: float32; const ASpacing: float32): Vector2: The size the codepointsACodepointstake. C: MeasureTextCodepoints Parameters:ACodepointsthe codepoints;ASizethe size;ASpacingthe spacing. Returns: the size the codepointsACodepointstakeconst method GlyphIndex(const ACodepoint: int32): int32: The index of codepointACodepoint's glyph ('?''s when the font lacks it). C: GetGlyphIndex Parameters:ACodepointthe codepoint. Returns: the index of codepointACodepoint's glyph ('?''s when the font lacks it)const method Glyph(const ACodepoint: int32): GlyphInfo: CodepointACodepoint's glyph. C: GetGlyphInfo Parameters:ACodepointthe codepoint. Returns: codepointACodepoint's glyphconst method GlyphRect(const ACodepoint: int32): Rectangle: CodepointACodepoint's rectangle in the atlas. C: GetGlyphAtlasRec Parameters:ACodepointthe codepoint. Returns: codepointACodepoint's rectangle in the atlasconst method Atlas(): TextureRes: The glyph atlas (a view: valid while this font lives). Returns: the glyph atlas (a view: valid while this font lives)const method ExportAsCode(const APath: string): bool: Saves the font as a C header atAPath. C: ExportFontAsCode Parameters:APaththe file's path. Returns:truewhen the file was writtenstatic method LineSpacing(const ASpacing: int32): The gap between lines of a text with line breaks, for every font. C: SetTextLineSpacing Parameters:ASpacingthe spacing.
Example: LMono: FontRes("fonts/JetBrainsMonoRegular.ttf", 32); Draw.Text(LMono, "Score", Vector2(x: 8, y: 8), 32.0f, 1.0f, WHITE);
ShaderRes
type ShaderRes = object
A GPU shader program (vertex + fragment): a shared handle, unloaded with the last copy or the window's close. Draws between Begin and End go through it. C: UnloadShader (the last copy's release)
Members
init(): An empty handle (holds nothing:IsValid()false, its changes do nothing), as a variable declared with no arguments starts.init(const AVertexPath: string; const AFragmentPath: string): Loads and links the shader files atAVertexPath/AFragmentPath(from the mounted source); "" takes raylib's default for that stage. C: LoadShader Parameters:AVertexPaththe vertex path;AFragmentPaththe fragment path.static method Adopt(const AShader: Shader): ShaderRes: Takes the .C shaderAShaderover: unloaded with the last copy (or the window). Parameters:AShaderthe shader. Returns: the newShaderResstatic method FromCode(const AVertex: string; const AFragment: string): ShaderRes: Compiles and links the GLSL sourcesAVertex/AFragment; "" takes raylib's default for that stage. C: LoadShaderFromMemory Parameters:AVertexthe vertex;AFragmentthe fragment. Returns: the newShaderResstatic method FromIO(const AVertex: IO; const AFragment: IO): ShaderRes: Loads the stages fromAVertex/AFragment(nil takes raylib's default for that stage). Parameters:AVertexthe vertex;AFragmentthe fragment. Returns: the newShaderResconst method Handle(): Shader: The .C shader (borrowed, for .C calls; raylib's empty shader when none is held). Returns: the .C shader (borrowed, for .C calls; raylib's empty shader when none is held)const method IsValid(): bool: True when the program is linked on the GPU. C: IsShaderValid Returns:truewhen the program is linked on the GPUconst method Location(const AName: string): int32: The location of the uniformAName(-1 when the program has none). C: GetShaderLocation Parameters:ANamethe name. Returns: the location of the uniformAName(-1 when the program has none)const method Attrib(const AName: string): int32: The location of the vertex attributeAName(-1 when the program has none). C: GetShaderLocationAttrib Parameters:ANamethe name. Returns: the location of the vertex attributeAName(-1 when the program has none)method SetLoc(const ALoc: ShaderLoc; const ALocation: int32): self: Makes raylib's drawing feedALocthroughALocation(a uniform or an attribute of this program, from Location / Attrib). C: shader.locs[] Parameters:ALocthe loc;ALocationthe location. Returns: this object, so calls chainmethod Set(const ALocation: int32; const AValue: float32): self: Sets the float uniform atALocation. C: SetShaderValue Parameters:ALocationthe location;AValuethe value. Returns: this object, so calls chainmethod Set(const ALocation: int32; const AValue: int32): self: Sets the int uniform (or sampler unit) atALocation. C: SetShaderValue Parameters:ALocationthe location;AValuethe value. Returns: this object, so calls chainmethod Set(const ALocation: int32; const AValue: Vector2): self: Sets the vec2 uniform atALocation. C: SetShaderValue Parameters:ALocationthe location;AValuethe value. Returns: this object, so calls chainmethod Set(const ALocation: int32; const AValue: Vector3): self: Sets the vec3 uniform atALocation. C: SetShaderValue Parameters:ALocationthe location;AValuethe value. Returns: this object, so calls chainmethod Set(const ALocation: int32; const AValue: Vector4): self: Sets the vec4 uniform atALocation. C: SetShaderValue Parameters:ALocationthe location;AValuethe value. Returns: this object, so calls chainmethod Set(const ALocation: int32; const AColor: Color): self: Sets the vec4 uniform atALocationtoAColornormalized (each channel 0..1). C: SetShaderValue, ColorNormalize Parameters:ALocationthe location;AColorthe colour. Returns: this object, so calls chainmethod Set(const ALocation: int32; const AValues: array of float32; const AType: UniformType): self: Sets the uniform array atALocationfromAValuesas elements ofAType(a vec3 takes three values each; an int / uint type takes each value as a whole number). C: SetShaderValueV Parameters:ALocationthe location;AValuesthe values;ATypethe type. Returns: this object, so calls chainmethod Set(const ALocation: int32; const AMatrix: Matrix): self: Sets the mat4 uniform atALocation. C: SetShaderValueMatrix Parameters:ALocationthe location;AMatrixthe matrix. Returns: this object, so calls chainmethod Set(const ALocation: int32; const ATexture: TextureRes): self: BindsATextureto the sampler uniform atALocation. C: SetShaderValueTexture Parameters:ALocationthe location;ATexturethe texture. Returns: this object, so calls chainconst method Begin(): Drawing goes through this shader until End (the shader kept alive until then). C: BeginShaderModestatic method End(): Ends Begin: raylib's default shader again. C: EndShaderMode
Example: LGlow := ShaderRes("", "res/assets/shaders/glow.fs"); LGlow.Set(LGlow.Location("strength"), 0.5f);
MaterialRes
type MaterialRes = object
A material: a shader and its maps (a texture, a colour and a value each), what a mesh is drawn with. A shared handle, unloaded with the last copy or the window's close: the textures and shader it loaded go with it, one set from a Res is kept alive by it. C: UnloadMaterial (the last copy's release)
Members
init(): An empty handle (holds nothing:IsValid()false, its changes do nothing), as a variable declared with no arguments starts.static method Adopt(const AMaterial: Material): MaterialRes: Takes the .C materialAMaterialover: its maps, and the textures and shader that are not raylib's defaults, unloaded with the last copy (or the window). Parameters:AMaterialthe material. Returns: the newMaterialResstatic method Default(): MaterialRes: raylib's default material (its default shader, a white albedo). C: LoadMaterialDefault Returns: raylib's default material (its default shader, a white albedo)static method Load(const APath: string): array of MaterialRes: The materials of the file atAPath(an .mtl, from the mounted source; its textures load beside it). C: LoadMaterials Parameters:APaththe file's path. Returns: the materials of the file atAPath(an .mtl, from the mounted source; its textures load beside it)const method Handle(): Material: The .C material (borrowed, for .C calls; raylib's empty material when none is held). Returns: the .C material (borrowed, for .C calls; raylib's empty material when none is held)const method IsValid(): bool: True when the material has its maps and a shader. C: IsMaterialValid Returns:truewhen the material has its maps and a shadermethod SetTexture(const AMap: MapIndex; const ATexture: TextureRes): self: MapAMaptakesATexture(kept alive by the material; a texture the material loaded for that map is unloaded). C: SetMaterialTexture Parameters:AMapthe map;ATexturethe texture. Returns: this object, so calls chainmethod SetColor(const AMap: MapIndex; const AColor: Color): self: MapAMap's colour (the albedo map's tints the texture). Parameters:AMapthe map;AColorthe colour. Returns: this object, so calls chainmethod SetValue(const AMap: MapIndex; const AValue: float32): self: MapAMap's value (a strength the shader reads: metalness, roughness ...). Parameters:AMapthe map;AValuethe value. Returns: this object, so calls chainmethod SetShader(const AShader: ShaderRes): self: The material draws throughAShader(kept alive by it; a shader the material loaded is unloaded). Parameters:AShaderthe shader. Returns: this object, so calls chain
Example: LSkin := MaterialRes.Default().SetTexture(MapIndex.Albedo, LTex).SetColor(MapIndex.Albedo, GOLD);
MeshRes
type MeshRes = object
A mesh: vertex data on the CPU and its buffers on the GPU (uploaded as it is made). A shared handle, unloaded with the last copy or the window's close; a model's meshes are MeshRes too, so a mesh lives while any model or handle still uses it. C: UnloadMesh (the last copy's release)
Members
init(): An empty handle (holds nothing:IsValid()false, its changes do nothing), as a variable declared with no arguments starts.static method Adopt(const AMesh: Mesh): MeshRes: Takes the .C meshAMeshover: its data and buffers unloaded with the last copy (or the window). Parameters:AMeshthe mesh. Returns: the newMeshResstatic method Poly(const ASides: int32; const ARadius: float32): MeshRes: A flat polygon ofASidessides. C: GenMeshPoly Parameters:ASideshow many sides;ARadiusthe radius. Returns: a flat polygon ofASidessidesstatic method Plane(const AWidth: float32; const ALength: float32; const AResX: int32; const AResZ: int32): MeshRes: A flat planeAWidthxALength,AResXxAResZquads. C: GenMeshPlane Parameters:AWidththe width;ALengththe length;AResXthe res X;AResZthe res Z. Returns: a flat planeAWidthxALength,AResXxAResZquadsstatic method Cube(const AWidth: float32; const AHeight: float32; const ALength: float32): MeshRes: A box. C: GenMeshCube Parameters:AWidththe width;AHeightthe height;ALengththe length. Returns: a boxstatic method Sphere(const ARadius: float32; const ARings: int32; const ASlices: int32): MeshRes: A sphere ofARingsrings andASlicesslices. C: GenMeshSphere Parameters:ARadiusthe radius;ARingshow many rings;ASliceshow many slices. Returns: a sphere ofARingsrings andASlicesslicesstatic method HemiSphere(const ARadius: float32; const ARings: int32; const ASlices: int32): MeshRes: A half sphere (no base). C: GenMeshHemiSphere Parameters:ARadiusthe radius;ARingshow many rings;ASliceshow many slices. Returns: a half sphere (no base)static method Cylinder(const ARadius: float32; const AHeight: float32; const ASlices: int32): MeshRes: A cylinder. C: GenMeshCylinder Parameters:ARadiusthe radius;AHeightthe height;ASliceshow many slices. Returns: a cylinderstatic method Cone(const ARadius: float32; const AHeight: float32; const ASlices: int32): MeshRes: A cone (its baseARadius). C: GenMeshCone Parameters:ARadiusthe radius;AHeightthe height;ASliceshow many slices. Returns: a cone (its baseARadius)static method Torus(const ARadius: float32; const ASize: float32; const ARadSeg: int32; const ASides: int32): MeshRes: A torus (ASizeits tube's radius). C: GenMeshTorus Parameters:ARadiusthe radius;ASizethe size;ARadSegthe rad seg;ASideshow many sides. Returns: a torus (ASizeits tube's radius)static method Knot(const ARadius: float32; const ASize: float32; const ARadSeg: int32; const ASides: int32): MeshRes: A trefoil knot. C: GenMeshKnot Parameters:ARadiusthe radius;ASizethe size;ARadSegthe rad seg;ASideshow many sides. Returns: a trefoil knotstatic method Heightmap(const AImage: ImageRes; const ASize: Vector3): MeshRes: A terrain fromAImage's brightness,ASizeits extent. C: GenMeshHeightmap Parameters:AImagethe image;ASizethe size. Returns: a terrain fromAImage's brightness,ASizeits extentstatic method Cubicmap(const AImage: ImageRes; const ACubeSize: Vector3): MeshRes: Walls fromAImage(a white pixel a cube ofACubeSize). C: GenMeshCubicmap Parameters:AImagethe image;ACubeSizethe cube size. Returns: the newMeshResconst method Handle(): Mesh: The .C mesh (borrowed, for .C calls; raylib's empty mesh when none is held). Returns: the .C mesh (borrowed, for .C calls; raylib's empty mesh when none is held)const method IsValid(): bool: True when the mesh's buffers are on the GPU (it can be drawn). Returns:truewhen the mesh's buffers are on the GPU (it can be drawn)const method VertexCount(): int32: The vertices. Returns: the verticesconst method TriangleCount(): int32: The triangles. Returns: the trianglesmethod Upload(const ADynamic: bool): self: Puts the vertex data on the GPU (ADynamic: buffers meant for UpdateBuffer); a mesh made here is uploaded already, so this is for an adopted one. C: UploadMesh Parameters:ADynamictruefor a buffer meant to be updated. Returns: this object, so calls chainmethod UpdateBuffer(const AIndex: int32; const AData: ptr to const; const ASize: int32; const AOffset: int32): self: ReplacesASizebytes atAOffsetof vertex bufferAIndexwithAData. C: UpdateMeshBuffer Parameters:AIndexthe index, from 0;ADatathe data;ASizethe size;AOffsetthe offset. Returns: this object, so calls chainmethod GenTangents(): self: Computes the tangents (for normal maps). C: GenMeshTangents Returns: this object, so calls chainconst method Bounds(): BoundingBox: The box around the vertices. C: GetMeshBoundingBox Returns: the box around the verticesconst method Draw(const AMaterial: MaterialRes; const ATransform: Matrix): Draws the mesh withAMaterial, placed byATransform(inside Begin3D). C: DrawMesh Parameters:AMaterialthe material;ATransformthe transform.const method DrawInstanced(const AMaterial: MaterialRes; const ATransforms: array of Matrix): Draws the mesh once per transform ofATransforms(a shader that reads the instance transform attribute). C: DrawMeshInstanced Parameters:AMaterialthe material;ATransformsthe transforms.const method Export(const APath: string): bool: Writes the mesh as an .obj file. C: ExportMesh Parameters:APaththe file's path. Returns:truewhen the file was writtenconst method ExportAsCode(const APath: string): bool: Writes the mesh as a C header of arrays. C: ExportMeshAsCode Parameters:APaththe file's path. Returns:truewhen the file was written
Example: LBall := MeshRes.Sphere(1.0f, 16, 16); LBall.Draw(MaterialRes.Default(), MatrixIdentity());
ModelAnimationRes
type ModelAnimationRes = object
One animation clip of a set LoadModelAnimations reads from a model file: a shared handle on the set, unloaded with the last copy of any of its clips.
Members
init(): An empty handle (holds nothing:IsValid()false), as a variable declared with no arguments starts.static method Adopt(const AAnimations: ptr to ModelAnimation; const ACount: int32): array of ModelAnimationRes: Takes the setAAnimationsofACountclips over (LoadModelAnimations's result): unloaded with the last copy of its clips. C: UnloadModelAnimations Parameters:AAnimationsthe animations;ACounthow many. Returns: a handle for each clipstatic method Load(const APath: string): array of ModelAnimationRes: The animation clips of the model file atAPath(from the mounted source). C: LoadModelAnimations Parameters:APaththe file's path. Returns: the animation clips of the model file atAPath(from the mounted source)const method Handle(): ModelAnimation: The .C clip (borrowed, for .C calls; raylib's empty clip when none is held). Returns: the .C clip (borrowed, for .C calls; raylib's empty clip when none is held)const method IsValid(): bool: True when the handle holds a clip with frames. Returns:truewhen the handle holds a clip with framesconst method Name(): string: The clip's name (as the model file gives it). Returns: the clip's name (as the model file gives it)const method BoneCount(): int32: The bones each frame poses. Returns: the bones each frame posesconst method FrameCount(): int32: The frames. Returns: the frames
Example: LClips := ModelAnimationRes.Load("res/assets/models/robot.glb"); LRobot.Animate(LClips[0], LFrame);
ModelRes
type ModelRes = object
A model: meshes, the materials they are drawn with, and (for an animated file) a skeleton. A shared handle; its meshes and materials are MeshRes / MaterialRes of their own, unloaded with their last user (the window's close too). C: UnloadModel (the last copy's release)
Members
init(): An empty handle (holds nothing:IsValid()false, its changes do nothing), as a variable declared with no arguments starts.init(const APath: string): Loads the model file atAPath(glTF / glb, OBJ, IQM, VOX, M3D; its materials and textures from beside it in the mounted source). C: LoadModel Parameters:APaththe file's path.static method Adopt(const AModel: Model): ModelRes: Takes the .C modelAModelover (its meshes, materials, the textures and shaders its materials hold that are not raylib's defaults, its skeleton). Parameters:AModelthe model. Returns: the newModelResstatic method FromMesh(const AMesh: MeshRes): ModelRes: A model ofAMeshalone (shared: the mesh staysAMesh's too) with raylib's default material. C: LoadModelFromMesh Parameters:AMeshthe mesh. Returns: a model ofAMeshalone (shared: the mesh staysAMesh's too) with raylib's default materialconst method Handle(): Model: The .C model (borrowed, for .C calls; raylib's empty model when none is held). Returns: the .C model (borrowed, for .C calls; raylib's empty model when none is held)const method IsValid(): bool: True when every mesh is on the GPU with a material. C: IsModelValid Returns:truewhen every mesh is on the GPU with a materialconst method Bounds(): BoundingBox: The box around every mesh, through the model's transform. C: GetModelBoundingBox Returns: the box around every mesh, through the model's transformconst method MeshCount(): int32: The meshes. Returns: the meshesconst method MaterialCount(): int32: The materials. Returns: the materialsconst method Mesh(const AIndex: int32): MeshRes: MeshAIndex(shared with the model; an empty handle out of range). Parameters:AIndexthe index, from 0. Returns: meshAIndex(shared with the model; an empty handle out of range)const method Material(const AIndex: int32): MaterialRes: MaterialAIndex(shared with the model: a change shows in the model; an empty handle out of range). Parameters:AIndexthe index, from 0. Returns: materialAIndex(shared with the model: a change shows in the model; an empty handle out of range)method SetMeshMaterial(const AMesh: int32; const AMaterial: int32): self: MeshAMeshis drawn with materialAMaterial(both in range, else no change). C: SetModelMeshMaterial Parameters:AMeshthe mesh;AMaterialthe material's index. Returns: this object, so calls chainmethod SetMaterial(const AIndex: int32; const AMaterial: MaterialRes): self: Material slotAIndextakesAMaterial(shared; the slot's material before goes with its last user). In range, else no change. Parameters:AIndexthe index, from 0;AMaterialthe material. Returns: this object, so calls chainproperty Transform: Matrix read; write: The model's transform (applied to every mesh as it is drawn).const method Draw(const APosition: Vector3; const AScale: float32; const ATint: Color): Draws the model atAPosition, scaled, tinted (inside Begin3D). C: DrawModel Parameters:APositionthe position;AScalethe scale;ATintthe tint colour.const method Draw(const APosition: Vector3; const AAxis: Vector3; const AAngle: float32; const AScale: Vector3; const ATint: Color): Draws the model atAPosition, turnedAAngledegrees aboutAAxis, scaled per axis. C: DrawModelEx Parameters:APositionthe position;AAxisthe axis;AAnglethe angle;AScalethe scale;ATintthe tint colour.const method DrawWires(const APosition: Vector3; const AScale: float32; const ATint: Color): Draws the model's triangle edges. C: DrawModelWires Parameters:APositionthe position;AScalethe scale;ATintthe tint colour.const method DrawWires(const APosition: Vector3; const AAxis: Vector3; const AAngle: float32; const AScale: Vector3; const ATint: Color): Draws the model's triangle edges, turned and scaled per axis. C: DrawModelWiresEx Parameters:APositionthe position;AAxisthe axis;AAnglethe angle;AScalethe scale;ATintthe tint colour.method Animate(const AClip: ModelAnimationRes; const AFrame: float32): Poses the model at frameAFrameofAClip(fractions blend neighbouring frames). C: UpdateModelAnimation Parameters:AClipthe clip;AFramethe frame.method Animate(const AClipA: ModelAnimationRes; const AFrameA: float32; const AClipB: ModelAnimationRes; const AFrameB: float32; const ABlend: float32): Poses the model between frameAFrameAofAClipAand frameAFrameBofAClipB(ABlend0: A alone, 1: B alone). C: UpdateModelAnimationEx Parameters:AClipAthe clip A;AFrameAthe frame A;AClipBthe clip B;AFrameBthe frame B;ABlendthe blend.const method Fits(const AClip: ModelAnimationRes): bool: True whenAClipposes this model's skeleton (the same bones). C: IsModelAnimationValid Parameters:AClipthe clip. Returns:truewhenAClipposes this model's skeleton (the same bones)
Example: LRobot: ModelRes("res/assets/models/robot.glb"); LRobot.Draw(Vector3Zero(), 1.0f, WHITE);
AudioFunc
type AudioFunc = ref func(ABuffer: ptr; AFrames: uint32)
A routine raylib's audio thread calls with sample frames: an audio stream's callback (it fills ABuffer with AFrames frames) or a processor (it changes them in place, float32 samples, interleaved). A closure, so it may hold what it reads or writes; it runs on the audio thread, while raylib holds its audio lock.
Example: LTone.Callback(func(ABuffer: ptr; AFrames: uint32) begin FillTone(ABuffer, AFrames); end);
AudioProcessor
type AudioProcessor = object
An audio processor: a closure raylib runs over sample frames (float32, interleaved, in place) as they go to the speakers, attached to one stream (AudioStreamRes.Attach) or to everything mixed (AudioDevice.AttachMixed). A copy is the same processor, so the value attached is the one to detach.
Members
init(): No processor (IsValid()false: attaching it does nothing).init(const AFunc: AudioFunc): A processor runningAFuncon each block of frames. Parameters:AFuncthe closure the audio thread runs.const method IsValid(): bool: True when it runs a closure. Returns: whether it can be attachedconst method Func(): AudioCallback: The C function pointer raylib calls (nil when empty): for the .C attach calls, which then need this value kept alive while attached. Returns: the thunk as raylib's AudioCallback
Example: LHalf := AudioProcessor(func(ABuffer: ptr; AFrames: uint32) begin Scale(ABuffer, AFrames, 0.5f); end); LStream.Attach(LHalf);
AudioDevice
type AudioDevice = object
raylib's audio device: open while any copy is held (a copy shares it; the last copy's done unloads every sound, music, stream and video still alive, then closes it). Sounds, music and streams need it open; waves do not. C: InitAudioDevice / CloseAudioDevice
Members
init(): Opens the device (holds the one open already, if any).Ready()false when no device could be opened. C: InitAudioDevicecopy(const ASource: AudioDevice): One more hold on the same device: it stays open while any copy is held. Parameters:ASourcethe device value copied.done: Lets this hold go: the last one closes the device (every sound, music, stream and video still alive unloaded first).const method Ready(): bool: True while the device is open. C: IsAudioDeviceReady Returns: whether sounds playproperty Volume: float32 read; write: The master volume as a level a person sets, 0 (silent) to 1 (full; clamped): equal steps sound like equal steps (System.Math's PerceivedVolume / PerceivedLevel over raylib's linear gain). C: GetMasterVolume / SetMasterVolumestatic method BufferSize(const AFrames: int32): The buffer size, in sample frames, of the streams loaded after it (0: raylib's). C: SetAudioStreamBufferSizeDefault Parameters:AFramesthe frames of each buffer.static method AttachMixed(const AProcessor: AudioProcessor): bool: RunsAProcessorover everything mixed, kept alive until DetachMixed or the device's close. C: AttachAudioMixedProcessor Parameters:AProcessorthe processor. Returns: false when the device is not open or the processor is empty (nothing attached); attaching one already attached does nothing morestatic method DetachMixed(const AProcessor: AudioProcessor): Stops runningAProcessor(the value AttachMixed was given, or a copy of it) over the mix. C: DetachAudioMixedProcessor Parameters:AProcessorthe processor.
Example: LAudio: AudioDevice; LAudio.Volume := 0.8f; LCoin := SoundRes("res/assets/audio/sfx/coin_pickup.ogg");
WaveRes
type WaveRes = object
Wave data (samples in memory, no device needed): a shared handle, unloaded with the last copy. Its changes (Crop, ToFormat) change it for every copy; Copy() gives one of its own. C: UnloadWave (the last copy's release)
Members
init(): An empty handle (holds nothing:IsValid()false, its changes do nothing).init(const APath: string): Loads the sound file atAPath(from the mounted source: .wav, .ogg, .mp3, .qoa, .flac). C: LoadWave Parameters:APaththe file's path.static method Adopt(const AWave: Wave): WaveRes: Takes the .C waveAWaveover: unloaded with the last copy. Parameters:AWavethe wave. Returns: the newWaveResstatic method FromIO(const AIO: IO; const AType: string): WaveRes: Loads a wave of typeAType(".wav" ...) fromAIO(the IO stays the caller's). Parameters:AIOthe IO;ATypethe type. Returns: the newWaveResstatic method FromMemory(const AType: string; const AData: array of uint8): WaveRes: Loads a wave of typeAType(".wav" ...) from the file bytesAData. C: LoadWaveFromMemory Parameters:ATypethe type;ADatathe bytes. Returns: the newWaveResconst method Handle(): Wave: The .C wave (borrowed, for .C calls; an empty one when none is held). Returns: the .C wave (borrowed, for .C calls; an empty one when none is held)const method IsValid(): bool: True when it holds sample data. C: IsWaveValid Returns:truewhen it holds sample dataconst method Copy(): WaveRes: A wave of its own with the same samples. C: WaveCopy Returns: a wave of its own with the same samplesmethod Crop(const AFirst: int32; const ALast: int32): self: Keeps the framesAFirstup to (not including)ALastonly. C: WaveCrop Parameters:AFirstthe first frame kept;ALastthe frame the kept ones end before. Returns: this object, so calls chainmethod ToFormat(const ASampleRate: int32; const ASampleSize: int32; const AChannels: int32): self: Converts the samples toASampleRateHz,ASampleSizebits (8, 16 or 32: float) andAChannelschannels. C: WaveFormat Parameters:ASampleRatethe sample rate;ASampleSizethe sample size;AChannelsthe channels. Returns: this object, so calls chainconst method Samples(): array of float32: The samples as float32 (-1 .. 1), interleaved: Frames() x Channels() of them. C: LoadWaveSamples / UnloadWaveSamples Returns: the samples as float32 (-1 .const method Frames(): int32: Its length in sample frames. Returns: its length in sample framesconst method SampleRate(): int32: Its sample rate in Hz. Returns: its sample rate in Hzconst method SampleSize(): int32: Bits per sample (8, 16 or 32). Returns: the bits per sample (8, 16 or 32)const method Channels(): int32: Its channels (1 mono, 2 stereo). Returns: its channels (1 mono, 2 stereo)const method Export(const APath: string): bool: Writes the wave to the fileAPath(.wav or .qoa). C: ExportWave Parameters:APaththe file's path. Returns: false when it could not be writtenconst method ExportAsCode(const APath: string): bool: Writes the samples as a C header toAPath. C: ExportWaveAsCode Parameters:APaththe file's path. Returns: false when it could not be written
Example: LHit := WaveRes("res/assets/audio/sfx/explo_rock.ogg").Crop(0, 22050); LSound := LHit.ToSound();
SoundRes
type SoundRes = object
A sound effect (fully in memory, played at once): a shared handle, unloaded with the last copy or the device's close. Needs the audio device. Alias() gives one more voice of the same data, to play over itself. C: UnloadSound (the last copy's release)
Members
init(): An empty handle (holds nothing:IsValid()false, its changes do nothing).init(const APath: string): Loads the sound file atAPath(from the mounted source). C: LoadSound Parameters:APaththe file's path.static method Adopt(const ASound: Sound): SoundRes: Takes the .C soundASoundover: unloaded with the last copy (or the device). Parameters:ASoundthe sound. Returns: the newSoundResstatic method FromIO(const AIO: IO; const AType: string): SoundRes: Loads a sound of typeAType(".wav" ...) fromAIO(the IO stays the caller's). Parameters:AIOthe IO;ATypethe type. Returns: the newSoundResstatic method FromWave(const AWave: WaveRes): SoundRes: A sound ofAWave's samples (copied: the wave may go). C: LoadSoundFromWave Parameters:AWavethe wave. Returns: a sound ofAWave's samples (copied: the wave may go)const method Handle(): Sound: The .C sound (borrowed, for .C calls; an empty one when none is held). Returns: the .C sound (borrowed, for .C calls; an empty one when none is held)const method IsValid(): bool: True when it holds a sound the device can play. C: IsSoundValid Returns:truewhen it holds a sound the device can playconst method Alias(): SoundRes: One more voice playing this sound's data (its own volume, pitch, pan, position): the data stays while any alias does. C: LoadSoundAlias / UnloadSoundAlias Returns: the new aliasmethod Play(): self: Plays it from its start. C: PlaySound Returns: this object, so calls chainmethod Stop(): self: Stops it. C: StopSound Returns: this object, so calls chainmethod Pause(): self: Pauses it where it is. C: PauseSound Returns: this object, so calls chainmethod Resume(): self: Plays on from where it paused. C: ResumeSound Returns: this object, so calls chainconst method Playing(): bool: True while it plays. C: IsSoundPlaying Returns:truewhile it playsmethod Volume(const AVolume: float32): self: Its volume as a level a person sets, 0 (silent) to 1 (full; clamped): equal steps sound like equal steps (System.Math's PerceivedVolume over raylib's linear gain). C: SetSoundVolume Parameters:AVolumethe volume, 0 (silent) to 1 (full). Returns: this object, so calls chainmethod Pitch(const APitch: float32): self: Its pitch (1: as recorded). C: SetSoundPitch Parameters:APitchthe pitch. Returns: this object, so calls chainmethod Pan(const APan: float32): self: Its pan, 0 (left) to 1 (right), 0.5 the middle. C: SetSoundPan Parameters:APanthe pan. Returns: this object, so calls chainmethod Update(const AData: ptr to const; const AFrames: int32): self: Replaces its samples withAFramesframes atAData(its own format). C: UpdateSound Parameters:ADatathe data;AFramesthe frames. Returns: this object, so calls chain
Example: LCoin := SoundRes("res/assets/audio/sfx/coin_pickup.ogg").Volume(0.6f); LCoin.Play();
MusicRes
type MusicRes = object
Music, decoded as it plays (call Update() once a frame): a shared handle, unloaded with the last copy or the device's close. Needs the audio device. C: UnloadMusicStream (the last copy's release)
Members
init(): An empty handle (holds nothing:IsValid()false, its changes do nothing).init(const APath: string): Opens the music file atAPath(from the mounted source). C: LoadMusicStream Parameters:APaththe file's path.static method FromIO(const AIO: IO; const AType: string): MusicRes: Opens music of typeAType(".ogg" ...) read fromAIOwhile it plays (the IO stays the caller's: open until the last copy goes). Parameters:AIOthe IO;ATypethe type. Returns: the newMusicResstatic method FromMemory(const AType: string; const AData: array of uint8): MusicRes: Opens music of typeAType(".ogg" ...) from the file bytesAData(kept with it while it plays). C: LoadMusicStreamFromMemory Parameters:ATypethe type;ADatathe bytes. Returns: the newMusicResconst method Handle(): Music: The .C music (borrowed, for .C calls; an empty one when none is held). Returns: the .C music (borrowed, for .C calls; an empty one when none is held)const method IsValid(): bool: True when it holds music the device can play. C: IsMusicValid Returns:truewhen it holds music the device can playmethod Play(): self: Plays it (from its start, or from where it paused). C: PlayMusicStream Returns: this object, so calls chainmethod Stop(): self: Stops it (back to its start). C: StopMusicStream Returns: this object, so calls chainmethod Pause(): self: Pauses it where it is. C: PauseMusicStream Returns: this object, so calls chainmethod Resume(): self: Plays on from where it paused. C: ResumeMusicStream Returns: this object, so calls chainmethod Update(): Decodes the next part into its buffers: once a frame while it plays. C: UpdateMusicStreamconst method Playing(): bool: True while it plays. C: IsMusicStreamPlaying Returns:truewhile it playsmethod Seek(const ASeconds: float32): self: Moves it toASecondsfrom its start. C: SeekMusicStream Parameters:ASecondsthe time, in seconds. Returns: this object, so calls chainmethod Volume(const AVolume: float32): self: Its volume as a level a person sets, 0 (silent) to 1 (full; clamped): equal steps sound like equal steps (System.Math's PerceivedVolume over raylib's linear gain). C: SetMusicVolume Parameters:AVolumethe volume, 0 (silent) to 1 (full). Returns: this object, so calls chainmethod Pitch(const APitch: float32): self: Its pitch (1: as recorded). C: SetMusicPitch Parameters:APitchthe pitch. Returns: this object, so calls chainmethod Pan(const APan: float32): self: Its pan, 0 (left) to 1 (right), 0.5 the middle. C: SetMusicPan Parameters:APanthe pan. Returns: this object, so calls chainmethod Looping(const ALoop: bool): self: Plays again from its start at its end (true) or stops there. C: music.looping Parameters:ALooptrueto loop. Returns: this object, so calls chainconst method Looping(): bool: True when it plays again from its start at its end. C: music.looping Returns:truewhen it plays again from its start at its endconst method Length(): float32: Its length in seconds. C: GetMusicTimeLength Returns: its length in secondsconst method Played(): float32: The seconds played since its start. C: GetMusicTimePlayed Returns: the seconds played since its start
Example: LSong := MusicRes("res/assets/audio/music/song01.ogg").Looping(true).Play(); ... LSong.Update();
AudioStreamRes
type AudioStreamRes = object
A raw audio stream the program feeds (Update with frames, or a Callback raylib calls for them): a shared handle, unloaded with the last copy or the device's close. Needs the audio device. C: UnloadAudioStream (the last copy's release)
Members
init(): An empty handle (holds nothing:IsValid()false, its changes do nothing).init(const ASampleRate: uint32; const ASampleSize: uint32; const AChannels: uint32): A stream ofASampleRateHz,ASampleSizebits (8, 16 or 32: float) andAChannelschannels. C: LoadAudioStream Parameters:ASampleRatethe sample rate;ASampleSizethe sample size;AChannelsthe channels.const method Handle(): AudioStream: The .C stream (borrowed, for .C calls; an empty one when none is held). Returns: the .C stream (borrowed, for .C calls; an empty one when none is held)const method IsValid(): bool: True when it holds a stream the device plays. C: IsAudioStreamValid Returns:truewhen it holds a stream the device playsmethod Update(const AData: ptr to const; const AFrames: int32): self: QueuesAFramesframes atAData(the stream's format) when a buffer is free (Processed). C: UpdateAudioStream Parameters:ADatathe data;AFramesthe frames. Returns: this object, so calls chainconst method Processed(): bool: True when a buffer is free for Update. C: IsAudioStreamProcessed Returns:truewhen a buffer is free for Updatemethod Play(): self: Plays it. C: PlayAudioStream Returns: this object, so calls chainmethod Pause(): self: Pauses it. C: PauseAudioStream Returns: this object, so calls chainmethod Resume(): self: Plays on from where it paused. C: ResumeAudioStream Returns: this object, so calls chainmethod Stop(): self: Stops it. C: StopAudioStream Returns: this object, so calls chainconst method Playing(): bool: True while it plays. C: IsAudioStreamPlaying Returns:truewhile it playsmethod Volume(const AVolume: float32): self: Its volume as a level a person sets, 0 (silent) to 1 (full; clamped): equal steps sound like equal steps (System.Math's PerceivedVolume over raylib's linear gain). C: SetAudioStreamVolume Parameters:AVolumethe volume, 0 (silent) to 1 (full). Returns: this object, so calls chainmethod Pitch(const APitch: float32): self: Its pitch (1: as fed). C: SetAudioStreamPitch Parameters:APitchthe pitch. Returns: this object, so calls chainmethod Pan(const APan: float32): self: Its pan, 0 (left) to 1 (right), 0.5 the middle. C: SetAudioStreamPan Parameters:APanthe pan. Returns: this object, so calls chainmethod Callback(const AFunc: AudioFunc): self: Has raylib's audio thread callAFuncfor frames whenever the stream needs them (nil: none, fed by Update again); the closure is kept while the stream may call it. C: SetAudioStreamCallback Parameters:AFuncthe func it runs. Returns: this object, so calls chainmethod Attach(const AProcessor: AudioProcessor): self: RunsAProcessorover the stream's frames (after any attached before it), kept alive until Detach or the stream goes. Attaching one attached already does nothing more. C: AttachAudioStreamProcessor Parameters:AProcessorthe processor. Returns: this object, so calls chainmethod Detach(const AProcessor: AudioProcessor): self: Stops runningAProcessor(the value Attach was given, or a copy of it). C: DetachAudioStreamProcessor Parameters:AProcessorthe processor. Returns: this object, so calls chain
Example: LTone := AudioStreamRes(44100, 32, 1).Callback(func(ABuffer: ptr; AFrames: uint32) begin Sine(ABuffer, AFrames); end).Play();
VideoStatusHandler
type VideoStatusHandler = ref func(const AStatus: VideoStatus)
A video's status handler: called with its new status on every change (Play, Pause, Stop, and its end when it does not loop).
Example: LIntro.OnStatus(func(const AStatus: VideoStatus) begin LEnded := AStatus = VideoStatus.VideoStopped; end);
VideoRes
type VideoRes = object
An MPEG-1 video (pl_mpeg) with its MP2 audio, played as MusicRes is: Play(), then Update() once a frame and Draw.Video it. A shared handle, unloaded with the last copy, the window's close or the audio device's. The sound plays when the audio device was open at the load. It loads with no window: frames are uploaded once one is open.
Members
init(): An empty handle (holds nothing:IsValid()false, its changes do nothing).init(const APath: string): Opens the .mpg atAPath(an entry of the mounted source, else a file). Parameters:APaththe file's path.static method FromIO(const AIO: IO; const AName: string): VideoRes: Opens a video read fromAIO(the IO stays the caller's: open while the video is);ANamenames it. Parameters:AIOthe IO;ANamethe name. Returns: the newVideoResconst method Handle(): Video: The .C video (borrowed, for the procedural calls; an empty one when none is held). Returns: the .C video (borrowed, for the procedural calls; an empty one when none is held)const method IsValid(): bool: True when it holds a video. Returns:truewhen it holds a videomethod Play(): self: Plays it (from where it paused, or from its start). Returns: this object, so calls chainmethod Pause(): self: Pauses it, its frame still drawn. Returns: this object, so calls chainmethod Stop(): self: Stops it (back to its start, no frame drawn until it plays). Returns: this object, so calls chainmethod Update(): Plays on by the time since the last update: once a frame.method Update(const ASeconds: float64): Plays on byASeconds(a fixed step). Parameters:ASecondsthe time, in seconds.method Seek(const ASeconds: float64): bool: Moves it toASecondsfrom its start. Parameters:ASecondsthe time, in seconds. Returns: false when it holds no video or cannot seek thereconst method Status(): VideoStatus: Where it stands (stopped, playing, paused). Returns: where it stands (stopped, playing, paused)const method Playing(): bool: True while it plays. Returns:truewhile it playsmethod Looping(const ALoop: bool): self: Plays again from its start at its end (true) or stops there. Parameters:ALooptrueto loop. Returns: this object, so calls chainconst method Looping(): bool: True when it plays again from its start at its end. Returns:truewhen it plays again from its start at its endmethod Volume(const AVolume: float32): self: Its sound's volume as a level a person sets, 0 (silent) to 1 (full; clamped): equal steps sound like equal steps (System.Math's PerceivedVolume). Parameters:AVolumethe volume, 0 (silent) to 1 (full). Returns: this object, so calls chainconst method Volume(): float32: Its sound's volume level (as Volume(AVolume) set it). Returns: its sound's volume level (as Volume(AVolume) set it)method OnStatus(const AHandler: VideoStatusHandler): self: CallsAHandlerwith its new status on every change (nil: none). The handler is kept while the video is. Parameters:AHandlerthe handler. Returns: this object, so calls chainconst method HasAudio(): bool: True when it has a sound track. Returns:truewhen it has a sound trackconst method ShaderUsed(): bool: True when its frames are converted on the GPU (decided at its first frame with a window). Returns:truewhen its frames are converted on the GPU (decided at its first frame with a window)const method FrameRate(): float64: Its frames per second. Returns: its frames per secondconst method Duration(): float64: Its length in seconds. Returns: its length in secondsconst method Time(): float64: The seconds played since its start. Returns: the seconds played since its startconst method SampleRate(): int32: Its sound's sample rate in Hz (0: no sound). Returns: its sound's sample rate in Hz (0: no sound)const method Width(): int32: Its frame width in pixels. Returns: its frame width in pixelsconst method Height(): int32: Its frame height in pixels. Returns: its frame height in pixels
Example: LIntro := VideoRes("res/assets/videos/intro.mpg").Looping(true).Play(); ... LIntro.Update(); Draw.Video(LIntro, Vector2(x: 0, y: 0), WHITE);
AutomationRes
type AutomationRes = object
An automation event list: the input events of each frame recorded into it (the list in use, Use) and played back one by one, saved to and loaded from raylib's .rae text. A shared handle: a copy shares the events, the last copy unloads them; the list in use is kept alive until another is used. C: UnloadAutomationEventList (the last copy's release)
Members
init(): An empty handle (holds nothing:IsValid()false, its changes do nothing).init(const ACapacity: int32): A list with room forACapacityevents, none recorded yet (raylib's own empty list, LoadAutomationEventList(NULL), has room for its MAX_AUTOMATION_EVENTS). Holds nothing for a capacity below 1. C: LoadAutomationEventList Parameters:ACapacityhow many events it can record.init(const APath: string): Loads the .rae events atAPath(from the mounted source). A missing or bad file gives an empty list with raylib's room (Count 0), raylib's rule. C: LoadAutomationEventList Parameters:APaththe file's path.static method Adopt(const AList: AutomationEventList): AutomationRes: Takes the .C listAListover: unloaded with the last copy. Parameters:AListthe list. Returns: the newAutomationResstatic method FromIO(const AIO: IO): AutomationRes: Loads .rae events fromAIO(the IO stays the caller's; nil gives raylib's empty list). Parameters:AIOthe IO. Returns: the newAutomationResconst method IsValid(): bool: True when it holds a list (its room for events). Returns:truewhen it holds a list (its room for events)const method Handle(): AutomationEventList: The .C list (borrowed, for .C calls; an empty one when none is held). Returns: the .C list (borrowed, for .C calls; an empty one when none is held)method Use(): Makes it the list raylib records into (kept alive while it is the one in use, until another is used). C: SetAutomationEventListstatic method BaseFrame(const AFrame: int32): The frame recording counts from (frame numbers are relative to it). C: SetAutomationEventBaseFrame Parameters:AFramethe frame.static method StartRecording(): Starts recording each frame's input events into the list in use (nothing when no list is: raylib would record into none). C: StartAutomationEventRecordingstatic method StopRecording(): Stops recording. C: StopAutomationEventRecordingconst method Count(): int32: How many events it holds (recording adds to it). Returns: how many events it holds (recording adds to it)const method Event(const AIndex: int32): AutomationEvent: EventAIndex(0 to Count() - 1; an empty one outside). Parameters:AIndexthe index, from 0. Returns: eventAIndex(0 to Count() - 1; an empty one outside)static method Play(const AEvent: AutomationEvent): PlaysAEventback: raylib takes it as that frame's input. C: PlayAutomationEvent Parameters:AEventthe event. Example:if LRun.Event(LNext).frame = LFrame then AutomationRes.Play(LRun.Event(LNext)); end;const method Export(const APath: string): bool: Saves the events toAPathas .rae text; false when it holds none or the write fails. C: ExportAutomationEventList Parameters:APaththe file's path. Returns:truewhen the file was written
Example: LRun: AutomationRes(4096); LRun.Use(); AutomationRes.StartRecording();
VRStereoRes
type VRStereoRes = object
A VR stereo config: the projections, view offsets and lens values raylib computes for a headset, drawn through between Begin and End (a stereo pair, one half per eye; raylib's pattern draws it into a render texture, then through a lens distortion shader set from Handle()'s values). A shared handle: a copy shares it. C: UnloadVrStereoConfig (the last copy's release)
Members
init(): An empty handle (holds nothing:IsValid()false, its Begin does nothing).init(const ADevice: VrDeviceInfo): The config for the headsetADevice. C: LoadVrStereoConfig Parameters:ADevicethe device.const method IsValid(): bool: True when it holds a config. Returns:truewhen it holds a configconst method Handle(): VrStereoConfig: The .C config (a copy, for .C calls and the distortion shader's values; an empty one when none is held). Returns: the .C config (a copy, for .C calls and the distortion shader's values; an empty one when none is held)const method Begin(): Drawing renders the stereo pair through this config until End. C: BeginVrStereoModestatic method End(): Ends Begin: drawing is single again. C: EndVrStereoMode
Example: LVR: VRStereoRes(LDevice); Draw.BeginTexture(LTarget); LVR.Begin(); Draw.Begin3D(LCam); Draw.Grid(10, 1.0f); Draw.End3D(); VRStereoRes.End(); Draw.EndTexture();
Dropped
type Dropped = object
The files dropped on the window: raylib keeps the last drop until it is read.
Members
static method Any(): bool: True when files were dropped since the last Files(). C: IsFileDropped Returns:truewhen files were dropped since the last Files()static method Files(): array of string: The paths of the files dropped (empty when none were), clearing the drop. C: LoadDroppedFiles / UnloadDroppedFiles Returns: the paths of the files dropped (empty when none were), clearing the drop
Example: if Dropped.Any() then for LPath in Dropped.Files() do Load(LPath); end; end;
LogHandler
type LogHandler = ref func(const ALevel: LogLevel; const AText: string)
The routine Log.Handler hands raylib's trace log to: each line's level and its text, formatted (a closure, so it may hold what it writes to).
Example: Log.Handler(func(const ALevel: LogLevel; const AText: string) begin LLines.Add(AText); end);
WindowConfig
type WindowConfig = object
A frame window's settings, built fluently: every method returns the config, Open opens the window. Start one with Window.Config().
Members
init(): raylib's defaults: an 800 x 450 base, no title, no flags (the frame window is always resizable), zoom 1, a white frame with black bars, no target frame rate, Escape closes itmethod Size(const ABaseWidth: int32; const ABaseHeight: int32): self: The base (virtual) size everything is drawn in. Parameters:ABaseWidththe base width, more than 0;ABaseHeightthe base height, more than 0. Returns: this object, so calls chainmethod Title(const AText: string): self: The window's title. Parameters:ATextthe text. Returns: this object, so calls chainmethod Flags(const AFlags: WindowFlags): self: raylib's window flags, set before the window opens. C: SetConfigFlags Parameters:AFlagsthe flags. Returns: this object, so calls chain Example:Window.Config().Flags([WindowFlag.VSyncHint, WindowFlag.Msaa4xHint])method Zoom(const AZoom: float32): self: The window's normal size: base x AZoom x the monitor's scale. Parameters:AZoomthe zoom. Returns: this object, so calls chainmethod IntegerScale(const AOn: bool): self: The letterbox kept a whole multiple of the base size (pixel art). C: SetFrameIntegerScale Parameters:AOntrueto turn it on,falseto turn it off. Returns: this object, so calls chainmethod Color(const AColor: Color): self: The colour the frame is cleared to each BeginFrame. Parameters:AColorthe colour. Returns: this object, so calls chainmethod BarColor(const AColor: Color): self: The colour of the bars outside the frame. Parameters:AColorthe colour. Returns: this object, so calls chainmethod TargetFPS(const AFPS: int32): self: The frame rate EndFrame waits for (0: no wait). C: SetTargetFPS Parameters:AFPSthe FPS. Returns: this object, so calls chainmethod ExitKey(const AKey: Key): self: The key that closes the window (Key.Null: none). C: SetExitKey Parameters:AKeythe key. Returns: this object, so calls chainmethod MinSize(const AWidth: int32; const AHeight: int32): self: The smallest size the window may be resized to, in window units. C: SetWindowMinSize Parameters:AWidththe width;AHeightthe height. Returns: this object, so calls chainmethod MaxSize(const AWidth: int32; const AHeight: int32): self: The largest size the window may be resized to, in window units. C: SetWindowMaxSize Parameters:AWidththe width;AHeightthe height. Returns: this object, so calls chainmethod Icon(const AImage: ImageRes): self: The window's icon, set as it opens (R8G8B8A8; the @exeicon icon otherwise). C: SetWindowIcon Parameters:AImagethe image. Returns: this object, so calls chainmethod Icons(const AImages: array of ImageRes): self: The window's icons, sizes the OS picks from, set as it opens (each R8G8B8A8; none: the @exeicon icon). C: SetWindowIcons Parameters:AImagesthe images. Returns: this object, so calls chainconst method Open(): Window: Opens the frame window with these settings (InitFrameWindow):Ready()is false on the Window when it could not open (a base size of 0 or less, a raylib window already open, or raylib could not make one). Returns: the window: the last copy of it closes it
Example: LWin := Window.Config().Size(800, 450).Title("Game").TargetFPS(60).Open();
Window
type Window = object
The frame window (raylib's one window per program): a base (virtual) size drawn DPI-scaled and letterboxed, in base units between BeginFrame and EndFrame. A copy shares the window; the last copy's done closes it. C: InitWindow (WindowConfig.Open, init) / CloseWindow (the last copy's done)
Members
init(): The frame window open now, if any (Ready()false when none is): what WindowConfig.Open gives.init(const ABaseWidth: int32; const ABaseHeight: int32; const ATitle: string): Opens the frame window at a base size of ABaseWidth x ABaseHeight (InitFrameWindow, the frame's settings as they are): the short form ofWindow.Config()...Open(). Parameters:ABaseWidththe base width, more than 0;ABaseHeightthe base height, more than 0;ATitlethe window's title.copy(const ASource: Window): One more hold on the same window: it stays open while any copy is held. Parameters:ASourcethe window value copied.done: Lets this hold go: the last one closes the window.static method Config(): WindowConfig: A window's settings with raylib's defaults, to build fluently. Returns: a window's settings with raylib's defaults, to build fluently Example:LWin := Window.Config().Size(320, 180).Zoom(3.0f).IntegerScale(true).Open();const method Running(): bool: True while the window is open and not asked to close (its close button, the exit key): the loop's condition. C: not WindowShouldClose (events are polled by EndFrame) Returns:truewhile the window is open and not asked to close (its close button, the exit key): the loop's conditionmethod BeginFrame(): Begins a frame: BeginDrawing, then the frame in base units (the bars cleared, the frame filled with its colour). C: BeginDrawingmethod EndFrame(): Ends the frame and shows it (events polled, the target frame rate waited for). C: EndDrawingmethod Clear(const AColor: Color): Clears what is being drawn into to AColor: the window (inside BeginFrame / EndFrame), or a render texture between its Begin and End. C: ClearBackground Parameters:AColorthe colour.method RestoreClip(): Holds drawing to the frame again (after an EndScissorMode of the program's own).const method Ready(): bool: True while this value's window is open. C: IsWindowReady Returns:truewhile this value's window is openconst method Fullscreen(): bool: True while the window is fullscreen. C: IsWindowFullscreen Returns:truewhile the window is fullscreenconst method Hidden(): bool: True while the window is hidden. C: IsWindowHidden Returns:truewhile the window is hiddenconst method Minimized(): bool: True while the window is minimized. C: IsWindowMinimized Returns:truewhile the window is minimizedconst method Maximized(): bool: True while the window is maximized. C: IsWindowMaximized Returns:truewhile the window is maximizedconst method Focused(): bool: True while the window has the keyboard focus. C: IsWindowFocused Returns:truewhile the window has the keyboard focusconst method Resized(): bool: True when the window was resized in the last frame. C: IsWindowResized Returns:truewhen the window was resized in the last frameconst method HasFlags(const AFlags: WindowFlags): bool: True when every flag of AFlags is set on the window (an empty set: true). C: IsWindowState, each flag Parameters:AFlagsthe flags. Returns:truewhen every flag of AFlags is set on the window (an empty set: true)method SetFlags(const AFlags: WindowFlags): Sets AFlags on the open window. C: SetWindowState Parameters:AFlagsthe flags.method ClearFlags(const AFlags: WindowFlags): Clears AFlags on the open window. C: ClearWindowState Parameters:AFlagsthe flags.method ToggleFullscreen(): Exclusive fullscreen on or off (the monitor takes the window's size;Fullscreen()tells which), the frame letterboxed in it as in the window. C: ToggleFullscreenmethod ToggleBorderless(): Borderless windowed on or off: the window, undecorated, covers the monitor it is on at the desktop's own mode, the frame letterboxed in it; off, it is back at its place and size (Borderless()tells which). The frame does it itself, a move and a resize, so it stays on its own monitor on every desktop (a window manager's fullscreen can spread over every monitor). C: ToggleBorderlessWindowedconst method Borderless(): bool: True while the window is borderless (ToggleBorderless). Returns:truewhile the window is borderless (ToggleBorderless)method Maximize(): Maximizes the window (a resizable one). C: MaximizeWindowmethod Minimize(): Minimizes the window (a resizable one). C: MinimizeWindowmethod Restore(): The window back from maximized or minimized. C: RestoreWindowmethod Focus(): Gives the window the input focus. C: SetWindowFocusedmethod SetOpacity(const AOpacity: float32): The window's opacity, 0 (clear) to 1 (opaque). C: SetWindowOpacity Parameters:AOpacitythe opacity.method SetTitle(const AText: string): Sets the window's title. C: SetWindowTitle Parameters:ATextthe new title.method SetPosition(const AX: int32; const AY: int32): The window's place on the screen, in window units. C: SetWindowPosition Parameters:AXthe x coordinate;AYthe y coordinate.method SetMonitor(const AMonitor: int32): Moves the window to monitor AMonitor (Monitor.Count's range). C: SetWindowMonitor Parameters:AMonitorthe monitor's index.method SetSize(const AWidth: int32; const AHeight: int32): The window's size in window units (the frame letterboxed in it). C: SetWindowSize Parameters:AWidththe width;AHeightthe height.method SetMinSize(const AWidth: int32; const AHeight: int32): The smallest size the user can make the window. C: SetWindowMinSize Parameters:AWidththe width;AHeightthe height.method SetMaxSize(const AWidth: int32; const AHeight: int32): The largest size the user can make the window. C: SetWindowMaxSize Parameters:AWidththe width;AHeightthe height.method SetExitKey(const AKey: Key): The key that closes the window from now on (Key.Null: none, the program's own close only), as WindowConfig.ExitKey set it at the open. C: SetExitKey Parameters:AKeythe key.const method Position(): Vector2: The window's place on the screen. C: GetWindowPosition Returns: the window's place on the screenconst method ScaleDPI(): Vector2: The monitor's scale (DPI / 96 on each axis, as raylib reports it). C: GetWindowScaleDPI Returns: the monitor's scale (DPI / 96 on each axis, as raylib reports it)const method DPI(): int32: The DPI the window is shown at now (96: scale 1; 96 with no window): Windows the window's own, X11's Xft.dpi. Returns: the DPI the window is shown at now (96: scale 1; 96 with no window): Windows the window's own, X11's Xft.dpiconst method ScreenWidth(): int32: The window's width in screen coordinates. C: GetScreenWidth Returns: the widthconst method ScreenHeight(): int32: The window's height in screen coordinates. C: GetScreenHeight Returns: the heightconst method RenderWidth(): int32: The width of the framebuffer drawn to, in pixels (more than the screen width on a high-DPI screen). C: GetRenderWidth Returns: the widthconst method RenderHeight(): int32: The height of the framebuffer drawn to, in pixels (more than the screen height on a high-DPI screen). C: GetRenderHeight Returns: the heightconst method Handle(): ptr: The native window (an HWND on Windows, an X11 Window on linux), for OS calls. C: GetWindowHandle Returns: the native window (an HWND on Windows, an X11 Window on linux), for OS callsconst method Width(): int32: The base width (0 with no window). Returns: the base width (0 with no window)const method Height(): int32: The base height (0 with no window). Returns: the base height (0 with no window)const method Scale(): float32: The monitor's scale the window is sized for:DPI()/ 96 (the letterbox's own scale, window units per base unit, isCamera().zoom). Returns: the monitor's scale the window is sized for:DPI()/ 96 (the letterbox's own scale, window units per base unit, isCamera().zoom)const method Zoom(): float32: The zoom the window's normal size takes. Returns: the zoom the window's normal size takesmethod SetZoom(const AZoom: float32): A new zoom: the window takes base x AZoom x the monitor's scale. Parameters:AZoomthe zoom.const method Letterbox(): Rectangle: The frame's rectangle in the window now, in window units. Returns: the frame's rectangle in the window now, in window unitsconst method Camera(): Camera2D: The camera the frame draws through (base units into the letterbox). Returns: the camera the frame draws through (base units into the letterbox)property Color: Color read; write: The colour the frame is cleared to each BeginFrame.property BarColor: Color read; write: The colour of the bars outside the frame.property IntegerScale: bool read; write: The letterbox kept a whole multiple of the base size.method WaitEvents(const AOn: bool): Waits for an event in EndFrame instead of polling (an app that redraws only on input). C: EnableEventWaiting / DisableEventWaiting Parameters:AOntrueto turn it on,falseto turn it off.method SwapBuffers(): Shows what was drawn (a custom loop with raylib's SUPPORT_CUSTOM_FRAME_CONTROL). C: SwapScreenBuffermethod PollEvents(): Takes the input events since the last call (a custom loop with SwapBuffers: EndFrame polls them itself). C: PollInputEventsmethod Screenshot(const APath: string): Saves the window's picture as a PNG at APath. C: TakeScreenshot Parameters:APaththe file's path.const method Snapshot(): ImageRes: What the window shows so far this frame, at its real pixel size, as an image: call it between BeginFrame and EndFrame, after the drawing (raylib's pending batch is drawn first). After EndFrame the back buffer belongs to the next frame. C: LoadImageFromScreen Returns: what the window shows so far this frame, at its real pixel size, as an image: call it between BeginFrame and EndFrame, after the drawing (raylib's pending batch is drawn first)method SetIcon(const AImage: ImageRes): The window's icon (R8G8B8A8). C: SetWindowIcon Parameters:AImagethe image.method SetIcons(const AImages: array of ImageRes): The window's icons, sizes the OS picks from (each R8G8B8A8; none: raylib's default). C: SetWindowIcons Parameters:AImagesthe images.static method LetterboxRect(const AWindowWidth: int32; const AWindowHeight: int32; const ABaseWidth: int32; const ABaseHeight: int32): Rectangle: The letterbox a base size takes in a window size: the largest rectangle of the base's aspect, centred. Parameters:AWindowWidththe window width;AWindowHeightthe window height;ABaseWidththe frame's base width;ABaseHeightthe frame's base height. Returns: the letterbox a base size takes in a window size: the largest rectangle of the base's aspect, centredstatic method IntegerLetterboxRect(const AWindowWidth: int32; const AWindowHeight: int32; const ABaseWidth: int32; const ABaseHeight: int32): Rectangle: The letterbox a base size takes in a window size, a whole multiple of the base (1 at the least). Parameters:AWindowWidththe window width;AWindowHeightthe window height;ABaseWidththe frame's base width;ABaseHeightthe frame's base height. Returns: the letterbox a base size takes in a window size, a whole multiple of the base (1 at the least)static method ScaledFrameSize(const ABaseWidth: int32; const ABaseHeight: int32; const ADPI: int32): Vector2: The window size a base size opens at for a DPI (scale DPI / 96). Parameters:ABaseWidththe frame's base width;ABaseHeightthe frame's base height;ADPIthe DPI. Returns: the window size a base size opens at for a DPI (scale DPI / 96)static method FramePoint(const APoint: Vector2; const ALetterbox: Rectangle; const ABaseWidth: int32; const ABaseHeight: int32): Vector2: A window point in base units through a letterbox (clamped to the base). C: GetFramePoint Parameters:APointthe point;ALetterboxthe letterbox;ABaseWidththe frame's base width;ABaseHeightthe frame's base height. Returns: a window point in base units through a letterbox (clamped to the base)
Example: LWin: Window(800, 450, "Game"); while LWin.Running() do LWin.BeginFrame(); DrawCircle(400, 225, 50.0f, RED); LWin.EndFrame(); end;
Monitor
type Monitor = object
The monitors (raylib's numbering, 0 the first).
Members
static method Count(): int32: How many monitors are connected. C: GetMonitorCount Returns: the number of monitorsstatic method Current(): int32: The monitor the window is on. C: GetCurrentMonitor Returns: the monitor the window is onstatic method Name(const AMonitor: int32): string: The monitor's name ("" when there is none of that number). C: GetMonitorName Parameters:AMonitorthe monitor's index. Returns: the monitor's name ("" when there is none of that number)static method Position(const AMonitor: int32): Vector2: MonitorAMonitor's top-left corner on the desktop, in screen coordinates. C: GetMonitorPosition Parameters:AMonitorthe monitor's index. Returns: the cornerstatic method Width(const AMonitor: int32): int32: The monitor's current video mode's width. C: GetMonitorWidth Parameters:AMonitorthe monitor's index. Returns: the monitor's current video mode's widthstatic method Height(const AMonitor: int32): int32: The monitor's current video mode's height. C: GetMonitorHeight Parameters:AMonitorthe monitor's index. Returns: the monitor's current video mode's heightstatic method PhysicalWidth(const AMonitor: int32): int32: In millimetres. C: GetMonitorPhysicalWidth Parameters:AMonitorthe monitor's index. Returns: the width in millimetresstatic method PhysicalHeight(const AMonitor: int32): int32: In millimetres. C: GetMonitorPhysicalHeight Parameters:AMonitorthe monitor's index. Returns: the height in millimetresstatic method RefreshRate(const AMonitor: int32): int32: MonitorAMonitor's refresh rate, in hertz. C: GetMonitorRefreshRate Parameters:AMonitorthe monitor's index. Returns: the rate
Time
type Time = object
The frame clock.
Members
static method FPS(): int32: The frames per second now. C: GetFPS Returns: the frames per second nowstatic method Delta(): float32: The last frame's time in seconds. C: GetFrameTime Returns: the last frame's time in secondsstatic method Now(): float64: Seconds since the window opened. C: GetTime Returns: the seconds since the window openedstatic method SetTargetFPS(const AFPS: int32): The frame rate EndFrame waits for (0: no wait). C: SetTargetFPS Parameters:AFPSthe FPS.static method Wait(const ASeconds: float64): Waits ASeconds (raylib's precise wait). C: WaitTime Parameters:ASecondsthe time, in seconds.
Example: LPos := LPos + LVel * Time.Delta();
Clipboard
type Clipboard = object
The system clipboard (needs the window open).
Members
static method Text(): string: The clipboard's text ("" when it holds none). C: GetClipboardText Returns: the clipboard's text ("" when it holds none)static method SetText(const AText: string): PutsATexton the clipboard. C: SetClipboardText Parameters:ATextthe text.static method Image(): ImageRes: The clipboard's image (an empty one when it holds none). C: GetClipboardImage Returns: the clipboard's image (an empty one when it holds none)
Log
type Log = object
raylib's trace log.
Members
static method Level(const ALevel: LogLevel): The lowest level written (LogLevel.None: nothing). C: SetTraceLogLevel Parameters:ALevelthe level.static method Write(const ALevel: LogLevel; const AText: string): Writes AText to the log at ALevel (as is: no format). C: TraceLog Parameters:ALevelthe level;ATextthe text.static method Handler(const AHandler: LogHandler): Hands every log line, formatted, to AHandler in place of raylib's own output (nil: raylib's output again). The level filter (Level) still applies. C: SetTraceLogCallback Parameters:AHandlerthe handler.
Example: Log.Level(LogLevel.Warning);
Random
type Random = object
raylib's random numbers (one generator for the program).
Members
static method Seed(const ASeed: uint32): Seeds the generator (a run with the same seed gives the same numbers). C: SetRandomSeed Parameters:ASeedthe seed.static method Value(const ALow: int32; const AHigh: int32): int32: A number from ALow to AHigh, both included. C: GetRandomValue Parameters:ALowthe lowest number;AHighthe highest number. Returns: a number from ALow to AHigh, both includedstatic method Sequence(const ACount: int32; const ALow: int32; const AHigh: int32): array of int32: ACount numbers from ALow to AHigh with no repeat; none for a count of 0 or less or more than the range holds. C: LoadRandomSequence / UnloadRandomSequence Parameters:ACounthow many;ALowthe lowest number;AHighthe highest number. Returns: the numbers
Keyboard
type Keyboard = object
The keyboard (the window's focus).
Members
static method Pressed(const AKey: Key): bool: True in the frame AKey went down. C: IsKeyPressed Parameters:AKeythe key. Returns:truein the frame AKey went downstatic method PressedRepeat(const AKey: Key): bool: True in a frame the system repeats a held AKey. C: IsKeyPressedRepeat Parameters:AKeythe key. Returns:truein a frame the system repeats a held AKeystatic method Down(const AKey: Key): bool: True while AKey is held. C: IsKeyDown Parameters:AKeythe key. Returns:truewhile AKey is heldstatic method Released(const AKey: Key): bool: True in the frame AKey came up. C: IsKeyReleased Parameters:AKeythe key. Returns:truein the frame AKey came upstatic method Up(const AKey: Key): bool: True while AKey is not held. C: IsKeyUp Parameters:AKeythe key. Returns:truewhile AKey is not heldstatic method Next(): Key: The next key pressed this frame, from raylib's queue (Key.Null when it is empty). C: GetKeyPressed Returns: the next key pressed this frame, from raylib's queue (Key.Null when it is empty)static method NextChar(): int32: The next character typed this frame (a Unicode code point), from raylib's queue (0 when it is empty). C: GetCharPressed Returns: the next character typed this frame (a Unicode code point), from raylib's queue (0 when it is empty)static method Name(const AKey: Key): string: The character AKey types in the keyboard's layout ("" for a key that types none, Escape or an arrow). C: GetKeyName Parameters:AKeythe key. Returns: the character AKey types in the keyboard's layout ("" for a key that types none, Escape or an arrow)
Example: if Keyboard.Pressed(Key.Space) then Jump(); end;
Mouse
type Mouse = object
The mouse and its cursor.
Members
static method Pressed(const AButton: Button): bool: True in the frame AButton went down. C: IsMouseButtonPressed Parameters:AButtonthe button. Returns:truein the frame AButton went downstatic method Down(const AButton: Button): bool: True while AButton is held. C: IsMouseButtonDown Parameters:AButtonthe button. Returns:truewhile AButton is heldstatic method Released(const AButton: Button): bool: True in the frame AButton came up. C: IsMouseButtonReleased Parameters:AButtonthe button. Returns:truein the frame AButton came upstatic method Up(const AButton: Button): bool: True while AButton is not held. C: IsMouseButtonUp Parameters:AButtonthe button. Returns:truewhile AButton is not heldstatic method X(): int32: The mouse's x in window pixels. C: GetMouseX Returns: the mouse's x in window pixelsstatic method Y(): int32: The mouse's y in window pixels. C: GetMouseY Returns: the mouse's y in window pixelsstatic method Position(): Vector2: The mouse in window pixels (SetOffset / SetScale applied). C: GetMousePosition Returns: the mouse in window pixels (SetOffset / SetScale applied)static method FramePosition(): Vector2: The mouse in the frame's base units, as BeginFrame took it (clamped to the frame). Returns: the mouse in the frame's base units, as BeginFrame took it (clamped to the frame)static method Delta(): Vector2: How far the mouse moved since the last frame, in window pixels. C: GetMouseDelta Returns: how far the mouse moved since the last frame, in window pixelsstatic method Wheel(): float32: The wheel's move this frame (the larger of its two axes). C: GetMouseWheelMove Returns: the wheel's move this frame (the larger of its two axes)static method WheelV(): Vector2: The wheel's move this frame on both axes. C: GetMouseWheelMoveV Returns: the wheel's move this frame on both axesstatic method SetPosition(const AX: int32; const AY: int32): Moves the system cursor to AX, AY in window pixels. C: SetMousePosition Parameters:AXthe x coordinate;AYthe y coordinate.static method SetOffset(const AX: int32; const AY: int32): What Position adds to the cursor's place (before SetScale). C: SetMouseOffset Parameters:AXthe x coordinate;AYthe y coordinate.static method SetScale(const AX: float32; const AY: float32): What Position scales the offset cursor's place by. C: SetMouseScale Parameters:AXthe x coordinate;AYthe y coordinate.static method SetCursor(const ACursor: Cursor): The cursor's shape over the window. C: SetMouseCursor Parameters:ACursorthe cursor.static method Show(): Shows the mouse cursor. C: ShowCursorstatic method Hide(): Hides the mouse cursor. C: HideCursorstatic method Hidden(): bool: True while the cursor is hidden. C: IsCursorHidden Returns:truewhile the cursor is hiddenstatic method Enable(): The cursor shown and free again (after Disable). C: EnableCursorstatic method Disable(): The cursor hidden and held in the window (a first-person camera reads Delta). C: DisableCursorstatic method OnScreen(): bool: True while the cursor is over the window. C: IsCursorOnScreen Returns:truewhile the cursor is over the window
Example: if Mouse.Pressed(Button.Left) then Fire(Mouse.FramePosition()); end;
Gamepad
type Gamepad = object
One gamepad, by its index (0 to 3): a pad that is not there reads as nothing held.
Members
init(const AIndex: int32): The gamepad AIndex (0 to 3; any other index is never available). Parameters:AIndexthe index, from 0.const method Index(): int32: The pad's index. Returns: the pad's indexconst method Available(): bool: True while the pad is connected. C: IsGamepadAvailable Returns:truewhile the pad is connectedconst method Name(): string: The pad's name ("" when it is not there). C: GetGamepadName Returns: the pad's name ("" when it is not there)const method Pressed(const AButton: PadButton): bool: True in the frame AButton went down. C: IsGamepadButtonPressed Parameters:AButtonthe button. Returns:truein the frame AButton went downconst method Down(const AButton: PadButton): bool: True while AButton is held. C: IsGamepadButtonDown Parameters:AButtonthe button. Returns:truewhile AButton is heldconst method Released(const AButton: PadButton): bool: True in the frame AButton came up. C: IsGamepadButtonReleased Parameters:AButtonthe button. Returns:truein the frame AButton came upconst method Up(const AButton: PadButton): bool: True while AButton is not held (a pad that is not there: true). C: IsGamepadButtonUp Parameters:AButtonthe button. Returns:truewhile AButton is not held (a pad that is not there: true)static method Next(): PadButton: The last button pressed on any pad (PadButton.Unknown: none). C: GetGamepadButtonPressed Returns: the last button pressed on any pad (PadButton.Unknown: none)const method AxisCount(): int32: How many axes the pad has (0 when it is not there). C: GetGamepadAxisCount Returns: how many axes the pad has (0 when it is not there)const method Axis(const AAxis: PadAxis): float32: AAxis's place, -1 to 1 (a trigger 0 to 1 on some pads; 0 when it is not there). C: GetGamepadAxisMovement Parameters:AAxisthe axis. Returns: the axis's placemethod Vibrate(const ALeft: float32; const ARight: float32; const ASeconds: float32): Shakes the pad: the motors' strengths 0 to 1 for ASeconds. C: SetGamepadVibration Parameters:ALeftthe left motor's strength, 0 to 1;ARightthe right motor's strength, 0 to 1;ASecondsthe time, in seconds.static method Mappings(const AMappings: string): int32: Adds SDL_GameControllerDB mapping lines for pads raylib does not know; what raylib returns (1 when they were taken). C: SetGamepadMappings Parameters:AMappingsthe mappings. Returns: raylib's result (1 when the lines were taken)
Example: LPad: Gamepad(0); if LPad.Down(PadButton.RightFaceDown) then Jump(); end;
Touch
type Touch = object
Touch points and gestures (a touch screen; on a desktop the mouse's left button is touch point 0).
Members
static method X(): int32: Touch point 0's x in window pixels. C: GetTouchX Returns: touch point 0's x, in window pixelsstatic method Y(): int32: Touch point 0's y in window pixels. C: GetTouchY Returns: touch point 0's y, in window pixelsstatic method Position(const AIndex: int32): Vector2: Touch point AIndex's place in window pixels. C: GetTouchPosition Parameters:AIndexthe index, from 0. Returns: the point's place, in window pixelsstatic method PointId(const AIndex: int32): int32: Touch point AIndex's id (-1 for none). C: GetTouchPointId Parameters:AIndexthe index, from 0. Returns: the point's id (-1 for none)static method Count(): int32: How many points touch now. C: GetTouchPointCount Returns: how many points touch nowstatic method Enable(const AGestures: TouchGestures): The gestures raylib looks for (all by default). C: SetGesturesEnabled Parameters:AGesturesthe gestures.static method Detected(const AGesture: TouchGesture): bool: True when AGesture was made this frame. C: IsGestureDetected Parameters:AGesturethe gesture. Returns:truewhen AGesture was made this framestatic method Last(): TouchGestures: The gesture made last, as a set: one member, or none when there was none. C: GetGestureDetected Returns: the gesture made last, as a set: one member, or none when there was nonestatic method HoldDuration(): float32: How long the hold gesture lasts, in seconds. C: GetGestureHoldDuration Returns: how long the hold gesture lasts, in secondsstatic method DragVector(): Vector2: The drag gesture's move. C: GetGestureDragVector Returns: the drag gesture's movestatic method DragAngle(): float32: The drag gesture's angle in degrees. C: GetGestureDragAngle Returns: the drag gesture's angle in degreesstatic method PinchVector(): Vector2: The pinch gesture's move. C: GetGesturePinchVector Returns: the pinch gesture's movestatic method PinchAngle(): float32: The pinch gesture's angle in degrees. C: GetGesturePinchAngle Returns: the pinch gesture's angle in degrees
Example: Touch.Enable([TouchGesture.Tap, TouchGesture.Drag]); if Touch.Detected(TouchGesture.Tap) then Select(); end;
Draw
type Draw = object
Draws shapes, lines, text and 3D primitives, in the frame's base units (between BeginFrame and EndFrame; the 3D ones between Begin3D and End3D).
Members
static method Begin2D(const ACamera: Camera2D): Starts drawing throughACamerainside the frame (letterboxed). C: BeginMode2D Parameters:ACamerathe camera, in base units. Example:Draw.Begin2D(LCamera); Draw.Rect(LWall, GRAY); Draw.End2D();static method End2D(): Ends Begin2D: drawing is through the frame's own camera again. C: EndMode2Dstatic method Begin3D(const ACamera: Camera3D): Starts drawing a 3D scene throughACamerainside the frame (its projection at the base size's aspect, its viewport the letterbox). C: BeginMode3D Parameters:ACamerathe 3D camera. Example:Draw.Begin3D(LCamera); Draw.Grid(10, 1.0f); Draw.End3D();static method End3D(): Ends Begin3D: drawing is in base units through the frame's camera and clip again. C: EndMode3Dstatic method BeginBlend(const ABlend: Blend): Starts blending what is drawn byABlend. C: BeginBlendMode Parameters:ABlendthe blend mode. Example:Draw.BeginBlend(Blend.Additive); Draw.Circle(LSpark, 4.0f, ORANGE); Draw.EndBlend();static method EndBlend(): Ends BeginBlend: alpha blending again. C: EndBlendModestatic method BeginTexture(const ATarget: RenderTextureRes): Drawing lands inATarget, in its pixels, until EndTexture (inside a frame too: the frame comes back at EndTexture). C: BeginTextureMode Parameters:ATargetthe target. Example:Draw.BeginTexture(LCanvas); Draw.Clear(BLANK); Draw.Circle(LDot, 4.0f, RED); Draw.EndTexture();static method EndTexture(): Ends BeginTexture: drawing goes to the window (and the frame) again. C: EndTextureModestatic method BeginShader(const AShader: ShaderRes): Drawing goes throughAShaderuntil EndShader (the shader kept alive until then). C: BeginShaderMode Parameters:AShaderthe shader. Example:Draw.BeginShader(LGlow); Draw.Texture(LScene, Vector2Zero(), WHITE); Draw.EndShader();static method EndShader(): Ends BeginShader: raylib's default shader again. C: EndShaderModestatic method BeginVR(const AConfig: VRStereoRes): Drawing renders the stereo pair throughAConfiguntil EndVR. C: BeginVrStereoMode Parameters:AConfigthe config. Example:Draw.BeginTexture(LTarget); Draw.BeginVR(LVR); Draw.Begin3D(LCam); Draw.Grid(10, 1.0f); Draw.End3D(); Draw.EndVR(); Draw.EndTexture();static method EndVR(): Ends BeginVR: drawing is single again. C: EndVrStereoModestatic method ShapesTexture(const ATexture: TextureRes; const ARect: Rectangle): The texture and its partARectraylib's shapes are drawn with (kept alive while set). C: SetShapesTexture Parameters:ATexturethe texture;ARectthe rectangle.static method ShapesTexture(): TextureRes: The texture raylib's shapes are drawn with (a view: raylib's default white pixel unless ShapesTexture set one). C: GetShapesTexture Returns: the texture raylib's shapes are drawn with (a view: raylib's default white pixel unless ShapesTexture set one)static method ShapesTextureRect(): Rectangle: The part of the shapes texture raylib's shapes use. C: GetShapesTextureRectangle Returns: the part of the shapes texture raylib's shapes usestatic method BeginScissor(const ARect: Rectangle): Holds drawing toARect, in base units: inside the frame it is mapped through the frame's camera and kept within the letterbox. C: BeginScissorMode Parameters:ARectthe area drawing is held to. Example:Draw.BeginScissor(LPanel); Draw.Text(LLog, LPanel.Position(), 10.0f, WHITE); Draw.EndScissor();static method EndScissor(): Ends BeginScissor: inside the frame drawing is held to the letterbox again (the frame's clip), else nothing holds it. C: EndScissorModestatic method Pixel(const APos: Vector2; const AColor: Color): One pixel atAPos. C: DrawPixel / DrawPixelV Parameters:APosthe position;AColorthe colour.static method Line(const AStart: Vector2; const AEnd: Vector2; const AColor: Color): A line fromAStarttoAEnd. C: DrawLine / DrawLineV Parameters:AStartthe start;AEndthe end;AColorthe colour. Example:Draw.Line(LFrom, LTo, WHITE);static method Line(const AStart: Vector2; const AEnd: Vector2; const AThick: float32; const AColor: Color): A lineAThickwide. C: DrawLineEx Parameters:AStartthe start;AEndthe end;AThickthe line thickness;AColorthe colour.static method LineStrip(const APoints: array of Vector2; const AColor: Color): Lines joiningAPointsin order (nothing for fewer than two). C: DrawLineStrip Parameters:APointsthe points;AColorthe colour.static method LineBezier(const AStart: Vector2; const AEnd: Vector2; const AThick: float32; const AColor: Color): A cubic-eased curve fromAStarttoAEnd,AThickwide. C: DrawLineBezier Parameters:AStartthe start;AEndthe end;AThickthe line thickness;AColorthe colour.static method LineDashed(const AStart: Vector2; const AEnd: Vector2; const ADash: int32; const ASpace: int32; const AColor: Color): A dashed line:ADashdrawn,ASpaceleft, in turn. C: DrawLineDashed Parameters:AStartthe start;AEndthe end;ADashthe dash;ASpacethe space;AColorthe colour.static method Triangle(const AA: Vector2; const AB: Vector2; const AC: Vector2; const AColor: Color): A filled triangle (corners counter-clockwise). C: DrawTriangle Parameters:AAthe first corner;ABthe second corner;ACthe third corner;AColorthe colour.static method Triangle(const AA: Vector2; const AB: Vector2; const AC: Vector2; const AColorA: Color; const AColorB: Color; const AColorC: Color): A filled triangle shaded between its corners' colors. C: DrawTriangleGradient Parameters:AAthe first corner;ABthe second corner;ACthe third corner;AColorAthe color A;AColorBthe color B;AColorCthe color C.static method TriangleLines(const AA: Vector2; const AB: Vector2; const AC: Vector2; const AColor: Color): A triangle's outline. C: DrawTriangleLines Parameters:AAthe first corner;ABthe second corner;ACthe third corner;AColorthe colour.static method TriangleLines(const AA: Vector2; const AB: Vector2; const AC: Vector2; const AThick: float32; const AColor: Color): A triangle's outlineAThickwide. C: DrawTriangleLinesEx Parameters:AAthe first corner;ABthe second corner;ACthe third corner;AThickthe line thickness;AColorthe colour.static method TriangleFan(const APoints: array of Vector2; const AColor: Color): A triangle fan: the first point is the center (nothing for fewer than three). C: DrawTriangleFan Parameters:APointsthe points;AColorthe colour.static method TriangleStrip(const APoints: array of Vector2; const AColor: Color): A triangle strip (nothing for fewer than three points). C: DrawTriangleStrip Parameters:APointsthe points;AColorthe colour.static method Rect(const ARect: Rectangle; const AColor: Color): A filled rectangle. C: DrawRectangle / DrawRectangleV / DrawRectangleRec Parameters:ARectthe rectangle;AColorthe colour. Example:Draw.Rect(Rectangle(x: 10, y: 10, width: 100, height: 40), DARKBLUE);static method Rect(const ARect: Rectangle; const AOrigin: Vector2; const ARotation: float32; const AColor: Color): A filled rectangle turnedARotationdegrees aboutAOrigin(relative to its corner, which lands at the rectangle's x, y). C: DrawRectanglePro Parameters:ARectthe rectangle;AOriginthe origin;ARotationthe rotation;AColorthe colour.static method RectGradientV(const ARect: Rectangle; const ATop: Color; const ABottom: Color): A rectangle shaded fromATopdown toABottom. C: DrawRectangleGradientV Parameters:ARectthe rectangle;ATopthe top colour;ABottomthe bottom colour.static method RectGradientH(const ARect: Rectangle; const ALeft: Color; const ARight: Color): A rectangle shaded fromALeftacross toARight. C: DrawRectangleGradientH Parameters:ARectthe rectangle;ALeftthe left colour;ARightthe right colour.static method RectGradient(const ARect: Rectangle; const ATopLeft: Color; const ABottomLeft: Color; const ABottomRight: Color; const ATopRight: Color): A rectangle shaded between its corners' colors. C: DrawRectangleGradientEx Parameters:ATopLeftthe top-left corner's color, then bottom-left, bottom-right, top-right;ARectthe rectangle;ABottomLeftthe bottom-left corner's colour;ABottomRightthe bottom-right corner's colour;ATopRightthe top-right corner's colour.static method RectLines(const ARect: Rectangle; const AColor: Color): A rectangle's outline, one unit wide. C: DrawRectangleLines Parameters:ARectthe rectangle;AColorthe colour.static method RectLines(const ARect: Rectangle; const AThick: float32; const AColor: Color): A rectangle's outlineAThickwide, inside the rectangle. C: DrawRectangleLinesEx Parameters:ARectthe rectangle;AThickthe line thickness;AColorthe colour.static method RectRounded(const ARect: Rectangle; const ARoundness: float32; const ASegments: int32; const AColor: Color): A filled rectangle with rounded corners. C: DrawRectangleRounded Parameters:ARoundness0 (square) to 1 (the short side a half circle);ASegmentsthe segments per corner (0: raylib picks);ARectthe rectangle;AColorthe colour.static method RectRoundedLines(const ARect: Rectangle; const ARoundness: float32; const ASegments: int32; const AColor: Color): A rounded rectangle's outline. C: DrawRectangleRoundedLines Parameters:ARectthe rectangle;ARoundnessthe roundness;ASegmentshow many segments;AColorthe colour.static method RectRoundedLines(const ARect: Rectangle; const ARoundness: float32; const ASegments: int32; const AThick: float32; const AColor: Color): A rounded rectangle's outlineAThickwide. C: DrawRectangleRoundedLinesEx Parameters:ARectthe rectangle;ARoundnessthe roundness;ASegmentshow many segments;AThickthe line thickness;AColorthe colour.static method Poly(const ACenter: Vector2; const ASides: int32; const ARadius: float32; const ARotation: float32; const AColor: Color): A filled regular polygon. C: DrawPoly Parameters:ARotationdegrees;ACenterthe centre;ASideshow many sides;ARadiusthe radius;AColorthe colour.static method PolyLines(const ACenter: Vector2; const ASides: int32; const ARadius: float32; const ARotation: float32; const AColor: Color): A regular polygon's outline. C: DrawPolyLines Parameters:ACenterthe centre;ASideshow many sides;ARadiusthe radius;ARotationthe rotation;AColorthe colour.static method PolyLines(const ACenter: Vector2; const ASides: int32; const ARadius: float32; const ARotation: float32; const AThick: float32; const AColor: Color): A regular polygon's outlineAThickwide. C: DrawPolyLinesEx Parameters:ACenterthe centre;ASideshow many sides;ARadiusthe radius;ARotationthe rotation;AThickthe line thickness;AColorthe colour.static method Circle(const ACenter: Vector2; const ARadius: float32; const AColor: Color): A filled circle. C: DrawCircle / DrawCircleV Parameters:ACenterthe centre;ARadiusthe radius;AColorthe colour.static method CircleGradient(const ACenter: Vector2; const ARadius: float32; const AInner: Color; const AOuter: Color): A circle shaded fromAInnerat its center toAOuterat its edge. C: DrawCircleGradient Parameters:ACenterthe centre;ARadiusthe radius;AInnerthe colour at the centre;AOuterthe colour at the edge.static method CircleSector(const ACenter: Vector2; const ARadius: float32; const AStartAngle: float32; const AEndAngle: float32; const ASegments: int32; const AColor: Color): A filled slice of a circle, angles in degrees. C: DrawCircleSector Parameters:ASegmentsthe slice's segments (0: raylib picks);ACenterthe centre;ARadiusthe radius;AStartAnglethe start angle, in degrees;AEndAnglethe end angle, in degrees;AColorthe colour.static method CircleSectorLines(const ACenter: Vector2; const ARadius: float32; const AStartAngle: float32; const AEndAngle: float32; const ASegments: int32; const AColor: Color): A circle slice's outline. C: DrawCircleSectorLines Parameters:ACenterthe centre;ARadiusthe radius;AStartAnglethe start angle, in degrees;AEndAnglethe end angle, in degrees;ASegmentshow many segments;AColorthe colour.static method CircleSectorLines(const ACenter: Vector2; const ARadius: float32; const AStartAngle: float32; const AEndAngle: float32; const ASegments: int32; const AThick: float32; const AColor: Color): A circle slice's outlineAThickwide. C: DrawCircleSectorLinesEx Parameters:ACenterthe centre;ARadiusthe radius;AStartAnglethe start angle, in degrees;AEndAnglethe end angle, in degrees;ASegmentshow many segments;AThickthe line thickness;AColorthe colour.static method CircleLines(const ACenter: Vector2; const ARadius: float32; const AColor: Color): A circle's outline. C: DrawCircleLines / DrawCircleLinesV Parameters:ACenterthe centre;ARadiusthe radius;AColorthe colour.static method CircleLines(const ACenter: Vector2; const ARadius: float32; const AThick: float32; const AColor: Color): A circle's outlineAThickwide. C: DrawCircleLinesEx Parameters:ACenterthe centre;ARadiusthe radius;AThickthe line thickness;AColorthe colour.static method Ellipse(const ACenter: Vector2; const ARadiusH: float32; const ARadiusV: float32; const AColor: Color): A filled ellipse. C: DrawEllipse / DrawEllipseV Parameters:ACenterthe centre;ARadiusHthe horizontal radius;ARadiusVthe vertical radius;AColorthe colour.static method EllipseLines(const ACenter: Vector2; const ARadiusH: float32; const ARadiusV: float32; const AColor: Color): An ellipse's outline. C: DrawEllipseLines / DrawEllipseLinesV Parameters:ACenterthe centre;ARadiusHthe horizontal radius;ARadiusVthe vertical radius;AColorthe colour.static method EllipseLines(const ACenter: Vector2; const ARadiusH: float32; const ARadiusV: float32; const AThick: float32; const AColor: Color): An ellipse's outlineAThickwide. C: DrawEllipseLinesEx Parameters:ACenterthe centre;ARadiusHthe horizontal radius;ARadiusVthe vertical radius;AThickthe line thickness;AColorthe colour.static method Ring(const ACenter: Vector2; const AInner: float32; const AOuter: float32; const AStartAngle: float32; const AEndAngle: float32; const ASegments: int32; const AColor: Color): A filled ring (or a slice of one), angles in degrees. C: DrawRing Parameters:ACenterthe centre;AInnerthe inner radius;AOuterthe outer radius;AStartAnglethe start angle, in degrees;AEndAnglethe end angle, in degrees;ASegmentshow many segments;AColorthe colour.static method RingLines(const ACenter: Vector2; const AInner: float32; const AOuter: float32; const AStartAngle: float32; const AEndAngle: float32; const ASegments: int32; const AColor: Color): A ring's outline. C: DrawRingLines Parameters:ACenterthe centre;AInnerthe inner radius;AOuterthe outer radius;AStartAnglethe start angle, in degrees;AEndAnglethe end angle, in degrees;ASegmentshow many segments;AColorthe colour.static method RingLines(const ACenter: Vector2; const AInner: float32; const AOuter: float32; const AStartAngle: float32; const AEndAngle: float32; const ASegments: int32; const AThick: float32; const AColor: Color): A ring's outlineAThickwide. C: DrawRingLinesEx Parameters:ACenterthe centre;AInnerthe inner radius;AOuterthe outer radius;AStartAnglethe start angle, in degrees;AEndAnglethe end angle, in degrees;ASegmentshow many segments;AThickthe line thickness;AColorthe colour.static method SplineLinear(const APoints: array of Vector2; const AThick: float32; const AColor: Color): Straight lines throughAPoints,AThickwide (nothing for fewer than two). C: DrawSplineLinear Parameters:APointsthe points;AThickthe line thickness;AColorthe colour.static method SplineBasis(const APoints: array of Vector2; const AThick: float32; const AColor: Color): A B-spline overAPoints(at least four). C: DrawSplineBasis Parameters:APointsthe points;AThickthe line thickness;AColorthe colour.static method SplineCatmullRom(const APoints: array of Vector2; const AThick: float32; const AColor: Color): A Catmull-Rom spline throughAPoints(at least four). C: DrawSplineCatmullRom Parameters:APointsthe points;AThickthe line thickness;AColorthe colour.static method SplineBezierQuadratic(const APoints: array of Vector2; const AThick: float32; const AColor: Color): Quadratic Bezier pieces: point, control, point, control, .. point. C: DrawSplineBezierQuadratic Parameters:APointsthe points;AThickthe line thickness;AColorthe colour.static method SplineBezierCubic(const APoints: array of Vector2; const AThick: float32; const AColor: Color): Cubic Bezier pieces: point, control, control, point, control, control, .. point. C: DrawSplineBezierCubic Parameters:APointsthe points;AThickthe line thickness;AColorthe colour.static method SegmentLinear(const AStart: Vector2; const AEnd: Vector2; const AThick: float32; const AColor: Color): One straight piece. C: DrawSplineSegmentLinear Parameters:AStartthe start;AEndthe end;AThickthe line thickness;AColorthe colour.static method SegmentBasis(const AP1: Vector2; const AP2: Vector2; const AP3: Vector2; const AP4: Vector2; const AThick: float32; const AColor: Color): One B-spline piece over four points. C: DrawSplineSegmentBasis Parameters:AP1the first point;AP2the second point;AP3the third point;AP4the fourth point;AThickthe line thickness;AColorthe colour.static method SegmentCatmullRom(const AP1: Vector2; const AP2: Vector2; const AP3: Vector2; const AP4: Vector2; const AThick: float32; const AColor: Color): One Catmull-Rom piece over four points. C: DrawSplineSegmentCatmullRom Parameters:AP1the first point;AP2the second point;AP3the third point;AP4the fourth point;AThickthe line thickness;AColorthe colour.static method SegmentBezierQuadratic(const AStart: Vector2; const AControl: Vector2; const AEnd: Vector2; const AThick: float32; const AColor: Color): One quadratic Bezier piece. C: DrawSplineSegmentBezierQuadratic Parameters:AStartthe start;AControlthe control;AEndthe end;AThickthe line thickness;AColorthe colour.static method SegmentBezierCubic(const AStart: Vector2; const AControl1: Vector2; const AControl2: Vector2; const AEnd: Vector2; const AThick: float32; const AColor: Color): One cubic Bezier piece. C: DrawSplineSegmentBezierCubic Parameters:AStartthe start;AControl1the first control point;AControl2the second control point;AEndthe end;AThickthe line thickness;AColorthe colour.static method Text(const AText: string; const APos: Vector2; const ASize: float32; const AColor: Color):ATextin raylib's default font,ASizeunits high (10 at least, as raylib's DrawText). C: DrawText Parameters:ATextthe text;APosthe position;ASizethe size;AColorthe colour. Example:Draw.Text("Game Over", Vector2(x: 8, y: 8), 20.0f, WHITE);static method FPS(const APos: Vector2): The frames per second, in green (orange, red as it drops). C: DrawFPS Parameters:APosthe position.static method Texture(const ATexture: TextureRes; const APos: Vector2; const ATint: Color):ATextureatAPos, multiplied byATint. C: DrawTexture / DrawTextureV Parameters:ATexturethe texture;APosthe position;ATintthe tint colour. Example:Draw.Texture(LHero, LHeroPos, WHITE);static method Texture(const ATexture: TextureRes; const APos: Vector2; const ARotation: float32; const AScale: float32; const ATint: Color):ATextureturnedARotationdegrees about its corner and scaled byAScale. C: DrawTextureEx Parameters:ATexturethe texture;APosthe position;ARotationthe rotation;AScalethe scale;ATintthe tint colour.static method Texture(const ATexture: TextureRes; const ASource: Rectangle; const APos: Vector2; const ATint: Color): The partASourceofATextureatAPos(a negative width or height flips it). C: DrawTextureRec Parameters:ATexturethe texture;ASourcethe source;APosthe position;ATintthe tint colour.static method Texture(const ATexture: TextureRes; const ASource: Rectangle; const ADest: Rectangle; const AOrigin: Vector2; const ARotation: float32; const ATint: Color): The partASourceofATexturescaled intoADest, turnedARotationdegrees aboutAOrigin(from the destination's corner). C: DrawTexturePro Parameters:ATexturethe texture;ASourcethe source;ADestthe rectangle drawn into;AOriginthe origin;ARotationthe rotation;ATintthe tint colour.static method Texture(const ATarget: RenderTextureRes; const APos: Vector2; const ATint: Color):ATarget's picture atAPos, the right way up. C: DrawTextureRec (rows flipped) Parameters:ATargetthe target;APosthe position;ATintthe tint colour.static method Texture(const ATarget: RenderTextureRes; const APos: Vector2; const ARotation: float32; const AScale: float32; const ATint: Color):ATarget's picture the right way up, turnedARotationdegrees about its corner and scaled byAScale. C: DrawTexturePro (rows flipped) Parameters:ATargetthe target;APosthe position;ARotationthe rotation;AScalethe scale;ATintthe tint colour.static method Texture(const ATarget: RenderTextureRes; const ASource: Rectangle; const APos: Vector2; const ATint: Color): The partASourceofATarget's picture (in its pixels, top-down) atAPos, the right way up. C: DrawTextureRec (rows flipped) Parameters:ATargetthe target;ASourcethe source;APosthe position;ATintthe tint colour.static method Texture(const ATarget: RenderTextureRes; const ASource: Rectangle; const ADest: Rectangle; const AOrigin: Vector2; const ARotation: float32; const ATint: Color): The partASourceofATarget's picture scaled intoADest, the right way up, turnedARotationdegrees aboutAOrigin. C: DrawTexturePro (rows flipped) Parameters:ATargetthe target;ASourcethe source;ADestthe rectangle drawn into;AOriginthe origin;ARotationthe rotation;ATintthe tint colour. Example:Draw.Texture(LCanvas, Rectangle(x: 0, y: 0, width: 160, height: 90), Rectangle(x: 0, y: 0, width: 320, height: 180), Vector2(x: 0, y: 0), 0.0f, WHITE);static method Video(const AVideo: VideoRes; const APos: Vector2; const ATint: Color):AVideo's frame atAPos(nothing before its first frame). Parameters:AVideothe video;APosthe position;ATintthe tint colour. Example:LIntro.Update(); Draw.Video(LIntro, Vector2(x: 0.0f, y: 0.0f), WHITE);static method Video(const AVideo: VideoRes; const APos: Vector2; const ARotation: float32; const AScale: float32; const ATint: Color):AVideo's frame turnedARotationdegrees about its corner and scaled byAScale. Parameters:AVideothe video;APosthe position;ARotationthe rotation;AScalethe scale;ATintthe tint colour.static method Video(const AVideo: VideoRes; const ASource: Rectangle; const APos: Vector2; const ATint: Color): The partASource(in its pixels) ofAVideo's frame atAPos. Parameters:AVideothe video;ASourcethe source;APosthe position;ATintthe tint colour.static method Video(const AVideo: VideoRes; const ASource: Rectangle; const ADest: Rectangle; const AOrigin: Vector2; const ARotation: float32; const ATint: Color): The partASourceofAVideo's frame scaled intoADest, turnedARotationdegrees aboutAOrigin(from the destination's corner). Parameters:AVideothe video;ASourcethe source;ADestthe rectangle drawn into;AOriginthe origin;ARotationthe rotation;ATintthe tint colour. Example:Draw.Video(LIntro, Rectangle(x: 0, y: 0, width: 320, height: 180), Rectangle(x: 0, y: 0, width: 640, height: 360), Vector2(x: 0, y: 0), 0.0f, WHITE);static method NPatch(const ATexture: TextureRes; const AInfo: NPatchInfo; const ADest: Rectangle; const AOrigin: Vector2; const ARotation: float32; const ATint: Color):ATexturestretched intoADestbyAInfo(a 9-patch or 3-patch: the corners kept, the edges and middle stretched), turnedARotationdegrees aboutAOrigin. C: DrawTextureNPatch Parameters:ATexturethe texture;AInfothe info;ADestthe rectangle drawn into;AOriginthe origin;ARotationthe rotation;ATintthe tint colour.static method Text(const AFont: FontRes; const AText: string; const APos: Vector2; const ASize: float32; const ASpacing: float32; const ATint: Color):ATextinAFontatASize,ASpacingbetween glyphs. C: DrawTextEx Parameters:AFontthe font;ATextthe text;APosthe position;ASizethe size;ASpacingthe spacing;ATintthe tint colour. Example:Draw.Text(LMono, "Score 100", Vector2(x: 8, y: 8), 16.0f, 1.0f, WHITE);static method Text(const AFont: FontRes; const AText: string; const APos: Vector2; const AOrigin: Vector2; const ARotation: float32; const ASize: float32; const ASpacing: float32; const ATint: Color):ATextinAFontturnedARotationdegrees aboutAOrigin. C: DrawTextPro Parameters:AFontthe font;ATextthe text;APosthe position;AOriginthe origin;ARotationthe rotation;ASizethe size;ASpacingthe spacing;ATintthe tint colour.static method Codepoint(const AFont: FontRes; const ACodepoint: int32; const APos: Vector2; const ASize: float32; const ATint: Color): One codepoint's glyph inAFont. C: DrawTextCodepoint Parameters:AFontthe font;ACodepointthe codepoint;APosthe position;ASizethe size;ATintthe tint colour.static method Codepoints(const AFont: FontRes; const ACodepoints: array of int32; const APos: Vector2; const ASize: float32; const ASpacing: float32; const ATint: Color): The glyphs ofACodepointsinAFont(nothing for none). C: DrawTextCodepoints Parameters:AFontthe font;ACodepointsthe codepoints;APosthe position;ASizethe size;ASpacingthe spacing;ATintthe tint colour.static method Line3D(const AStart: Vector3; const AEnd: Vector3; const AColor: Color): A 3D line. C: DrawLine3D Parameters:AStartthe start;AEndthe end;AColorthe colour.static method Point3D(const APos: Vector3; const AColor: Color): A 3D point. C: DrawPoint3D Parameters:APosthe position;AColorthe colour.static method Circle3D(const ACenter: Vector3; const ARadius: float32; const AAxis: Vector3; const AAngle: float32; const AColor: Color): A circle turnedAAngledegrees aboutAAxis. C: DrawCircle3D Parameters:ACenterthe centre;ARadiusthe radius;AAxisthe axis;AAnglethe angle;AColorthe colour.static method Triangle3D(const AA: Vector3; const AB: Vector3; const AC: Vector3; const AColor: Color): A filled 3D triangle (corners counter-clockwise). C: DrawTriangle3D Parameters:AAthe first corner;ABthe second corner;ACthe third corner;AColorthe colour.static method TriangleStrip3D(const APoints: array of Vector3; const AColor: Color): A 3D triangle strip (nothing for fewer than three points). C: DrawTriangleStrip3D Parameters:APointsthe points;AColorthe colour.static method Cube(const APos: Vector3; const ASize: Vector3; const AColor: Color): A filled box centered atAPos. C: DrawCube / DrawCubeV Parameters:ASizeits width, height and length;APosthe position;AColorthe colour.static method CubeWires(const APos: Vector3; const ASize: Vector3; const AColor: Color): A box's edges. C: DrawCubeWires / DrawCubeWiresV Parameters:APosthe position;ASizethe size;AColorthe colour.static method Sphere(const ACenter: Vector3; const ARadius: float32; const AColor: Color): A filled sphere. C: DrawSphere Parameters:ACenterthe centre;ARadiusthe radius;AColorthe colour.static method Sphere(const ACenter: Vector3; const ARadius: float32; const ARings: int32; const ASlices: int32; const AColor: Color): A filled sphere ofARingsrings andASlicesslices. C: DrawSphereEx Parameters:ACenterthe centre;ARadiusthe radius;ARingshow many rings;ASliceshow many slices;AColorthe colour.static method SphereWires(const ACenter: Vector3; const ARadius: float32; const ARings: int32; const ASlices: int32; const AColor: Color): A sphere's wires. C: DrawSphereWires Parameters:ACenterthe centre;ARadiusthe radius;ARingshow many rings;ASliceshow many slices;AColorthe colour.static method Cylinder(const APos: Vector3; const ARadiusTop: float32; const ARadiusBottom: float32; const AHeight: float32; const ASides: int32; const AColor: Color): A filled cylinder (a cone when a radius is 0) standing onAPos. C: DrawCylinder Parameters:APosthe position;ARadiusTopthe radius top;ARadiusBottomthe radius bottom;AHeightthe height;ASideshow many sides;AColorthe colour.static method Cylinder(const AStart: Vector3; const AEnd: Vector3; const AStartRadius: float32; const AEndRadius: float32; const ASides: int32; const AColor: Color): A filled cylinder fromAStarttoAEnd. C: DrawCylinderEx Parameters:AStartthe start;AEndthe end;AStartRadiusthe start radius;AEndRadiusthe end radius;ASideshow many sides;AColorthe colour.static method CylinderWires(const APos: Vector3; const ARadiusTop: float32; const ARadiusBottom: float32; const AHeight: float32; const ASides: int32; const AColor: Color): A cylinder's wires, standing onAPos. C: DrawCylinderWires Parameters:APosthe position;ARadiusTopthe radius top;ARadiusBottomthe radius bottom;AHeightthe height;ASideshow many sides;AColorthe colour.static method CylinderWires(const AStart: Vector3; const AEnd: Vector3; const AStartRadius: float32; const AEndRadius: float32; const ASides: int32; const AColor: Color): A cylinder's wires fromAStarttoAEnd. C: DrawCylinderWiresEx Parameters:AStartthe start;AEndthe end;AStartRadiusthe start radius;AEndRadiusthe end radius;ASideshow many sides;AColorthe colour.static method Capsule(const AStart: Vector3; const AEnd: Vector3; const ARadius: float32; const ASlices: int32; const ARings: int32; const AColor: Color): A filled capsule fromAStarttoAEnd. C: DrawCapsule Parameters:AStartthe start;AEndthe end;ARadiusthe radius;ASliceshow many slices;ARingshow many rings;AColorthe colour.static method CapsuleWires(const AStart: Vector3; const AEnd: Vector3; const ARadius: float32; const ASlices: int32; const ARings: int32; const AColor: Color): A capsule's wires. C: DrawCapsuleWires Parameters:AStartthe start;AEndthe end;ARadiusthe radius;ASliceshow many slices;ARingshow many rings;AColorthe colour.static method Plane(const ACenter: Vector3; const ASize: Vector2; const AColor: Color): A flat plane on the XZ axes. C: DrawPlane Parameters:ACenterthe centre;ASizethe size;AColorthe colour.static method Ray(const ARay: Ray; const AColor: Color): A ray as a line from its position along its direction. C: DrawRay Parameters:ARaythe ray;AColorthe colour.static method Grid(const ASlices: int32; const ASpacing: float32): A grid on the XZ plane centered on the origin. C: DrawGrid Parameters:ASlicesthe lines each way;ASpacingthe spacing.static method Box(const ABox: BoundingBox; const AColor: Color): A bounding box's edges. C: DrawBoundingBox Parameters:ABoxthe box;AColorthe colour.static method Billboard(const ACamera: Camera3D; const ATexture: TextureRes; const APos: Vector3; const AScale: float32; const ATint: Color):ATexturefacingACameraatAPos,AScaleunits high. C: DrawBillboard Parameters:ACamerathe camera;ATexturethe texture;APosthe position;AScalethe scale;ATintthe tint colour.static method Billboard(const ACamera: Camera3D; const ATexture: TextureRes; const ASource: Rectangle; const APos: Vector3; const ASize: Vector2; const ATint: Color): The partASourceofATexturefacingACamera,ASizeunits. C: DrawBillboardRec Parameters:ACamerathe camera;ATexturethe texture;ASourcethe source;APosthe position;ASizethe size;ATintthe tint colour.static method Billboard(const ACamera: Camera3D; const ATexture: TextureRes; const ASource: Rectangle; const APos: Vector3; const AUp: Vector3; const ASize: Vector2; const AOrigin: Vector2; const ARotation: float32; const ATint: Color): The partASourceofATexturefacingACamerawithAUpas its up, turnedARotationdegrees aboutAOrigin. C: DrawBillboardPro Parameters:ACamerathe camera;ATexturethe texture;ASourcethe source;APosthe position;AUpthe up direction;ASizethe size;AOriginthe origin;ARotationthe rotation;ATintthe tint colour.
Example: Draw.Circle(Vector2(x: 160, y: 90), 20.0f, RED);
Spline
type Spline = object
A point on a spline: AT runs 0 to 1 along it. C: GetSplinePoint*
Members
static method Linear(const AStart: Vector2; const AEnd: Vector2; const AT: float32): Vector2: On a straight piece. C: GetSplinePointLinear Parameters:AStartthe start;AEndthe end;AThow far along, 0 to 1. Returns: the pointATof the way along the piecestatic method Basis(const AP1: Vector2; const AP2: Vector2; const AP3: Vector2; const AP4: Vector2; const AT: float32): Vector2: On a B-spline piece. C: GetSplinePointBasis Parameters:AP1the first point;AP2the second point;AP3the third point;AP4the fourth point;AThow far along, 0 to 1. Returns: the pointATof the way along the piecestatic method CatmullRom(const AP1: Vector2; const AP2: Vector2; const AP3: Vector2; const AP4: Vector2; const AT: float32): Vector2: On a Catmull-Rom piece (AP2 at 0, AP3 at 1). C: GetSplinePointCatmullRom Parameters:AP1the first point;AP2the second point;AP3the third point;AP4the fourth point;AThow far along, 0 to 1. Returns: the pointATof the way along the piecestatic method BezierQuadratic(const AStart: Vector2; const AControl: Vector2; const AEnd: Vector2; const AT: float32): Vector2: On a quadratic Bezier piece. C: GetSplinePointBezierQuadratic Parameters:AStartthe start;AControlthe control;AEndthe end;AThow far along, 0 to 1. Returns: the pointATof the way along the piecestatic method BezierCubic(const AStart: Vector2; const AControl1: Vector2; const AControl2: Vector2; const AEnd: Vector2; const AT: float32): Vector2: On a cubic Bezier piece. C: GetSplinePointBezierCubic Parameters:AStartthe start;AControl1the first control point;AControl2the second control point;AEndthe end;AThow far along, 0 to 1. Returns: the pointATof the way along the piece
Example: LShip := Spline.CatmullRom(LP1, LP2, LP3, LP4, LTime);
GLVersion
type GLVersion = choices(
The GL raylib runs on, rlgl's rlGlVersion values.
Members
GLVersion.Software: Software rendering. C: RL_OPENGL_SOFTWAREGLVersion.OpenGL11: OpenGL 1.1. C: RL_OPENGL_11GLVersion.OpenGL21: OpenGL 2.1 (GLSL 120). C: RL_OPENGL_21GLVersion.OpenGL33: OpenGL 3.3 (GLSL 330). C: RL_OPENGL_33GLVersion.OpenGL43: OpenGL 4.3 (using GLSL 330). C: RL_OPENGL_43GLVersion.OpenGLES20: OpenGL ES 2.0 (GLSL 100). C: RL_OPENGL_ES_20GLVersion.OpenGLES30: OpenGL ES 3.0 (GLSL 300 es). C: RL_OPENGL_ES_30
GLCull
type GLCull = choices(
The faces culled, rlgl's rlCullMode values.
Members
GLCull.Front: The front faces. C: RL_CULL_FACE_FRONTGLCull.Back: The back faces. C: RL_CULL_FACE_BACK
GLAttachType
type GLAttachType = choices(
A framebuffer attachment point, rlgl's rlFramebufferAttachType values.
Members
GLAttachType.Color0: Framebuffer attachment type: color 0. C: RL_ATTACHMENT_COLOR_CHANNEL0GLAttachType.Color1: Framebuffer attachment type: color 1. C: RL_ATTACHMENT_COLOR_CHANNEL1GLAttachType.Color2: Framebuffer attachment type: color 2. C: RL_ATTACHMENT_COLOR_CHANNEL2GLAttachType.Color3: Framebuffer attachment type: color 3. C: RL_ATTACHMENT_COLOR_CHANNEL3GLAttachType.Color4: Framebuffer attachment type: color 4. C: RL_ATTACHMENT_COLOR_CHANNEL4GLAttachType.Color5: Framebuffer attachment type: color 5. C: RL_ATTACHMENT_COLOR_CHANNEL5GLAttachType.Color6: Framebuffer attachment type: color 6. C: RL_ATTACHMENT_COLOR_CHANNEL6GLAttachType.Color7: Framebuffer attachment type: color 7. C: RL_ATTACHMENT_COLOR_CHANNEL7GLAttachType.Depth: Framebuffer attachment type: depth. C: RL_ATTACHMENT_DEPTHGLAttachType.Stencil: Framebuffer attachment type: stencil. C: RL_ATTACHMENT_STENCIL
GLAttachTextureType
type GLAttachTextureType = choices(
What a framebuffer attachment is, rlgl's rlFramebufferAttachTextureType values.
Members
GLAttachTextureType.CubemapPositiveX: Framebuffer texture attachment type: cubemap, +X side. C: RL_ATTACHMENT_CUBEMAP_POSITIVE_XGLAttachTextureType.CubemapNegativeX: Framebuffer texture attachment type: cubemap, -X side. C: RL_ATTACHMENT_CUBEMAP_NEGATIVE_XGLAttachTextureType.CubemapPositiveY: Framebuffer texture attachment type: cubemap, +Y side. C: RL_ATTACHMENT_CUBEMAP_POSITIVE_YGLAttachTextureType.CubemapNegativeY: Framebuffer texture attachment type: cubemap, -Y side. C: RL_ATTACHMENT_CUBEMAP_NEGATIVE_YGLAttachTextureType.CubemapPositiveZ: Framebuffer texture attachment type: cubemap, +Z side. C: RL_ATTACHMENT_CUBEMAP_POSITIVE_ZGLAttachTextureType.CubemapNegativeZ: Framebuffer texture attachment type: cubemap, -Z side. C: RL_ATTACHMENT_CUBEMAP_NEGATIVE_ZGLAttachTextureType.Texture2D: Framebuffer texture attachment type: texture2d. C: RL_ATTACHMENT_TEXTURE2DGLAttachTextureType.RenderBuffer: Framebuffer texture attachment type: renderbuffer. C: RL_ATTACHMENT_RENDERBUFFER
GLMatrix
type GLMatrix = choices(
The matrix stack GL's transforms change (RL_MODELVIEW, RL_PROJECTION, RL_TEXTURE).
Members
GLMatrix.Modelview: The modelview matrix (GL_MODELVIEW). C: RL_MODELVIEWGLMatrix.Projection: The projection matrix (GL_PROJECTION). C: RL_PROJECTIONGLMatrix.Texture: The texture matrix (GL_TEXTURE). C: RL_TEXTURE
GLMode
type GLMode = choices(
The primitives GL.Begin draws (RL_LINES, RL_TRIANGLES, RL_QUADS).
Members
GLMode.Lines: Lines (GL_LINES). C: RL_LINESGLMode.Triangles: Triangles (GL_TRIANGLES). C: RL_TRIANGLESGLMode.Quads: Quads (GL_QUADS). C: RL_QUADS
GLShaderType
type GLShaderType = choices(
A shader stage (RL_FRAGMENT_SHADER, RL_VERTEX_SHADER, RL_COMPUTE_SHADER).
Members
GLShaderType.Fragment: The fragment stage (GL_FRAGMENT_SHADER). C: RL_FRAGMENT_SHADERGLShaderType.Vertex: The vertex stage (GL_VERTEX_SHADER). C: RL_VERTEX_SHADERGLShaderType.Compute: The compute stage (GL_COMPUTE_SHADER). C: RL_COMPUTE_SHADER
GLUsage
type GLUsage = choices(
A GPU buffer's usage hint (RL_STREAM_DRAW ..).
Members
GLUsage.StreamDraw: Stream draw use (GL_STREAM_DRAW). C: RL_STREAM_DRAWGLUsage.StreamRead: Stream read use (GL_STREAM_READ). C: RL_STREAM_READGLUsage.StreamCopy: Stream copy use (GL_STREAM_COPY). C: RL_STREAM_COPYGLUsage.StaticDraw: Static draw use (GL_STATIC_DRAW). C: RL_STATIC_DRAWGLUsage.StaticRead: Static read use (GL_STATIC_READ). C: RL_STATIC_READGLUsage.StaticCopy: Static copy use (GL_STATIC_COPY). C: RL_STATIC_COPYGLUsage.DynamicDraw: Dynamic draw use (GL_DYNAMIC_DRAW). C: RL_DYNAMIC_DRAWGLUsage.DynamicRead: Dynamic read use (GL_DYNAMIC_READ). C: RL_DYNAMIC_READGLUsage.DynamicCopy: Dynamic copy use (GL_DYNAMIC_COPY). C: RL_DYNAMIC_COPY
GLDataType
type GLDataType = choices(
A vertex attribute's component type (RL_UNSIGNED_BYTE, RL_FLOAT).
Members
GLDataType.UnsignedByte: Unsigned byte components (GL_UNSIGNED_BYTE). C: RL_UNSIGNED_BYTEGLDataType.Float: Float components (GL_FLOAT). C: RL_FLOAT
GLTexParam
type GLTexParam = choices(
A texture parameter GL.TextureParameters / CubemapParameters sets (RL_TEXTURE_MAG_FILTER ..).
Members
GLTexParam.MagFilter: The mag filter parameter (GL_TEXTURE_MAG_FILTER). C: RL_TEXTURE_MAG_FILTERGLTexParam.MinFilter: The min filter parameter (GL_TEXTURE_MIN_FILTER). C: RL_TEXTURE_MIN_FILTERGLTexParam.WrapS: The wrap S parameter (GL_TEXTURE_WRAP_S). C: RL_TEXTURE_WRAP_SGLTexParam.WrapT: The wrap T parameter (GL_TEXTURE_WRAP_T). C: RL_TEXTURE_WRAP_TGLTexParam.Anisotropic: Anisotropic filter (custom identifier). C: RL_TEXTURE_FILTER_ANISOTROPICGLTexParam.MipmapBiasRatio: Texture mipmap bias, percentage ratio (custom identifier). C: RL_TEXTURE_MIPMAP_BIAS_RATIO
GLTexFilter
type GLTexFilter = choices(
A GL texture filter for MagFilter / MinFilter (RL_TEXTURE_FILTER_NEAREST ..).
Members
GLTexFilter.Nearest: Nearest filtering (GL_NEAREST). C: RL_TEXTURE_FILTER_NEARESTGLTexFilter.Linear: Linear filtering (GL_LINEAR). C: RL_TEXTURE_FILTER_LINEARGLTexFilter.MipNearest: Mip nearest filtering (GL_NEAREST_MIPMAP_NEAREST). C: RL_TEXTURE_FILTER_MIP_NEARESTGLTexFilter.LinearMipNearest: Linear mip nearest filtering (GL_LINEAR_MIPMAP_NEAREST). C: RL_TEXTURE_FILTER_LINEAR_MIP_NEARESTGLTexFilter.NearestMipLinear: Nearest mip linear filtering (GL_NEAREST_MIPMAP_LINEAR). C: RL_TEXTURE_FILTER_NEAREST_MIP_LINEARGLTexFilter.MipLinear: Mip linear filtering (GL_LINEAR_MIPMAP_LINEAR). C: RL_TEXTURE_FILTER_MIP_LINEAR
GLTexWrap
type GLTexWrap = choices(
A GL texture wrap for WrapS / WrapT (RL_TEXTURE_WRAP_REPEAT ..).
Members
GLTexWrap.Repeat: Repeat wrapping (GL_REPEAT). C: RL_TEXTURE_WRAP_REPEATGLTexWrap.Clamp: Clamp wrapping (GL_CLAMP_TO_EDGE). C: RL_TEXTURE_WRAP_CLAMPGLTexWrap.MirrorRepeat: Mirror repeat wrapping (GL_MIRRORED_REPEAT). C: RL_TEXTURE_WRAP_MIRROR_REPEATGLTexWrap.MirrorClamp: Mirror clamp wrapping (GL_MIRROR_CLAMP_EXT). C: RL_TEXTURE_WRAP_MIRROR_CLAMP
GLBlendFactor
type GLBlendFactor = choices(
A blend factor (RL_ZERO, RL_ONE, RL_SRC_COLOR ..).
Members
GLBlendFactor.Zero: The zero factor (GL_ZERO). C: RL_ZEROGLBlendFactor.One: The one factor (GL_ONE). C: RL_ONEGLBlendFactor.SrcColor: The src color factor (GL_SRC_COLOR). C: RL_SRC_COLORGLBlendFactor.OneMinusSrcColor: The one minus src color factor (GL_ONE_MINUS_SRC_COLOR). C: RL_ONE_MINUS_SRC_COLORGLBlendFactor.SrcAlpha: The src alpha factor (GL_SRC_ALPHA). C: RL_SRC_ALPHAGLBlendFactor.OneMinusSrcAlpha: The one minus src alpha factor (GL_ONE_MINUS_SRC_ALPHA). C: RL_ONE_MINUS_SRC_ALPHAGLBlendFactor.DstAlpha: The dst alpha factor (GL_DST_ALPHA). C: RL_DST_ALPHAGLBlendFactor.OneMinusDstAlpha: The one minus dst alpha factor (GL_ONE_MINUS_DST_ALPHA). C: RL_ONE_MINUS_DST_ALPHAGLBlendFactor.DstColor: The dst color factor (GL_DST_COLOR). C: RL_DST_COLORGLBlendFactor.OneMinusDstColor: The one minus dst color factor (GL_ONE_MINUS_DST_COLOR). C: RL_ONE_MINUS_DST_COLORGLBlendFactor.SrcAlphaSaturate: The src alpha saturate factor (GL_SRC_ALPHA_SATURATE). C: RL_SRC_ALPHA_SATURATEGLBlendFactor.ConstantColor: The constant color factor (GL_CONSTANT_COLOR). C: RL_CONSTANT_COLORGLBlendFactor.OneMinusConstantColor: The one minus constant color factor (GL_ONE_MINUS_CONSTANT_COLOR). C: RL_ONE_MINUS_CONSTANT_COLORGLBlendFactor.ConstantAlpha: The constant alpha factor (GL_CONSTANT_ALPHA). C: RL_CONSTANT_ALPHAGLBlendFactor.OneMinusConstantAlpha: The one minus constant alpha factor (GL_ONE_MINUS_CONSTANT_ALPHA). C: RL_ONE_MINUS_CONSTANT_ALPHA
GLBlendEquation
type GLBlendEquation = choices(
A blend equation (RL_FUNC_ADD, RL_MIN, RL_MAX, RL_FUNC_SUBTRACT, RL_FUNC_REVERSE_SUBTRACT).
Members
GLBlendEquation.Add: The add equation (GL_FUNC_ADD). C: RL_FUNC_ADDGLBlendEquation.Min: The min equation (GL_MIN). C: RL_MINGLBlendEquation.Max: The max equation (GL_MAX). C: RL_MAXGLBlendEquation.Subtract: The subtract equation (GL_FUNC_SUBTRACT). C: RL_FUNC_SUBTRACTGLBlendEquation.ReverseSubtract: The reverse subtract equation (GL_FUNC_REVERSE_SUBTRACT). C: RL_FUNC_REVERSE_SUBTRACT
GLFramebufferTarget
type GLFramebufferTarget = choices(
A framebuffer binding target (RL_READ_FRAMEBUFFER, RL_DRAW_FRAMEBUFFER).
Members
GLFramebufferTarget.Read: The read target (GL_READ_FRAMEBUFFER). C: RL_READ_FRAMEBUFFERGLFramebufferTarget.Draw: The draw target (GL_DRAW_FRAMEBUFFER). C: RL_DRAW_FRAMEBUFFER
GL
type GL = object
rlgl, raylib's GL layer: the matrix stack, immediate-mode vertices, GL state, render batches, vertex buffers and arrays, textures, framebuffers, shaders and compute.
Members
static method MatrixMode(const AMode: GLMatrix): The stack the transforms change. C: rlMatrixMode Parameters:AModethe mode.static method PushMatrix(): Saves the current matrix on the stack. C: rlPushMatrixstatic method PopMatrix(): Restores the matrix saved last. C: rlPopMatrixstatic method LoadIdentity(): The current matrix becomes the identity. C: rlLoadIdentitystatic method Translate(const AX: float32; const AY: float32; const AZ: float32): Moves by (AX,AY,AZ). C: rlTranslatef Parameters:AXthe x coordinate;AYthe y coordinate;AZthe z coordinate.static method Rotate(const AAngle: float32; const AX: float32; const AY: float32; const AZ: float32): TurnsAAngledegrees about the axis (AX,AY,AZ). C: rlRotatef Parameters:AAnglethe angle;AXthe x coordinate;AYthe y coordinate;AZthe z coordinate.static method Scale(const AX: float32; const AY: float32; const AZ: float32): Scales by (AX,AY,AZ). C: rlScalef Parameters:AXthe x coordinate;AYthe y coordinate;AZthe z coordinate.static method MultMatrix(const AMatrix: Matrix): Multiplies the current matrix byAMatrix. C: rlMultMatrixf Parameters:AMatrixthe matrix.static method Frustum(const ALeft: float64; const ARight: float64; const ABottom: float64; const ATop: float64; const ANear: float64; const AFar: float64): A perspective projection by its clip planes. C: rlFrustum Parameters:ALeftthe left of the view volume;ARightthe right of the view volume;ABottomthe bottom of the view volume;ATopthe top of the view volume;ANearthe near clip distance;AFarthe far clip distance.static method Ortho(const ALeft: float64; const ARight: float64; const ABottom: float64; const ATop: float64; const ANear: float64; const AFar: float64): An orthographic projection by its clip planes. C: rlOrtho Parameters:ALeftthe left of the view volume;ARightthe right of the view volume;ABottomthe bottom of the view volume;ATopthe top of the view volume;ANearthe near clip distance;AFarthe far clip distance.static method Viewport(const AX: int32; const AY: int32; const AWidth: int32; const AHeight: int32): The viewport, in framebuffer pixels. C: rlViewport Parameters:AXthe x coordinate;AYthe y coordinate;AWidththe width;AHeightthe height.static method SetClipPlanes(const ANear: float64; const AFar: float64): The near / far clip planes raylib's 3D modes project with. C: rlSetClipPlanes Parameters:ANearthe near clip distance;AFarthe far clip distance.static method GetCullDistanceNear(): float64: The near clip plane. C: rlGetCullDistanceNear Returns: the near clip planestatic method GetCullDistanceFar(): float64: The far clip plane. C: rlGetCullDistanceFar Returns: the far clip planestatic method Begin(const AMode: GLMode): Starts a primitive run: the vertices up to End makeAMode's shapes. C: rlBegin Parameters:AModethe mode.static method End(): Ends Begin's run. C: rlEndstatic method Vertex(const AX: int32; const AY: int32): A vertex at whole (AX,AY). C: rlVertex2i Parameters:AXthe x coordinate;AYthe y coordinate.static method Vertex(const AX: float32; const AY: float32): A vertex at (AX,AY). C: rlVertex2f Parameters:AXthe x coordinate;AYthe y coordinate.static method Vertex(const AX: float32; const AY: float32; const AZ: float32): A vertex at (AX,AY,AZ). C: rlVertex3f Parameters:AXthe x coordinate;AYthe y coordinate;AZthe z coordinate.static method Vertex(const APoint: Vector2): A vertex atAPoint. C: rlVertex2f Parameters:APointthe point.static method Vertex(const APoint: Vector3): A vertex atAPoint. C: rlVertex3f Parameters:APointthe point.static method TexCoord(const AX: float32; const AY: float32): The next vertices' texture coordinate. C: rlTexCoord2f Parameters:AXthe x coordinate;AYthe y coordinate.static method TexCoord(const ACoord: Vector2): The next vertices' texture coordinate. C: rlTexCoord2f Parameters:ACoordthe coord.static method Normal(const AX: float32; const AY: float32; const AZ: float32): The next vertices' normal. C: rlNormal3f Parameters:AXthe x coordinate;AYthe y coordinate;AZthe z coordinate.static method Normal(const ANormal: Vector3): The next vertices' normal. C: rlNormal3f Parameters:ANormalthe normal.static method Color(const AColor: Color): The next vertices' color. C: rlColor4ub Parameters:AColorthe colour.static method Color(const AR: float32; const AG: float32; const AB: float32): The next vertices' color, opaque, its parts 0 to 1. C: rlColor3f Parameters:ARthe red part, 0 to 1;AGthe green part, 0 to 1;ABthe blue part, 0 to 1.static method Color(const AR: float32; const AG: float32; const AB: float32; const AA: float32): The next vertices' color, its parts 0 to 1. C: rlColor4f Parameters:ARthe red part, 0 to 1;AGthe green part, 0 to 1;ABthe blue part, 0 to 1;AAthe alpha part, 0 to 1.static method EnableVertexArray(const AVaoId: uint32): bool: Binds the vertex arrayAVaoId; false when vertex arrays are not supported. C: rlEnableVertexArray Parameters:AVaoIdthe vao id. Returns:truewhen it was boundstatic method DisableVertexArray(): Unbinds the vertex array. C: rlDisableVertexArraystatic method EnableVertexBuffer(const AId: uint32): Binds the vertex bufferAId. C: rlEnableVertexBuffer Parameters:AIdthe id.static method DisableVertexBuffer(): Unbinds the vertex buffer. C: rlDisableVertexBufferstatic method EnableVertexBufferElement(const AId: uint32): Binds the element (index) bufferAId. C: rlEnableVertexBufferElement Parameters:AIdthe id.static method DisableVertexBufferElement(): Unbinds the element (index) buffer. C: rlDisableVertexBufferElementstatic method EnableVertexAttribute(const AIndex: uint32): Turns the vertex attributeAIndexon. C: rlEnableVertexAttribute Parameters:AIndexthe index, from 0.static method DisableVertexAttribute(const AIndex: uint32): Turns the vertex attributeAIndexoff. C: rlDisableVertexAttribute Parameters:AIndexthe index, from 0.static method EnableStatePointer(const AAttribType: int32; const ABuffer: ptr): GL 1.1's client state arrayAAttribType(GL_VERTEX_ARRAY ..) readingABuffer. C: rlEnableStatePointer Parameters:AAttribTypethe attrib type;ABufferthe buffer.static method DisableStatePointer(const AAttribType: int32): Turns a client state array off (OpenGL 1.1). C: rlDisableStatePointer Parameters:AAttribTypethe array's attribute type.static method LoadVertexArray(): uint32: A new vertex array's id (0 when not supported). C: rlLoadVertexArray Returns: a new vertex array's id (0 when not supported)static method LoadVertexBuffer(const ABuffer: ptr to const; const ASize: int32; const ADynamic: bool): uint32: A new vertex buffer holdingASizebytes fromABuffer(nil: room only). C: rlLoadVertexBuffer Parameters:ABufferthe buffer;ASizethe size;ADynamictruefor a buffer meant to be updated. Returns: a new vertex buffer holdingASizebytes fromABuffer(nil: room only)static method LoadVertexBufferElement(const ABuffer: ptr to const; const ASize: int32; const ADynamic: bool): uint32: A new element (index) buffer holdingASizebytes fromABuffer. C: rlLoadVertexBufferElement Parameters:ABufferthe buffer;ASizethe size;ADynamictruefor a buffer meant to be updated. Returns: a new element (index) buffer holdingASizebytes fromABufferstatic method UpdateVertexBuffer(const AId: uint32; const AData: ptr to const; const ADataSize: int32; const AOffset: int32): WritesADataSizebytes fromADatainto the vertex bufferAIdat byteAOffset. C: rlUpdateVertexBuffer Parameters:AIdthe id;ADatathe data;ADataSizethe data size;AOffsetthe offset.static method UpdateVertexBufferElements(const AId: uint32; const AData: ptr to const; const ADataSize: int32; const AOffset: int32): WritesADataSizebytes fromADatainto the element bufferAIdat byteAOffset. C: rlUpdateVertexBufferElements Parameters:AIdthe id;ADatathe data;ADataSizethe data size;AOffsetthe offset.static method UnloadVertexArray(const AVaoId: uint32): Deletes the vertex arrayAVaoId. C: rlUnloadVertexArray Parameters:AVaoIdthe vertex array's id.static method UnloadVertexBuffer(const AVboId: uint32): Deletes the vertex bufferAVboId. C: rlUnloadVertexBuffer Parameters:AVboIdthe buffer's id.static method SetVertexAttribute(const AIndex: uint32; const ACompSize: int32; const AType: GLDataType; const ANormalized: bool; const AStride: int32; const AOffset: int32): AttributeAIndexreadsACompSizecomponents ofATypeper vertex,AStridebytes apart, from byteAOffsetof the bound buffer. C: rlSetVertexAttribute Parameters:AIndexthe index, from 0;ACompSizethe comp size;ATypethe type;ANormalizedthe normalized;AStridethe stride;AOffsetthe offset.static method SetVertexAttributeDivisor(const AIndex: uint32; const ADivisor: int32): AttributeAIndexadvances once perADivisorinstances (0: per vertex). C: rlSetVertexAttributeDivisor Parameters:AIndexthe index, from 0;ADivisorthe divisor.static method SetVertexAttributeDefault(const ALocIndex: int32; const AValue: ptr to const; const AType: AttribType; const ACount: int32): The value attribute locationALocIndextakes when no buffer feeds it. C: rlSetVertexAttributeDefault Parameters:ALocIndexthe shader location;AValuethe value;ATypethe type;ACounthow many.static method DrawVertexArray(const AOffset: int32; const ACount: int32): DrawsACountvertices of the bound array fromAOffset. C: rlDrawVertexArray Parameters:AOffsetthe offset;ACounthow many.static method DrawVertexArrayElements(const AOffset: int32; const ACount: int32; const ABuffer: ptr to const): DrawsACountindexed vertices fromAOffset(ABuffer: the indices, nil for the bound element buffer). C: rlDrawVertexArrayElements Parameters:AOffsetthe offset;ACounthow many;ABufferthe buffer.static method DrawVertexArrayInstanced(const AOffset: int32; const ACount: int32; const AInstances: int32): DrawsAInstancescopies ofACountvertices fromAOffset. C: rlDrawVertexArrayInstanced Parameters:AOffsetthe offset;ACounthow many;AInstancesthe instances.static method DrawVertexArrayElementsInstanced(const AOffset: int32; const ACount: int32; const ABuffer: ptr to const; const AInstances: int32): DrawsAInstancescopies ofACountindexed vertices fromAOffset. C: rlDrawVertexArrayElementsInstanced Parameters:AOffsetthe offset;ACounthow many;ABufferthe buffer;AInstancesthe instances.static method ActiveTextureSlot(const ASlot: int32): The texture unit the next texture binds go to. C: rlActiveTextureSlot Parameters:ASlotthe slot.static method EnableTexture(const AId: uint32): Binds the textureAId. C: rlEnableTexture Parameters:AIdthe id.static method DisableTexture(): Unbinds the 2D texture. C: rlDisableTexturestatic method EnableTextureCubemap(const AId: uint32): Binds the cubemapAId. C: rlEnableTextureCubemap Parameters:AIdthe id.static method DisableTextureCubemap(): Unbinds the cubemap texture. C: rlDisableTextureCubemapstatic method TextureParameters(const AId: uint32; const AParam: GLTexParam; const AValue: int32): Sets the textureAId'sAParamtoAValue(Anisotropic: the level; MipmapBiasRatio: the bias x 100). C: rlTextureParameters Parameters:AIdthe id;AParamthe parameter;AValuethe value.static method TextureParameters(const AId: uint32; const AParam: GLTexParam; const AFilter: GLTexFilter): Sets the textureAId's MagFilter or MinFilter toAFilter. C: rlTextureParameters Parameters:AIdthe id;AParamthe parameter;AFilterthe filter.static method TextureParameters(const AId: uint32; const AParam: GLTexParam; const AWrap: GLTexWrap): Sets the textureAId's WrapS or WrapT toAWrap. C: rlTextureParameters Parameters:AIdthe id;AParamthe parameter;AWrapthe wrap mode.static method CubemapParameters(const AId: uint32; const AParam: GLTexParam; const AValue: int32): Sets the cubemapAId'sAParamtoAValue. C: rlCubemapParameters Parameters:AIdthe id;AParamthe parameter;AValuethe value.static method CubemapParameters(const AId: uint32; const AParam: GLTexParam; const AFilter: GLTexFilter): Sets the cubemapAId's MagFilter or MinFilter toAFilter. C: rlCubemapParameters Parameters:AIdthe id;AParamthe parameter;AFilterthe filter.static method CubemapParameters(const AId: uint32; const AParam: GLTexParam; const AWrap: GLTexWrap): Sets the cubemapAId's WrapS or WrapT toAWrap. C: rlCubemapParameters Parameters:AIdthe id;AParamthe parameter;AWrapthe wrap mode.static method LoadTexture(const AData: ptr to const; const AWidth: int32; const AHeight: int32; const AFormat: Pixel; const AMipmaps: int32): uint32: A new texture fromAData(nil: room only), its id (0 on a failure). C: rlLoadTexture Parameters:ADatathe data;AWidththe width;AHeightthe height;AFormatthe pixel format;AMipmapshow many mipmap levels. Returns: a new texture fromAData(nil: room only), its id (0 on a failure)static method LoadTextureDepth(const AWidth: int32; const AHeight: int32; const AUseRenderBuffer: bool): uint32: A new depth texture (or a depth render buffer). C: rlLoadTextureDepth Parameters:AWidththe width;AHeightthe height;AUseRenderBufferthe use render buffer. Returns: a new depth texture (or a depth render buffer)static method LoadTextureCubemap(const AData: ptr to const; const ASize: int32; const AFormat: Pixel; const AMipmaps: int32): uint32: A new cubemap fromAData(six faces ofASizexASize). C: rlLoadTextureCubemap Parameters:ADatathe data;ASizethe size;AFormatthe pixel format;AMipmapshow many mipmap levels. Returns: a new cubemap fromAData(six faces ofASizexASize)static method UpdateTexture(const AId: uint32; const AX: int32; const AY: int32; const AWidth: int32; const AHeight: int32; const AFormat: Pixel; const AData: ptr to const): Writes the pixelsADatainto the textureAIdat (AX,AY). C: rlUpdateTexture Parameters:AIdthe id;AXthe x coordinate;AYthe y coordinate;AWidththe width;AHeightthe height;AFormatthe pixel format;ADatathe data.static method GetGLTextureFormats(const AFormat: Pixel; var AGLInternalFormat: uint32; var AGLFormat: uint32; var AGLType: uint32): The GL internal format, format and type ofAFormat. C: rlGetGlTextureFormats Parameters:AFormatthe pixel format;AGLInternalFormatthe GL internal format;AGLFormatthe GL format;AGLTypethe GL type.static method GetPixelFormatName(const AFormat: Pixel): string:AFormat's name ("R8G8B8A8" ..). C: rlGetPixelFormatName Parameters:AFormatthe pixel format. Returns:AFormat's name ("R8G8B8A8" ..)static method UnloadTexture(const AId: uint32): Deletes the textureAIdfrom the GPU. C: rlUnloadTexture Parameters:AIdthe texture's id.static method GenTextureMipmaps(const AId: uint32; const AWidth: int32; const AHeight: int32; const AFormat: Pixel; var AMipmaps: int32): Makes the textureAId's mipmaps;AMipmapsgets how many it has. C: rlGenTextureMipmaps Parameters:AIdthe id;AWidththe width;AHeightthe height;AFormatthe pixel format;AMipmapshow many mipmap levels.static method ReadTexturePixels(const AId: uint32; const AWidth: int32; const AHeight: int32; const AFormat: Pixel): ptr: The textureAId's pixels inAFormat, in memory the program frees with MemFree (nil on a failure). C: rlReadTexturePixels Parameters:AIdthe id;AWidththe width;AHeightthe height;AFormatthe pixel format. Returns: the textureAId's pixels inAFormat, in memory the program frees with MemFree (nil on a failure)static method ReadScreenPixels(const AWidth: int32; const AHeight: int32): ptr to uint8: The screen's pixels (R8G8B8A8, top row first), in memory the program frees with MemFree. C: rlReadScreenPixels Parameters:AWidththe width;AHeightthe height. Returns: the screen's pixels (R8G8B8A8, top row first), in memory the program frees with MemFreestatic method SetTexture(const AId: uint32): Binds the textureAIdfor the next immediate-mode vertices (0: raylib's default white texture). C: rlSetTexture Parameters:AIdthe id.static method EnableFramebuffer(const AId: uint32): Binds the framebufferAId(drawing lands in it). C: rlEnableFramebuffer Parameters:AIdthe id.static method DisableFramebuffer(): Drawing lands on the screen again. C: rlDisableFramebufferstatic method GetActiveFramebuffer(): uint32: The framebuffer drawing lands in (0: the screen). C: rlGetActiveFramebuffer Returns: the framebuffer drawing lands in (0: the screen)static method ActiveDrawBuffers(const ACount: int32): How many color attachments the next draws write (1 to 8). C: rlActiveDrawBuffers Parameters:ACounthow many.static method BlitFramebuffer(const ASrcX: int32; const ASrcY: int32; const ASrcWidth: int32; const ASrcHeight: int32; const ADstX: int32; const ADstY: int32; const ADstWidth: int32; const ADstHeight: int32; const ABufferMask: int32): Copies a rectangle of the read framebuffer into the draw one;ABufferMaskis GL's buffer bits (GL_COLOR_BUFFER_BIT ..). C: rlBlitFramebuffer Parameters:ASrcXthe src X;ASrcYthe src Y;ASrcWidththe src width;ASrcHeightthe src height;ADstXthe dst X;ADstYthe dst Y;ADstWidththe dst width;ADstHeightthe dst height;ABufferMaskthe buffer mask.static method BindFramebuffer(const ATarget: GLFramebufferTarget; const AFramebuffer: uint32): Binds the framebufferAFramebufferasATarget's. C: rlBindFramebuffer Parameters:ATargetthe target;AFramebufferthe framebuffer.static method LoadFramebuffer(): uint32: A new framebuffer's id (0 on a failure). C: rlLoadFramebuffer Returns: a new framebuffer's id (0 on a failure)static method FramebufferAttach(const AId: uint32; const ATexId: uint32; const AAttach: GLAttachType; const ATexType: GLAttachTextureType; const AMipLevel: int32): Attaches the texture or render bufferATexIdto the framebufferAId. C: rlFramebufferAttach Parameters:AIdthe id;ATexIdthe tex id;AAttachthe attach;ATexTypethe tex type;AMipLevelthe mip level.static method FramebufferComplete(const AId: uint32): bool: True when the framebufferAIdcan be drawn into. C: rlFramebufferComplete Parameters:AIdthe id. Returns:truewhen the framebufferAIdcan be drawn intostatic method UnloadFramebuffer(const AId: uint32): Unloads the framebufferAIdand its attachments. C: rlUnloadFramebuffer Parameters:AIdthe id.static method CopyFramebuffer(const AX: int32; const AY: int32; const AWidth: int32; const AHeight: int32; const AFormat: Pixel; const APixels: ptr): Copies a rectangle of the active framebuffer intoAPixelsinAFormat. C: rlCopyFramebuffer Parameters:AXthe x coordinate;AYthe y coordinate;AWidththe width;AHeightthe height;AFormatthe pixel format;APixelsthe pixels.static method ResizeFramebuffer(const AWidth: int32; const AHeight: int32): Resizes the active framebuffer. C: rlResizeFramebuffer Parameters:AWidththe width;AHeightthe height.static method EnableColorBlend(): Turns colour blending on. C: rlEnableColorBlendstatic method DisableColorBlend(): Turns colour blending off. C: rlDisableColorBlendstatic method EnableDepthTest(): Turns the depth test on. C: rlEnableDepthTeststatic method DisableDepthTest(): Turns the depth test off. C: rlDisableDepthTeststatic method EnableDepthMask(): Depth writes on. C: rlEnableDepthMaskstatic method DisableDepthMask(): Depth writes off. C: rlDisableDepthMaskstatic method EnableBackfaceCulling(): Turns back-face culling on. C: rlEnableBackfaceCullingstatic method DisableBackfaceCulling(): Turns back-face culling off. C: rlDisableBackfaceCullingstatic method ColorMask(const AR: bool; const AG: bool; const AB: bool; const AA: bool): Which color channels drawing writes. C: rlColorMask Parameters:ARtrueto write red;AGtrueto write green;ABtrueto write blue;AAtrueto write alpha.static method SetCullFace(const AFace: GLCull): The faces culled while culling is on. C: rlSetCullFace Parameters:AFacethe face.static method EnableScissorTest(): Turns the scissor test on. C: rlEnableScissorTeststatic method DisableScissorTest(): Turns the scissor test off. C: rlDisableScissorTeststatic method Scissor(const AX: int32; const AY: int32; const AWidth: int32; const AHeight: int32): The scissor rectangle, in framebuffer pixels (bottom-left origin). C: rlScissor Parameters:AXthe x coordinate;AYthe y coordinate;AWidththe width;AHeightthe height.static method EnablePointMode(): Polygons drawn as their corner points. C: rlEnablePointModestatic method DisablePointMode(): Turns point mode off. C: rlDisablePointModestatic method SetPointSize(const ASize: float32): The size points are drawn at. C: rlSetPointSize Parameters:ASizethe size, in pixels.static method GetPointSize(): float32: The size points are drawn at. C: rlGetPointSize Returns: the size, in pixelsstatic method EnableWireMode(): Polygons drawn as their edges. C: rlEnableWireModestatic method DisableWireMode(): Turns wire mode off. C: rlDisableWireModestatic method SetLineWidth(const AWidth: float32): The width lines are drawn at. C: rlSetLineWidth Parameters:AWidththe width, in pixels.static method GetLineWidth(): float32: The width lines are drawn at. C: rlGetLineWidth Returns: the width, in pixelsstatic method EnableSmoothLines(): Turns line smoothing on. C: rlEnableSmoothLinesstatic method DisableSmoothLines(): Turns line smoothing off. C: rlDisableSmoothLinesstatic method EnableStereoRender(): Drawing renders a stereo pair (VRStereoRes.Begin's). C: rlEnableStereoRenderstatic method DisableStereoRender(): Turns stereo rendering off. C: rlDisableStereoRenderstatic method IsStereoRenderEnabled(): bool: True while stereo rendering is on. C: rlIsStereoRenderEnabled Returns:truewhile stereo rendering is onstatic method ClearColor(const AColor: Color): The color the screen buffers clear to. C: rlClearColor Parameters:AColorthe colour.static method ClearScreenBuffers(): Clears the color and depth buffers. C: rlClearScreenBuffersstatic method CheckErrors(): Logs every GL error pending. C: rlCheckErrorsstatic method SetBlendMode(const ABlend: Blend): The blend mode drawing uses. C: rlSetBlendMode Parameters:ABlendthe blend mode.static method SetBlendFactors(const ASrc: GLBlendFactor; const ADst: GLBlendFactor; const AEquation: GLBlendEquation): The factors and equation Blend.Custom blends by. C: rlSetBlendFactors Parameters:ASrcthe src;ADstthe dst;AEquationthe equation.static method SetBlendFactorsSeparate(const ASrcRGB: GLBlendFactor; const ADstRGB: GLBlendFactor; const ASrcAlpha: GLBlendFactor; const ADstAlpha: GLBlendFactor; const AEqRGB: GLBlendEquation; const AEqAlpha: GLBlendEquation): The color / alpha factors and equations Blend.CustomSeparate blends by. C: rlSetBlendFactorsSeparate Parameters:ASrcRGBthe src RGB;ADstRGBthe dst RGB;ASrcAlphathe src alpha;ADstAlphathe dst alpha;AEqRGBthe eq RGB;AEqAlphathe eq alpha.static method Init(const AWidth: int32; const AHeight: int32): Starts rlgl over a GL context ofAWidthxAHeight(raylib's window does this itself). C: rlglInit Parameters:AWidththe width;AHeightthe height.static method Close(): Ends rlgl (raylib's window does this itself). C: rlglClosestatic method LoadExtensions(const ALoader: ptr): Loads the GL extensions throughALoader(a GL loader's proc address routine). C: rlLoadExtensions Parameters:ALoaderthe loader.static method GetProcAddress(const AName: string): ptr: The GL routineAName's address (nil when the GL has none). C: rlGetProcAddress Parameters:ANamethe name. Returns: the GL routineAName's address (nil when the GL has none)static method GetVersion(): GLVersion: The GL raylib runs on. C: rlGetVersion Returns: the GL raylib runs onstatic method SetFramebufferWidth(const AWidth: int32): The framebuffer width rlgl draws for. C: rlSetFramebufferWidth Parameters:AWidththe width.static method GetFramebufferWidth(): int32: The default framebuffer's width. C: rlGetFramebufferWidth Returns: the default framebuffer's widthstatic method SetFramebufferHeight(const AHeight: int32): The framebuffer height rlgl draws for. C: rlSetFramebufferHeight Parameters:AHeightthe height.static method GetFramebufferHeight(): int32: The default framebuffer's height. C: rlGetFramebufferHeight Returns: the default framebuffer's heightstatic method GetTextureIdDefault(): uint32: raylib's default white texture's id. C: rlGetTextureIdDefault Returns: raylib's default white texture's idstatic method GetShaderIdDefault(): uint32: raylib's default shader's id. C: rlGetShaderIdDefault Returns: raylib's default shader's idstatic method GetShaderLocsDefault(): ptr to int32: raylib's default shader's locations (RL_MAX_SHADER_LOCATIONS of them, raylib's). C: rlGetShaderLocsDefault Returns: raylib's default shader's locations (RL_MAX_SHADER_LOCATIONS of them, raylib's)static method LoadRenderBatch(const ABuffers: int32; const AElements: int32): rlRenderBatch: A new render batch:ABuffersbuffers ofAElementsquads each (unload it with UnloadRenderBatch). C: rlLoadRenderBatch Parameters:ABuffersthe buffers;AElementsthe elements. Returns: a new render batch:ABuffersbuffers ofAElementsquads each (unload it with UnloadRenderBatch)static method UnloadRenderBatch(const ABatch: rlRenderBatch): Frees the render batchABatch. C: rlUnloadRenderBatch Parameters:ABatchthe batch.static method DrawRenderBatch(var ABatch: rlRenderBatch): Draws whatABatchholds and empties it. C: rlDrawRenderBatch Parameters:ABatchthe batch.static method SetRenderBatchActive(const ABatch: ptr to rlRenderBatch): The batch the vertices go into (nil: raylib's default batch). C: rlSetRenderBatchActive Parameters:ABatchthe batch.static method DrawRenderBatchActive(): Draws what the active batch holds and empties it. C: rlDrawRenderBatchActivestatic method CheckRenderBatchLimit(const ACount: int32): bool: Draws the active batch first whenACountmore vertices would not fit; true when it did. C: rlCheckRenderBatchLimit Parameters:ACounthow many. Returns:truewhen the batch was drawnstatic method LoadShader(const ACode: string; const AType: GLShaderType): uint32: CompilesACodeas anATypestage, its id (0 on a failure). C: rlLoadShader Parameters:ACodethe stage's source code;ATypethe type. Returns: compilesACodeas anATypestage, its id (0 on a failure)static method LoadShaderProgram(const AVertexCode: string; const AFragmentCode: string): uint32: Compiles and links a program from GLSL code ("" takes raylib's default for that stage), its id (0 on a failure). C: rlLoadShaderProgram Parameters:AVertexCodethe vertex code;AFragmentCodethe fragment code. Returns: the program's id (0 on a failure)static method LoadShaderProgram(const AVertexId: uint32; const AFragmentId: uint32): uint32: Links a program from two compiled stages (LoadShader's ids). C: rlLoadShaderProgramEx Parameters:AVertexIdthe vertex id;AFragmentIdthe fragment id. Returns: the program's id (0 on a failure)static method LoadShaderProgramCompute(const AComputeId: uint32): uint32: Links a compute program from a compiled compute stage. C: rlLoadShaderProgramCompute Parameters:AComputeIdthe compute id. Returns: the program's id (0 on a failure)static method UnloadShader(const AId: uint32): Unloads a compiled stage. C: rlUnloadShader Parameters:AIdthe id.static method UnloadShaderProgram(const AId: uint32): Deletes the shader programAId. C: rlUnloadShaderProgram Parameters:AIdthe program's id.static method GetLocationUniform(const AId: uint32; const AName: string): int32: The location of the uniformANamein the programAId(-1: none). C: rlGetLocationUniform Parameters:AIdthe id;ANamethe name. Returns: the location of the uniformANamein the programAId(-1: none)static method GetLocationAttrib(const AId: uint32; const AName: string): int32: The location of the attributeANamein the programAId(-1: none). C: rlGetLocationAttrib Parameters:AIdthe id;ANamethe name. Returns: the location of the attributeANamein the programAId(-1: none)static method SetUniform(const ALocIndex: int32; const AValue: ptr to const; const AType: UniformType; const ACount: int32): SetsACountelements ofATypefromAValueat locationALocIndexof the enabled program. C: rlSetUniform Parameters:ALocIndexthe shader location;AValuethe value;ATypethe type;ACounthow many.static method SetUniformMatrix(const ALocIndex: int32; const AMatrix: Matrix): Sets the matrix uniform atALocIndexof the enabled program. C: rlSetUniformMatrix Parameters:ALocIndexthe shader location;AMatrixthe matrix.static method SetUniformMatrices(const ALocIndex: int32; const AMatrices: array of Matrix): Sets the matrix array at locationALocIndex. C: rlSetUniformMatrices Parameters:ALocIndexthe shader location;AMatricesthe matrices.static method SetUniformSampler(const ALocIndex: int32; const ATextureId: uint32): Binds the textureATextureIdto the sampler at locationALocIndex. C: rlSetUniformSampler Parameters:ALocIndexthe shader location;ATextureIdthe texture id.static method SetShader(const AId: uint32; const ALocs: ptr to int32): The program (and its locations) raylib's batch draws with. C: rlSetShader Parameters:AIdthe id;ALocsthe locs.static method EnableShader(const AId: uint32): Binds the programAId. C: rlEnableShader Parameters:AIdthe id.static method DisableShader(): Unbinds the shader program. C: rlDisableShaderstatic method ComputeShaderDispatch(const AGroupX: uint32; const AGroupY: uint32; const AGroupZ: uint32): Runs the bound compute program overAGroupXxAGroupYxAGroupZwork groups. C: rlComputeShaderDispatch Parameters:AGroupXthe group X;AGroupYthe group Y;AGroupZthe group Z.static method LoadShaderBuffer(const ASize: uint32; const AData: ptr to const; const AUsage: GLUsage): uint32: A new shader storage buffer ofASizebytes fromAData(nil: zeroed). C: rlLoadShaderBuffer Parameters:ASizethe size;ADatathe data;AUsagethe usage. Returns: a new shader storage buffer ofASizebytes fromAData(nil: zeroed)static method UnloadShaderBuffer(const AId: uint32): Deletes the shader bufferAId. C: rlUnloadShaderBuffer Parameters:AIdthe buffer's id.static method UpdateShaderBuffer(const AId: uint32; const AData: ptr to const; const ASize: uint32; const AOffset: uint32): WritesASizebytes fromADatainto the bufferAIdat byteAOffset. C: rlUpdateShaderBuffer Parameters:AIdthe id;ADatathe data;ASizethe size;AOffsetthe offset.static method BindShaderBuffer(const AId: uint32; const AIndex: uint32): Binds the bufferAIdto binding pointAIndex. C: rlBindShaderBuffer Parameters:AIdthe id;AIndexthe index, from 0.static method ReadShaderBuffer(const AId: uint32; const ADest: ptr; const ACount: uint32; const AOffset: uint32): ReadsACountbytes of the bufferAIdfrom byteAOffsetintoADest. C: rlReadShaderBuffer Parameters:AIdthe id;ADestwhere the bytes go;ACounthow many;AOffsetthe offset.static method CopyShaderBuffer(const ADestId: uint32; const ASrcId: uint32; const ADestOffset: uint32; const ASrcOffset: uint32; const ACount: uint32): CopiesACountbytes between two buffers. C: rlCopyShaderBuffer Parameters:ADestIdthe dest id;ASrcIdthe src id;ADestOffsetthe dest offset;ASrcOffsetthe src offset;ACounthow many.static method GetShaderBufferSize(const AId: uint32): uint32: The bufferAId's size in bytes. C: rlGetShaderBufferSize Parameters:AIdthe id. Returns: the bufferAId's size in bytesstatic method BindImageTexture(const AId: uint32; const AIndex: uint32; const AFormat: Pixel; const AReadOnly: bool): Binds the textureAIdas image unitAIndexfor compute programs. C: rlBindImageTexture Parameters:AIdthe id;AIndexthe index, from 0;AFormatthe pixel format;AReadOnlythe read only.static method GetMatrixModelview(): Matrix: The modelview matrix. C: rlGetMatrixModelview Returns: the modelview matrixstatic method GetMatrixProjection(): Matrix: The projection matrix. C: rlGetMatrixProjection Returns: the projection matrixstatic method GetMatrixTransform(): Matrix: The current transform (the matrix Translate / Rotate / Scale build). C: rlGetMatrixTransform Returns: the current transform (the matrix Translate / Rotate / Scale build)static method GetMatrixProjectionStereo(const AEye: int32): Matrix: EyeAEye's projection in stereo rendering (0 left, 1 right). C: rlGetMatrixProjectionStereo Parameters:AEyethe eye, 0 (left) or 1 (right). Returns: eyeAEye's projection in stereo rendering (0 left, 1 right)static method GetMatrixViewOffsetStereo(const AEye: int32): Matrix: EyeAEye's view offset in stereo rendering (0 left, 1 right). C: rlGetMatrixViewOffsetStereo Parameters:AEyethe eye, 0 (left) or 1 (right). Returns: eyeAEye's view offset in stereo rendering (0 left, 1 right)static method SetMatrixProjection(const AProjection: Matrix): Sets the projection matrix. C: rlSetMatrixProjection Parameters:AProjectionthe projection matrix.static method SetMatrixModelview(const AView: Matrix): Sets the modelview matrix. C: rlSetMatrixModelview Parameters:AViewthe view matrix.static method SetMatrixProjectionStereo(const ARight: Matrix; const ALeft: Matrix): The stereo pair's projections. C: rlSetMatrixProjectionStereo Parameters:ARightthe right eye's matrix;ALeftthe left eye's matrix.static method SetMatrixViewOffsetStereo(const ARight: Matrix; const ALeft: Matrix): The stereo pair's view offsets. C: rlSetMatrixViewOffsetStereo Parameters:ARightthe right eye's matrix;ALeftthe left eye's matrix.static method LoadDrawCube(): Draws a unit cube (raylib's skybox and cubemap work). C: rlLoadDrawCubestatic method LoadDrawQuad(): Draws a full-viewport quad (raylib's post-processing work). C: rlLoadDrawQuad
Example: GL.PushMatrix(); GL.Translate(10.0f, 0.0f, 0.0f); GL.Begin(GLMode.Quads); GL.Color(RED); GL.Vertex(LCorner); GL.End(); GL.PopMatrix();
Extends
extend Vector2
extend Vector2
Members
static method Zero(): Vector2: The vector (0, 0). C: Vector2Zero Returns: the vector (0, 0)static method One(): Vector2: The vector (1, 1). C: Vector2One Returns: the vector (1, 1)operator +(const A: Vector2; const B: Vector2): Vector2: Component-wise sum. C: Vector2Add Parameters:Athe left operand;Bthe right operand. Returns: the component-wise sumoperator +(const A: Vector2; const S: float32): Vector2:Sadded to each component. C: Vector2AddValue Parameters:Athe left operand;Sthe right operand. Returns:Sadded to each componentoperator -(const A: Vector2; const B: Vector2): Vector2: Component-wise difference. C: Vector2Subtract Parameters:Athe left operand;Bthe right operand. Returns: the component-wise differenceoperator -(const A: Vector2; const S: float32): Vector2:Staken from each component. C: Vector2SubtractValue Parameters:Athe left operand;Sthe right operand. Returns:Staken from each componentoperator *(const A: Vector2; const B: Vector2): Vector2: Component-wise product. C: Vector2Multiply Parameters:Athe left operand;Bthe right operand. Returns: the component-wise productoperator *(const A: Vector2; const S: float32): Vector2: The vector scaled byS. C: Vector2Scale Parameters:Athe left operand;Sthe right operand. Returns: the vector scaled bySoperator /(const A: Vector2; const B: Vector2): Vector2: Component-wise quotient. C: Vector2Divide Parameters:Athe left operand;Bthe right operand. Returns: the component-wise quotientoperator /(const A: Vector2; const S: float32): Vector2: The vector divided byS. C: Vector2Scale by 1 / S Parameters:Athe left operand;Sthe right operand. Returns: the vector divided bySoperator =(const A: Vector2; const B: Vector2): bool: True when the vectors are equal within raymath's epsilon. C: Vector2Equals Parameters:Athe left operand;Bthe right operand. Returns:truewhen the vectors are equal within raymath's epsilonoperator <>(const A: Vector2; const B: Vector2): bool: True when the vectors differ beyond raymath's epsilon. C: Vector2Equals Parameters:Athe left operand;Bthe right operand. Returns:truewhen the vectors differ beyond raymath's epsilonconst method Negate(): Vector2: The vector negated. C: Vector2Negate Returns: the vector negatedconst method Invert(): Vector2: Each component's reciprocal (1 / x, 1 / y). C: Vector2Invert Returns: each component's reciprocal (1 / x, 1 / y)const method Length(): float32: The vector's length. C: Vector2Length Returns: the vector's lengthconst method LengthSqr(): float32: The vector's squared length (no square root). C: Vector2LengthSqr Returns: the vector's squared length (no square root)const method Dot(const B: Vector2): float32: The dot product withB. C: Vector2DotProduct Parameters:Bthe other vector. Returns: the dot product withBconst method Cross(const B: Vector2): float32: The 2D cross product (the z of the 3D one) withB. C: Vector2CrossProduct Parameters:Bthe other vector. Returns: the 2D cross product (the z of the 3D one) withBconst method Distance(const B: Vector2): float32: The distance toB. C: Vector2Distance Parameters:Bthe other point. Returns: the distance toBconst method DistanceSqr(const B: Vector2): float32: The squared distance toB. C: Vector2DistanceSqr Parameters:Bthe other point. Returns: the squared distance toBconst method Angle(const B: Vector2): float32: The signed angle in radians from this vector toB. C: Vector2Angle Parameters:Bthe other vector. Returns: the signed angle in radians from this vector toBconst method LineAngle(const B: Vector2): float32: The angle in radians of the line from this point toB. C: Vector2LineAngle Parameters:Bthe line's end. Returns: the angle in radians of the line from this point toBconst method Normalize(): Vector2: The vector at length 1 (zero stays zero). C: Vector2Normalize Returns: the vector at length 1 (zero stays zero)const method Transform(const M: Matrix): Vector2: The point transformed byM. C: Vector2Transform Parameters:Mthe transform. Returns: the point transformed byMconst method Lerp(const B: Vector2; const T: float32): Vector2: The pointTof the way toB(0 here, 1 atB). C: Vector2Lerp Parameters:Bthe end;Tthe amount. Returns: the pointTof the way toB(0 here, 1 atB)const method Reflect(const ANormal: Vector2): Vector2: The vector reflected off a surface of normalANormal. C: Vector2Reflect Parameters:ANormalthe surface's normal. Returns: the vector reflected off a surface of normalANormalconst method Refract(const ANormal: Vector2; const R: float32): Vector2: The (normalized) vector refracted through a surface of normalANormal. C: Vector2Refract Parameters:ANormalthe surface's normal (normalized);Rthe ratio of the refractive indices. Returns: the (normalized) vector refracted through a surface of normalANormalconst method Min(const B: Vector2): Vector2: Component-wise minimum withB. C: Vector2Min Parameters:Bthe otherVector2. Returns: the component-wise minimum withBconst method Max(const B: Vector2): Vector2: Component-wise maximum withB. C: Vector2Max Parameters:Bthe otherVector2. Returns: the component-wise maximum withBconst method Rotate(const AAngle: float32): Vector2: The vector rotated byAAngleradians. C: Vector2Rotate Parameters:AAnglethe angle in radians. Returns: the vector rotated byAAngleradiansconst method MoveTowards(const ATarget: Vector2; const AMaxDistance: float32): Vector2: The point moved towardATargetby at mostAMaxDistance. C: Vector2MoveTowards Parameters:ATargetwhere it moves to;AMaxDistancethe longest step. Returns: the point moved towardATargetby at mostAMaxDistanceconst method Clamp(const ALo: Vector2; const AHi: Vector2): Vector2: Each component clamped betweenALo's andAHi's. C: Vector2Clamp Parameters:ALothe low corner;AHithe high corner. Returns: each component clamped betweenALo's andAHi'sconst method Clamp(const ALo: float32; const AHi: float32): Vector2: The vector with its length clamped betweenALoandAHi. C: Vector2ClampValue Parameters:ALothe shortest length;AHithe longest length. Returns: the vector with its length clamped betweenALoandAHiconst method In(const R: Rectangle): bool: True when the point is insideR. C: CheckCollisionPointRec Parameters:Rthe rectangle. Returns:truewhen the point is insideRconst method InCircle(const ACenter: Vector2; const ARadius: float32): bool: True when the point is inside the circle. C: CheckCollisionPointCircle Parameters:ACenterthe circle's centre;ARadiusits radius. Returns:truewhen the point is inside the circleconst method InTriangle(const AP1: Vector2; const AP2: Vector2; const AP3: Vector2): bool: True when the point is inside the triangle. C: CheckCollisionPointTriangle Parameters:AP1the first point;AP2the second point;AP3the third point. Returns:truewhen the point is inside the triangleconst method OnLine(const AP1: Vector2; const AP2: Vector2; const AThreshold: int32): bool: True when the point is on the line fromAP1toAP2, withinAThresholdpixels. C: CheckCollisionPointLine Parameters:AP1the first point;AP2the second point;AThresholdthe threshold. Returns:truewhen the point is on the line fromAP1toAP2, withinAThresholdpixelsconst method InPoly(const APoints: array of Vector2): bool: True when the point is inside the polygonAPoints(false for an empty one). C: CheckCollisionPointPoly Parameters:APointsthe polygon's corners in order. Returns:truewhen the point is inside the polygonAPoints(false for an empty one)static method LinesCross(const AS1: Vector2; const AE1: Vector2; const AS2: Vector2; const AE2: Vector2; var AAt: Vector2): bool: True when the segments cross;AAtis then where. C: CheckCollisionLines Parameters:AAtthe crossing point, set when they cross;AS1the first line's start;AE1the first line's end;AS2the second line's start;AE2the second line's end. Returns:truewhen the segments cross;AAtis then wherestatic method CirclesOverlap(const AC1: Vector2; const AR1: float32; const AC2: Vector2; const AR2: float32): bool: True when the two circles overlap (touching counts). C: CheckCollisionCircles Parameters:AC1the first circle's centre;AR1its radius;AC2the second circle's centre;AR2its radius. Returns:truewhen the two circles overlap (touching counts) Example:if Vector2.CirclesOverlap(LShip, 12.0f, LRock, 20.0f) then Explode(); end;static method CircleOverlapsLine(const ACenter: Vector2; const ARadius: float32; const AP1: Vector2; const AP2: Vector2): bool: True when the circle touches the segment fromAP1toAP2. C: CheckCollisionCircleLine Parameters:ACenterthe circle's centre;ARadiusits radius;AP1the segment's start;AP2the segment's end. Returns:truewhen the circle touches the segment fromAP1toAP2Example:if Vector2.CircleOverlapsLine(LBall, 8.0f, LWallA, LWallB) then Bounce(); end;const method ScreenToWorld(const ACam: Camera2D): Vector2: The screen point as a world point ofACam. C: GetScreenToWorld2D Parameters:ACamthe camera. Returns: the screen point as a world point ofACamconst method WorldToScreen(const ACam: Camera2D): Vector2: The world point ofACamas a screen point. C: GetWorldToScreen2D Parameters:ACamthe camera. Returns: the world point ofACamas a screen pointconst method ScreenToRay(const ACam: Camera3D): Ray: The ray fromACamthrough this screen point (the window's size). C: GetScreenToWorldRay Parameters:ACamthe camera. Returns: the ray fromACamthrough this screen point (the window's size)const method ScreenToRay(const ACam: Camera3D; const AWidth: int32; const AHeight: int32): Ray: The ray fromACamthrough this point of aAWidthxAHeightview. C: GetScreenToWorldRayEx Parameters:ACamthe camera;AWidththe width;AHeightthe height. Returns: the ray fromACamthrough this point of aAWidthxAHeightview
extend Vector3
extend Vector3
Members
static method Zero(): Vector3: The vector (0, 0, 0). C: Vector3Zero Returns: the vector (0, 0, 0)static method One(): Vector3: The vector (1, 1, 1). C: Vector3One Returns: the vector (1, 1, 1)operator +(const A: Vector3; const B: Vector3): Vector3: Component-wise sum. C: Vector3Add Parameters:Athe left operand;Bthe right operand. Returns: the component-wise sumoperator +(const A: Vector3; const S: float32): Vector3:Sadded to each component. C: Vector3AddValue Parameters:Athe left operand;Sthe right operand. Returns:Sadded to each componentoperator -(const A: Vector3; const B: Vector3): Vector3: Component-wise difference. C: Vector3Subtract Parameters:Athe left operand;Bthe right operand. Returns: the component-wise differenceoperator -(const A: Vector3; const S: float32): Vector3:Staken from each component. C: Vector3SubtractValue Parameters:Athe left operand;Sthe right operand. Returns:Staken from each componentoperator *(const A: Vector3; const B: Vector3): Vector3: Component-wise product. C: Vector3Multiply Parameters:Athe left operand;Bthe right operand. Returns: the component-wise productoperator *(const A: Vector3; const S: float32): Vector3: The vector scaled byS. C: Vector3Scale Parameters:Athe left operand;Sthe right operand. Returns: the vector scaled bySoperator /(const A: Vector3; const B: Vector3): Vector3: Component-wise quotient. C: Vector3Divide Parameters:Athe left operand;Bthe right operand. Returns: the component-wise quotientoperator /(const A: Vector3; const S: float32): Vector3: The vector divided byS. C: Vector3Scale by 1 / S Parameters:Athe left operand;Sthe right operand. Returns: the vector divided bySoperator =(const A: Vector3; const B: Vector3): bool: True when equal within raymath's epsilon. C: Vector3Equals Parameters:Athe left operand;Bthe right operand. Returns:truewhen equal within raymath's epsilonoperator <>(const A: Vector3; const B: Vector3): bool: True when they differ beyond raymath's epsilon. C: Vector3Equals Parameters:Athe left operand;Bthe right operand. Returns:truewhen they differ beyond raymath's epsilonconst method Negate(): Vector3: The vector negated. C: Vector3Negate Returns: the vector negatedconst method Invert(): Vector3: Each component's reciprocal. C: Vector3Invert Returns: each component's reciprocalconst method Length(): float32: The vector's length. C: Vector3Length Returns: the vector's lengthconst method LengthSqr(): float32: The squared length. C: Vector3LengthSqr Returns: the squared lengthconst method Normalize(): Vector3: The vector at length 1 (zero stays zero). C: Vector3Normalize Returns: the vector at length 1 (zero stays zero)const method Perpendicular(): Vector3: A vector perpendicular to this one. C: Vector3Perpendicular Returns: a vector perpendicular to this oneconst method Dot(const B: Vector3): float32: The dot product withB. C: Vector3DotProduct Parameters:Bthe otherVector3. Returns: the dot product withBconst method Cross(const B: Vector3): Vector3: The cross product withB. C: Vector3CrossProduct Parameters:Bthe otherVector3. Returns: the cross product withBconst method Distance(const B: Vector3): float32: The distance toB. C: Vector3Distance Parameters:Bthe otherVector3. Returns: the distance toBconst method DistanceSqr(const B: Vector3): float32: The squared distance toB. C: Vector3DistanceSqr Parameters:Bthe otherVector3. Returns: the squared distance toBconst method Angle(const B: Vector3): float32: The angle in radians between this vector andB. C: Vector3Angle Parameters:Bthe otherVector3. Returns: the angle in radians between this vector andBconst method Project(const B: Vector3): Vector3: This vector projected ontoB. C: Vector3Project Parameters:Bthe otherVector3. Returns: this vector projected ontoBconst method Reject(const B: Vector3): Vector3: This vector's part perpendicular toB. C: Vector3Reject Parameters:Bthe otherVector3. Returns: this vector's part perpendicular toBstatic method OrthoNormalize(var AV1: Vector3; var AV2: Vector3): MakesAV1andAV2normalized and orthogonal (Gram-Schmidt). C: Vector3OrthoNormalize Parameters:AV1the first vector;AV2the second vector.const method Transform(const M: Matrix): Vector3: The point transformed byM. C: Vector3Transform Parameters:Mthe matrix. Returns: the point transformed byMconst method RotateBy(const Q: Quaternion): Vector3: The vector rotated by the quaternionQ. C: Vector3RotateByQuaternion Parameters:Qthe rotation. Returns: the vector rotated by the quaternionQconst method RotateBy(const AAxis: Vector3; const AAngle: float32): Vector3: The vector rotatedAAngleradians aboutAAxis. C: Vector3RotateByAxisAngle Parameters:AAxisthe axis;AAnglethe angle. Returns: the vector rotatedAAngleradians aboutAAxisconst method MoveTowards(const ATarget: Vector3; const AMaxDistance: float32): Vector3: The point moved towardATargetby at mostAMaxDistance. C: Vector3MoveTowards Parameters:ATargetthe target;AMaxDistancethe max distance. Returns: the point moved towardATargetby at mostAMaxDistanceconst method Lerp(const B: Vector3; const T: float32): Vector3: The pointTof the way toB. C: Vector3Lerp Parameters:Bthe otherVector3;Thow far along, 0 to 1. Returns: the pointTof the way toBstatic method CubicHermite(const AV1: Vector3; const ATangent1: Vector3; const AV2: Vector3; const ATangent2: Vector3; const AAmount: float32): Vector3: The cubic Hermite point atAAmountbetweenAV1andAV2. C: Vector3CubicHermite Parameters:AV1the first vector;ATangent1the tangent1;AV2the second vector;ATangent2the tangent2;AAmountthe amount. Returns: the cubic Hermite point atAAmountbetweenAV1andAV2const method Reflect(const ANormal: Vector3): Vector3: The vector reflected off a surface of normalANormal. C: Vector3Reflect Parameters:ANormalthe normal. Returns: the vector reflected off a surface of normalANormalconst method Refract(const ANormal: Vector3; const R: float32): Vector3: The (normalized) vector refracted through a surface of normalANormal,Rthe ratio of the refractive indices. C: Vector3Refract Parameters:ANormalthe normal;Rthe ratio of the refractive indices. Returns: the (normalized) vector refracted through a surface of normalANormal,Rthe ratio of the refractive indicesconst method Min(const B: Vector3): Vector3: Component-wise minimum withB. C: Vector3Min Parameters:Bthe otherVector3. Returns: the component-wise minimum withBconst method Max(const B: Vector3): Vector3: Component-wise maximum withB. C: Vector3Max Parameters:Bthe otherVector3. Returns: the component-wise maximum withBconst method Clamp(const ALo: Vector3; const AHi: Vector3): Vector3: Each component clamped betweenALo's andAHi's. C: Vector3Clamp Parameters:ALothe lowest components;AHithe highest components. Returns: each component clamped betweenALo's andAHi'sconst method Clamp(const ALo: float32; const AHi: float32): Vector3: The vector with its length clamped betweenALoandAHi. C: Vector3ClampValue Parameters:ALothe shortest length;AHithe longest length. Returns: the vector with its length clamped betweenALoandAHistatic method Barycenter(const AP: Vector3; const AA: Vector3; const AB: Vector3; const AC: Vector3): Vector3: The barycentric coordinates (u, v, w) ofAPin the triangle. C: Vector3Barycenter Parameters:APthe point;AAthe first corner;ABthe second corner;ACthe third corner. Returns: the barycentric coordinates (u, v, w) ofAPin the triangleconst method Unproject(const AProjection: Matrix; const AView: Matrix): Vector3: The point unprojected from normalized device space. C: Vector3Unproject Parameters:AProjectionthe projection matrix;AViewthe view matrix. Returns: the point unprojected from normalized device spaceconst method ToArray(): array[0..2] of float32: The components as (x, y, z). C: Vector3ToFloatV Returns: the components as (x, y, z)const method WorldToScreen(const ACam: Camera3D): Vector2: The world point as a screen point ofACam(the window's size). C: GetWorldToScreen Parameters:ACamthe camera. Returns: the world point as a screen point ofACam(the window's size)const method WorldToScreen(const ACam: Camera3D; const AWidth: int32; const AHeight: int32): Vector2: The world point as a point of aAWidthxAHeightview. C: GetWorldToScreenEx Parameters:ACamthe camera;AWidththe width;AHeightthe height. Returns: the world point as a point of aAWidthxAHeightview
extend Vector4
extend Vector4
Members
static method Zero(): Vector4: The vector (0, 0, 0, 0). C: Vector4Zero Returns: the vector (0, 0, 0, 0)static method One(): Vector4: The vector (1, 1, 1, 1). C: Vector4One Returns: the vector (1, 1, 1, 1)static method Identity(): Quaternion: The identity quaternion (0, 0, 0, 1). C: QuaternionIdentity Returns: the identity quaternion (0, 0, 0, 1)operator +(const A: Vector4; const B: Vector4): Vector4: Component-wise sum. C: Vector4Add Parameters:Athe left operand;Bthe right operand. Returns: the component-wise sumoperator +(const A: Vector4; const S: float32): Vector4:Sadded to each component. C: Vector4AddValue Parameters:Athe left operand;Sthe right operand. Returns:Sadded to each componentoperator -(const A: Vector4; const B: Vector4): Vector4: Component-wise difference. C: Vector4Subtract Parameters:Athe left operand;Bthe right operand. Returns: the component-wise differenceoperator -(const A: Vector4; const S: float32): Vector4:Staken from each component. C: Vector4SubtractValue Parameters:Athe left operand;Sthe right operand. Returns:Staken from each componentoperator *(const A: Vector4; const B: Vector4): Vector4: Component-wise product (not the quaternion product:Product). C: Vector4Multiply Parameters:Athe left operand;Bthe right operand. Returns: the component-wise product (not the quaternion product:Product)operator *(const A: Vector4; const S: float32): Vector4: The vector scaled byS. C: Vector4Scale Parameters:Athe left operand;Sthe right operand. Returns: the vector scaled bySoperator /(const A: Vector4; const B: Vector4): Vector4: Component-wise quotient. C: Vector4Divide Parameters:Athe left operand;Bthe right operand. Returns: the component-wise quotientoperator /(const A: Vector4; const S: float32): Vector4: The vector divided byS. C: Vector4Scale by 1 / S Parameters:Athe left operand;Sthe right operand. Returns: the vector divided bySoperator =(const A: Vector4; const B: Vector4): bool: True when equal within raymath's epsilon. C: Vector4Equals Parameters:Athe left operand;Bthe right operand. Returns:truewhen equal within raymath's epsilonoperator <>(const A: Vector4; const B: Vector4): bool: True when they differ beyond raymath's epsilon. C: Vector4Equals Parameters:Athe left operand;Bthe right operand. Returns:truewhen they differ beyond raymath's epsilonconst method Negate(): Vector4: The vector negated. C: Vector4Negate Returns: the vector negatedconst method Invert(): Vector4: Each component's reciprocal. C: Vector4Invert Returns: each component's reciprocalconst method Length(): float32: The vector's length. C: Vector4Length Returns: the vector's lengthconst method LengthSqr(): float32: The squared length. C: Vector4LengthSqr Returns: the squared lengthconst method Normalize(): Vector4: The vector (or quaternion) at length 1. C: Vector4Normalize Returns: the vector (or quaternion) at length 1const method Dot(const B: Vector4): float32: The dot product withB. C: Vector4DotProduct Parameters:Bthe otherVector4. Returns: the dot product withBconst method Distance(const B: Vector4): float32: The distance toB. C: Vector4Distance Parameters:Bthe otherVector4. Returns: the distance toBconst method DistanceSqr(const B: Vector4): float32: The squared distance toB. C: Vector4DistanceSqr Parameters:Bthe otherVector4. Returns: the squared distance toBconst method Min(const B: Vector4): Vector4: Component-wise minimum withB. C: Vector4Min Parameters:Bthe otherVector4. Returns: the component-wise minimum withBconst method Max(const B: Vector4): Vector4: Component-wise maximum withB. C: Vector4Max Parameters:Bthe otherVector4. Returns: the component-wise maximum withBconst method Lerp(const B: Vector4; const T: float32): Vector4: The pointTof the way toB(component-wise; a quaternion's isNlerp/Slerp). C: Vector4Lerp Parameters:Bthe otherVector4;Thow far along, 0 to 1. Returns: the pointTof the way toB(component-wise; a quaternion's isNlerp/Slerp)const method MoveTowards(const ATarget: Vector4; const AMaxDistance: float32): Vector4: The point moved towardATargetby at mostAMaxDistance. C: Vector4MoveTowards Parameters:ATargetthe target;AMaxDistancethe max distance. Returns: the point moved towardATargetby at mostAMaxDistanceconst method Product(const B: Quaternion): Quaternion: The quaternion product (Hamilton) self xB. C: QuaternionMultiply Parameters:Bthe quaternion it is multiplied by. Returns: the quaternion product (Hamilton) self xBconst method QInvert(): Quaternion: The quaternion's inverse (conjugate over the squared length). C: QuaternionInvert Returns: the quaternion's inverse (conjugate over the squared length)const method Nlerp(const B: Quaternion; const T: float32): Quaternion: The normalized linear interpolationTof the way toB. C: QuaternionNlerp Parameters:Bthe quaternion it turns towards;Thow far along, 0 to 1. Returns: the normalized linear interpolationTof the way toBconst method Slerp(const B: Quaternion; const T: float32): Quaternion: The spherical linear interpolationTof the way toB. C: QuaternionSlerp Parameters:Bthe quaternion it turns towards;Thow far along, 0 to 1. Returns: the spherical linear interpolationTof the way toBstatic method CubicHermite(const AQ1: Quaternion; const AOutTangent1: Quaternion; const AQ2: Quaternion; const AInTangent2: Quaternion; const T: float32): Quaternion: The cubic Hermite spline point atT. C: QuaternionCubicHermiteSpline Parameters:AQ1the first rotation;AOutTangent1the out tangent1;AQ2the second rotation;AInTangent2the in tangent2;Thow far along, 0 to 1. Returns: the cubic Hermite spline point atTstatic method FromTo(const AFrom: Vector3; const ATo: Vector3): Quaternion: The rotation that turnsAFromontoATo. C: QuaternionFromVector3ToVector3 Parameters:AFromthe direction turned from;ATothe direction turned onto. Returns: the rotation that turnsAFromontoATostatic method FromMatrix(const M: Matrix): Quaternion: The rotation of a matrix. C: QuaternionFromMatrix Parameters:Mthe matrix. Returns: the rotation of a matrixconst method ToMatrix(): Matrix: The quaternion's rotation matrix. C: QuaternionToMatrix Returns: the quaternion's rotation matrixstatic method FromAxisAngle(const AAxis: Vector3; const AAngle: float32): Quaternion: The rotation ofAAngleradians aboutAAxis. C: QuaternionFromAxisAngle Parameters:AAxisthe axis;AAnglethe angle. Returns: the rotation ofAAngleradians aboutAAxisconst method ToAxisAngle(var AAxis: Vector3; var AAngle: float32): The quaternion's rotation as an axis and an angle in radians. C: QuaternionToAxisAngle Parameters:AAxisset to the axis;AAngleset to the angle.static method FromEuler(const APitch: float32; const AYaw: float32; const ARoll: float32): Quaternion: The rotation of the Euler angles in radians. C: QuaternionFromEuler Parameters:APitchthe pitch angle, in radians;AYawthe yaw;ARollthe roll. Returns: the rotation of the Euler angles in radiansconst method ToEuler(): Vector3: The quaternion's Euler angles in radians (pitch, yaw, roll). C: QuaternionToEuler Returns: the quaternion's Euler angles in radians (pitch, yaw, roll)const method Transform(const M: Matrix): Quaternion: The quaternion transformed byM. C: QuaternionTransform Parameters:Mthe matrix. Returns: the quaternion transformed byM
extend Matrix
extend Matrix
Members
static method Identity(): Matrix: The identity matrix. C: MatrixIdentity Returns: the identity matrixstatic method Translate(const AX: float32; const AY: float32; const AZ: float32): Matrix: A translation. C: MatrixTranslate Parameters:AXthe x coordinate;AYthe y coordinate;AZthe z coordinate. Returns: a translationstatic method Rotate(const AAxis: Vector3; const AAngle: float32): Matrix: A rotation ofAAngleradians aboutAAxis. C: MatrixRotate Parameters:AAxisthe axis;AAnglethe angle. Returns: a rotation ofAAngleradians aboutAAxisstatic method RotateX(const AAngle: float32): Matrix: A rotation about x, radians. C: MatrixRotateX Parameters:AAnglethe angle. Returns: a rotation about x, radiansstatic method RotateY(const AAngle: float32): Matrix: A rotation about y, radians. C: MatrixRotateY Parameters:AAnglethe angle. Returns: a rotation about y, radiansstatic method RotateZ(const AAngle: float32): Matrix: A rotation about z, radians. C: MatrixRotateZ Parameters:AAnglethe angle. Returns: a rotation about z, radiansstatic method RotateXYZ(const AAngles: Vector3): Matrix: The rotations about x, y then z, radians. C: MatrixRotateXYZ Parameters:AAnglesthe angles. Returns: the rotations about x, y then z, radiansstatic method RotateZYX(const AAngles: Vector3): Matrix: The rotations about z, y then x, radians. C: MatrixRotateZYX Parameters:AAnglesthe angles. Returns: the rotations about z, y then x, radiansstatic method Scale(const AX: float32; const AY: float32; const AZ: float32): Matrix: A scaling. C: MatrixScale Parameters:AXthe x coordinate;AYthe y coordinate;AZthe z coordinate. Returns: a scalingstatic method Frustum(const ALeft: float64; const ARight: float64; const ABottom: float64; const ATop: float64; const ANear: float64; const AFar: float64): Matrix: A perspective frustum. C: MatrixFrustum Parameters:ALeftthe left of the view volume;ARightthe right of the view volume;ABottomthe bottom of the view volume;ATopthe top of the view volume;ANearthe near clip distance;AFarthe far clip distance. Returns: a perspective frustumstatic method Perspective(const AFovY: float64; const AAspect: float64; const ANear: float64; const AFar: float64): Matrix: A perspective projection,AFovYin radians. C: MatrixPerspective Parameters:AFovYthe fov Y;AAspectthe aspect;ANearthe near clip distance;AFarthe far clip distance. Returns: a perspective projection,AFovYin radiansstatic method Ortho(const ALeft: float64; const ARight: float64; const ABottom: float64; const ATop: float64; const ANear: float64; const AFar: float64): Matrix: An orthographic projection. C: MatrixOrtho Parameters:ALeftthe left of the view volume;ARightthe right of the view volume;ABottomthe bottom of the view volume;ATopthe top of the view volume;ANearthe near clip distance;AFarthe far clip distance. Returns: an orthographic projectionstatic method LookAt(const AEye: Vector3; const ATarget: Vector3; const AUp: Vector3): Matrix: A view matrix fromAEyelooking atATarget. C: MatrixLookAt Parameters:AEyethe eye position;ATargetthe target;AUpthe up direction. Returns: a view matrix fromAEyelooking atATargetstatic method Compose(const AT: Vector3; const AR: Quaternion; const AS: Vector3): Matrix: The transform of a translation, a rotation and a scale. C: MatrixCompose Parameters:ATthe translation;ARthe rotation;ASthe scale. Returns: the transform of a translation, a rotation and a scaleoperator +(const A: Matrix; const B: Matrix): Matrix: Element-wise sum. C: MatrixAdd Parameters:Athe left operand;Bthe right operand. Returns: element-wise sumoperator -(const A: Matrix; const B: Matrix): Matrix: Element-wise difference. C: MatrixSubtract Parameters:Athe left operand;Bthe right operand. Returns: element-wise differenceoperator *(const A: Matrix; const B: Matrix): Matrix: The matrix product:Aapplied first, thenB(raymath's order). C: MatrixMultiply Parameters:Athe left operand;Bthe right operand. Returns: the matrix product:Aapplied first, thenB(raymath's order)operator *(const A: Matrix; const S: float32): Matrix: Each element scaled byS. C: MatrixMultiplyValue Parameters:Athe left operand;Sthe right operand. Returns: each element scaled bySconst method Determinant(): float32: The determinant. C: MatrixDeterminant Returns: the determinantconst method Trace(): float32: The trace (the diagonal's sum). C: MatrixTrace Returns: the trace (the diagonal's sum)const method Transpose(): Matrix: The transpose. C: MatrixTranspose Returns: the transposeconst method Invert(): Matrix: The inverse. C: MatrixInvert Returns: the inverseconst method Decompose(var AT: Vector3; var AR: Quaternion; var AS: Vector3): The matrix as a translation, a rotation and a scale. C: MatrixDecompose Parameters:ATreceives the translation;ARreceives the rotation;ASreceives the scale.const method ToArray(): array[0..15] of float32: The 16 elements, column-major (m0, m1, m2 ..). C: MatrixToFloatV Returns: the 16 elements, column-major (m0, m1, m2 ..)
extend Color
extend Color
Members
static method Hex(const AHex: string; const ADefault: Color): Color: The colour web pages and Raven themes write:#RGB,#RGBA,#RRGGBBor#RRGGBBAA(the#optional, digits in either case; no alpha is opaque). Parameters:AHexthe colour's text;ADefaultreturned whenAHexis none of those forms. Returns: the colour, orADefaultstatic method FromInt(const AHex: uint32): Color: The colour of a 0xRRGGBBAA value. C: GetColor Parameters:AHexthe hex. Returns: the colour of a 0xRRGGBBAA valueconst method ToInt(): int32: The colour as 0xRRGGBBAA. C: ColorToInt Returns: the colour as 0xRRGGBBAAstatic method FromHSV(const AH: float32; const AS: float32; const AV: float32): Color: The colour of a hue (0..360), saturation and value (0..1). C: ColorFromHSV Parameters:AHthe hue, in degrees (0 to 360);ASthe saturation, 0 to 1;AVthe value (brightness), 0 to 1. Returns: the colour of a hue (0..360), saturation and value (0..1)const method ToHSV(): Vector3: The colour as (hue, saturation, value). C: ColorToHSV Returns: the colour as (hue, saturation, value)static method FromNormalized(const AN: Vector4): Color: The colour of components 0..1. C: ColorFromNormalized Parameters:ANthe colour as (r, g, b, a), each 0 to 1. Returns: the colour of components 0..1const method Normalized(): Vector4: The colour's components 0..1. C: ColorNormalize Returns: the colour's components 0..1operator =(const A: Color; const B: Color): bool: True when every component is equal. C: ColorIsEqual Parameters:Athe left operand;Bthe right operand. Returns:truewhen every component is equaloperator <>(const A: Color; const B: Color): bool: True when any component differs. C: ColorIsEqual Parameters:Athe left operand;Bthe right operand. Returns:truewhen any component differsconst method Fade(const AAlpha: float32): Color: The colour with its alpha timesAAlpha(0..1). C: Fade Parameters:AAlphathe alpha. Returns: the colour with its alpha timesAAlpha(0..1)const method Alpha(const AAlpha: float32): Color: The colour with its alpha set toAAlpha(0..1). C: ColorAlpha Parameters:AAlphathe alpha. Returns: the colour with its alpha set toAAlpha(0..1)const method Tint(const ATint: Color): Color: The colour multiplied byATint. C: ColorTint Parameters:ATintthe tint colour. Returns: the colour multiplied byATintconst method Brightness(const AFactor: float32): Color: The colour brightened (> 0) or darkened (< 0) byAFactor(-1..1). C: ColorBrightness Parameters:AFactorthe factor. Returns: the colour brightened (> 0) or darkened (< 0) byAFactor(-1..1)const method Contrast(const AContrast: float32): Color: The colour's contrast changed byAContrast(-1..1). C: ColorContrast Parameters:AContrastthe contrast. Returns: the colour's contrast changed byAContrast(-1..1)const method Lerp(const B: Color; const T: float32): Color: The colourTof the way toB. C: ColorLerp Parameters:Bthe otherColor;Thow far along, 0 to 1. Returns: the colourTof the way toBconst method AlphaBlend(const ASrc: Color; const ATint: Color): Color:ASrctinted byATintblended over this colour. C: ColorAlphaBlend Parameters:ASrcthe src;ATintthe tint colour. Returns:ASrctinted byATintblended over this colourstatic method FromPixel(const AP: ptr to const; const AFormat: Pixel): Color: The colour of one pixel in formatAFormatatAP. C: GetPixelColor Parameters:APwhere the pixel is read;AFormatthe pixel format. Returns: the colour of one pixel in formatAFormatatAPconst method ToPixel(const AP: ptr; const AFormat: Pixel): Writes the colour as one pixel in formatAFormatatAP. C: SetPixelColor Parameters:APwhere the pixel is written;AFormatthe pixel format.static method PixelDataSize(const AWidth: int32; const AHeight: int32; const AFormat: Pixel): int32: The bytes of aAWidthxAHeightimage in formatAFormat. C: GetPixelDataSize Parameters:AWidththe width;AHeightthe height;AFormatthe pixel format. Returns: the bytes of aAWidthxAHeightimage in formatAFormat
extend Rectangle
extend Rectangle
Members
const method Overlaps(const B: Rectangle): bool: True when the rectangles overlap. C: CheckCollisionRecs Parameters:Bthe otherRectangle. Returns:truewhen the rectangles overlapconst method Overlap(const B: Rectangle): Rectangle: The rectangle where both overlap (empty when they do not). C: GetCollisionRec Parameters:Bthe otherRectangle. Returns: the rectangle where both overlap (empty when they do not)const method OverlapsCircle(const ACenter: Vector2; const ARadius: float32): bool: True when the circle overlaps the rectangle. C: CheckCollisionCircleRec Parameters:ACenterthe centre;ARadiusthe radius. Returns:truewhen the circle overlaps the rectangleconst method Contains(const AP: Vector2): bool: True whenAPis inside. C: CheckCollisionPointRec Parameters:APthe point. Returns:truewhenAPis insideconst method Position(): Vector2: The top-left corner. Returns: the top-left cornerconst method Size(): Vector2: The width and height. Returns: the width and heightconst method Center(): Vector2: The centre point. Returns: the centre pointconst method Moved(const AD: Vector2): Rectangle: The rectangle moved byAD. Parameters:ADthe offset. Returns: the rectangle moved byADconst method Grown(const AD: float32): Rectangle: The rectangle grown byADon every side (shrunk whenAD< 0). Parameters:ADhow much on each side. Returns: the rectangle grown byADon every side (shrunk whenAD< 0)
extend Ray
extend Ray
Members
const method HitSphere(const ACenter: Vector3; const ARadius: float32): RayCollision: Where the ray hits the sphere. C: GetRayCollisionSphere Parameters:ACenterthe centre;ARadiusthe radius. Returns: where the ray hits the sphereconst method HitBox(const ABox: BoundingBox): RayCollision: Where the ray hits the box. C: GetRayCollisionBox Parameters:ABoxthe box. Returns: where the ray hits the boxconst method HitTriangle(const AP1: Vector3; const AP2: Vector3; const AP3: Vector3): RayCollision: Where the ray hits the triangle. C: GetRayCollisionTriangle Parameters:AP1the first point;AP2the second point;AP3the third point. Returns: where the ray hits the triangleconst method HitQuad(const AP1: Vector3; const AP2: Vector3; const AP3: Vector3; const AP4: Vector3): RayCollision: Where the ray hits the quad. C: GetRayCollisionQuad Parameters:AP1the first point;AP2the second point;AP3the third point;AP4the fourth point. Returns: where the ray hits the quadconst method HitMesh(const AMesh: MeshRes; const ATransform: Matrix): RayCollision: Where the ray meetsAMeshplaced byATransform(its vertex data). C: GetRayCollisionMesh Parameters:AMeshthe mesh;ATransformthe transform. Returns: where the ray meetsAMeshplaced byATransform(its vertex data)
extend BoundingBox
extend BoundingBox
Members
const method Overlaps(const B: BoundingBox): bool: True when the boxes overlap. C: CheckCollisionBoxes Parameters:Bthe otherBoundingBox. Returns:truewhen the boxes overlapconst method OverlapsSphere(const ACenter: Vector3; const ARadius: float32): bool: True when the sphere overlaps the box. C: CheckCollisionBoxSphere Parameters:ACenterthe centre;ARadiusthe radius. Returns:truewhen the sphere overlaps the boxstatic method SpheresOverlap(const AC1: Vector3; const AR1: float32; const AC2: Vector3; const AR2: float32): bool: True when the two spheres overlap. C: CheckCollisionSpheres Parameters:AC1the first sphere's centre;AR1the first sphere's radius;AC2the second sphere's centre;AR2the second sphere's radius. Returns:truewhen the two spheres overlap
extend Camera2D
extend Camera2D
Members
static method Make(const ATarget: Vector2; const AOffset: Vector2; const ARotation: float32; const AZoom: float32): Camera2D: A camera looking atATarget, shown atAOffsetof the screen. Parameters:ATargetthe target;AOffsetthe offset;ARotationthe rotation;AZoomthe zoom. Returns: a camera looking atATarget, shown atAOffsetof the screenconst method Matrix(): Matrix: The camera's view matrix. C: GetCameraMatrix2D Returns: the camera's view matrixconst method Begin(): Starts drawing through this camera inside the frame. C: BeginMode2D, letterboxedstatic method End(): Ends the camera's drawing. C: EndMode2D
extend Camera3D
extend Camera3D
Members
static method Make(const APosition: Vector3; const ATarget: Vector3; const AUp: Vector3; const AFovY: float32; const AProjection: Projection): Camera3D: A camera atAPositionlooking atATarget,AFovYin degrees. Parameters:APositionthe position;ATargetthe target;AUpthe up direction;AFovYthe fov Y;AProjectionthe projection. Returns: a camera atAPositionlooking atATarget,AFovYin degreesconst method Matrix(): Matrix: The camera's view matrix. C: GetCameraMatrix Returns: the camera's view matrixmethod Update(const AStyle: CameraStyle): Moves the camera by raylib's built-in controls forAStyle. C: UpdateCamera Parameters:AStylethe style.method Update(const AMovement: Vector3; const ARotation: Vector3; const AZoom: float32): Moves and turns the camera (rotation in degrees: yaw, pitch, roll) and zooms it. C: UpdateCameraPro Parameters:AMovementthe movement;ARotationthe rotation;AZoomthe zoom.const method Begin(): Starts drawing through this camera inside the frame. C: BeginMode3D, letterboxedstatic method End(): Ends the camera's drawing. C: EndMode3D
extend AutomationEvent
extend AutomationEvent
Members
const method Kind(): AutomationKind: The event's kind (AutomationKind.None for a value raylib does not make). Returns: the event's kind (AutomationKind.None for a value raylib does not make)
extend ImageRes
extend ImageRes
Members
static method FromTexture(const ATexture: TextureRes): ImageRes:ATexture's pixels as a new image. C: LoadImageFromTexture Parameters:ATexturethe texture. Returns:ATexture's pixels as a new imagestatic method FromText(const AWidth: int32; const AHeight: int32; const AText: string): ImageRes: An imageAWidthxAHeightholdingAText(raylib's test pattern). C: GenImageText Parameters:AWidththe width;AHeightthe height;ATextthe text. Returns: an imageAWidthxAHeightholdingAText(raylib's test pattern)static method FromText(const AText: string; const ASize: int32; const AColor: Color): ImageRes: An image ofATextin raylib's default font atASize. C: ImageText Parameters:ATextthe text;ASizethe size;AColorthe colour. Returns: an image ofATextin raylib's default font atASizestatic method FromText(const AFont: FontRes; const AText: string; const ASize: float32; const ASpacing: float32; const ATint: Color): ImageRes: An image ofATextinAFontatASize,ASpacingbetween glyphs. C: ImageTextEx Parameters:AFontthe font;ATextthe text;ASizethe size;ASpacingthe spacing;ATintthe tint colour. Returns: an image ofATextinAFontatASize,ASpacingbetween glyphsmethod Text(const AText: string; const APos: Vector2; const ASize: int32; const AColor: Color): ImageRes:ATextin raylib's default font atASizepixels. C: ImageDrawText Parameters:ATextthe text;APosthe position;ASizethe size;AColorthe colour. Returns:ATextin raylib's default font atASizepixelsmethod Text(const AFont: FontRes; const AText: string; const APos: Vector2; const ASize: float32; const ASpacing: float32; const ATint: Color): ImageRes:ATextinAFontatASize,ASpacingbetween glyphs. C: ImageDrawTextEx Parameters:AFontthe font;ATextthe text;APosthe position;ASizethe size;ASpacingthe spacing;ATintthe tint colour. Returns:ATextinAFontatASize,ASpacingbetween glyphsmethod Text(const AFont: FontRes; const AText: string; const APos: Vector2; const AOrigin: Vector2; const ARotation: float32; const ASize: float32; const ASpacing: float32; const ATint: Color): ImageRes:ATextinAFontturnedARotationdegrees aboutAOrigin. C: ImageDrawTextPro Parameters:AFontthe font;ATextthe text;APosthe position;AOriginthe origin;ARotationthe rotation;ASizethe size;ASpacingthe spacing;ATintthe tint colour. Returns:ATextinAFontturnedARotationdegrees aboutAOriginconst method ToTexture(): TextureRes: The image as a texture (the window must be open). C: LoadTextureFromImage Returns: the image as a texture (the window must be open)const method ToCubemap(const ALayout: CubeLayout): TextureRes: The image's six faces, laid out asALayout, as a cubemap. C: LoadTextureCubemap Parameters:ALayoutthe layout. Returns: the image's six faces, laid out asALayout, as a cubemap
extend WaveRes
extend WaveRes
Members
const method ToSound(): SoundRes: The wave as a sound (the device must be open). C: LoadSoundFromWave Returns: the wave as a sound (the device must be open)
System.Raylib.Ext.Linux64
System.Raylib.Ext's platform unit for x86_64-linux-gnu: what the frame window needs from X11 (the target triple picks it; System.Raylib.Ext.Win64 has the same names).
Import it with import System.Raylib.Ext.Linux64;.
Types
RaylibWindowGoneFn
type RaylibWindowGoneFn = func(const AWindow: uint64)
The notice System.Raylib.Ext takes of a native window going (its X11 Window id).
Parameters
AWindow: the window's X11 Window id
Constants
| Name | Declaration | Description |
|---|---|---|
ADAM_RAYLIB_DPI_CHECK_SECONDS | const ADAM_RAYLIB_DPI_CHECK_SECONDS: float64 = 1.0 | How often the frame asks the DPI again, in seconds: once a second. |
Routines
dlsym
func dlsym(AHandle: ptr; AName: ptr to const char): ptr
The hook on glibc's dlsym (System.HookABI): the real one's answer, except that GLFW's libX11 asking for XCreateWindow / XDestroyWindow gets this unit's hooks of them (the window icon, the window-gone notice). AName is nonnull by glibc's own declaration.
Parameters
AHandle: the library handle (or RTLD_DEFAULT / RTLD_NEXT)AName: the symbol's name
Returns: the symbol's address (nil when it is not found)
RaylibPlatformSetWindowGone
func cpplink RaylibPlatformSetWindowGone(const ANotice: RaylibWindowGoneFn)
Sets the notice the XDestroyWindow hook gives as a window goes (nil: none).
Parameters
ANotice: the routine told each native window's id as it is destroyed
RaylibPlatformNativeWindow
func cpplink RaylibPlatformNativeWindow(const AHandle: ptr): uint64
raylib's window as X11 names it: its Window id (raylib's GetWindowHandle points at its copy of it); 0 for none.
Parameters
AHandle: raylib's GetWindowHandle()
Returns: the Window id (0 for none)
RaylibPlatformQueryDPI
func cpplink RaylibPlatformQueryDPI(const AHandle: ptr): int32
X11's Xft.dpi as it is now (the root window's RESOURCE_MANAGER), rounded; 0 when it is unset or below 1, or before GLFW made an X11 window.
Parameters
AHandle: raylib's GetWindowHandle() (not needed on X11: the root window's setting)
Returns: the DPI (0 when unset or below 1, or before GLFW made an X11 window)
System.Raylib.Ext.Win64
System.Raylib.Ext's platform unit for x86_64-windows-gnu: what the frame window and the program icon need from Windows (the target triple picks it; System.Raylib.Ext.Linux64 has the same names).
Import it with import System.Raylib.Ext.Win64;.
Types
RaylibWindowGoneFn
type RaylibWindowGoneFn = func(const AWindow: uint64)
The notice System.Raylib.Ext takes of a native window going (its HWND, as a number).
Parameters
AWindow: the window's HWND, as a number
Constants
| Name | Declaration | Description |
|---|---|---|
ADAM_RAYLIB_DPI_CHECK_SECONDS | const ADAM_RAYLIB_DPI_CHECK_SECONDS: float64 = 0.0 | How often the frame asks the DPI again, in seconds: each frame. |
Routines
RaylibPlatformSetWindowGone
func cpplink RaylibPlatformSetWindowGone(const ANotice: RaylibWindowGoneFn)
Sets the notice the DestroyWindow hook gives as a window goes (nil: none).
Parameters
ANotice: the routine told each native window's number as it is destroyed
RaylibPlatformNativeWindow
func cpplink RaylibPlatformNativeWindow(const AHandle: ptr): uint64
raylib's window as Windows names it: its HWND as a number (0 for none).
Parameters
AHandle: raylib's GetWindowHandle()
Returns: the HWND as a number (0 for none)
RaylibPlatformQueryDPI
func cpplink RaylibPlatformQueryDPI(const AHandle: ptr): int32
The DPI the window AHandle is shown at (its monitor's), else the system's; 0 when Windows answers neither.
Parameters
AHandle: raylib's GetWindowHandle() (nil: the system's DPI only)
Returns: the DPI (0 when Windows answers neither)
CreateWindowExW
func CreateWindowExW(AExStyle: uint32; AClassName: ptr to const uint16; AWindowName: ptr to const uint16; AStyle: uint32; AX: int32; AY: int32; AWidth: int32; AHeight: int32; AParent: ptr; AMenu: ptr; AInstance: ptr; AParam: ptr): ptr
The hook on user32's CreateWindowExW (System.HookABI): the real one, then the program's icon set on a top-level window. Its parameters and result are user32's own.
Parameters
AExStyle: the extended window styleAClassName: the window class's nameAWindowName: the window's titleAStyle: the window styleAX: the x positionAY: the y positionAWidth: the widthAHeight: the heightAParent: the parent or owner windowAMenu: the menu or child idAInstance: the module instanceAParam: the creation parameter
Returns: the new window (nil on a failure)
DestroyWindow
func DestroyWindow(AWindow: ptr): int32
The hook on user32's DestroyWindow (System.HookABI): System.Raylib.Ext told the window goes, then the real one.
Parameters
AWindow: the window destroyed
Returns: the real one's BOOL (0 when the real one is not found)
System.ResData
the files a build added with @addresdata, read back by key (BNF sec 2)
Import it with import System.ResData;.
Types
ResDataEntry
type ResDataEntry = record
A key's bytes in the binary (FindResData): Data[Size] is a zero byte, so text can be read as a C string.
Members
Data: ptr to const uint8: The first byte (nil when the key is missing).Size: int64: How many bytes the key holds.
Constants
| Name | Declaration | Description |
|---|---|---|
ADAM_RESDATA_COMPILER_PREFIX | const ADAM_RESDATA_COMPILER_PREFIX: string = "adam/" | The prefix of the keys the compiler adds itself (never one of a program's own). |
ADAM_RESDATA_EXEICON_KEY | const ADAM_RESDATA_EXEICON_KEY: string = "adam/exeicon" | The key @exeicon's image is stored under. |
ADAM_RESDATA_EXEICON_HEADER | const ADAM_RESDATA_EXEICON_HEADER: int64 = 8 | The bytes before the @exeicon entry's pixels. |
Routines
ResDataCount
func cpplink ResDataCount(): int64
How many @addresdata keys this binary holds.
Returns: the key count (a key two tables hold counted once)
ResDataKey
func cpplink ResDataKey(const AIndex: int64): string
A key this binary holds, in byte-wise key order.
Parameters
AIndex: the key's place, 0 .. ResDataCount() - 1
Returns: the key ("" outside that range)
Example: for LI := 0 to ResDataCount() - 1 do println("{}", ResDataKey(LI)); end;
FindResData
func cpplink FindResData(const AKey: string): ResDataEntry
The bytes an @addresdata added under a key.
Parameters
AKey: the key
Returns: its bytes and their count; Data nil and Size 0 when no @addresdata adds AKey
Example: LEntry := FindResData("about.txt");
HasResData
func cpplink HasResData(const AKey: string): bool
Whether an @addresdata adds a key to this binary.
Parameters
AKey: the key
Returns: true when the binary holds it
System.Sign
digital signatures in Adam: Ed25519 (RFC 8032) and minisign's key and signature files over it.
Import it with import System.Sign;.
Types
MinisignKey
type MinisignKey = object
A minisign key: its 8-byte id, its Ed25519 public key and, for signing, its secret seed. Make one with Generate, or load one (LoadSecretKey gives both halves, LoadPublicKey / FromPublicKeyText the public half to verify with). Public key and .minisig files are stock minisign's (minisign -V checks what SignFile writes); a secret key file is the unencrypted packer form (T1, never minisign's encrypted one): keep it private.
Members
method Generate(): bool: A new key: a random seed and key id from the system's secure generator. Returns: false when the generator gives no bytes (the key is then empty)method Clear(): Forgets the key (no id, no halves).const method HasSecret(): bool: The key can sign (its secret seed is held). Returns: a seed is heldconst method HasPublic(): bool: The key can verify (its public key is held). Returns: a public key is heldconst method KeyIdText(): string: The key id as minisign prints it: 16 uppercase hex digits, byte by byte. Returns: the id's text ("" for no key)const method PublicKeyText(): string: The public key as one Base64 line, the formminisign -Ptakes. Returns: the line ("" when no public key is held)method FromPublicKeyText(const AText: string): bool: Takes the public half from its Base64 line (PublicKeyText's form); the seed is dropped. Parameters:ATextthe line. Returns: false (the key cleared) when the text is no minisign public keyconst method SavePublicKey(const APath: string): bool: Writes the public key file (minisign's: an untrusted comment line, the Base64 line). Parameters:APaththe file (e.g.release.pub). Returns: false when no public key is held or the file cannot be writtenmethod LoadPublicKey(const APath: string): bool: Reads a public key file (minisign's form). Parameters:APaththe file. Returns: false (the key cleared) when it cannot be read or holds no public keyconst method SaveSecretKey(const APath: string): bool: Writes the secret key file:T1, the key id, the seed and the public key in one Base64 line under a comment. It is NOT encrypted: keep the file private. Parameters:APaththe file (e.g.release.key). Returns: false when no secret is held or the file cannot be writtenmethod LoadSecretKey(const APath: string): bool: Reads a secret key file (SaveSecretKey's form, StdApp's packer's too): both halves. Parameters:APaththe file. Returns: false (the key cleared) when it cannot be read, is no such key, or its public half is not its seed'sconst method SignFile(const APath: string; const ATrustedComment: string; const AUntrustedComment: string): bool: Signs a file: writes<APath>.minisigin minisign's prehashed form (the file's BLAKE2b-512 digest signed, then a global signature over that signature and the trusted comment), the file read in blocks. Parameters:APaththe file signed;ATrustedCommentthe signed comment ("" givesfile:<name>andhashed, tab apart);AUntrustedCommentthe unsigned first line ("" gives minisign's own wording). Returns: false when no secret is held, or the file cannot be read or the signature writtenconst method VerifyFile(const APath: string; const ASignaturePath: string): bool: Checks a file against its minisign signature (prehashedED, or the legacyEdform over the whole file): the key id must be this key's, both the signature and the global signature over the trusted comment must be good. Parameters:APaththe file;ASignaturePathits signature file ("" means<APath>.minisig). Returns: the file is exactly what this key signed
Example: LKey.LoadSecretKey("release.key"); LKey.SignFile("app.zip", "app 1.0", "");
Routines
Ed25519PublicKey
func cpplink Ed25519PublicKey(const ASeed: ByteArray): ByteArray
The Ed25519 public key of a secret seed (RFC 8032 sec 5.1.5).
Parameters
ASeed: the 32-byte secret seed (e.g. fromSecureRandomBytes(32, LSeed))
Returns: the 32-byte public key; empty when the seed is not 32 bytes
Example: LPublic := Ed25519PublicKey(LSeed);
Ed25519Sign
func cpplink Ed25519Sign(const AMessage: ByteArray; const ASeed: ByteArray): ByteArray
The Ed25519 signature of a message (RFC 8032 sec 5.1.6): deterministic, the same seed and message always give the same 64 bytes.
Parameters
AMessage: the bytes signed (any length)ASeed: the 32-byte secret seed
Returns: the 64-byte signature (R then S); empty when the seed is not 32 bytes
Example: LSignature := Ed25519Sign(LMessage, LSeed);
Ed25519Verify
func cpplink Ed25519Verify(const AMessage: ByteArray; const ASignature: ByteArray; const APublicKey: ByteArray): bool
Checks an Ed25519 signature (RFC 8032 sec 5.1.7): true only for a signature the public key's seed made over exactly these bytes; a malformed key or signature, or an S not below the group order, is false.
Parameters
AMessage: the bytes that were signedASignature: the 64-byte signatureAPublicKey: the signer's 32-byte public key
Returns: the signature is good
Example: if Ed25519Verify(LMessage, LSignature, LPublic) then println("good"); end;
System.SysUtils
Adam's OS-free utilities: the UTF-8 codec, string helpers, string lists, path names as text, numbers as text
Import it with import System.SysUtils;.
Types
StringArray
type StringArray = array of string
A list of names or arguments.
ByteArray
type ByteArray = array of uint8
A list of bytes (a file's contents, an object's image).
Int64Array
type Int64Array = array of int64
A list of 64-bit integers (ids, offsets, per-id maps).
BoolArray
type BoolArray = array of bool
A list of flags (a set over ids).
CodepointArray
type CodepointArray = array of uint32
Unicode code points, one a character (StringToCodepoints / StringFromCodepoints)
CString
type CString = object
A string's text kept as a C string (NUL-terminated) for as long as the CString lives, for a pointer C keeps past a call (a struct C stores, a registered name). A string argument to a ptr to const char parameter needs none: it is passed zero-copy for the call (BNF sec 6), and a trackable record field keeps its own text (F4).
- The text is shared, never copied: a copy of a
CStringpoints at the same text, which lives until the last copy ends. Ptris nevernil: an empty text is an empty C string.
Members
init(): An empty C string (Ptris the empty C string, nevernil)init(const AText: string): A C string ofATextParameters:ATextthe text.property Text: string read FText: The text, as an Adam stringproperty Ptr: ptr to const char read: The text as a C string, valid while thisCString(or a copy) livesproperty OrNil: ptr to const char read:Ptr, ornilwhen the text is "": for a C parameter whereNULLmeans "none" (a password, a prefix, an optional id), valid while thisCString(or a copy) lives Example:LPrefix := CString(APrefix); xmlNewNs(LNode, LURI, LPrefix.OrNil);property Length: int64 read: The text's length in bytes, its NUL left out
Example: GName := CString("player"); RegisterName(GName.Ptr);
CStringArray
type CStringArray = object
A list of texts kept as C strings with a nil after the last, as C takes an argv or any other NUL-ended char * array (Ptr), for as long as the CStringArray lives. Its texts are shared as CString's are: a copy points at the same texts.
Members
init(): An empty list (Ptrpoints at its onenil)init(const ATexts: StringArray): A list ofATexts, in order Parameters:ATextsthe texts.method Add(const AText: string):ATextadded at the end Parameters:ATextthe text.property Count: int64 read: How many texts it holds (thenilafter them not counted)property Item[const AIndex: int64]: ptr to const char read: TextAIndex(0-based) as a C stringproperty Ptr: ptr to const ptr to const char read: The C strings, thennil: C'sconst char *const argv[](the list is this object's: C reads it, never writes it), valid while this list (or a copy) lives
Example: LArgs := CStringArray(["/bin/ls", "-l"]); posix_spawn(LPid, LArgs.Item[0], nil, nil, ptr to const ptr to char(LArgs.Ptr), environ); (a char *const argv[] taker casts, as C does)
Constants
| Name | Declaration | Description |
|---|---|---|
ADAM_SYSUTILS_REPLACEMENT | const ADAM_SYSUTILS_REPLACEMENT: uint32 = 0xFFFD | The code point a malformed UTF-8 sequence or a lone UTF-16 surrogate becomes. |
ADAM_SYSUTILS_FNV_OFFSET | const ADAM_SYSUTILS_FNV_OFFSET: uint64 = 0xCBF29CE484222325 | FNV-1a 64's offset basis (Fnv1a64). |
ADAM_SYSUTILS_FNV_PRIME | const ADAM_SYSUTILS_FNV_PRIME: uint64 = 0x100000001B3 | FNV-1a 64's prime (Fnv1a64). |
Kilobyte | const Kilobyte: int64 = 1024 | The bytes in a kilobyte (1024, binary): 4 * Kilobyte is 4096. |
Megabyte | const Megabyte: int64 = 1024 * 1024 | The bytes in a megabyte (1024 x 1024, binary). |
Gigabyte | const Gigabyte: int64 = 1024 * 1024 * 1024 | The bytes in a gigabyte (1024 x 1024 x 1024, binary). |
Routines
DecodeUTF8Char
func cpplink DecodeUTF8Char(const AText: string; var AIndex: int64): uint32
Decodes the UTF-8 sequence at AIndex of AText and returns its code point, AIndex past it. A malformed sequence (a stray continuation byte, a cut sequence, an overlong form, a surrogate, a value past U+10FFFF) gives ADAM_SYSUTILS_REPLACEMENT and consumes one byte, so decoding always moves on. AIndex must be inside AText.
Parameters
AText: the textAIndex: the byte index of the sequence; moved past it
Returns: the code point
EncodeUTF8Char
func cpplink EncodeUTF8Char(var AText: string; var AAt: int64; const ACode: uint32)
Writes ACode as UTF-8 into AText at AAt, AAt past it. The caller makes the room: up to 4 bytes from AAt on (1 below U+80, 2 below U+800, 3 below U+10000, else 4).
Parameters
AText: the text written into (its room made by the caller)AAt: the byte index to write at; moved past the bytes writtenACode: the code point
EncodeUTF8Bytes
func cpplink EncodeUTF8Bytes(var ABytes: ByteArray; var AAt: int64; const ACode: uint32)
Writes ACode as UTF-8 into ABytes at AAt, AAt past it; the room rule of EncodeUTF8Char.
Parameters
ABytes: the bytes written into (their room made by the caller)AAt: the index to write at; moved past the bytes writtenACode: the code point
StringToCodepoints
func cpplink StringToCodepoints(const AText: string): CodepointArray
The code points of AText as DecodeUTF8Char reads them, one a character (a malformed byte one U+FFFD): for a font's glyph list or per-character work.
Parameters
AText: UTF-8 text
Returns: its code points (empty for "")
Example: LCodes := StringToCodepoints("Grüße"); gives 5 code points
StringFromCodepoints
func cpplink StringFromCodepoints(const ACodes: CodepointArray): string
ACodes as UTF-8 text; a value no character has (a UTF-16 surrogate, past U+10FFFF) becomes U+FFFD, so the text is always valid UTF-8.
Parameters
ACodes: the code points
Returns: the text ("" for none)
Example: StringFromCodepoints(StringToCodepoints(LText)) = LText for valid UTF-8
UTF8Length
func cpplink UTF8Length(const AText: string): int64
How many characters (code points) AText holds, as DecodeUTF8Char reads them (a malformed byte one); len(AText) is its bytes.
Parameters
AText: UTF-8 text
Returns: its code point count
Example: UTF8Length("Grüße") is 5, len("Grüße") 7
DecodeUTF8CharBefore
func cpplink DecodeUTF8CharBefore(const AText: string; var AIndex: int64): uint32
The code point that ends just before AIndex in AText, AIndex moved back to its first byte: DecodeUTF8Char walking backwards (a text cursor's left arrow). A byte that is no whole sequence's end gives U+FFFD and moves back one byte, so walking back always moves on and meets the same characters walking forward does on valid UTF-8.
Parameters
AText: UTF-8 textAIndex: a byte offset above 0 and at mostlen(AText); moved back
Returns: the code point before it
Example: LAt := len(LText); LLast := DecodeUTF8CharBefore(LText, LAt);
WholeUTF8Length
func cpplink WholeUTF8Length(const AText: string): int64
How many bytes of AText end on a whole UTF-8 character: len(AText) unless its last lead byte still waits for continuation bytes (a read cut it), then that lead byte's index, so the cut sequence is kept for the next read. Used by every reader that hands text on as it arrives.
Parameters
AText: the text read so far
Returns: the length of its whole characters
WindowsPathToWSL
func cpplink WindowsPathToWSL(const APath: string): string
StdApp.Utils' WindowsPathToWSL: an absolute Windows drive path as WSL names it (C:\foo\bar -> /mnt/c/foo/bar, '/' or '\' between its parts, the drive letter lower case); "" for any other path (relative, UNC, a long-path \?\ spelling: resolve and strip it first). Text only: the disk is never touched.
Parameters
APath: an absolute Windows drive path
Returns: the WSL path, or ""
IsUTF8
func cpplink IsUTF8(const AText: string): bool
True when AText is strict UTF-8 (RFC 3629): no overlong form, no surrogate, nothing past U+10FFFF, no cut sequence or stray continuation byte. Unlike DecodeUTF8Char it tells a malformed sequence from a written U+FFFD.
Parameters
AText: the text to test
Returns: true when it is strict UTF-8
EncodeUTF16Char
func cpplink EncodeUTF16Char(var AText: wstring; var AAt: int64; const ACode: uint32)
Writes ACode as UTF-16 into AText at AAt, AAt past it: one unit below U+10000, else a surrogate pair. The caller makes the room (up to 2 units from AAt on). ACode is a code point (at most U+10FFFF); a lone surrogate value is written as the one unit it is.
Parameters
AText: the wstring written into (its room made by the caller)AAt: the unit index to write at; moved past the units writtenACode: the code point
StringOfChar
func cpplink StringOfChar(const AChar: char; const ACount: int64): string
ACount copies of AChar ("" when ACount is 0 or less).
Parameters
AChar: the characterACount: how many copies
Returns: the text
StringFromC
func cpplink StringFromC(const AText: ptr to const char; const ACount: int64): string
The ACount bytes at AText as an Adam string, zero bytes included: the one place C text becomes Adam text ("" for nil or ACount 0 or less).
Parameters
AText: the C bytes (nil allowed)ACount: how many bytes
Returns: the Adam string
CTextLength
func cpplink CTextLength(const AText: ptr to const char): int64
The bytes of the NUL-terminated text at AText before its NUL (0 for nil).
Parameters
AText: the NUL-terminated text (nil allowed)
Returns: its length in bytes
func cpplink StringFromC(const AText: ptr to const char): string
The NUL-terminated text at AText as an Adam string, its NUL left out ("" for nil).
Parameters
AText: the NUL-terminated text (nil allowed)
Returns: the Adam string
StringToC
func cpplink StringToC(const AText: string): ptr to char
A new getmem copy of AText's bytes and a NUL, for a C text that C itself frees through Adam's allocator: a library whose memory hooks are Adam's getmem / freemem (libxml2's xmlMemSetup strdup hook). Passing a string to C needs no copy:
- a string argument to a
ptr to const charparameter is borrowed for the call (BNF sec 6); - a
ptr to const charfield of a trackable record keeps its text with the variable; CString/CStringArraykeep a text C holds on to past a call.
Parameters
AText: the text
Returns: the copy (freemem frees it), or nil when there is no room
Example: return StringToC(StringFromC(AText)); (a C strdup hook)
Substring
func cpplink Substring(const AText: string; const AFrom: int64; const ACount: int64): string
The ACount bytes of AText from AFrom on (0-based, as Delphi's string Substring), cut to the text's end; "" when nothing is left or AFrom is negative.
Parameters
AText: the textAFrom: the first byte, from 0ACount: how many bytes
Returns: the part
Trim
func cpplink Trim(const AText: string): string
AText without the bytes at or below a space at both ends, as Delphi's Trim (a UTF-8 lead or continuation byte is never one, so text is never cut inside a character).
Parameters
AText: the text
Returns: the trimmed text
TrimLeft
func cpplink TrimLeft(const AText: string): string
AText without the bytes at or below a space at its start, as Delphi's TrimLeft (never cut inside a UTF-8 character, as Trim).
Parameters
AText: the text
Returns: the trimmed text
TrimRight
func cpplink TrimRight(const AText: string): string
AText without the bytes at or below a space at its end, as Delphi's TrimRight (never cut inside a UTF-8 character, as Trim).
Parameters
AText: the text
Returns: the trimmed text
SplitString
func cpplink SplitString(const AText: string; const ADelimiters: string): StringArray
AText cut at each byte that is one of ADelimiters, as Delphi's SplitString: the parts in order, empty ones kept ("a..b" on '.' is a, "", b); "" gives one empty part.
Parameters
AText: the text to cutADelimiters: the bytes that cut it, any of them
Returns: the parts, in order
StartsStr
func cpplink StartsStr(const ASubText: string; const AText: string): bool
True when AText starts with ASubText, byte for byte (Delphi's StartsStr; "" starts every text).
Parameters
ASubText: the start to look forAText: the text
Returns: true when AText starts with it
StartsText
func cpplink StartsText(const ASubText: string; const AText: string): bool
True when AText starts with ASubText, A..Z and a..z taken as one (Delphi's StartsText: ASCII case aside, every other byte as it is; "" starts every text, a longer ASubText none).
Parameters
ASubText: the start to look forAText: the text
Returns: true when AText starts with it, ASCII case aside
EndsStr
func cpplink EndsStr(const ASubText: string; const AText: string): bool
True when AText ends with ASubText, byte for byte (Delphi's EndsStr; "" ends every text).
Parameters
ASubText: the end to look forAText: the text
Returns: true when AText ends with it
LowerCase
func cpplink LowerCase(const AText: string): string
AText with A..Z made a..z; every other byte as it is (Delphi's LowerCase: ASCII only, so a UTF-8 sequence is never touched).
Parameters
AText: the text
Returns: the lowercased text
JoinStrings
func cpplink JoinStrings(const AList: StringArray; const ASeparator: string; const AFirst: int64; const ACount: int64): string
The ACount strings of AList from AFirst on, ASeparator between each two (Delphi's String.Join(Separator, Values, StartIndex, Count)); "" for ACount 0. The caller keeps AFirst .. AFirst + ACount - 1 inside AList.
Parameters
AList: the stringsASeparator: the text put between each twoAFirst: the first index joinedACount: how many are joined
Returns: the joined text
func cpplink JoinStrings(const AList: StringArray; const ASeparator: string): string
Every string of AList, ASeparator between each two; "" for an empty list.
Parameters
AList: the stringsASeparator: the text put between each two
Returns: the joined text
IndexStr
func cpplink IndexStr(const AText: string; const AValues: StringArray): int64
The index of the first string of AValues equal to AText (case-sensitive), -1 for none (Delphi's StrUtils.IndexStr).
Parameters
AText: the text to findAValues: the strings to search
Returns: its index, or -1
UpperCase
func cpplink UpperCase(const AText: string): string
AText with a..z made A..Z; every other byte as it is (Delphi's UpperCase: ASCII only).
Parameters
AText: the text
Returns: the uppercased text
IndexOf
func cpplink IndexOf(const ASubText: string; const AText: string; const AFrom: int64): int64
The byte offset of the first occurrence of ASubText in AText at or after AFrom, byte for byte; -1 when there is none (Delphi's TStringHelper.IndexOf: 0-based, case-sensitive). An empty ASubText is found at AFrom; AFrom below 0 counts from 0, past the end finds nothing.
Parameters
ASubText: the text to findAText: the text searchedAFrom: the byte offset the search starts at
Returns: the byte offset found, or -1
NormalizePath
func cpplink NormalizePath(const APath: string): string
APath with its . parts dropped and each .. taking away the part before it, as text only: no disk is asked, so it is right for names inside an archive, URLs and paths of another machine.
/and\both separate parts; the result separates them with/.- A leading separator (a root) is kept.
- A
..with nothing before it stays in a relative path and is dropped at a root. - Empty parts (two separators in a row) are dropped.
Parameters
APath: the path
Returns: the path normalized
Example: NormalizePath("res/assets/maps/../tilesets/a.png") is "res/assets/tilesets/a.png"
TryStrToInt
func cpplink TryStrToInt(const AText: string; var AValue: int64): bool
Reads AText as a decimal whole number, a '-' allowed first, into AValue; false (AValue unchanged) when AText is not one or does not fit an int64. Unlike Delphi's TryStrToInt, no blank, '+' or '$' hex form is taken: the text is exactly the number.
Parameters
AText: the text to readAValue: receives the number (unchanged on failure)
Returns: true when AText is exactly a decimal int64
StrToIntDef
func cpplink StrToIntDef(const AText: string; const ADefault: int64): int64
AText as a decimal whole number (TryStrToInt's rule), else ADefault (Delphi's StrToIntDef).
Parameters
AText: the text to readADefault: the value when it is not a number
Returns: the number, or ADefault
MatchesGlob
func cpplink MatchesGlob(const AText: string; const AMask: string): bool
True when AText matches AMask byte for byte, case-sensitive, where '*' in AMask matches any run of bytes (none included) and '?' any one byte. No other character is special.
Parameters
AText: the textAMask: the mask, with * and ?
Returns: true when it matches
ReplaceStr
func cpplink ReplaceStr(const AText: string; const AFromText: string; const AToText: string): string
AText with every occurrence of AFromText replaced by AToText, byte for byte and case-sensitive, left to right (Delphi's ReplaceStr). A replacement is never searched again: replacing "a" by "aa" doubles each "a" once. An empty AFromText changes nothing.
Parameters
AText: the textAFromText: what to replaceAToText: what goes in its place
Returns: the new text
Example: LUnix := ReplaceStr(LText, "\r\n", "\n");
MatchesPathGlob
func cpplink MatchesPathGlob(const APath: string; const AMask: string): bool
True when the relative path APath matches the path mask AMask, both with / between their parts, byte for byte and case-sensitive (the same answer on every target). A part ** matches none or more whole parts; in any other part * matches any run of bytes and ? any one byte, never across a / (MatchesGlob within the part). \ in either is read as /. A mask with no / names a file at the top only: *.md takes README.md, not docs/a.md (that is **/*.md).
Parameters
APath: the path ("bin/res/std/a.adam")AMask: the mask ("bin/res/**","projects/*/output/**","**/*.pdb")
Returns: true when it matches
Example: if MatchesPathGlob(LName, "**/__pycache__/**") then .. end;
PascalCase
func cpplink PascalCase(const AText: string): string
AText in PascalCase: its words (split at _, -, spaces and other punctuation, and where a capital follows a small letter or ends a run of capitals) each capitalized and joined. ASCII letters only change case; other bytes stay as they are.
Parameters
AText: the text ("hello_world","hello world","helloWorld"...)
Returns: the PascalCase text ("HelloWorld"; "XMLFile" gives "XMLFile")
Example: PascalCase("player_score") is "PlayerScore"
CamelCase
func cpplink CamelCase(const AText: string): string
AText in camelCase: PascalCase's words, the first all small letters.
Parameters
AText: the text
Returns: the camelCase text
Example: CamelCase("Player Score") is "playerScore"
SnakeCase
func cpplink SnakeCase(const AText: string): string
AText in snake_case: PascalCase's words in small letters, _ between them.
Parameters
AText: the text
Returns: the snake_case text
Example: SnakeCase("PlayerScore") is "player_score"
ReplaceBetween
func cpplink ReplaceBetween(const AText: string; const ABegin: string; const AEnd: string; const AReplacement: string): string
AText with the text between the first ABegin and the first AEnd after it replaced by AReplacement, both markers kept: a template's slot filled. Byte for byte, case-sensitive; with either marker missing (or "") AText comes back unchanged.
Parameters
AText: the textABegin: the marker the slot starts afterAEnd: the marker the slot ends beforeAReplacement: what goes in the slot
Returns: the new text
Example: ReplaceBetween("<b>old</b>", "<b>", "</b>", "new") is "<b>new</b>"
Between
func cpplink Between(const AText: string; const ABegin: string; const AEnd: string): string
The text between the first ABegin in AText and the first AEnd after it, the markers left out: a template's slot read (ReplaceBetween's twin). Byte for byte, case-sensitive; "" with either marker missing (or ""), and for an empty slot.
Parameters
AText: the textABegin: the marker the slot starts afterAEnd: the marker the slot ends before
Returns: the slot's text
Example: Between("<b>hi</b>", "<b>", "</b>") is "hi"
SortStrings
func cpplink SortStrings(var AList: StringArray)
Sorts AList by its UTF-8 bytes as unsigned values, a prefix first: the same order on every machine. Stable; a bottom-up merge sort (n log n, as SortInt64s).
Parameters
AList: the list, sorted in place
ExtractFileName
func cpplink ExtractFileName(const APath: string): string
The name part of a path, as Delphi's ExtractFileName: the text after its last separator ('/', '\' or a drive's ':'), "" when the path ends in one. The path is taken as text (the disk is never touched).
Parameters
APath: the path
Returns: its name part
ExtractFileDir
func cpplink ExtractFileDir(const APath: string): string
The folder part of a path, as Delphi's ExtractFileDir: the text before its name part, without the last separator unless that separator is the root's ("/x" -> "/", "c:\x" -> "c:\", "c:x" -> "c:"); "" when the path has no separator. The disk is never touched.
Parameters
APath: the path
Returns: its folder part
ChangeFileExt
func cpplink ChangeFileExt(const APath: string; const AExt: string): string
A path with its extension changed, as Delphi's ChangeFileExt: the name part's text from its last '.' on is replaced by AExt (".bak", or "" to drop it); a name with no '.' gets AExt added. Separators as ExtractFileName reads them.
Parameters
APath: the pathAExt: the new extension, with its dot (or "" to drop it)
Returns: the changed path
ExtractFileExt
func cpplink ExtractFileExt(const APath: string): string
A path's extension, as Delphi's ExtractFileExt: the name part's text from its last '.' on, the '.' included ("a.tar.gz" -> ".gz", "a." -> ".", ".profile" -> ".profile"); "" when the name has no '.'. The one way to read an extension (ChangeFileExt the one way to set it); the disk is never touched.
Parameters
APath: the path
Returns: its extension, or ""
IsFileNameValid
func cpplink IsFileNameValid(const AName: string): bool
True when AName is one file or folder name that every target can hold, so a name a program makes (a save slot, an export) works on Windows and Linux alike. Refused:
"",".",".."and a name past 255 bytes;- a path separator (
/,\), a control character or one of:<>"|?*; - a last character
.or space (Windows drops it, so two names would mean one file); - a Windows device name (
CON,PRN,AUX,NUL,COM1-9,LPT1-9, any case, with any extension).
Text only: the disk is never asked, so the name need not exist.
Parameters
AName: the name (no folder part)
Returns: true when it is a valid name on every target
Example: if not IsFileNameValid(LSlot + ".sav") then LSlot := "slot1"; end;
UIntToStr
func cpplink UIntToStr(const AValue: uint64): string
AValue in decimal.
Parameters
AValue: the number
Returns: its decimal text
IntToHex
func cpplink IntToHex(const AValue: uint64; const AMinDigits: int32): string
AValue in uppercase hex, padded with '0' to at least AMinDigits digits (at most 16: a uint64 has no more).
Parameters
AValue: the numberAMinDigits: the fewest digits written
Returns: its hex text
TryHexToRGBA
func cpplink TryHexToRGBA(const AText: string; var ARGBA: uint32): bool
The colour the hex text AText names, as 0xRRGGBBAA: an optional #, then 3, 4, 6 or 8 hex digits (RGB, RGBA, RRGGBB or RRGGBBAA, either case); a short form's digits count twice (F is FF) and the alpha is 0xFF when none is given.
Parameters
AText: the text, e.g."#3a7bd5","FFF","#00000080"ARGBA: the colour, 0xRRGGBBAA (red in the highest byte); unchanged when the text names none
Returns: true when AText is such a colour, false for any other text
Example: if TryHexToRGBA("#3a7bd5", LRGBA) then LRed := (LRGBA shr 24) & 255; end;
RGBAToHex
func cpplink RGBAToHex(const ARGBA: uint32; const AAlpha: bool): string
The hex text of the colour ARGBA (0xRRGGBBAA, red in the highest byte), uppercase: #RRGGBB, or #RRGGBBAA when AAlpha is true. TryHexToRGBA reads it back.
Parameters
ARGBA: the colourAAlpha:trueto write the alpha too
Returns: the text
Example: RGBAToHex(0x3A7BD5FF, false) is "#3A7BD5"
IntToStr
func cpplink IntToStr(const AValue: int64): string
AValue in decimal, a '-' before a negative one (the lowest int64 included).
Parameters
AValue: the number
Returns: its decimal text
BoolToStr
func cpplink BoolToStr(const AValue: bool): string
"true" or "false", as println prints a bool.
Parameters
AValue: the bool
Returns: "true" or "false"
Float64ToBits
func cpplink Float64ToBits(const AValue: float64): uint64
The IEEE 754 binary64 bits of AValue, as it sits in memory (sign, 11 exponent bits, 52 mantissa bits).
Parameters
AValue: the float
Returns: its bits
Float64FromBits
func cpplink Float64FromBits(const ABits: uint64): float64
The float64 whose IEEE 754 binary64 bits are ABits (Float64ToBits' inverse: every bit pattern back as it was, NaN payloads included).
Parameters
ABits: the bits
Returns: the float
Float32ToBits
func cpplink Float32ToBits(const AValue: float32): uint32
The IEEE 754 binary32 bits of AValue, as it sits in memory (sign, 8 exponent bits, 23 mantissa bits); the caller converts to float32 first, once (C's rounding: to nearest).
Parameters
AValue: the float
Returns: its bits
Float32FromBits
func cpplink Float32FromBits(const ABits: uint32): float32
The float32 whose IEEE 754 binary32 bits are ABits (Float32ToBits' inverse: every bit pattern back as it was, NaN payloads included).
Parameters
ABits: the bits
Returns: the float
FloatToStr
func cpplink FloatToStr(const AValue: float64): string
AValue as the shortest text that reads back as the same float64, as println prints it (C++'s std::format "{}"): fixed or scientific, whichever is shorter (fixed on a tie): 1, 0.1, 100, 1e+20, 1.5e-07, 5e-324. Zero keeps its sign (-0); inf, -inf, nan, -nan.
Parameters
AValue: the float
Returns: its shortest text
TryStrToFloat
func cpplink TryStrToFloat(const AText: string; var AValue: float64): bool
The float64 a C++ float literal's text (without its suffix) means, as clang reads it: decimal (1.5, 2e10, 1'000.5) or hex (0x1.8p3), rounded once, half to even. False when AText is no such literal (AValue 0); a value past the largest float64 is inf.
Parameters
AText: the literal textAValue: receives the value (0 on failure)
Returns: true when AText is a float literal
TryStrToFloat32
func cpplink TryStrToFloat32(const AText: string; var AValue: float64): bool
As TryStrToFloat, rounded once to float32 (a literal with the f suffix): AValue holds the float32 value exactly; a value past the largest float32 is inf.
Parameters
AText: the literal textAValue: receives the float32 value (0 on failure)
Returns: true when AText is a float literal
PutLe
func cpplink PutLe(var ABytes: ByteArray; const AAt: int64; const AValue: uint64; const ACount: int64)
Writes the low ACount bytes of AValue into ABytes at AAt, the lowest byte first (the little-endian order COFF and PE use). The caller keeps AAt .. AAt + ACount - 1 inside ABytes and ACount in 1..8.
Parameters
ABytes: the bytes written intoAAt: the index of the first byteAValue: the numberACount: how many of its bytes, 1..8
GetLe
func cpplink GetLe(const ABytes: ByteArray; const AAt: int64; const ACount: int64): uint64
The ACount bytes of ABytes at AAt read as an unsigned number, the lowest byte first (PutLe's reverse). The caller keeps AAt .. AAt + ACount - 1 inside ABytes and ACount in 1..8.
Parameters
ABytes: the bytesAAt: the index of the first byteACount: how many bytes, 1..8
Returns: the number
ReadLowBits
func cpplink ReadLowBits(const AValue: int64; const AWidth: int64; const ASigned: bool): int64
The integer the low AWidth bits of AValue are: read as two's complement when ASigned (the top bit of the AWidth copied up), else as an unsigned number (the bits above cleared). The caller keeps AWidth in 1..64; at 64 AValue comes back as it is.
Parameters
AValue: the valueAWidth: how many low bits, 1..64ASigned: true to read them as two's complement
Returns: the integer they are
BitMask
func cpplink BitMask(const AWidth: int64; const AAt: int64): int64
The mask of AWidth set bits starting at bit AAt (bit 0 the lowest), as the int64 those 64 bits are: BitMask(3, 4) = 0x70. The caller keeps AWidth in 1..64 and AAt + AWidth at most 64; at 64 every bit is set.
Parameters
AWidth: how many bits, 1..64AAt: the lowest bit set
Returns: the mask
AlignUp
func cpplink AlignUp(const AValue: int64; const AAlign: int64): int64
AValue rounded up to the next multiple of AAlign, a power of two the caller keeps above 0 (sections, tables and file offsets laid out at their alignment).
Parameters
AValue: the valueAAlign: the alignment, a power of two
Returns: the rounded value
Fnv1a64
func cpplink Fnv1a64(const AText: string): uint64
FNV-1a 64 over AText's bytes: each byte xor-ed in, then a multiply by the prime. The one content hash of the std (a source's bytes, a type's text, a salted password): stable across runs, builds and targets, so it may be written into files.
Parameters
AText: the bytes hashed
Returns: the hash
ProgramFilePath
func cpplink ProgramFilePath(): string
The full path of the program's own exe, as the system reports it ("" when the runtime cannot read it).
Returns: the path, or ""
IsPowerOfTwo
func cpplink IsPowerOfTwo(const AValue: int64): bool
True when AValue is a power of two (1, 2, 4, ...); false for 0 and below (an alignment checked before AlignUp or a mask relies on it).
Parameters
AValue: the value
Returns: true for a power of two
SortInt64s
func cpplink SortInt64s(var AList: Int64Array)
Sorts AList ascending. Stable; a bottom-up merge sort (runs of 1, 2, 4, ... merged into a second array, the two arrays trading places each pass), so long lists sort in n log n.
Parameters
AList: the list, sorted in place
System.TOML.Ext
TOML documents in Adam, over tomlc17's C API (System.TOML.C): a TOMLDocument parses a text or a file (read by System.Runtime's ReadFileBytes: target-neutral), then hands out its values by path with typed getters. Every getter returns false on a failure and leaves the reason in ErrorText, in Adam's form "file(line,col): message": a parse error at the place tomlc17 reports, a value error at the value it is about. What tomlc17 hands back is freed by the document's done (or its next parse); no getter result needs freeing.
Import it with import System.TOML.Ext;.
Types
TOMLKind
type TOMLKind = choices(
The kind of a value (TOML v1.0's kinds), as KindOf gives it.
Members
TOMLKind.Missing: The path names no value.TOMLKind.String: A string.TOMLKind.Integer: A whole number (int64).TOMLKind.Float: A float (float64).TOMLKind.Boolean: true or false.TOMLKind.LocalDate: A date with no time or offset.TOMLKind.LocalTime: A time with no date or offset.TOMLKind.LocalDateTime: A date and a time, no offset.TOMLKind.OffsetDateTime: A date and a time with an offset from UTC.TOMLKind.Array: An array.TOMLKind.Table: A table.
TOMLDateTime
type TOMLDateTime = record
A date / time value's parts, as GetDateTime gives them; those its Kind does not hold are 0 (a LocalDate has no time, a LocalTime no date, only an OffsetDateTime an offset).
Members
Kind: TOMLKind: Which of the four date / time kinds it is.Year: int32: The year.Month: int32: The month, 1 .. 12.Day: int32: The day of the month, 1 .. 31.Hour: int32: The hour, 0 .. 23.Minute: int32: The minute, 0 .. 59.Second: int32: The second, 0 .. 60.Microsecond: int32: The microsecond, 0 .. 999999.OffsetMinutes: int32: The offset from UTC in minutes east (an OffsetDateTime's only).
TOMLDocument
type TOMLDocument = object
A parsed TOML document: ParseText or ParseFile, then its values by path through the typed getters, each false with ErrorText on a failure. What tomlc17 hands back is freed by its done or its next parse; no getter result needs freeing.
Members
init(): A document with nothing parsed yet.method Release(): Frees the last parse's result, if one is held (done and the next parse do it too).done: Frees the last parse's result.method Fail(const ALine: int64; const ACol: int64; const AText: string): bool: Records an error placed at a line and column of the document, as the getters do, for a caller that checks a value itself (Find, then its own rule). Parameters:ALinethe line (0: not known);AColthe column (0: not known);ATextthe message. Returns: false, always (what a failing getter returns)method ParseText(const AText: string; const ASourceName: string): bool: Parses TOML text. Parameters:ATextthe TOML text;ASourceNamethe name errors are placed at ("" for<text>). Returns: false with ErrorText when it is no valid TOMLmethod ParseFile(const APath: string): bool: Reads and parses a TOML file, its path naming it in errors. Parameters:APaththe file (relative to the working folder). Returns: false with ErrorText when it cannot be read or is no valid TOMLconst method ErrorText(): string: The last failure, infile(line,col): messageform. Returns: the reason, or "" after a successconst method IsParsed(): bool: Whether the last parse succeeded. Returns: true when it didmethod Find(const APath: string; var ADatum: toml_datum_t): bool: The raw tomlc17 value a path names, for a caller that reads it itself (its line and column, a kind no getter covers). Parameters:APaththe path (keys joined by., an item as[N]; "" the top table);ADatumreceives the value. Returns: false with ErrorText (at the value it is about) on a failureconst method Has(const APath: string): bool: Whether a path names a value (no error recorded either way). Parameters:APaththe path (keys joined by., an item as[N]; "" the top table). Returns: true when it doesconst method KindOf(const APath: string): TOMLKind: The kind of the value a path names (no error recorded). Parameters:APaththe path (keys joined by., an item as[N]; "" the top table). Returns: the kind; Missing when it names nonemethod GetString(const APath: string; var AValue: string): bool: Reads the string a path names. Parameters:APaththe path (keys joined by., an item as[N]; "" the top table);AValuereceives the string. Returns: false with ErrorText (at the value it is about) on a failuremethod GetInt64(const APath: string; var AValue: int64): bool: Reads the integer a path names. Parameters:APaththe path (keys joined by., an item as[N]; "" the top table);AValuereceives the integer. Returns: false with ErrorText (at the value it is about) on a failuremethod GetFloat64(const APath: string; var AValue: float64): bool: Reads the float a path names (an integer is not taken: TOML keeps the two apart). Parameters:APaththe path (keys joined by., an item as[N]; "" the top table);AValuereceives the float. Returns: false with ErrorText (at the value it is about) on a failuremethod GetBool(const APath: string; var AValue: bool): bool: Reads the boolean a path names. Parameters:APaththe path (keys joined by., an item as[N]; "" the top table);AValuereceives the boolean. Returns: false with ErrorText (at the value it is about) on a failuremethod GetDateTime(const APath: string; var AValue: TOMLDateTime): bool: Reads the date / time a path names (any of the four kinds). Parameters:APaththe path (keys joined by., an item as[N]; "" the top table);AValuereceives its parts. Returns: false with ErrorText (at the value it is about) on a failuremethod Count(const APath: string; var ACount: int64): bool: How many items the array, or keys the table, a path names holds. Parameters:APaththe path (keys joined by., an item as[N]; "" the top table);ACountreceives the count. Returns: false with ErrorText (at the value it is about) on a failuremethod KeyAt(const APath: string; const AIndex: int64; var AKey: string): bool: One key of the table a path names, in the document's order; its value is atAPath + "." + TOMLQuoteKey(AKey). Parameters:APaththe path (keys joined by., an item as[N]; "" the top table);AIndexthe key's place (0-based);AKeyreceives the key. Returns: false with ErrorText (at the value it is about) on a failure
Example: if LDoc.ParseFile("game.toml") and LDoc.GetInt64("window.width", LWidth) then ... end;
Routines
TOMLQuoteKey
func cpplink TOMLQuoteKey(const AKey: string): string
A key as one key of a path: bare when it can be, else quoted (" and \ escaped).
Parameters
AKey: the key
Returns: the path key
Example: LDoc.GetString("servers." + TOMLQuoteKey("eu.west") + ".host", LHost);
TOMLQuoteString
func cpplink TOMLQuoteString(const AText: string): string
A text as a TOML basic string, to write into a .toml file: in double quotes, " and \ escaped, a control byte as \b \t \n \f \r or \u00XX (UTF-8 passes through).
Parameters
AText: the text
Returns: the TOML string
Example: WriteLine(LFile, "name = " + TOMLQuoteString(LName));
System.TextTemplate
a text template engine for any kind of text: HTML, Markdown or plain text. A template is text with tags in double braces; rendering fills them from a JSON value (System.JSON.Ext), built in code or loaded from a file, so a page's look lives in a template file read at run time and never in the program.
Import it with import System.TextTemplate;.
Types
TextKind
type TextKind = choices(
The kind of text a template writes: it picks how {{value}} escapes and what the built-in image helper writes.
Members
TextKind.HTML:& < > " 'become entities;imageembeds the file as a data URI.TextKind.Markdown: Markdown's marks get a backslash;imagewrites.TextKind.Text: Nothing is escaped;imagewrites its alt text.
TemplateArgs
type TemplateArgs = object
The arguments a helper or a filter is called with: positional ones by index, named ones (key=value) by name, each a JSON value (a path's value, or a literal's); with the template's kind and the folder of the template file the tag is in.
Members
init(): Empty arguments for an HTML template from text (no folder).init(const AKind: TextKind; const AFolder: string): Empty arguments for a tag in a template of a kind. Parameters:AKindthe template's kind of text;AFolderthe folder of the template file holding the tag ("" for text / an IO).method Add(const AValue: JSON): Adds a positional argument after the others. Parameters:AValuethe argument.method Add(const AName: string; const AValue: JSON): Adds a named argument (one already of that name is replaced). Parameters:ANamethe name;AValuethe argument.const method Count(): int64: How many positional arguments there are. Returns: the countconst method Get(const AIndex: int64): JSON: A positional argument. Parameters:AIndexits index, from 0. Returns: its value; null when there is no such argumentconst method Has(const AName: string): bool: Whether a named argument was given. Parameters:ANamethe name. Returns: true when it wasconst method Get(const AName: string): JSON: A named argument. Parameters:ANamethe name. Returns: its value; null when it was not givenconst method Text(const AIndex: int64): string: A positional argument's text (a string as itself, a number as written, null as ""). Parameters:AIndexits index, from 0. Returns: the text; "" when there is no such argumentconst method Text(const AName: string; const AFallback: string): string: A named argument's text (a string as itself, a number as written). Parameters:ANamethe name;AFallbackthe text when it was not given (or is null). Returns: the text, or AFallbackconst method Kind(): TextKind: The kind of text the template writes (what a helper's own output must be). Returns: the kindconst method Folder(): string: The folder of the template file holding the tag, for files a helper reads beside it. Returns: the folder; "" for a template from text or an IO
TemplateHelper
type TemplateHelper = ref func(const AArgs: TemplateArgs): string
A helper a program adds to a template: {{name arg key=value}} calls it, and its text goes into the output as it is (a helper writes markup of the template's kind itself: EscapeText for the parts that are text).
TemplateFilter
type TemplateFilter = ref func(const AValue: string; const AArgs: TemplateArgs): string
A filter a program adds to a template: {{x | name arg}} calls it with the text so far.
TextTemplate
type TextTemplate = object
A parsed text template (see the unit's header for the tags). Make one with FromString, FromFile or FromIO, add any helpers and filters, then Render it with JSON data, as often as needed. A failed parse or render leaves its reason in ErrorText.
Members
static method FromString(const AText: string; const AKind: TextKind): TextTemplate: A template parsed from text; its includes and images are found from the working folder. Parameters:ATextthe template;AKindthe kind of text it writes. Returns: the template (ErrorText says why when it did not parse)static method FromFile(const APath: string): TextTemplate: A template read from a file, its kind from the extension (.html / .htm: HTML, .md / .markdown: Markdown, else Text); its includes and images are found beside it. Parameters:APaththe file ($P:and the other ResolvePath forms work). Returns: the template (ErrorText says why when it could not be read or parsed)static method FromIO(const AIO: IO; const AKind: TextKind): TextTemplate: A template read from an IO (a file in a zip, memory ...); its includes and images are found from the working folder. Parameters:AIOthe IO, read to its end;AKindthe kind of text it writes. Returns: the template (ErrorText says why when it could not be read or parsed)const method ErrorText(): string: Why the template did not parse, or why the last Render failed. Returns:<template>:<line>:<col>: <reason>; "" when all went wellconst method Kind(): TextKind: The kind of text the template writes. Returns: the kindmethod AddHelper(const AName: string; const AHelper: TemplateHelper): TextTemplate: Adds a helper{{AName ..}}calls (one already of that name is replaced; a helper named image replaces the built-in one). Parameters:ANamethe name the tags use;AHelperthe routine. Returns: the template, for chainingmethod AddFilter(const AName: string; const AFilter: TemplateFilter): TextTemplate: Adds a filter{{x | AName ..}}calls (one already of that name, or a built-in one, is replaced). Parameters:ANamethe name the tags use;AFilterthe routine. Returns: the template, for chainingmethod Render(const AData: JSON): string: The template filled from data. Parameters:ADatathe data its paths are looked up in (JSON.FromString / FromFile, or built with Add). Returns: the text; "" when the template did not parse or the render failed (ErrorText says why)method RenderToFile(const AData: JSON; const APath: string): bool: The template filled from data, written to a file (its folder made first). Parameters:ADatathe data;APaththe file. Returns: true when it rendered and was written (else ErrorText says why a render failed)method RenderToIO(const AData: JSON; const AIO: IO): bool: The template filled from data, written to an IO. Parameters:ADatathe data;AIOthe IO written to. Returns: true when it rendered and was written (else ErrorText says why a render failed)
Example: TextTemplate.FromString("<h1>{{title}}</h1>", TextKind.HTML).Render(JSON.FromString("{\"title\":\"Adam\"}")) gives <h1>Adam</h1>
Routines
EscapeText
func cpplink EscapeText(const AText: string; const AKind: TextKind): string
Text made safe to put into a template's output of a kind.
HTML:&<>"'become entitiesMarkdown:\`*_[]<>|#get a backslashText: unchanged
Parameters
AText: the textAKind: the kind of text it goes into
Returns: the escaped text
Example: EscapeText("a < b", TextKind.HTML) gives a < b
System.Windows
Adam's Windows layer: paths, files, folders, processes and the program's own end over the Win32 API
Import it with import System.Windows;.
Types
WideBuffer
type WideBuffer = array[0..32767] of uint16
A NUL-terminated UTF-16 text as Win32 reads and writes it
WideBox
type WideBox = final object
A WideBuffer on the heap: a routine's 64 KB buffer kept off its stack frame, freed on every way out (return or raise) by its own
Members
Data: array[0..32767] of uint16: The buffer.
PseudoConsole
type PseudoConsole = object
A pseudo console (ConPTY) a started program takes as its console (StdApp.Utils' CaptureConsolePTY; System.IO's captured runs and the debugger's Terminal mode both use it): CreatePseudoConsole over two plain pipes, nothing inheritable, so the program reaches only the pseudo console. Open makes it; AttributeList names it (and a standard input of the program's own) for STARTUPINFOEXW; Output is its output pipe's read end (VT text, UTF-8), WriteKeys writes its input pipe, Resize sizes it. Close closes it on a task while this thread reads its output to the pipe's break: it writes out what it still holds first (an older Windows waits in ClosePseudoConsole for that drain), so nothing is lost to timing
Members
method Open(const ACols: int32; const ARows: int32): uint32: Made at ACols x ARows (each held to 1..32767); 0, else Windows' reason (a GetLastError code, or CreatePseudoConsole's HRESULT); nothing is left open when it fails. One still open is closed first (its last output dropped) Parameters:AColsthe columns;ARowsthe lines. Returns: 0, else Windows' reasonmethod IsOpen(): bool: Made and not yet closed Returns: true while openmethod Output(): uint64: The output pipe's read end (0 when not open): read with WinReadAvailable / WinReadSome Returns: the read end, or 0method AttributeList(const AStdin: uint64): ptr: The list for STARTUPINFOEXW.lpAttributeList: this pseudo console, and with AStdin <> 0 that handle as the only one the program inherits (CreateProcessW's bInheritHandles 1 then, AStdin inheritable and open until it returned). nil when not open or Windows refuses. ReleaseList frees it after CreateProcessW Parameters:AStdinthe one handle the program inherits, or 0. Returns: the list, or nilmethod ReleaseList(): AttributeList's list freed (nothing when there is none)method WriteKeys(const AText: string): bool: AText (UTF-8 keys) written whole into the program's terminal. False when not open or the pipe is gone Parameters:ATextthe keys, UTF-8. Returns: false when not open or the pipe is gonemethod Resize(const ACols: int32; const ARows: int32): bool: The terminal's new size (each side held to 1..32767). False when not open or refused Parameters:AColsthe columns;ARowsthe lines. Returns: false when not open or refusedmethod Close(var ATail: string): Closed (see the type): what it still writes out appended to ATail, then both pipe ends and the list. Nothing when it is not open (its pipe ends still closed) Parameters:ATailgets its last output appended.done: One still open at the end is closed (its last output dropped)
Constants
| Name | Declaration | Description |
|---|---|---|
ADAM_WINDOWS_WIDE_MAX | const ADAM_WINDOWS_WIDE_MAX: int32 = 32767 | The UTF-16 units a Win32 path or command line holds, its NUL not counted |
ADAM_WINDOWS_SHORT_PATH_MAX | const ADAM_WINDOWS_SHORT_PATH_MAX: int64 = 247 | The UTF-16 units up to which WinResolvePath writes a path with '/' (the plain Win32 limit); past it, the long-path spelling |
ADAM_WINDOWS_ENV_LOCAL_APP_DATA | const ADAM_WINDOWS_ENV_LOCAL_APP_DATA: string = "LOCALAPPDATA" | The environment variable naming this user's local (not roaming) application data folder |
ADAM_WINDOWS_IO_SIZE | const ADAM_WINDOWS_IO_SIZE: uint32 = 4096 | The bytes one pipe read takes (WinReadAvailable's reads). |
ADAM_WINDOWS_REPLACE_TRIES | const ADAM_WINDOWS_REPLACE_TRIES: int32 = 10 | The tries WinReplaceFile makes while another process (a virus scanner, the search indexer) briefly holds the file: about a second in all with ADAM_WINDOWS_REPLACE_WAIT_MS |
ADAM_WINDOWS_REPLACE_WAIT_MS | const ADAM_WINDOWS_REPLACE_WAIT_MS: int32 = 10 | WinReplaceFile's first wait between tries, in milliseconds: each wait doubles, up to ADAM_WINDOWS_REPLACE_WAIT_MAX_MS |
ADAM_WINDOWS_REPLACE_WAIT_MAX_MS | const ADAM_WINDOWS_REPLACE_WAIT_MAX_MS: int32 = 160 | WinReplaceFile's longest wait between tries, in milliseconds |
ADAM_WINDOWS_CPU_KEY | const ADAM_WINDOWS_CPU_KEY: wstring = "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0" | The registry key (under HKEY_LOCAL_MACHINE) that describes the first processor |
ADAM_WINDOWS_CPU_NAME_VALUE | const ADAM_WINDOWS_CPU_NAME_VALUE: wstring = "ProcessorNameString" | The value of ADAM_WINDOWS_CPU_KEY that names the processor (its brand string) |
Routines
GetLastError
func clink GetLastError(): uint32
Windows' GetLastError.
Returns: as Windows' GetLastError returns it
GetStdHandle
func clink GetStdHandle(AStdHandle: uint32): uint64
Windows' GetStdHandle.
Parameters
AStdHandle: as Windows'GetStdHandletakes it
Returns: as Windows' GetStdHandle returns it
GetConsoleMode
func clink GetConsoleMode(AConsole: uint64; var AMode: uint32): int32
Windows' GetConsoleMode.
Parameters
AConsole: as Windows'GetConsoleModetakes itAMode: as Windows'GetConsoleModetakes it
Returns: as Windows' GetConsoleMode returns it
GetModuleHandleW
func clink GetModuleHandleW(AModuleName: ptr to const uint16): uint64
Windows' GetModuleHandleW.
Parameters
AModuleName: as Windows'GetModuleHandleWtakes it
Returns: as Windows' GetModuleHandleW returns it
LoadIconW
func clink LoadIconW(AInstance: uint64; AIconName: ptr to const uint16): uint64
Windows' LoadIconW.
Parameters
AInstance: as Windows'LoadIconWtakes itAIconName: as Windows'LoadIconWtakes it
Returns: as Windows' LoadIconW returns it
SendMessageW
func clink SendMessageW(AWindow: uint64; AMsg: uint32; AWParam: uint64; ALParam: int64): int64
Windows' SendMessageW.
Parameters
AWindow: as Windows'SendMessageWtakes itAMsg: as Windows'SendMessageWtakes itAWParam: as Windows'SendMessageWtakes itALParam: as Windows'SendMessageWtakes it
Returns: as Windows' SendMessageW returns it
LoadImageW
func clink LoadImageW(AInstance: uint64; AName: ptr to const uint16; AType: uint32; ACx: int32; ACy: int32; ALoad: uint32): uint64
Windows' LoadImageW.
Parameters
AInstance: as Windows'LoadImageWtakes itAName: as Windows'LoadImageWtakes itAType: as Windows'LoadImageWtakes itACx: as Windows'LoadImageWtakes itACy: as Windows'LoadImageWtakes itALoad: as Windows'LoadImageWtakes it
Returns: as Windows' LoadImageW returns it
DestroyIcon
func clink DestroyIcon(AIcon: uint64): int32
Windows' DestroyIcon.
Parameters
AIcon: as Windows'DestroyIcontakes it
Returns: as Windows' DestroyIcon returns it
GetSystemMetrics
func clink GetSystemMetrics(AIndex: int32): int32
Windows' GetSystemMetrics.
Parameters
AIndex: as Windows'GetSystemMetricstakes it
Returns: as Windows' GetSystemMetrics returns it
SetTimer
func clink SetTimer(AWindow: uint64; AIdEvent: uint64; AElapse: uint32; ATimerFunc: TIMERPROC): uint64
Windows' SetTimer.
Parameters
AWindow: as Windows'SetTimertakes itAIdEvent: as Windows'SetTimertakes itAElapse: as Windows'SetTimertakes itATimerFunc: as Windows'SetTimertakes it
Returns: as Windows' SetTimer returns it
KillTimer
func clink KillTimer(AWindow: uint64; AIdEvent: uint64): int32
Windows' KillTimer.
Parameters
AWindow: as Windows'KillTimertakes itAIdEvent: as Windows'KillTimertakes it
Returns: as Windows' KillTimer returns it
GetTickCount64
func clink GetTickCount64(): uint64
Windows' GetTickCount64.
Returns: as Windows' GetTickCount64 returns it
GetSystemTimeAsFileTime
func clink GetSystemTimeAsFileTime(var ASystemTimeAsFileTime: FILETIME)
Windows' GetSystemTimeAsFileTime.
Parameters
ASystemTimeAsFileTime: as Windows'GetSystemTimeAsFileTimetakes it
CreatePipe
func clink CreatePipe(var ARead: uint64; var AWrite: uint64; var AAttributes: SECURITY_ATTRIBUTES; ASize: uint32): int32
Windows' CreatePipe.
Parameters
ARead: as Windows'CreatePipetakes itAWrite: as Windows'CreatePipetakes itAAttributes: as Windows'CreatePipetakes itASize: as Windows'CreatePipetakes it
Returns: as Windows' CreatePipe returns it
SetHandleInformation
func clink SetHandleInformation(AHandle: uint64; AMask: uint32; AFlags: uint32): int32
Windows' SetHandleInformation.
Parameters
AHandle: as Windows'SetHandleInformationtakes itAMask: as Windows'SetHandleInformationtakes itAFlags: as Windows'SetHandleInformationtakes it
Returns: as Windows' SetHandleInformation returns it
CreateFileW
func clink CreateFileW(var AFileName: WideBuffer; AAccess: uint32; AShare: uint32; var AAttributes: SECURITY_ATTRIBUTES; ADisposition: uint32; AFlags: uint32; ATemplate: uint64): uint64
Windows' CreateFileW.
Parameters
AFileName: as Windows'CreateFileWtakes itAAccess: as Windows'CreateFileWtakes itAShare: as Windows'CreateFileWtakes itAAttributes: as Windows'CreateFileWtakes itADisposition: as Windows'CreateFileWtakes itAFlags: as Windows'CreateFileWtakes itATemplate: as Windows'CreateFileWtakes it
Returns: as Windows' CreateFileW returns it
CreateProcessW
func clink CreateProcessW(var AApplication: WideBuffer; var ACommandLine: WideBuffer; AProcessAttributes: ptr; AThreadAttributes: ptr; AInheritHandles: int32; AFlags: uint32; AEnvironment: ptr; var ACurrentDirectory: WideBuffer; var AStartup: STARTUPINFOW; var AInfo: PROCESS_INFORMATION): int32
Windows' CreateProcessW.
Parameters
AApplication: as Windows'CreateProcessWtakes itACommandLine: as Windows'CreateProcessWtakes itAProcessAttributes: as Windows'CreateProcessWtakes itAThreadAttributes: as Windows'CreateProcessWtakes itAInheritHandles: as Windows'CreateProcessWtakes itAFlags: as Windows'CreateProcessWtakes itAEnvironment: as Windows'CreateProcessWtakes itACurrentDirectory: as Windows'CreateProcessWtakes itAStartup: as Windows'CreateProcessWtakes itAInfo: as Windows'CreateProcessWtakes it
Returns: as Windows' CreateProcessW returns it
LoadLibraryExW
func clink LoadLibraryExW(var AFileName: WideBuffer; AFile: uint64; AFlags: uint32): uint64
Windows' LoadLibraryExW: A PE image's resources read (LoadLibraryExW as a data file) and replaced (the update API); a type or name argument is an id (its value) or a UTF-16 text's address
Parameters
AFileName: as Windows'LoadLibraryExWtakes itAFile: as Windows'LoadLibraryExWtakes itAFlags: as Windows'LoadLibraryExWtakes it
Returns: as Windows' LoadLibraryExW returns it
FreeLibrary
func clink FreeLibrary(AModule: uint64): int32
Windows' FreeLibrary.
Parameters
AModule: as Windows'FreeLibrarytakes it
Returns: as Windows' FreeLibrary returns it
EnumResourceNamesW
func clink EnumResourceNamesW(AModule: uint64; AType: uint64; AEnum: ENUMRESNAMEPROCW; AParam: ptr): int32
Windows' EnumResourceNamesW.
Parameters
AModule: as Windows'EnumResourceNamesWtakes itAType: as Windows'EnumResourceNamesWtakes itAEnum: as Windows'EnumResourceNamesWtakes itAParam: as Windows'EnumResourceNamesWtakes it
Returns: as Windows' EnumResourceNamesW returns it
EnumResourceLanguagesW
func clink EnumResourceLanguagesW(AModule: uint64; AType: uint64; AName: uint64; AEnum: ENUMRESLANGPROCW; AParam: ptr): int32
Windows' EnumResourceLanguagesW.
Parameters
AModule: as Windows'EnumResourceLanguagesWtakes itAType: as Windows'EnumResourceLanguagesWtakes itAName: as Windows'EnumResourceLanguagesWtakes itAEnum: as Windows'EnumResourceLanguagesWtakes itAParam: as Windows'EnumResourceLanguagesWtakes it
Returns: as Windows' EnumResourceLanguagesW returns it
BeginUpdateResourceW
func clink BeginUpdateResourceW(var AFileName: WideBuffer; ADeleteExisting: int32): uint64
Windows' BeginUpdateResourceW.
Parameters
AFileName: as Windows'BeginUpdateResourceWtakes itADeleteExisting: as Windows'BeginUpdateResourceWtakes it
Returns: as Windows' BeginUpdateResourceW returns it
UpdateResourceW
func clink UpdateResourceW(AUpdate: uint64; AType: uint64; AName: uint64; ALanguage: uint16; AData: ptr to const; ASize: uint32): int32
Windows' UpdateResourceW.
Parameters
AUpdate: as Windows'UpdateResourceWtakes itAType: as Windows'UpdateResourceWtakes itAName: as Windows'UpdateResourceWtakes itALanguage: as Windows'UpdateResourceWtakes itAData: as Windows'UpdateResourceWtakes itASize: as Windows'UpdateResourceWtakes it
Returns: as Windows' UpdateResourceW returns it
EndUpdateResourceW
func clink EndUpdateResourceW(AUpdate: uint64; ADiscard: int32): int32
Windows' EndUpdateResourceW.
Parameters
AUpdate: as Windows'EndUpdateResourceWtakes itADiscard: as Windows'EndUpdateResourceWtakes it
Returns: as Windows' EndUpdateResourceW returns it
ReadFile
func clink ReadFile(AFile: uint64; ABuffer: ptr; AToRead: uint32; var ARead: uint32; AOverlapped: ptr): int32
Windows' ReadFile.
Parameters
AFile: as Windows'ReadFiletakes itABuffer: as Windows'ReadFiletakes itAToRead: as Windows'ReadFiletakes itARead: as Windows'ReadFiletakes itAOverlapped: as Windows'ReadFiletakes it
Returns: as Windows' ReadFile returns it
WriteFile
func clink WriteFile(AFile: uint64; ABuffer: ptr to const; AToWrite: uint32; var AWritten: uint32; AOverlapped: ptr): int32
Windows' WriteFile.
Parameters
AFile: as Windows'WriteFiletakes itABuffer: as Windows'WriteFiletakes itAToWrite: as Windows'WriteFiletakes itAWritten: as Windows'WriteFiletakes itAOverlapped: as Windows'WriteFiletakes it
Returns: as Windows' WriteFile returns it
PeekNamedPipe
func clink PeekNamedPipe(APipe: uint64; ABuffer: ptr; ASize: uint32; ARead: ptr; var AAvailable: uint32; ALeft: ptr): int32
Windows' PeekNamedPipe.
Parameters
APipe: as Windows'PeekNamedPipetakes itABuffer: as Windows'PeekNamedPipetakes itASize: as Windows'PeekNamedPipetakes itARead: as Windows'PeekNamedPipetakes itAAvailable: as Windows'PeekNamedPipetakes itALeft: as Windows'PeekNamedPipetakes it
Returns: as Windows' PeekNamedPipe returns it
GetFileType
func clink GetFileType(AFile: uint64): uint32
Windows' GetFileType.
Parameters
AFile: as Windows'GetFileTypetakes it
Returns: as Windows' GetFileType returns it
CreatePseudoConsole
func clink CreatePseudoConsole(ASize: COORD; AInput: uint64; AOutput: uint64; AFlags: uint32; var AConsole: uint64): int32
Windows' CreatePseudoConsole: The pseudo console (consoleapi.h: HPCON a handle, HRESULT 0 = S_OK)
Parameters
ASize: as Windows'CreatePseudoConsoletakes itAInput: as Windows'CreatePseudoConsoletakes itAOutput: as Windows'CreatePseudoConsoletakes itAFlags: as Windows'CreatePseudoConsoletakes itAConsole: as Windows'CreatePseudoConsoletakes it
Returns: as Windows' CreatePseudoConsole returns it
ResizePseudoConsole
func clink ResizePseudoConsole(AConsole: uint64; ASize: COORD): int32
Windows' ResizePseudoConsole.
Parameters
AConsole: as Windows'ResizePseudoConsoletakes itASize: as Windows'ResizePseudoConsoletakes it
Returns: as Windows' ResizePseudoConsole returns it
ClosePseudoConsole
func clink ClosePseudoConsole(AConsole: uint64)
Windows' ClosePseudoConsole.
Parameters
AConsole: as Windows'ClosePseudoConsoletakes it
InitializeProcThreadAttributeList
func clink InitializeProcThreadAttributeList(AList: ptr; ACount: uint32; AFlags: uint32; var ASize: uint64): int32
Windows' InitializeProcThreadAttributeList.
Parameters
AList: as Windows'InitializeProcThreadAttributeListtakes itACount: as Windows'InitializeProcThreadAttributeListtakes itAFlags: as Windows'InitializeProcThreadAttributeListtakes itASize: as Windows'InitializeProcThreadAttributeListtakes it
Returns: as Windows' InitializeProcThreadAttributeList returns it
UpdateProcThreadAttribute
func clink UpdateProcThreadAttribute(AList: ptr; AFlags: uint32; AAttribute: uint64; AValue: ptr; ASize: uint64; APrevious: ptr; AReturnSize: ptr): int32
Windows' UpdateProcThreadAttribute.
Parameters
AList: as Windows'UpdateProcThreadAttributetakes itAFlags: as Windows'UpdateProcThreadAttributetakes itAAttribute: as Windows'UpdateProcThreadAttributetakes itAValue: as Windows'UpdateProcThreadAttributetakes itASize: as Windows'UpdateProcThreadAttributetakes itAPrevious: as Windows'UpdateProcThreadAttributetakes itAReturnSize: as Windows'UpdateProcThreadAttributetakes it
Returns: as Windows' UpdateProcThreadAttribute returns it
DeleteProcThreadAttributeList
func clink DeleteProcThreadAttributeList(AList: ptr)
Windows' DeleteProcThreadAttributeList.
Parameters
AList: as Windows'DeleteProcThreadAttributeListtakes it
GetCurrentProcess
func clink GetCurrentProcess(): uint64
Windows' GetCurrentProcess.
Returns: as Windows' GetCurrentProcess returns it
DuplicateHandle
func clink DuplicateHandle(ASourceProcess: uint64; ASource: uint64; ATargetProcess: uint64; var ATarget: uint64; AAccess: uint32; AInherit: int32; AOptions: uint32): int32
Windows' DuplicateHandle.
Parameters
ASourceProcess: as Windows'DuplicateHandletakes itASource: as Windows'DuplicateHandletakes itATargetProcess: as Windows'DuplicateHandletakes itATarget: as Windows'DuplicateHandletakes itAAccess: as Windows'DuplicateHandletakes itAInherit: as Windows'DuplicateHandletakes itAOptions: as Windows'DuplicateHandletakes it
Returns: as Windows' DuplicateHandle returns it
MultiByteToWideChar
func clink MultiByteToWideChar(ACodePage: uint32; AFlags: uint32; ASource: ptr to const; ASourceSize: int32; AWide: ptr; AWideSize: int32): int32
Windows' MultiByteToWideChar.
Parameters
ACodePage: as Windows'MultiByteToWideChartakes itAFlags: as Windows'MultiByteToWideChartakes itASource: as Windows'MultiByteToWideChartakes itASourceSize: as Windows'MultiByteToWideChartakes itAWide: as Windows'MultiByteToWideChartakes itAWideSize: as Windows'MultiByteToWideChartakes it
Returns: as Windows' MultiByteToWideChar returns it
IsDBCSLeadByteEx
func clink IsDBCSLeadByteEx(ACodePage: uint32; AByte: uint8): int32
Windows' IsDBCSLeadByteEx.
Parameters
ACodePage: as Windows'IsDBCSLeadByteExtakes itAByte: as Windows'IsDBCSLeadByteExtakes it
Returns: as Windows' IsDBCSLeadByteEx returns it
GetConsoleScreenBufferInfo
func clink GetConsoleScreenBufferInfo(AConsole: uint64; var AInfo: CONSOLE_SCREEN_BUFFER_INFO): int32
Windows' GetConsoleScreenBufferInfo.
Parameters
AConsole: as Windows'GetConsoleScreenBufferInfotakes itAInfo: as Windows'GetConsoleScreenBufferInfotakes it
Returns: as Windows' GetConsoleScreenBufferInfo returns it
WaitForSingleObject
func clink WaitForSingleObject(AHandle: uint64; AMilliseconds: uint32): uint32
Windows' WaitForSingleObject.
Parameters
AHandle: as Windows'WaitForSingleObjecttakes itAMilliseconds: as Windows'WaitForSingleObjecttakes it
Returns: as Windows' WaitForSingleObject returns it
CreateThread
func clink CreateThread(AAttributes: ptr; AStackSize: uint64; AStart: func(AParameter: ptr): uint32; AParameter: ptr; AFlags: uint32; AThreadId: ptr to uint32): uint64
A new thread running AStart(AParameter) (AStackSize 0: the image's default; AFlags 0: it runs at once; its id into AThreadId when not nil): its handle, 0 on a failure
Parameters
AAttributes: as Windows'CreateThreadtakes itAStackSize: as Windows'CreateThreadtakes itAStart: as Windows'CreateThreadtakes itAParameter: as Windows'CreateThreadtakes itAFlags: as Windows'CreateThreadtakes itAThreadId: as Windows'CreateThreadtakes it
Returns: as Windows' CreateThread returns it
GetExitCodeProcess
func clink GetExitCodeProcess(AProcess: uint64; var AExitCode: uint32): int32
Windows' GetExitCodeProcess.
Parameters
AProcess: as Windows'GetExitCodeProcesstakes itAExitCode: as Windows'GetExitCodeProcesstakes it
Returns: as Windows' GetExitCodeProcess returns it
CloseHandle
func clink CloseHandle(AHandle: uint64): int32
Windows' CloseHandle.
Parameters
AHandle: as Windows'CloseHandletakes it
Returns: as Windows' CloseHandle returns it
UTF8ToWide
func UTF8ToWide(const AText: string; var ABuffer: WideBuffer): bool
AText (UTF-8) into ABuffer as NUL-terminated UTF-16; malformed input becomes U+FFFD. False when it needs more than ADAM_WINDOWS_WIDE_MAX units
Parameters
AText: the UTF-8 textABuffer: receives the UTF-16 text
Returns: false when it does not fit
WideToUTF8
func WideToUTF8(var ABuffer: WideBuffer; const ALength: int32): string
The UTF-8 text of ABuffer's first ALength units, or up to its NUL when that comes first; a lone surrogate becomes U+FFFD
Parameters
ABuffer: the UTF-16 textALength: the most units to read
Returns: the UTF-8 text
QuoteArg
func QuoteArg(const AArg: string): string
AArg as one argument of a Windows command line, by the rules CommandLineToArgvW reads back (StdApp.Utils' QuoteCommandArg): as is when nothing in it splits or quotes (an empty one still needs ""), else quoted, each backslash run before a quote or the closing quote doubled and the quote itself escaped
Parameters
AArg: the argument
Returns: the argument as the command line writes it
WinResolvePath
func WinResolvePath(const APath: string; const ABaseDir: string): string
Resolves APath to one full, normalized path against ABaseDir. A prefix at the very start, in either case, names the base: $P: the folder of this program's exe (asked of the OS), $D: the current working directory, $S: ABaseDir (the same as none). $R: (the project root) is a build-time prefix of the compiler only: it gives "". A rooted path is only normalized; any other is resolved against its base (ABaseDir "" = the current working directory). '.' and '..' are folded and repeated separators joined, as text: the disk is never touched. Leading and trailing blanks are trimmed. The result uses '/' up to ADAM_WINDOWS_SHORT_PATH_MAX UTF-16 units and the long-path spelling past it (\?\C:\..., \?\UNC\server\share\...), so every file routine takes it at any length; resolving a result again gives it back unchanged. "" for an empty path, only a prefix, or a $R: path
Parameters
APath: the pathABaseDir: the folder a relative path (and$S:) is resolved against
Returns: the full path, or "" when it does not fit
func WinResolvePath(const APath: string): string
Resolves APath against the current working directory; see WinResolvePath(APath, ABaseDir) for the prefixes and the result's form
Parameters
APath: the path
Returns: the full path, or ""
WinSamePath
func WinSamePath(const AFirst: string; const ASecond: string): bool
True when AFirst and ASecond (each resolved against the current working directory) name the same path as Windows tells paths apart: without case, as the file system does (CompareStringOrdinal, ignoring case). False when either resolves to "" or does not fit
Parameters
AFirst: one pathASecond: the other
Returns: true when they name the same path
WinExeDir
func WinExeDir(): string
The folder that holds this program's exe file, in the form WinResolvePath returns, with no trailing separator (except at a root). Asked of the OS, so it is right however the program was started; "" when the OS cannot tell
Returns: the folder, or ""
WinTempDir
func WinTempDir(): string
The system's folder for temporary files (GetTempPathW: TMP, TEMP, USERPROFILE or the Windows folder), in the form WinResolvePath returns, with no trailing separator (except at a root); "" when the system names none
Returns: the folder, or ""
WinCPUName
func WinCPUName(): string
The processor's name as its maker gives it (the registry's ProcessorNameString), the padding blanks some makers add trimmed; "" when the registry does not say
Returns: the processor's name, or ""
WinOSVersion
func WinOSVersion(): string
The running Windows' version as "Windows <major>.<minor>.<build>" (RtlGetVersion: the real version, never the one a compatibility shim reports); "Windows" alone when it cannot be asked
Returns: the version text
WinCPUCount
func WinCPUCount(): int64
The logical processors this process may run on, every processor group's (GetActiveProcessorCount); at least 1
Returns: the count
WinMemoryTotal
func WinMemoryTotal(): int64
The physical memory installed, in bytes (GlobalMemoryStatusEx's ullTotalPhys); 0 when it cannot be asked
Returns: the bytes, or 0
WinSystemDir
func WinSystemDir(): string
The system folder (GetSystemDirectoryW: where Windows keeps its DLLs, C:\Windows\System32 on most systems), in the form WinResolvePath returns, with no trailing separator (except at a root); "" when the system names none
Returns: the folder, or ""
WinFileExists
func WinFileExists(const APath: string): bool
True when APath names an existing file (not a folder); false for a folder, a missing path, "" or a path the OS cannot read. The path goes through WinResolvePath first
Parameters
APath: the path
Returns: true for an existing file
WinDirectoryExists
func WinDirectoryExists(const APath: string): bool
True when APath names an existing folder. The path goes through WinResolvePath first
Parameters
APath: the path
Returns: true for an existing folder
WinDeleteFile
func WinDeleteFile(const APath: string): bool
Deletes a file, as Delphi's WinDeleteFile: a folder is never removed by it. True when the file was deleted; false for a folder, a missing path or one the OS refuses (a file open elsewhere)
Parameters
APath: the path
Returns: true when the file was deleted
WinCreateDir
func WinCreateDir(const APath: string): bool
Creates one folder, as Delphi's WinCreateDir: its parent must exist already (nothing above it is made). True when the folder was made; false when something of that name exists already (a folder or a file), its parent is missing, or the OS refuses it
Parameters
APath: the path
Returns: true when the folder was made
WinRemoveDir
func WinRemoveDir(const APath: string): bool
Removes an empty folder, as Delphi's RemoveDir: a folder that holds anything is left as it is. True when it was removed; false when it is not empty, is a file, is missing, or the OS refuses it
Parameters
APath: the path
Returns: true when it was removed
WinForceDirectories
func WinForceDirectories(const APath: string): bool
Creates a folder and every missing folder above it, as Delphi's WinForceDirectories. A folder already there is a success. True when the path is a folder afterwards; false when a file is in the way, the path is "" or the OS refuses it. A loop, never a recursion, so a deep path takes no stack
Parameters
APath: the path
Returns: true when the path is a folder afterwards
WinRenameFile
func WinRenameFile(const AOldPath: string; const ANewPath: string): bool
Gives a file a new name or moves it, as Delphi's RenameFile, to another drive too (copied, then deleted): something at the new name is never replaced (delete it first). True when the file was renamed; false when AOldPath is not a file, ANewPath exists already, its folder is missing or the OS refuses it
Parameters
AOldPath: the fileANewPath: its new name
Returns: true when it was renamed
WinReplaceFile
func WinReplaceFile(const ASourcePath: string; const ATargetPath: string): bool
Puts the file ASourcePath in ATargetPath's place in one step: a file already there is replaced, never left half written (write a temporary file, then WinReplaceFile it into place). True when the file is at ATargetPath afterwards; false when ASourcePath is not a file, ATargetPath is a folder, its folder is missing or the OS refuses it (another drive, a target held open elsewhere for longer than the tries last). A file another process holds for a moment (a virus scanner or the search indexer reading a file just written) is waited for: up to ADAM_WINDOWS_REPLACE_TRIES tries, the wait doubling from ADAM_WINDOWS_REPLACE_WAIT_MS
Parameters
ASourcePath: the new fileATargetPath: the place it takes
Returns: true when the file is at ATargetPath afterwards
WinSetFileReadOnly
func WinSetFileReadOnly(const APath: string; const AReadOnly: bool): bool
Marks the file APath read-only (AReadOnly) or writable again: a read-only file is never replaced, renamed over or deleted until it is writable. Its other attributes are kept. True when the file has the asked state afterwards; false for a folder, a missing path or one the OS refuses
Parameters
APath: the pathAReadOnly: true for read-only, false for writable
Returns: true when the file has that state afterwards
WinIsFileHidden
func WinIsFileHidden(const APath: string): bool
True when APath names an existing file or folder whose hidden attribute is set (what Explorer leaves out of a listing by default); false for a missing path
Parameters
APath: the path
Returns: true when its hidden attribute is set
WinSetCurrentDir
func WinSetCurrentDir(const APath: string): bool
Makes the folder APath (resolved) the process's working folder (SetCurrentDirectoryW: the OS's own, never a C runtime hook's). False for a file, a missing path or one the OS refuses
Parameters
APath: the path
Returns: false when it cannot be the working folder
WinCopyFile
func WinCopyFile(const ASourcePath: string; const ATargetPath: string; const AOverwrite: bool): bool
Copies the file ASourcePath to ATargetPath (CopyFileW: data, attributes and times), a file already there replaced only when AOverwrite. False when ASourcePath is not a file, ATargetPath is a folder or exists (not AOverwrite), the two are one file, or the OS refuses
Parameters
ASourcePath: the file copiedATargetPath: the copyAOverwrite: true to replace a file there
Returns: true when it was copied
WinOpenURL
func WinOpenURL(const AURL: string): bool
Hands AURL to the shell's "open" verb (ShellExecuteW): the user's browser, mail program or the scheme's own handler. True when the shell took it; the caller checks the scheme
Parameters
AURL: the URL
Returns: true when the shell took it
WinGetEnvironmentVariable
func WinGetEnvironmentVariable(const AName: string): string
The value of this process's environment variable AName; "" when it is not set (or set to "") or AName is ""
Parameters
AName: the variable
Returns: its value, or ""
WinSetEnvironmentVariable
func WinSetEnvironmentVariable(const AName: string; const AValue: string): bool
Sets this process's environment variable AName to AValue (a process it starts inherits it); AValue "" leaves it empty, which GetEnvironmentVariable reads as not set. True when the variable has the asked value afterwards
Parameters
AName: the variableAValue: its new value
Returns: true when it has that value afterwards
WinUserCacheDir
func WinUserCacheDir(): string
This user's folder for caches a program may drop and make again (Windows: the local application data folder, %LOCALAPPDATA%), resolved; "" when the OS does not name one. A program keeps its own folder below it (<WinUserCacheDir><Program>\)
Returns: the folder, or ""
WinFileSize
func WinFileSize(const APath: string): int64
The size of a file in bytes, read from the file system without opening it; -1 when it is a folder, is missing or the OS refuses it
Parameters
APath: the path
Returns: the size in bytes, or -1
WinFileWriteTime
func WinFileWriteTime(const APath: string): int64
When a file was last written, as the file system keeps it (Windows: FILETIME's 100 ns ticks since 1601-01-01 UTC), read without opening it: a value to compare with an earlier one, never a clock time; -1 when it is a folder, is missing or the OS refuses it
Parameters
APath: the path
Returns: the write time in 100 ns ticks, or -1
WinSecureRandomBytes
func WinSecureRandomBytes(const ACount: int64; var ABytes: ByteArray): bool
ACount bytes from the system's secure random generator (BCryptGenRandom, the system-preferred RNG) as ABytes; false when the generator fails (ABytes is then empty)
Parameters
ACount: how many bytesABytes: receives them
Returns: false when the generator fails
WinGetFiles
func WinGetFiles(const ADir: string; var AList: StringArray): bool
The names of the files in ADir (no folders), sorted by their bytes. False when the folder cannot be read. The path goes through WinResolvePath first
Parameters
ADir: the folderAList: receives the names
Returns: false when the folder cannot be read
WinGetDirectories
func WinGetDirectories(const ADir: string; var AList: StringArray): bool
The names of the folders in ADir ("." and ".." left out), sorted by their bytes. False when the folder cannot be read. The path goes through WinResolvePath first
Parameters
ADir: the folderAList: receives the names
Returns: false when the folder cannot be read
WinRemoveTree
func WinRemoveTree(const APath: string): bool
Removes the folder APath and everything in it (System.IO's recursive RemoveDir): a link inside is removed as the link, never followed; APath itself a folder link: only the link goes. True when APath is gone after; false when it is no folder or anything in it cannot be removed (what could be is gone). The path goes through WinResolvePath first
Parameters
APath: the path
Returns: true when it is gone afterwards
WinProcessTexts
func WinProcessTexts(const AExe: string; const AArgs: StringArray; const AWorkDir: string; var AApplication: WideBuffer; var ACommandLine: WideBuffer; var ADirectory: WideBuffer): bool
What CreateProcessW takes for AExe run with AArgs in AWorkDir ("" = this process's folder): the application, the command line and the folder, as UTF-16. False when one cannot be made
Parameters
AExe: the programAArgs: its argumentsAWorkDir: the folder it runs in ("" for this process's)AApplication: receives the applicationACommandLine: receives the command lineADirectory: receives the folder
Returns: false when one cannot be made
WinRunAttached
func WinRunAttached(const AExe: string; const AArgs: StringArray; const AWorkDir: string; var AExitCode: uint32): bool
Runs AExe (the path of the exe file itself, its extension included: no PATH search; it goes through WinResolvePath) with AArgs, in AWorkDir ("" = this process's folder), on this process's own stdin, stdout and stderr: it reads and writes where this process does (a console, a pipe, a file), as if the shell had started it. AExitCode gets its exit code. False when it cannot start or its exit code cannot be read. Its process and thread handles are closed on every path
Parameters
AExe: the programAArgs: its argumentsAWorkDir: the folder it runs in ("" for this process's)AExitCode: receives its exit code
Returns: false when it cannot start or its exit code cannot be read
WinReadAvailable
func WinReadAvailable(const APipe: uint64; var AText: string): bool
What the pipe APipe holds now appended to AText (no wait: an empty pipe adds nothing), in reads of ADAM_WINDOWS_IO_SIZE bytes. False when the pipe is closed or broken (every writer gone and nothing left in it)
Parameters
APipe: the pipe's read endAText: gets what it holds appended
Returns: false when the pipe is closed or broken
WinReadSome
func WinReadSome(const APipe: uint64; var AText: string): bool
One read of the pipe APipe (waits until it holds bytes) appended to AText. False when the pipe is closed or broken: every writer gone, nothing left (the end of a child's output)
Parameters
APipe: the pipe's read endAText: gets the bytes appended
Returns: false when the pipe is closed or broken
WinOemToUTF8
func WinOemToUTF8(const ABytes: string): string
The bytes ABytes in the OEM code page (CP_OEMCP: what a console tool writes that does not write UTF-8) as UTF-8 text. Converted in pieces of at most ADAM_WINDOWS_WIDE_MAX bytes (one OEM byte gives at most one UTF-16 unit), a piece never ending inside a double-byte character
Parameters
ABytes: the OEM text
Returns: the UTF-8 text
WinRunPE
func WinRunPE(const AExe: string; const AArgs: StringArray; const AWorkDir: string; const AWait: bool; const AShowCmd: uint16; var AExitCode: uint32): bool
StdApp.Utils' RunPE: runs AExe (the path of the exe file itself, its extension included: the application named in full, no PATH search; it goes through WinResolvePath) with AArgs, in AWorkDir ("" = this process's folder), shown as AShowCmd (SW_*), no handle inherited, a Unicode environment. AWait: waits for it and takes its exit code into AExitCode; else it runs on (it may outlive this process) and AExitCode is 0. False when it cannot start or its exit code cannot be read. Its process and thread handles are closed on every path
Parameters
AExe: the programAArgs: its argumentsAWorkDir: the folder it runs in ("" for this process's)AWait: true to wait for itAShowCmd: how its window shows (SW_*)AExitCode: receives its exit code when waited for, else 0
Returns: false when it cannot start or its exit code cannot be read
WinRunProcess
func WinRunProcess(const AExe: string; const AArgs: StringArray; const AWorkDir: string; var AOutput: string; var AExitCode: uint32): bool
Runs AExe (the path of the exe file itself, its extension included: no PATH search; it goes through WinResolvePath) with AArgs, in AWorkDir ("" = this process's folder). stdin is NUL; stdout and stderr go to one pipe, so AOutput holds the bytes in the order written; AExitCode gets the exit code. False when it cannot start or its exit code cannot be read (AOutput then holds what was read, if anything). Every handle it opens is closed on every path
Parameters
AExe: the programAArgs: its argumentsAWorkDir: the folder it runs in ("" for this process's)AOutput: receives its outputAExitCode: receives its exit code
Returns: false when it cannot start
WinDelay
func WinDelay(const AMilliseconds: int32)
Waits AMilliseconds, then returns: at least that long (Sleep; the OS may wake the program a little later). A wait of 0 or less returns at once
Parameters
AMilliseconds: how long to wait
WinTickCountMs
func WinTickCountMs(): int64
Milliseconds since the system started (GetTickCount64): only the difference of two readings means anything, a duration (a build's time)
Returns: the milliseconds
WinSystemTime
func WinSystemTime(): int64
The time now as the file system keeps a write time (GetSystemTimeAsFileTime: FILETIME's 100 ns ticks since 1601-01-01 UTC), so it compares with WinFileWriteTime. The system clock a write time is stamped from, not the precise one: a precise reading taken before a write can be later than that file's write time
Returns: the ticks
WinPerformanceCounter
func WinPerformanceCounter(): int64
The high-resolution counter's reading (QueryPerformanceCounter): never going back, only the difference of two readings means anything, in WinPerformanceFrequency's units
Returns: the reading
WinPerformanceFrequency
func WinPerformanceFrequency(): int64
The high-resolution counter's counts per second (QueryPerformanceFrequency: fixed at boot, never 0 on Windows XP and later)
Returns: the counts per second
WinFormatCList
func WinFormatCList(const AFormat: ptr to const char; const AArgs: ptr): string
System.IO's FormatCList: the text of the C format AFormat over the C va_list AArgs, by ucrt's own formatter, measured then filled (a Windows va_list points at the arguments, so each call reads them anew); "" when the C runtime has no formatter or refuses the format
Parameters
AFormat: the C formatAArgs: the C va_list
Returns: the text, or ""
System.Windows.Debug
the Win32 debugging API, declared for Adam (x86_64-windows-gnu only)
Import it with import System.Windows.Debug;.
Types
EXCEPTION_RECORD
type EXCEPTION_RECORD = record
Windows' EXCEPTION_RECORD (152 bytes): the exception, where it happened, its parameters
Members
ExceptionCode: uint32: Windows'EXCEPTION_RECORD.ExceptionCode.ExceptionFlags: uint32: Windows'EXCEPTION_RECORD.ExceptionFlags.ExceptionRecord: uint64: Windows'EXCEPTION_RECORD.ExceptionRecord.ExceptionAddress: uint64: Windows'EXCEPTION_RECORD.ExceptionAddress.NumberParameters: uint32: Windows'EXCEPTION_RECORD.NumberParameters.ExceptionInformation: array[0..14] of uint64: Windows'EXCEPTION_RECORD.ExceptionInformation.
EXCEPTION_DEBUG_INFO
type EXCEPTION_DEBUG_INFO = record
Windows' EXCEPTION_DEBUG_INFO: EXCEPTION_DEBUG_INFO
Members
ExceptionRecord: EXCEPTION_RECORD: Windows'EXCEPTION_DEBUG_INFO.ExceptionRecord.dwFirstChance: uint32: Windows'EXCEPTION_DEBUG_INFO.dwFirstChance.
CREATE_THREAD_DEBUG_INFO
type CREATE_THREAD_DEBUG_INFO = record
Windows' CREATE_THREAD_DEBUG_INFO: CREATE_THREAD_DEBUG_INFO
Members
hThread: uint64: Windows'CREATE_THREAD_DEBUG_INFO.hThread.lpThreadLocalBase: uint64: Windows'CREATE_THREAD_DEBUG_INFO.lpThreadLocalBase.lpStartAddress: uint64: Windows'CREATE_THREAD_DEBUG_INFO.lpStartAddress.
CREATE_PROCESS_DEBUG_INFO
type CREATE_PROCESS_DEBUG_INFO = record
Windows' CREATE_PROCESS_DEBUG_INFO (File is the debugger's to close)
Members
hFile: uint64: Windows'CREATE_PROCESS_DEBUG_INFO.hFile.hProcess: uint64: Windows'CREATE_PROCESS_DEBUG_INFO.hProcess.hThread: uint64: Windows'CREATE_PROCESS_DEBUG_INFO.hThread.lpBaseOfImage: uint64: Windows'CREATE_PROCESS_DEBUG_INFO.lpBaseOfImage.dwDebugInfoFileOffset: uint32: Windows'CREATE_PROCESS_DEBUG_INFO.dwDebugInfoFileOffset.nDebugInfoSize: uint32: Windows'CREATE_PROCESS_DEBUG_INFO.nDebugInfoSize.lpThreadLocalBase: uint64: Windows'CREATE_PROCESS_DEBUG_INFO.lpThreadLocalBase.lpStartAddress: uint64: Windows'CREATE_PROCESS_DEBUG_INFO.lpStartAddress.lpImageName: uint64: Windows'CREATE_PROCESS_DEBUG_INFO.lpImageName.fUnicode: uint16: Windows'CREATE_PROCESS_DEBUG_INFO.fUnicode.
EXIT_THREAD_DEBUG_INFO
type EXIT_THREAD_DEBUG_INFO = record
Windows' EXIT_THREAD_DEBUG_INFO.
Members
dwExitCode: uint32: Windows'EXIT_THREAD_DEBUG_INFO.dwExitCode.
EXIT_PROCESS_DEBUG_INFO
type EXIT_PROCESS_DEBUG_INFO = record
Windows' EXIT_PROCESS_DEBUG_INFO.
Members
dwExitCode: uint32: Windows'EXIT_PROCESS_DEBUG_INFO.dwExitCode.
LOAD_DLL_DEBUG_INFO
type LOAD_DLL_DEBUG_INFO = record
Windows' LOAD_DLL_DEBUG_INFO (File is the debugger's to close)
Members
hFile: uint64: Windows'LOAD_DLL_DEBUG_INFO.hFile.lpBaseOfDll: uint64: Windows'LOAD_DLL_DEBUG_INFO.lpBaseOfDll.dwDebugInfoFileOffset: uint32: Windows'LOAD_DLL_DEBUG_INFO.dwDebugInfoFileOffset.nDebugInfoSize: uint32: Windows'LOAD_DLL_DEBUG_INFO.nDebugInfoSize.lpImageName: uint64: Windows'LOAD_DLL_DEBUG_INFO.lpImageName.fUnicode: uint16: Windows'LOAD_DLL_DEBUG_INFO.fUnicode.
UNLOAD_DLL_DEBUG_INFO
type UNLOAD_DLL_DEBUG_INFO = record
Windows' UNLOAD_DLL_DEBUG_INFO: UNLOAD_DLL_DEBUG_INFO
Members
lpBaseOfDll: uint64: Windows'UNLOAD_DLL_DEBUG_INFO.lpBaseOfDll.
OUTPUT_DEBUG_STRING_INFO
type OUTPUT_DEBUG_STRING_INFO = record
Windows' OUTPUT_DEBUG_STRING_INFO: OUTPUT_DEBUG_STRING_INFO
Members
lpDebugStringData: uint64: Windows'OUTPUT_DEBUG_STRING_INFO.lpDebugStringData.fUnicode: uint16: Windows'OUTPUT_DEBUG_STRING_INFO.fUnicode.nDebugStringLength: uint16: Windows'OUTPUT_DEBUG_STRING_INFO.nDebugStringLength.
RIP_INFO
type RIP_INFO = record
Windows' RIP_INFO: RIP_INFO
Members
dwError: uint32: Windows'RIP_INFO.dwError.dwType: uint32: Windows'RIP_INFO.dwType.
DEBUG_EVENT
type DEBUG_EVENT = record
Windows' DEBUG_EVENT (176 bytes): the event's code, its process and thread, and the code's record in the union at offset 16
Members
dwDebugEventCode: uint32: Windows'DEBUG_EVENT.dwDebugEventCode.dwProcessId: uint32: Windows'DEBUG_EVENT.dwProcessId.dwThreadId: uint32: Windows'DEBUG_EVENT.dwThreadId.u: DEBUG_EVENT.u: Windows'DEBUG_EVENT.u.
CONTEXT
type CONTEXT = record
Windows' CONTEXT: The x64 CONTEXT (1232 bytes; 16-byte aligned where the API reads or writes it)
Members
P1Home: uint64: Windows'CONTEXT.P1Home.P2Home: uint64: Windows'CONTEXT.P2Home.P3Home: uint64: Windows'CONTEXT.P3Home.P4Home: uint64: Windows'CONTEXT.P4Home.P5Home: uint64: Windows'CONTEXT.P5Home.P6Home: uint64: Windows'CONTEXT.P6Home.ContextFlags: uint32: Windows'CONTEXT.ContextFlags.MxCsr: uint32: Windows'CONTEXT.MxCsr.SegCs: uint16: Windows'CONTEXT.SegCs.SegDs: uint16: Windows'CONTEXT.SegDs.SegEs: uint16: Windows'CONTEXT.SegEs.SegFs: uint16: Windows'CONTEXT.SegFs.SegGs: uint16: Windows'CONTEXT.SegGs.SegSs: uint16: Windows'CONTEXT.SegSs.EFlags: uint32: Windows'CONTEXT.EFlags.Dr0: uint64: Windows'CONTEXT.Dr0.Dr1: uint64: Windows'CONTEXT.Dr1.Dr2: uint64: Windows'CONTEXT.Dr2.Dr3: uint64: Windows'CONTEXT.Dr3.Dr6: uint64: Windows'CONTEXT.Dr6.Dr7: uint64: Windows'CONTEXT.Dr7.Rax: uint64: Windows'CONTEXT.Rax.Rcx: uint64: Windows'CONTEXT.Rcx.Rdx: uint64: Windows'CONTEXT.Rdx.Rbx: uint64: Windows'CONTEXT.Rbx.Rsp: uint64: Windows'CONTEXT.Rsp.Rbp: uint64: Windows'CONTEXT.Rbp.Rsi: uint64: Windows'CONTEXT.Rsi.Rdi: uint64: Windows'CONTEXT.Rdi.R8: uint64: Windows'CONTEXT.R8.R9: uint64: Windows'CONTEXT.R9.R10: uint64: Windows'CONTEXT.R10.R11: uint64: Windows'CONTEXT.R11.R12: uint64: Windows'CONTEXT.R12.R13: uint64: Windows'CONTEXT.R13.R14: uint64: Windows'CONTEXT.R14.R15: uint64: Windows'CONTEXT.R15.Rip: uint64: Windows'CONTEXT.Rip.FltSave: array[0..63] of uint64: Windows'CONTEXT.FltSave: XMM_SAVE_AREA32 (FltSave), as its bytesVectorRegister: array[0..51] of uint64: Windows'CONTEXT.VectorRegister: VectorRegister[26] (M128A each), as its bytesVectorControl: uint64: Windows'CONTEXT.VectorControl: VectorRegister[26] (M128A each), as its bytesDebugControl: uint64: Windows'CONTEXT.DebugControl: VectorRegister[26] (M128A each), as its bytesLastBranchToRip: uint64: Windows'CONTEXT.LastBranchToRip: VectorRegister[26] (M128A each), as its bytesLastBranchFromRip: uint64: Windows'CONTEXT.LastBranchFromRip: VectorRegister[26] (M128A each), as its bytesLastExceptionToRip: uint64: Windows'CONTEXT.LastExceptionToRip: VectorRegister[26] (M128A each), as its bytesLastExceptionFromRip: uint64: Windows'CONTEXT.LastExceptionFromRip: VectorRegister[26] (M128A each), as its bytes
DebugSymbolInfo
type DebugSymbolInfo = record
SYMBOL_INFOW (88 bytes) with room for a name of MAX_SYM_NAME units: set SizeOfStruct to ADAM_WINDOWS_SYMBOL_INFO_SIZE and MaxNameLen to MAX_SYM_NAME
Members
SizeOfStruct: uint32: SYMBOL_INFOW'sSizeOfStruct: set to ADAM_WINDOWS_SYMBOL_INFO_SIZE.TypeIndex: uint32: SYMBOL_INFOW'sTypeIndex: the symbol's type.Reserved: array[0..1] of uint64: SYMBOL_INFOW'sReserved.Index: uint32: SYMBOL_INFOW'sIndex.Size: uint32: SYMBOL_INFOW'sSize: the symbol's size in bytes.ModBase: uint64: SYMBOL_INFOW'sModBase: the base of its module.Flags: uint32: SYMBOL_INFOW'sFlags(SYMFLAG_*).Value: uint64: SYMBOL_INFOW'sValue.Address: uint64: SYMBOL_INFOW'sAddress.Register: uint32: SYMBOL_INFOW'sRegister.Scope: uint32: SYMBOL_INFOW'sScope.Tag: uint32: SYMBOL_INFOW'sTag(a SymTag* value).NameLen: uint32: SYMBOL_INFOW'sNameLen: the units of Name used.MaxNameLen: uint32: SYMBOL_INFOW'sMaxNameLen: set to MAX_SYM_NAME.Name: array[0..1999] of uint16: SYMBOL_INFOW'sName, with room for MAX_SYM_NAME units (DbgSymbolName reads it).
IMAGEHLP_LINEW64
type IMAGEHLP_LINEW64 = record
Windows' IMAGEHLP_LINEW64 (40 bytes): set SizeOfStruct to ADAM_WINDOWS_LINE_INFO_SIZE; FileName points into DbgHelp's own memory (DbgWideText reads it)
Members
SizeOfStruct: uint32: Windows'IMAGEHLP_LINEW64.SizeOfStruct.Key: ptr: Windows'IMAGEHLP_LINEW64.Key.LineNumber: uint32: Windows'IMAGEHLP_LINEW64.LineNumber.FileName: ptr to const uint16: Windows'IMAGEHLP_LINEW64.FileName.Address: uint64: Windows'IMAGEHLP_LINEW64.Address.
DebugFindChildren
type DebugFindChildren = record
TI_FINDCHILDREN_PARAMS with room for ADAM_WINDOWS_FIND_CHILDREN_MAX children: set Count (TI_GET_CHILDRENCOUNT's) and Start 0
Members
Count: uint32: TI_FINDCHILDREN_PARAMS'Count: TI_GET_CHILDRENCOUNT's.Start: uint32: TI_FINDCHILDREN_PARAMS'Start: set to 0.ChildId: array[0..255] of uint32: TI_FINDCHILDREN_PARAMS'ChildId: the children's type ids.
PSYM_ENUMERATESYMBOLS_CALLBACKW
type PSYM_ENUMERATESYMBOLS_CALLBACKW = func clink(ASymbol: ptr to const DebugSymbolInfo;
Windows' PSYM_ENUMERATESYMBOLS_CALLBACKW: SymEnumSymbolsW's callback: each symbol, its size, the caller's context; 0 stops
SOURCEFILEW
type SOURCEFILEW = record
Windows' SOURCEFILEW: SOURCEFILEW: one source file a module's PDB names (FileName in DbgHelp's own memory)
Members
ModBase: uint64: Windows'SOURCEFILEW.ModBase.FileName: ptr to const uint16: Windows'SOURCEFILEW.FileName.
PSYM_ENUMSOURCEFILES_CALLBACKW
type PSYM_ENUMSOURCEFILES_CALLBACKW = func clink(ASource: ptr to const SOURCEFILEW;
Windows' PSYM_ENUMSOURCEFILES_CALLBACKW: SymEnumSourceFilesW's callback: each source file, the caller's context; 0 stops
DebugVariant
type DebugVariant = record
VARIANT (24 bytes) as TI_GET_VALUE writes an enum value: its kind, then the value's bytes
Members
Kind: uint16: VARIANT'svt: the value's kind.Reserved1: uint16: VARIANT'swReserved1.Reserved2: uint16: VARIANT'swReserved2.Reserved3: uint16: VARIANT'swReserved3.Value: uint64: The value's first 8 bytes.Extra: uint64: The value's next 8 bytes.
ADDRESS64
type ADDRESS64 = record
Windows' ADDRESS64 (16 bytes): an address and its mode (AddrModeFlat)
Members
Offset: uint64: Windows'ADDRESS64.Offset.Segment: uint16: Windows'ADDRESS64.Segment.Mode: uint32: Windows'ADDRESS64.Mode.
STACKFRAME64
type STACKFRAME64 = record
Windows' STACKFRAME64 (264 bytes): one frame StackWalk64 found; set AddrPC / AddrFrame / AddrStack (flat) before the first call, every other byte zero. KdHelp (KDHELP64) is only DbgHelp's
Members
AddrPC: ADDRESS64: Windows'STACKFRAME64.AddrPC.AddrReturn: ADDRESS64: Windows'STACKFRAME64.AddrReturn.AddrFrame: ADDRESS64: Windows'STACKFRAME64.AddrFrame.AddrStack: ADDRESS64: Windows'STACKFRAME64.AddrStack.AddrBStore: ADDRESS64: Windows'STACKFRAME64.AddrBStore.FuncTableEntry: ptr: Windows'STACKFRAME64.FuncTableEntry.Params: array[0..3] of uint64: Windows'STACKFRAME64.Params.Far: int32: Windows'STACKFRAME64.Far.Virtual: int32: Windows'STACKFRAME64.Virtual.Reserved: array[0..2] of uint64: Windows'STACKFRAME64.Reserved.KdHelp: array[0..13] of uint64: Windows'STACKFRAME64.KdHelp.
PREAD_PROCESS_MEMORY_ROUTINE64
type PREAD_PROCESS_MEMORY_ROUTINE64 = func clink(AProcess: uint64; AAddress: uint64; ABuffer: ptr;
Windows' PREAD_PROCESS_MEMORY_ROUTINE64: StackWalk64's routines: the debuggee's memory (bytes at an address into a buffer, how many read; 0 fails), a function table entry for an address (SymFunctionTableAccess64), the base of the module holding an address (SymGetModuleBase64)
PFUNCTION_TABLE_ACCESS_ROUTINE64
type PFUNCTION_TABLE_ACCESS_ROUTINE64 = func clink(AProcess: uint64; AAddress: uint64): ptr
Windows' PFUNCTION_TABLE_ACCESS_ROUTINE64.
PGET_MODULE_BASE_ROUTINE64
type PGET_MODULE_BASE_ROUTINE64 = func clink(AProcess: uint64; AAddress: uint64): uint64
Windows' PGET_MODULE_BASE_ROUTINE64.
PHANDLER_ROUTINE
type PHANDLER_ROUTINE = func clink(ACtrlType: uint32): int32
Windows' PHANDLER_ROUTINE: SetConsoleCtrlHandler's handler (PHANDLER_ROUTINE): run on a thread of the OS's for a console event (CTRL_*); nonzero = handled
Constants
| Name | Declaration | Description |
|---|---|---|
DEBUG_ONLY_THIS_PROCESS | const DEBUG_ONLY_THIS_PROCESS: uint32 = 0x2 | Windows' DEBUG_ONLY_THIS_PROCESS: CreateProcessW's flags: the new process is debugged by this one (not its children) |
CREATE_NEW_PROCESS_GROUP | const CREATE_NEW_PROCESS_GROUP: uint32 = 0x200 | Windows' CREATE_NEW_PROCESS_GROUP: ... in a process group of its own: the console's Ctrl+C is not its (the debugger's, D4) |
EXCEPTION_DEBUG_EVENT | const EXCEPTION_DEBUG_EVENT: uint32 = 1 | Windows' EXCEPTION_DEBUG_EVENT: DEBUG_EVENT's dwDebugEventCode |
CREATE_THREAD_DEBUG_EVENT | const CREATE_THREAD_DEBUG_EVENT: uint32 = 2 | Windows' CREATE_THREAD_DEBUG_EVENT: DEBUG_EVENT's dwDebugEventCode |
CREATE_PROCESS_DEBUG_EVENT | const CREATE_PROCESS_DEBUG_EVENT: uint32 = 3 | Windows' CREATE_PROCESS_DEBUG_EVENT: DEBUG_EVENT's dwDebugEventCode |
EXIT_THREAD_DEBUG_EVENT | const EXIT_THREAD_DEBUG_EVENT: uint32 = 4 | Windows' EXIT_THREAD_DEBUG_EVENT: DEBUG_EVENT's dwDebugEventCode |
EXIT_PROCESS_DEBUG_EVENT | const EXIT_PROCESS_DEBUG_EVENT: uint32 = 5 | Windows' EXIT_PROCESS_DEBUG_EVENT: DEBUG_EVENT's dwDebugEventCode |
LOAD_DLL_DEBUG_EVENT | const LOAD_DLL_DEBUG_EVENT: uint32 = 6 | Windows' LOAD_DLL_DEBUG_EVENT: DEBUG_EVENT's dwDebugEventCode |
UNLOAD_DLL_DEBUG_EVENT | const UNLOAD_DLL_DEBUG_EVENT: uint32 = 7 | Windows' UNLOAD_DLL_DEBUG_EVENT: DEBUG_EVENT's dwDebugEventCode |
OUTPUT_DEBUG_STRING_EVENT | const OUTPUT_DEBUG_STRING_EVENT: uint32 = 8 | Windows' OUTPUT_DEBUG_STRING_EVENT: DEBUG_EVENT's dwDebugEventCode |
RIP_EVENT | const RIP_EVENT: uint32 = 9 | Windows' RIP_EVENT: DEBUG_EVENT's dwDebugEventCode |
DBG_CONTINUE | const DBG_CONTINUE: uint32 = 0x00010002 | Windows' DBG_CONTINUE: ContinueDebugEvent's status: the event is handled / an exception goes to the program |
DBG_EXCEPTION_NOT_HANDLED | const DBG_EXCEPTION_NOT_HANDLED: uint32 = 0x80010001 | Windows' DBG_EXCEPTION_NOT_HANDLED: ContinueDebugEvent's status: the event is handled / an exception goes to the program |
EXCEPTION_BREAKPOINT | const EXCEPTION_BREAKPOINT: uint32 = 0x80000003 | Windows' EXCEPTION_BREAKPOINT: EXCEPTION_RECORD's ExceptionCode: an int3, a trap-flag step |
EXCEPTION_SINGLE_STEP | const EXCEPTION_SINGLE_STEP: uint32 = 0x80000004 | Windows' EXCEPTION_SINGLE_STEP: EXCEPTION_RECORD's ExceptionCode: an int3, a trap-flag step |
CONTEXT_ALL | const CONTEXT_ALL: uint32 = 0x0010001F | Windows' CONTEXT_ALL: CONTEXT's ContextFlags: CONTEXT_ALL for AMD64 (control, integer, segments, floating point, debug registers) |
ADAM_WINDOWS_TRAP_FLAG | const ADAM_WINDOWS_TRAP_FLAG: uint32 = 0x100 | The trap flag in EFlags: one instruction, then a single-step exception |
ADAM_WINDOWS_CONTEXT_SIZE | const ADAM_WINDOWS_CONTEXT_SIZE: int64 = 1232 | The bytes of a CONTEXT and the alignment GetThreadContext / SetThreadContext need |
ADAM_WINDOWS_CONTEXT_ALIGN | const ADAM_WINDOWS_CONTEXT_ALIGN: int64 = 16 | The alignment GetThreadContext / SetThreadContext need for a CONTEXT. |
PAGE_EXECUTE_READWRITE | const PAGE_EXECUTE_READWRITE: uint32 = 0x40 | Windows' PAGE_EXECUTE_READWRITE: VirtualProtectEx's protection for a code byte the debugger writes |
ERROR_SEM_TIMEOUT | const ERROR_SEM_TIMEOUT: uint32 = 121 | Windows' ERROR_SEM_TIMEOUT: WaitForDebugEvent's error when no event came in time |
ERROR_FILENAME_EXCED_RANGE | const ERROR_FILENAME_EXCED_RANGE: uint32 = 206 | Windows' ERROR_FILENAME_EXCED_RANGE: The error of a path or command line too long for Win32 |
ADAM_WINDOWS_THREAD_FAILED | const ADAM_WINDOWS_THREAD_FAILED: uint32 = 0xFFFFFFFF | SuspendThread / ResumeThread's failure |
ADAM_WINDOWS_DEBUG_TEXT_MAX | const ADAM_WINDOWS_DEBUG_TEXT_MAX: uint32 = 32767 | The UTF-16 units GetFinalPathNameByHandleW and WinErrorText write at most |
FORMAT_MESSAGE_FROM_SYSTEM | const FORMAT_MESSAGE_FROM_SYSTEM: uint32 = 0x1000 | Windows' FORMAT_MESSAGE_FROM_SYSTEM: FormatMessageW: the system's message table, its inserts left as they are |
FORMAT_MESSAGE_IGNORE_INSERTS | const FORMAT_MESSAGE_IGNORE_INSERTS: uint32 = 0x200 | Windows' FORMAT_MESSAGE_IGNORE_INSERTS: FormatMessageW: the system's message table, its inserts left as they are |
CTRL_C_EVENT | const CTRL_C_EVENT: uint32 = 0 | Windows' CTRL_C_EVENT: A console control handler's events: Ctrl+C, Ctrl+Break |
CTRL_BREAK_EVENT | const CTRL_BREAK_EVENT: uint32 = 1 | Windows' CTRL_BREAK_EVENT: A console control handler's events: Ctrl+C, Ctrl+Break |
SYMOPT_UNDNAME | const SYMOPT_UNDNAME: uint32 = 0x2 | Windows' SYMOPT_UNDNAME: DbgHelp: SymSetOptions' options (undecorated names, source lines, no error box, no _NT_SYMBOL_PATH, no prompt) |
SYMOPT_LOAD_LINES | const SYMOPT_LOAD_LINES: uint32 = 0x10 | Windows' SYMOPT_LOAD_LINES: DbgHelp: SymSetOptions' options (undecorated names, source lines, no error box, no _NT_SYMBOL_PATH, no prompt) |
SYMOPT_FAIL_CRITICAL_ERRORS | const SYMOPT_FAIL_CRITICAL_ERRORS: uint32 = 0x200 | Windows' SYMOPT_FAIL_CRITICAL_ERRORS: DbgHelp: SymSetOptions' options (undecorated names, source lines, no error box, no _NT_SYMBOL_PATH, no prompt) |
SYMOPT_IGNORE_NT_SYMPATH | const SYMOPT_IGNORE_NT_SYMPATH: uint32 = 0x1000 | Windows' SYMOPT_IGNORE_NT_SYMPATH: DbgHelp: SymSetOptions' options (undecorated names, source lines, no error box, no _NT_SYMBOL_PATH, no prompt) |
SYMOPT_NO_PROMPTS | const SYMOPT_NO_PROMPTS: uint32 = 0x80000 | Windows' SYMOPT_NO_PROMPTS: DbgHelp: SymSetOptions' options (undecorated names, source lines, no error box, no _NT_SYMBOL_PATH, no prompt) |
SYMFLAG_REGREL | const SYMFLAG_REGREL: uint32 = 0x10 | Windows' SYMFLAG_REGREL: SYMBOL_INFOW's Flags: a value relative to a register, a parameter, a local |
SYMFLAG_TLSREL | const SYMFLAG_TLSREL: uint32 = 0x4000 | Windows' SYMFLAG_TLSREL: A thread-local value (its Address the offset in the module's TLS block) |
SYMFLAG_PARAMETER | const SYMFLAG_PARAMETER: uint32 = 0x40 | Windows' SYMFLAG_PARAMETER: a SYMBOL_INFOW flag: the symbol is a parameter of its function |
SYMFLAG_LOCAL | const SYMFLAG_LOCAL: uint32 = 0x80 | Windows' SYMFLAG_LOCAL: a SYMBOL_INFOW flag: the symbol is a local variable of its function |
SymTagFunction | const SymTagFunction: uint32 = 5 | Windows' SymTagFunction: SymTagEnum: a symbol's or a type's kind (SYMBOL_INFOW's Tag, TI_GET_SYMTAG) |
SymTagData | const SymTagData: uint32 = 7 | Windows' SymTagData: SymTagEnum: a symbol's or a type's kind (SYMBOL_INFOW's Tag, TI_GET_SYMTAG) |
SymTagLabel | const SymTagLabel: uint32 = 9 | Windows' SymTagLabel: SymTagEnum: a symbol's or a type's kind (SYMBOL_INFOW's Tag, TI_GET_SYMTAG) |
SymTagPublicSymbol | const SymTagPublicSymbol: uint32 = 10 | Windows' SymTagPublicSymbol: SymTagEnum: a symbol's or a type's kind (SYMBOL_INFOW's Tag, TI_GET_SYMTAG) |
SymTagUDT | const SymTagUDT: uint32 = 11 | Windows' SymTagUDT: SymTagEnum: a symbol's or a type's kind (SYMBOL_INFOW's Tag, TI_GET_SYMTAG) |
SymTagEnum | const SymTagEnum: uint32 = 12 | Windows' SymTagEnum: SymTagEnum: a symbol's or a type's kind (SYMBOL_INFOW's Tag, TI_GET_SYMTAG) |
SymTagFunctionType | const SymTagFunctionType: uint32 = 13 | Windows' SymTagFunctionType: SymTagEnum: a symbol's or a type's kind (SYMBOL_INFOW's Tag, TI_GET_SYMTAG) |
SymTagPointerType | const SymTagPointerType: uint32 = 14 | Windows' SymTagPointerType: SymTagEnum: a symbol's or a type's kind (SYMBOL_INFOW's Tag, TI_GET_SYMTAG) |
SymTagArrayType | const SymTagArrayType: uint32 = 15 | Windows' SymTagArrayType: SymTagEnum: a symbol's or a type's kind (SYMBOL_INFOW's Tag, TI_GET_SYMTAG) |
SymTagBaseType | const SymTagBaseType: uint32 = 16 | Windows' SymTagBaseType: SymTagEnum: a symbol's or a type's kind (SYMBOL_INFOW's Tag, TI_GET_SYMTAG) |
SymTagTypedef | const SymTagTypedef: uint32 = 17 | Windows' SymTagTypedef: SymTagEnum: a symbol's or a type's kind (SYMBOL_INFOW's Tag, TI_GET_SYMTAG) |
SymTagThunk | const SymTagThunk: uint32 = 27 | Windows' SymTagThunk: SymTagEnum: a symbol's or a type's kind (SYMBOL_INFOW's Tag, TI_GET_SYMTAG) |
TI_GET_SYMTAG | const TI_GET_SYMTAG: uint32 = 0 | Windows' TI_GET_SYMTAG: IMAGEHLP_SYMBOL_TYPE_INFO: what SymGetTypeInfo writes (TI_GET_LENGTH a uint64, TI_GET_SYMNAME a LocalAlloc'd UTF-16 text, TI_FINDCHILDREN a DebugFindChildren, the rest a uint32) |
TI_GET_SYMNAME | const TI_GET_SYMNAME: uint32 = 1 | Windows' TI_GET_SYMNAME: IMAGEHLP_SYMBOL_TYPE_INFO: what SymGetTypeInfo writes (TI_GET_LENGTH a uint64, TI_GET_SYMNAME a LocalAlloc'd UTF-16 text, TI_FINDCHILDREN a DebugFindChildren, the rest a uint32) |
TI_GET_LENGTH | const TI_GET_LENGTH: uint32 = 2 | Windows' TI_GET_LENGTH: IMAGEHLP_SYMBOL_TYPE_INFO: what SymGetTypeInfo writes (TI_GET_LENGTH a uint64, TI_GET_SYMNAME a LocalAlloc'd UTF-16 text, TI_FINDCHILDREN a DebugFindChildren, the rest a uint32) |
TI_GET_TYPE | const TI_GET_TYPE: uint32 = 3 | Windows' TI_GET_TYPE: IMAGEHLP_SYMBOL_TYPE_INFO: what SymGetTypeInfo writes (TI_GET_LENGTH a uint64, TI_GET_SYMNAME a LocalAlloc'd UTF-16 text, TI_FINDCHILDREN a DebugFindChildren, the rest a uint32) |
TI_GET_BASETYPE | const TI_GET_BASETYPE: uint32 = 5 | Windows' TI_GET_BASETYPE: IMAGEHLP_SYMBOL_TYPE_INFO: what SymGetTypeInfo writes (TI_GET_LENGTH a uint64, TI_GET_SYMNAME a LocalAlloc'd UTF-16 text, TI_FINDCHILDREN a DebugFindChildren, the rest a uint32) |
TI_FINDCHILDREN | const TI_FINDCHILDREN: uint32 = 7 | Windows' TI_FINDCHILDREN: IMAGEHLP_SYMBOL_TYPE_INFO: what SymGetTypeInfo writes (TI_GET_LENGTH a uint64, TI_GET_SYMNAME a LocalAlloc'd UTF-16 text, TI_FINDCHILDREN a DebugFindChildren, the rest a uint32) |
TI_GET_OFFSET | const TI_GET_OFFSET: uint32 = 10 | Windows' TI_GET_OFFSET: IMAGEHLP_SYMBOL_TYPE_INFO: what SymGetTypeInfo writes (TI_GET_LENGTH a uint64, TI_GET_SYMNAME a LocalAlloc'd UTF-16 text, TI_FINDCHILDREN a DebugFindChildren, the rest a uint32) |
TI_GET_VALUE | const TI_GET_VALUE: uint32 = 11 | Windows' TI_GET_VALUE: IMAGEHLP_SYMBOL_TYPE_INFO: what SymGetTypeInfo writes (TI_GET_LENGTH a uint64, TI_GET_SYMNAME a LocalAlloc'd UTF-16 text, TI_FINDCHILDREN a DebugFindChildren, the rest a uint32) |
TI_GET_COUNT | const TI_GET_COUNT: uint32 = 12 | Windows' TI_GET_COUNT: IMAGEHLP_SYMBOL_TYPE_INFO: what SymGetTypeInfo writes (TI_GET_LENGTH a uint64, TI_GET_SYMNAME a LocalAlloc'd UTF-16 text, TI_FINDCHILDREN a DebugFindChildren, the rest a uint32) |
TI_GET_CHILDRENCOUNT | const TI_GET_CHILDRENCOUNT: uint32 = 13 | Windows' TI_GET_CHILDRENCOUNT: IMAGEHLP_SYMBOL_TYPE_INFO: what SymGetTypeInfo writes (TI_GET_LENGTH a uint64, TI_GET_SYMNAME a LocalAlloc'd UTF-16 text, TI_FINDCHILDREN a DebugFindChildren, the rest a uint32) |
TI_GET_BITPOSITION | const TI_GET_BITPOSITION: uint32 = 14 | Windows' TI_GET_BITPOSITION: a bitfield member's first bit in its unit (fails for any other member) |
TI_GET_ADDRESS | const TI_GET_ADDRESS: uint32 = 22 | Windows' TI_GET_ADDRESS: a symbol's address (a uint64) |
SYMSEARCH_ALLITEMS | const SYMSEARCH_ALLITEMS: uint32 = 0x08 | Windows' SYMSEARCH_ALLITEMS: SymSearchW's options: nested symbols too (a routine's labels) |
VT_I2 | const VT_I2: uint16 = 2 | Windows' VT_I2: TI_GET_VALUE's VARIANT kinds (DebugVariant.Kind) an enum value comes as |
VT_I4 | const VT_I4: uint16 = 3 | Windows' VT_I4: TI_GET_VALUE's VARIANT kinds (DebugVariant.Kind) an enum value comes as |
VT_I1 | const VT_I1: uint16 = 16 | Windows' VT_I1: TI_GET_VALUE's VARIANT kinds (DebugVariant.Kind) an enum value comes as |
VT_UI1 | const VT_UI1: uint16 = 17 | Windows' VT_UI1: TI_GET_VALUE's VARIANT kinds (DebugVariant.Kind) an enum value comes as |
VT_UI2 | const VT_UI2: uint16 = 18 | Windows' VT_UI2: TI_GET_VALUE's VARIANT kinds (DebugVariant.Kind) an enum value comes as |
VT_UI4 | const VT_UI4: uint16 = 19 | Windows' VT_UI4: TI_GET_VALUE's VARIANT kinds (DebugVariant.Kind) an enum value comes as |
VT_I8 | const VT_I8: uint16 = 20 | Windows' VT_I8: TI_GET_VALUE's VARIANT kinds (DebugVariant.Kind) an enum value comes as |
VT_UI8 | const VT_UI8: uint16 = 21 | Windows' VT_UI8: TI_GET_VALUE's VARIANT kinds (DebugVariant.Kind) an enum value comes as |
VT_INT | const VT_INT: uint16 = 22 | Windows' VT_INT: TI_GET_VALUE's VARIANT kinds (DebugVariant.Kind) an enum value comes as |
VT_UINT | const VT_UINT: uint16 = 23 | Windows' VT_UINT: TI_GET_VALUE's VARIANT kinds (DebugVariant.Kind) an enum value comes as |
btVoid | const btVoid: uint32 = 1 | Windows' btVoid: BasicType (TI_GET_BASETYPE): DbgHelp's kinds of a builtin type |
btChar | const btChar: uint32 = 2 | Windows' btChar: BasicType (TI_GET_BASETYPE): DbgHelp's kinds of a builtin type |
btWChar | const btWChar: uint32 = 3 | Windows' btWChar: BasicType (TI_GET_BASETYPE): DbgHelp's kinds of a builtin type |
btInt | const btInt: uint32 = 6 | Windows' btInt: BasicType (TI_GET_BASETYPE): DbgHelp's kinds of a builtin type |
btUInt | const btUInt: uint32 = 7 | Windows' btUInt: BasicType (TI_GET_BASETYPE): DbgHelp's kinds of a builtin type |
btFloat | const btFloat: uint32 = 8 | Windows' btFloat: BasicType (TI_GET_BASETYPE): DbgHelp's kinds of a builtin type |
btBool | const btBool: uint32 = 10 | Windows' btBool: BasicType (TI_GET_BASETYPE): DbgHelp's kinds of a builtin type |
btLong | const btLong: uint32 = 13 | Windows' btLong: BasicType (TI_GET_BASETYPE): DbgHelp's kinds of a builtin type |
btULong | const btULong: uint32 = 14 | Windows' btULong: BasicType (TI_GET_BASETYPE): DbgHelp's kinds of a builtin type |
btChar16 | const btChar16: uint32 = 30 | Windows' btChar16: BasicType (TI_GET_BASETYPE): DbgHelp's kinds of a builtin type |
btChar32 | const btChar32: uint32 = 31 | Windows' btChar32: BasicType (TI_GET_BASETYPE): DbgHelp's kinds of a builtin type |
btChar8 | const btChar8: uint32 = 32 | Windows' btChar8: BasicType (TI_GET_BASETYPE): DbgHelp's kinds of a builtin type |
AddrModeFlat | const AddrModeFlat: uint32 = 3 | Windows' AddrModeFlat: StackWalk64's flat addresses (its machine, IMAGE_FILE_MACHINE_AMD64, is System.Windows') |
ADAM_WINDOWS_SYMBOL_INFO_SIZE | const ADAM_WINDOWS_SYMBOL_INFO_SIZE: uint32 = 88 | The SizeOfStruct DbgHelp checks: SYMBOL_INFOW (its name's first unit included) and IMAGEHLP_LINEW64; the UTF-16 units a DebugSymbolInfo holds of a name; the children a DebugFindChildren holds |
ADAM_WINDOWS_LINE_INFO_SIZE | const ADAM_WINDOWS_LINE_INFO_SIZE: uint32 = 40 | The bytes of an IMAGEHLP_LINEW64 (its SizeOfStruct). |
MAX_SYM_NAME | const MAX_SYM_NAME: uint32 = 2000 | Windows' MAX_SYM_NAME. |
ADAM_WINDOWS_FIND_CHILDREN_MAX | const ADAM_WINDOWS_FIND_CHILDREN_MAX: uint32 = 256 | The children a DebugFindChildren holds. |
Routines
WaitForDebugEvent
func clink WaitForDebugEvent(var AEvent: DEBUG_EVENT; AMilliseconds: uint32): int32
Windows' WaitForDebugEvent.
Parameters
AEvent: as Windows'WaitForDebugEventtakes itAMilliseconds: as Windows'WaitForDebugEventtakes it
Returns: as Windows' WaitForDebugEvent returns it
ContinueDebugEvent
func clink ContinueDebugEvent(AProcessId: uint32; AThreadId: uint32; AStatus: uint32): int32
Windows' ContinueDebugEvent.
Parameters
AProcessId: as Windows'ContinueDebugEventtakes itAThreadId: as Windows'ContinueDebugEventtakes itAStatus: as Windows'ContinueDebugEventtakes it
Returns: as Windows' ContinueDebugEvent returns it
DebugBreakProcess
func clink DebugBreakProcess(AProcess: uint64): int32
Windows' DebugBreakProcess.
Parameters
AProcess: as Windows'DebugBreakProcesstakes it
Returns: as Windows' DebugBreakProcess returns it
TerminateProcess
func clink TerminateProcess(AProcess: uint64; AExitCode: uint32): int32
Windows' TerminateProcess.
Parameters
AProcess: as Windows'TerminateProcesstakes itAExitCode: as Windows'TerminateProcesstakes it
Returns: as Windows' TerminateProcess returns it
GetThreadContext
func clink GetThreadContext(AThread: uint64; AContext: ptr): int32
Windows' GetThreadContext.
Parameters
AThread: as Windows'GetThreadContexttakes itAContext: as Windows'GetThreadContexttakes it
Returns: as Windows' GetThreadContext returns it
SetThreadContext
func clink SetThreadContext(AThread: uint64; AContext: ptr): int32
Windows' SetThreadContext.
Parameters
AThread: as Windows'SetThreadContexttakes itAContext: as Windows'SetThreadContexttakes it
Returns: as Windows' SetThreadContext returns it
ReadProcessMemory
func clink ReadProcessMemory(AProcess: uint64; AAddress: uint64; ABuffer: ptr; ASize: uint64; var ARead: uint64): int32
Windows' ReadProcessMemory.
Parameters
AProcess: as Windows'ReadProcessMemorytakes itAAddress: as Windows'ReadProcessMemorytakes itABuffer: as Windows'ReadProcessMemorytakes itASize: as Windows'ReadProcessMemorytakes itARead: as Windows'ReadProcessMemorytakes it
Returns: as Windows' ReadProcessMemory returns it
WriteProcessMemory
func clink WriteProcessMemory(AProcess: uint64; AAddress: uint64; ABuffer: ptr to const; ASize: uint64; var AWritten: uint64): int32
Windows' WriteProcessMemory.
Parameters
AProcess: as Windows'WriteProcessMemorytakes itAAddress: as Windows'WriteProcessMemorytakes itABuffer: as Windows'WriteProcessMemorytakes itASize: as Windows'WriteProcessMemorytakes itAWritten: as Windows'WriteProcessMemorytakes it
Returns: as Windows' WriteProcessMemory returns it
VirtualProtectEx
func clink VirtualProtectEx(AProcess: uint64; AAddress: uint64; ASize: uint64; ANewProtect: uint32; var AOldProtect: uint32): int32
Windows' VirtualProtectEx.
Parameters
AProcess: as Windows'VirtualProtectExtakes itAAddress: as Windows'VirtualProtectExtakes itASize: as Windows'VirtualProtectExtakes itANewProtect: as Windows'VirtualProtectExtakes itAOldProtect: as Windows'VirtualProtectExtakes it
Returns: as Windows' VirtualProtectEx returns it
FlushInstructionCache
func clink FlushInstructionCache(AProcess: uint64; AAddress: uint64; ASize: uint64): int32
Windows' FlushInstructionCache.
Parameters
AProcess: as Windows'FlushInstructionCachetakes itAAddress: as Windows'FlushInstructionCachetakes itASize: as Windows'FlushInstructionCachetakes it
Returns: as Windows' FlushInstructionCache returns it
SuspendThread
func clink SuspendThread(AThread: uint64): uint32
Windows' SuspendThread.
Parameters
AThread: as Windows'SuspendThreadtakes it
Returns: as Windows' SuspendThread returns it
ResumeThread
func clink ResumeThread(AThread: uint64): uint32
Windows' ResumeThread.
Parameters
AThread: as Windows'ResumeThreadtakes it
Returns: as Windows' ResumeThread returns it
GetFinalPathNameByHandleW
func clink GetFinalPathNameByHandleW(AFile: uint64; var ABuffer: WideBuffer; ASize: uint32; AFlags: uint32): uint32
Windows' GetFinalPathNameByHandleW.
Parameters
AFile: as Windows'GetFinalPathNameByHandleWtakes itABuffer: as Windows'GetFinalPathNameByHandleWtakes itASize: as Windows'GetFinalPathNameByHandleWtakes itAFlags: as Windows'GetFinalPathNameByHandleWtakes it
Returns: as Windows' GetFinalPathNameByHandleW returns it
SetConsoleCtrlHandler
func clink SetConsoleCtrlHandler(AHandler: PHANDLER_ROUTINE; AAdd: int32): int32
Windows' SetConsoleCtrlHandler.
Parameters
AHandler: as Windows'SetConsoleCtrlHandlertakes itAAdd: as Windows'SetConsoleCtrlHandlertakes it
Returns: as Windows' SetConsoleCtrlHandler returns it
SymSetOptions
func clink SymSetOptions(AOptions: uint32): uint32
Windows' SymSetOptions.
Parameters
AOptions: as Windows'SymSetOptionstakes it
Returns: as Windows' SymSetOptions returns it
SymInitializeW
func clink SymInitializeW(AProcess: uint64; ASearchPath: ptr to const uint16; AInvadeProcess: int32): int32
Windows' SymInitializeW.
Parameters
AProcess: as Windows'SymInitializeWtakes itASearchPath: as Windows'SymInitializeWtakes itAInvadeProcess: as Windows'SymInitializeWtakes it
Returns: as Windows' SymInitializeW returns it
SymLoadModuleExW
func clink SymLoadModuleExW(AProcess: uint64; AFile: uint64; AImageName: ptr to const uint16; AModuleName: ptr to const uint16; ABase: uint64; ASize: uint32; AData: ptr; AFlags: uint32): uint64
Windows' SymLoadModuleExW.
Parameters
AProcess: as Windows'SymLoadModuleExWtakes itAFile: as Windows'SymLoadModuleExWtakes itAImageName: as Windows'SymLoadModuleExWtakes itAModuleName: as Windows'SymLoadModuleExWtakes itABase: as Windows'SymLoadModuleExWtakes itASize: as Windows'SymLoadModuleExWtakes itAData: as Windows'SymLoadModuleExWtakes itAFlags: as Windows'SymLoadModuleExWtakes it
Returns: as Windows' SymLoadModuleExW returns it
SymFromNameW
func clink SymFromNameW(AProcess: uint64; ASymbolName: ptr to const uint16; var ASymbol: DebugSymbolInfo): int32
Windows' SymFromNameW.
Parameters
AProcess: as Windows'SymFromNameWtakes itASymbolName: as Windows'SymFromNameWtakes itASymbol: as Windows'SymFromNameWtakes it
Returns: as Windows' SymFromNameW returns it
SymFromAddrW
func clink SymFromAddrW(AProcess: uint64; AAddress: uint64; var ADisplacement: uint64; var ASymbol: DebugSymbolInfo): int32
Windows' SymFromAddrW.
Parameters
AProcess: as Windows'SymFromAddrWtakes itAAddress: as Windows'SymFromAddrWtakes itADisplacement: as Windows'SymFromAddrWtakes itASymbol: as Windows'SymFromAddrWtakes it
Returns: as Windows' SymFromAddrW returns it
SymGetLineFromAddrW64
func clink SymGetLineFromAddrW64(AProcess: uint64; AAddress: uint64; var ADisplacement: uint32; var ALine: IMAGEHLP_LINEW64): int32
Windows' SymGetLineFromAddrW64.
Parameters
AProcess: as Windows'SymGetLineFromAddrW64takes itAAddress: as Windows'SymGetLineFromAddrW64takes itADisplacement: as Windows'SymGetLineFromAddrW64takes itALine: as Windows'SymGetLineFromAddrW64takes it
Returns: as Windows' SymGetLineFromAddrW64 returns it
SymGetLineFromNameW64
func clink SymGetLineFromNameW64(AProcess: uint64; AModuleName: ptr to const uint16; AFileName: ptr to const uint16; ALineNumber: uint32; var ADisplacement: int32; var ALine: IMAGEHLP_LINEW64): int32
Windows' SymGetLineFromNameW64.
Parameters
AProcess: as Windows'SymGetLineFromNameW64takes itAModuleName: as Windows'SymGetLineFromNameW64takes itAFileName: as Windows'SymGetLineFromNameW64takes itALineNumber: as Windows'SymGetLineFromNameW64takes itADisplacement: as Windows'SymGetLineFromNameW64takes itALine: as Windows'SymGetLineFromNameW64takes it
Returns: as Windows' SymGetLineFromNameW64 returns it
SymSetScopeFromAddr
func clink SymSetScopeFromAddr(AProcess: uint64; AAddress: uint64): int32
Windows' SymSetScopeFromAddr.
Parameters
AProcess: as Windows'SymSetScopeFromAddrtakes itAAddress: as Windows'SymSetScopeFromAddrtakes it
Returns: as Windows' SymSetScopeFromAddr returns it
SymEnumSymbolsW
func clink SymEnumSymbolsW(AProcess: uint64; ABase: uint64; AMask: ptr to const uint16; ACallback: PSYM_ENUMERATESYMBOLS_CALLBACKW; AContext: ptr): int32
Windows' SymEnumSymbolsW.
Parameters
AProcess: as Windows'SymEnumSymbolsWtakes itABase: as Windows'SymEnumSymbolsWtakes itAMask: as Windows'SymEnumSymbolsWtakes itACallback: as Windows'SymEnumSymbolsWtakes itAContext: as Windows'SymEnumSymbolsWtakes it
Returns: as Windows' SymEnumSymbolsW returns it
SymSearchW
func clink SymSearchW(AProcess: uint64; ABase: uint64; AIndex: uint32; ATag: uint32; AMask: ptr to const uint16; AAddress: uint64; ACallback: PSYM_ENUMERATESYMBOLS_CALLBACKW; AContext: ptr; AOptions: uint32): int32
Windows' SymSearchW: Every symbol of a module of the SymTagEnum ATag (0 any), nested ones too with SYMSEARCH_ALLITEMS, given to ACallback
Parameters
AProcess: as Windows'SymSearchWtakes itABase: as Windows'SymSearchWtakes itAIndex: as Windows'SymSearchWtakes itATag: as Windows'SymSearchWtakes itAMask: as Windows'SymSearchWtakes itAAddress: as Windows'SymSearchWtakes itACallback: as Windows'SymSearchWtakes itAContext: as Windows'SymSearchWtakes itAOptions: as Windows'SymSearchWtakes it
Returns: as Windows' SymSearchW returns it
SymGetTypeInfo
func clink SymGetTypeInfo(AProcess: uint64; ABase: uint64; ATypeId: uint32; AKind: uint32; AInfo: ptr): int32
Windows' SymGetTypeInfo.
Parameters
AProcess: as Windows'SymGetTypeInfotakes itABase: as Windows'SymGetTypeInfotakes itATypeId: as Windows'SymGetTypeInfotakes itAKind: as Windows'SymGetTypeInfotakes itAInfo: as Windows'SymGetTypeInfotakes it
Returns: as Windows' SymGetTypeInfo returns it
SymGetLineNextW64
func clink SymGetLineNextW64(AProcess: uint64; var ALine: IMAGEHLP_LINEW64): int32
Windows' SymGetLineNextW64.
Parameters
AProcess: as Windows'SymGetLineNextW64takes itALine: as Windows'SymGetLineNextW64takes it
Returns: as Windows' SymGetLineNextW64 returns it
SymEnumSourceFilesW
func clink SymEnumSourceFilesW(AProcess: uint64; ABase: uint64; AMask: ptr to const uint16; ACallback: PSYM_ENUMSOURCEFILES_CALLBACKW; AContext: ptr): int32
Windows' SymEnumSourceFilesW.
Parameters
AProcess: as Windows'SymEnumSourceFilesWtakes itABase: as Windows'SymEnumSourceFilesWtakes itAMask: as Windows'SymEnumSourceFilesWtakes itACallback: as Windows'SymEnumSourceFilesWtakes itAContext: as Windows'SymEnumSourceFilesWtakes it
Returns: as Windows' SymEnumSourceFilesW returns it
SymFunctionTableAccess64
func clink SymFunctionTableAccess64(AProcess: uint64; AAddress: uint64): ptr
Windows' SymFunctionTableAccess64.
Parameters
AProcess: as Windows'SymFunctionTableAccess64takes itAAddress: as Windows'SymFunctionTableAccess64takes it
Returns: as Windows' SymFunctionTableAccess64 returns it
SymGetModuleBase64
func clink SymGetModuleBase64(AProcess: uint64; AAddress: uint64): uint64
Windows' SymGetModuleBase64.
Parameters
AProcess: as Windows'SymGetModuleBase64takes itAAddress: as Windows'SymGetModuleBase64takes it
Returns: as Windows' SymGetModuleBase64 returns it
StackWalk64
func clink StackWalk64(AMachine: uint32; AProcess: uint64; AThread: uint64; var AFrame: STACKFRAME64; AContext: ptr; AReadMemory: PREAD_PROCESS_MEMORY_ROUTINE64; AFunctionTable: PFUNCTION_TABLE_ACCESS_ROUTINE64; AModuleBase: PGET_MODULE_BASE_ROUTINE64; ATranslate: ptr): int32
Windows' StackWalk64.
Parameters
AMachine: as Windows'StackWalk64takes itAProcess: as Windows'StackWalk64takes itAThread: as Windows'StackWalk64takes itAFrame: as Windows'StackWalk64takes itAContext: as Windows'StackWalk64takes itAReadMemory: as Windows'StackWalk64takes itAFunctionTable: as Windows'StackWalk64takes itAModuleBase: as Windows'StackWalk64takes itATranslate: as Windows'StackWalk64takes it
Returns: as Windows' StackWalk64 returns it
SymUnloadModule64
func clink SymUnloadModule64(AProcess: uint64; ABase: uint64): int32
Windows' SymUnloadModule64.
Parameters
AProcess: as Windows'SymUnloadModule64takes itABase: as Windows'SymUnloadModule64takes it
Returns: as Windows' SymUnloadModule64 returns it
SymCleanup
func clink SymCleanup(AProcess: uint64): int32
Windows' SymCleanup.
Parameters
AProcess: as Windows'SymCleanuptakes it
Returns: as Windows' SymCleanup returns it
WinErrorText
func WinErrorText(const ACode: uint32): string
The system's own message for the Win32 error ACode, its line end and a final '.' cut ("Windows error N" when the system has none)
Parameters
ACode: the Win32 error code
Returns: the message
WinLastErrorText
func WinLastErrorText(): string
WinErrorText of the calling thread's last error
Returns: the message
DbgWideText
func DbgWideText(const AText: ptr to const uint16): string
The UTF-16 text AText points to, up to its 0 (at most ADAM_WINDOWS_DEBUG_TEXT_MAX units), as a string; nil gives ""
Parameters
AText: the UTF-16 text, or nil
Returns: the text, or ""
DbgSymbolName
func DbgSymbolName(const ASymbol: DebugSymbolInfo): string
ASymbol's name (NameLen units, never past the room it has) as a string
Parameters
ASymbol: the symbol
Returns: its name
SymTypeName
func SymTypeName(const AProcess: uint64; const ABase: uint64; const ATypeId: uint32): string
The name of type ATypeId in the module at ABase (TI_GET_SYMNAME, its text freed); "" when the type has none
Parameters
AProcess: the process DbgHelp works onABase: the module's baseATypeId: the type
Returns: its name, or ""
System.Windows.SDK
the Windows SDK's own declarations, each once (AD.5a), with no code and no external: the Win32 constants and records System.Windows and the Windows platform units use, winnt.h's PE / COFF, winuser.h's RT_* and winver.h's VS_* / VOS_* / VFT_* that Adam's COFF part writes and reads, and the C runtime's lowio and stat names (ucrt's fcntl.h, share.h, sys/stat.h) System.HookIO.Win64 hooks.
Import it with import System.Windows.SDK;.
Types
ENUMRESNAMEPROCW
type ENUMRESNAMEPROCW = func clink(AModule: uint64; AType: uint64; AName: uint64;
The Windows SDK's ENUMRESNAMEPROCW: EnumResourceNamesW's and EnumResourceLanguagesW's callbacks (libloaderapi.h): a type or name is an id when it fits 16 bits (IS_INTRESOURCE), else a NUL-terminated UTF-16 text
ENUMRESLANGPROCW
type ENUMRESLANGPROCW = func clink(AModule: uint64; AType: uint64; AName: uint64;
The Windows SDK's ENUMRESLANGPROCW.
TIMERPROC
type TIMERPROC = func clink(AWindow: uint64; AMsg: uint32; AIdEvent: uint64; ATime: uint32)
The Windows SDK's TIMERPROC: SetTimer's callback (winuser.h): called by DispatchMessage when the timer's WM_TIMER is taken from the queue, so only while the window's thread reads its messages
_stat32
type _stat32 = record
The Windows SDK's _stat32: The C runtime's stat records (ucrt sys/stat.h), as Win64 lays them out: _stat32 (36 bytes: a 32-bit size and times), _stat32i64 (48: a 64-bit size, 32-bit times), _stat64i32 (48: a 32-bit size, 64-bit times, mingw's struct stat) and _stat64 (56: both 64 bits)
Members
st_dev: uint32: The Windows SDK's_stat32.st_dev.st_ino: uint16: The Windows SDK's_stat32.st_ino.st_mode: uint16: The Windows SDK's_stat32.st_mode.st_nlink: int16: The Windows SDK's_stat32.st_nlink.st_uid: int16: The Windows SDK's_stat32.st_uid.st_gid: int16: The Windows SDK's_stat32.st_gid.st_rdev: uint32: The Windows SDK's_stat32.st_rdev.st_size: int32: The Windows SDK's_stat32.st_size.st_atime: int32: The Windows SDK's_stat32.st_atime.st_mtime: int32: The Windows SDK's_stat32.st_mtime.st_ctime: int32: The Windows SDK's_stat32.st_ctime.
_stat32i64
type _stat32i64 = record
The Windows SDK's _stat32i64.
Members
st_dev: uint32: The Windows SDK's_stat32i64.st_dev.st_ino: uint16: The Windows SDK's_stat32i64.st_ino.st_mode: uint16: The Windows SDK's_stat32i64.st_mode.st_nlink: int16: The Windows SDK's_stat32i64.st_nlink.st_uid: int16: The Windows SDK's_stat32i64.st_uid.st_gid: int16: The Windows SDK's_stat32i64.st_gid.st_rdev: uint32: The Windows SDK's_stat32i64.st_rdev.st_size: int64: The Windows SDK's_stat32i64.st_size.st_atime: int32: The Windows SDK's_stat32i64.st_atime.st_mtime: int32: The Windows SDK's_stat32i64.st_mtime.st_ctime: int32: The Windows SDK's_stat32i64.st_ctime.
_stat64i32
type _stat64i32 = record
The Windows SDK's _stat64i32.
Members
st_dev: uint32: The Windows SDK's_stat64i32.st_dev.st_ino: uint16: The Windows SDK's_stat64i32.st_ino.st_mode: uint16: The Windows SDK's_stat64i32.st_mode.st_nlink: int16: The Windows SDK's_stat64i32.st_nlink.st_uid: int16: The Windows SDK's_stat64i32.st_uid.st_gid: int16: The Windows SDK's_stat64i32.st_gid.st_rdev: uint32: The Windows SDK's_stat64i32.st_rdev.st_size: int32: The Windows SDK's_stat64i32.st_size.st_atime: int64: The Windows SDK's_stat64i32.st_atime.st_mtime: int64: The Windows SDK's_stat64i32.st_mtime.st_ctime: int64: The Windows SDK's_stat64i32.st_ctime.
_stat64
type _stat64 = record
The Windows SDK's _stat64.
Members
st_dev: uint32: The Windows SDK's_stat64.st_dev.st_ino: uint16: The Windows SDK's_stat64.st_ino.st_mode: uint16: The Windows SDK's_stat64.st_mode.st_nlink: int16: The Windows SDK's_stat64.st_nlink.st_uid: int16: The Windows SDK's_stat64.st_uid.st_gid: int16: The Windows SDK's_stat64.st_gid.st_rdev: uint32: The Windows SDK's_stat64.st_rdev.st_size: int64: The Windows SDK's_stat64.st_size.st_atime: int64: The Windows SDK's_stat64.st_atime.st_mtime: int64: The Windows SDK's_stat64.st_mtime.st_ctime: int64: The Windows SDK's_stat64.st_ctime.
FILETIME
type FILETIME = record
The Windows SDK's FILETIME: The SDK's records the Windows units share (minwinbase.h, minwindef.h, processthreadsapi.h)
Members
dwLowDateTime: uint32: The Windows SDK'sFILETIME.dwLowDateTime.dwHighDateTime: uint32: The Windows SDK'sFILETIME.dwHighDateTime.
WIN32_FIND_DATAW
type WIN32_FIND_DATAW = record
The Windows SDK's WIN32_FIND_DATAW.
Members
dwFileAttributes: uint32: The Windows SDK'sWIN32_FIND_DATAW.dwFileAttributes.ftCreationTime: FILETIME: The Windows SDK'sWIN32_FIND_DATAW.ftCreationTime.ftLastAccessTime: FILETIME: The Windows SDK'sWIN32_FIND_DATAW.ftLastAccessTime.ftLastWriteTime: FILETIME: The Windows SDK'sWIN32_FIND_DATAW.ftLastWriteTime.nFileSizeHigh: uint32: The Windows SDK'sWIN32_FIND_DATAW.nFileSizeHigh.nFileSizeLow: uint32: The Windows SDK'sWIN32_FIND_DATAW.nFileSizeLow.dwReserved0: uint32: The Windows SDK'sWIN32_FIND_DATAW.dwReserved0.dwReserved1: uint32: The Windows SDK'sWIN32_FIND_DATAW.dwReserved1.cFileName: array[0..259] of uint16: The Windows SDK'sWIN32_FIND_DATAW.cFileName.cAlternateFileName: array[0..13] of uint16: The Windows SDK'sWIN32_FIND_DATAW.cAlternateFileName.
WIN32_FILE_ATTRIBUTE_DATA
type WIN32_FILE_ATTRIBUTE_DATA = record
The Windows SDK's WIN32_FILE_ATTRIBUTE_DATA.
Members
dwFileAttributes: uint32: The Windows SDK'sWIN32_FILE_ATTRIBUTE_DATA.dwFileAttributes.ftCreationTime: FILETIME: The Windows SDK'sWIN32_FILE_ATTRIBUTE_DATA.ftCreationTime.ftLastAccessTime: FILETIME: The Windows SDK'sWIN32_FILE_ATTRIBUTE_DATA.ftLastAccessTime.ftLastWriteTime: FILETIME: The Windows SDK'sWIN32_FILE_ATTRIBUTE_DATA.ftLastWriteTime.nFileSizeHigh: uint32: The Windows SDK'sWIN32_FILE_ATTRIBUTE_DATA.nFileSizeHigh.nFileSizeLow: uint32: The Windows SDK'sWIN32_FILE_ATTRIBUTE_DATA.nFileSizeLow.
SECURITY_ATTRIBUTES
type SECURITY_ATTRIBUTES = record
The Windows SDK's SECURITY_ATTRIBUTES.
Members
nLength: uint32: The Windows SDK'sSECURITY_ATTRIBUTES.nLength.lpSecurityDescriptor: ptr: The Windows SDK'sSECURITY_ATTRIBUTES.lpSecurityDescriptor.bInheritHandle: int32: The Windows SDK'sSECURITY_ATTRIBUTES.bInheritHandle.
STARTUPINFOW
type STARTUPINFOW = record
The Windows SDK's STARTUPINFOW.
Members
cb: uint32: The Windows SDK'sSTARTUPINFOW.cb.lpReserved: ptr: The Windows SDK'sSTARTUPINFOW.lpReserved.lpDesktop: ptr: The Windows SDK'sSTARTUPINFOW.lpDesktop.lpTitle: ptr: The Windows SDK'sSTARTUPINFOW.lpTitle.dwX: uint32: The Windows SDK'sSTARTUPINFOW.dwX.dwY: uint32: The Windows SDK'sSTARTUPINFOW.dwY.dwXSize: uint32: The Windows SDK'sSTARTUPINFOW.dwXSize.dwYSize: uint32: The Windows SDK'sSTARTUPINFOW.dwYSize.dwXCountChars: uint32: The Windows SDK'sSTARTUPINFOW.dwXCountChars.dwYCountChars: uint32: The Windows SDK'sSTARTUPINFOW.dwYCountChars.dwFillAttribute: uint32: The Windows SDK'sSTARTUPINFOW.dwFillAttribute.dwFlags: uint32: The Windows SDK'sSTARTUPINFOW.dwFlags.wShowWindow: uint16: The Windows SDK'sSTARTUPINFOW.wShowWindow.cbReserved2: uint16: The Windows SDK'sSTARTUPINFOW.cbReserved2.lpReserved2: ptr: The Windows SDK'sSTARTUPINFOW.lpReserved2.hStdInput: uint64: The Windows SDK'sSTARTUPINFOW.hStdInput.hStdOutput: uint64: The Windows SDK'sSTARTUPINFOW.hStdOutput.hStdError: uint64: The Windows SDK'sSTARTUPINFOW.hStdError.
STARTUPINFOEXW
type STARTUPINFOEXW = record
The Windows SDK's STARTUPINFOEXW: STARTUPINFOEXW: a STARTUPINFOW (cb its whole size) and its attribute list (a pseudo console's, EXTENDED_STARTUPINFO_PRESENT)
Members
StartupInfo: STARTUPINFOW: The Windows SDK'sSTARTUPINFOEXW.StartupInfo.lpAttributeList: ptr: The Windows SDK'sSTARTUPINFOEXW.lpAttributeList.
COORD
type COORD = record
The Windows SDK's COORD: wincontypes.h's COORD (a console's or a pseudo console's size, a cell)
Members
X: int16: The Windows SDK'sCOORD.X.Y: int16: The Windows SDK'sCOORD.Y.
SMALL_RECT
type SMALL_RECT = record
The Windows SDK's SMALL_RECT: wincontypes.h: CONSOLE_SCREEN_BUFFER_INFO with its SMALL_RECT
Members
Left: int16: The Windows SDK'sSMALL_RECT.Left.Top: int16: The Windows SDK'sSMALL_RECT.Top.Right: int16: The Windows SDK'sSMALL_RECT.Right.Bottom: int16: The Windows SDK'sSMALL_RECT.Bottom.
CONSOLE_SCREEN_BUFFER_INFO
type CONSOLE_SCREEN_BUFFER_INFO = record
The Windows SDK's CONSOLE_SCREEN_BUFFER_INFO.
Members
dwSize: COORD: The Windows SDK'sCONSOLE_SCREEN_BUFFER_INFO.dwSize.dwCursorPosition: COORD: The Windows SDK'sCONSOLE_SCREEN_BUFFER_INFO.dwCursorPosition.wAttributes: uint16: The Windows SDK'sCONSOLE_SCREEN_BUFFER_INFO.wAttributes.srWindow: SMALL_RECT: The Windows SDK'sCONSOLE_SCREEN_BUFFER_INFO.srWindow.dwMaximumWindowSize: COORD: The Windows SDK'sCONSOLE_SCREEN_BUFFER_INFO.dwMaximumWindowSize.
PROCESS_INFORMATION
type PROCESS_INFORMATION = record
The Windows SDK's PROCESS_INFORMATION.
Members
hProcess: uint64: The Windows SDK'sPROCESS_INFORMATION.hProcess.hThread: uint64: The Windows SDK'sPROCESS_INFORMATION.hThread.dwProcessId: uint32: The Windows SDK'sPROCESS_INFORMATION.dwProcessId.dwThreadId: uint32: The Windows SDK'sPROCESS_INFORMATION.dwThreadId.
OSVERSIONINFOW
type OSVERSIONINFOW = record
The Windows SDK's OSVERSIONINFOW (winnt.h): RtlGetVersion's answer, the running Windows' own version (never a compatibility shim's)
Members
dwOSVersionInfoSize: uint32: The Windows SDK'sOSVERSIONINFOW.dwOSVersionInfoSize: the record's size, set by the caller.dwMajorVersion: uint32: The Windows SDK'sOSVERSIONINFOW.dwMajorVersion.dwMinorVersion: uint32: The Windows SDK'sOSVERSIONINFOW.dwMinorVersion.dwBuildNumber: uint32: The Windows SDK'sOSVERSIONINFOW.dwBuildNumber.dwPlatformId: uint32: The Windows SDK'sOSVERSIONINFOW.dwPlatformId.szCSDVersion: array[0..127] of uint16: The Windows SDK'sOSVERSIONINFOW.szCSDVersion: the service pack, NUL-terminated UTF-16.
MEMORYSTATUSEX
type MEMORYSTATUSEX = record
The Windows SDK's MEMORYSTATUSEX (sysinfoapi.h): GlobalMemoryStatusEx's answer, in bytes
Members
dwLength: uint32: The Windows SDK'sMEMORYSTATUSEX.dwLength: the record's size, set by the caller.dwMemoryLoad: uint32: The Windows SDK'sMEMORYSTATUSEX.dwMemoryLoad.ullTotalPhys: uint64: The Windows SDK'sMEMORYSTATUSEX.ullTotalPhys: the physical memory installed.ullAvailPhys: uint64: The Windows SDK'sMEMORYSTATUSEX.ullAvailPhys.ullTotalPageFile: uint64: The Windows SDK'sMEMORYSTATUSEX.ullTotalPageFile.ullAvailPageFile: uint64: The Windows SDK'sMEMORYSTATUSEX.ullAvailPageFile.ullTotalVirtual: uint64: The Windows SDK'sMEMORYSTATUSEX.ullTotalVirtual.ullAvailVirtual: uint64: The Windows SDK'sMEMORYSTATUSEX.ullAvailVirtual.ullAvailExtendedVirtual: uint64: The Windows SDK'sMEMORYSTATUSEX.ullAvailExtendedVirtual.
Constants
| Name | Declaration | Description |
|---|---|---|
INVALID_HANDLE_VALUE | const INVALID_HANDLE_VALUE: uint64 = 0xFFFFFFFFFFFFFFFF | The Windows SDK's INVALID_HANDLE_VALUE. |
STD_INPUT_HANDLE | const STD_INPUT_HANDLE: uint32 = 0xFFFFFFF6 | The Windows SDK's STD_INPUT_HANDLE: GetStdHandle's standard input (DWORD)-10, output (DWORD)-11 and error (DWORD)-12 |
STD_OUTPUT_HANDLE | const STD_OUTPUT_HANDLE: uint32 = 0xFFFFFFF5 | The Windows SDK's STD_OUTPUT_HANDLE: GetStdHandle's standard input (DWORD)-10, output (DWORD)-11 and error (DWORD)-12 |
STD_ERROR_HANDLE | const STD_ERROR_HANDLE: uint32 = 0xFFFFFFF4 | The Windows SDK's STD_ERROR_HANDLE: GetStdHandle's standard input (DWORD)-10, output (DWORD)-11 and error (DWORD)-12 |
EXTENDED_STARTUPINFO_PRESENT | const EXTENDED_STARTUPINFO_PRESENT: uint32 = 0x00080000 | The Windows SDK's EXTENDED_STARTUPINFO_PRESENT: CreateProcessW's flag for a STARTUPINFOEXW; the pseudo console attribute (ProcThreadAttributeValue(22, FALSE, TRUE, FALSE)) |
PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE | const PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE: uint64 = 0x00020016 | The Windows SDK's PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE: CreateProcessW's flag for a STARTUPINFOEXW; the pseudo console attribute (ProcThreadAttributeValue(22, FALSE, TRUE, FALSE)) |
PROC_THREAD_ATTRIBUTE_HANDLE_LIST | const PROC_THREAD_ATTRIBUTE_HANDLE_LIST: uint64 = 0x00020002 | The Windows SDK's PROC_THREAD_ATTRIBUTE_HANDLE_LIST: The handles a child inherits, only these (ProcThreadAttributeValue(2, FALSE, TRUE, FALSE)) |
DUPLICATE_SAME_ACCESS | const DUPLICATE_SAME_ACCESS: uint32 = 0x2 | The Windows SDK's DUPLICATE_SAME_ACCESS: DuplicateHandle: the copy has the source's access |
WAIT_TIMEOUT | const WAIT_TIMEOUT: uint32 = 0x102 | The Windows SDK's WAIT_TIMEOUT: WaitForSingleObject: the wait ran out with the object not signaled |
CP_OEMCP | const CP_OEMCP: uint32 = 1 | The Windows SDK's CP_OEMCP: The OEM code page (MultiByteToWideChar): what a console tool writes when it is not UTF-8 |
FILE_TYPE_UNKNOWN | const FILE_TYPE_UNKNOWN: uint32 = 0 | The Windows SDK's FILE_TYPE_UNKNOWN: GetFileType's answers |
FILE_TYPE_DISK | const FILE_TYPE_DISK: uint32 = 1 | The Windows SDK's FILE_TYPE_DISK: GetFileType's answers |
FILE_TYPE_CHAR | const FILE_TYPE_CHAR: uint32 = 2 | The Windows SDK's FILE_TYPE_CHAR: GetFileType's answers |
FILE_TYPE_PIPE | const FILE_TYPE_PIPE: uint32 = 3 | The Windows SDK's FILE_TYPE_PIPE: GetFileType's answers |
INVALID_FILE_ATTRIBUTES | const INVALID_FILE_ATTRIBUTES: uint32 = 0xFFFFFFFF | The Windows SDK's INVALID_FILE_ATTRIBUTES: GetFileAttributesW's answer for a path that is not there or cannot be read |
FILE_ATTRIBUTE_DIRECTORY | const FILE_ATTRIBUTE_DIRECTORY: uint32 = 0x10 | The Windows SDK's FILE_ATTRIBUTE_DIRECTORY: a file attribute: the path is a folder |
FILE_ATTRIBUTE_READONLY | const FILE_ATTRIBUTE_READONLY: uint32 = 0x1 | The Windows SDK's FILE_ATTRIBUTE_READONLY: a file attribute: the file is read-only (never written, replaced or deleted until cleared) |
FILE_ATTRIBUTE_HIDDEN | const FILE_ATTRIBUTE_HIDDEN: uint32 = 0x2 | The Windows SDK's FILE_ATTRIBUTE_HIDDEN: a file attribute: the file or folder is hidden (Explorer leaves it out of a listing by default) |
FILE_ATTRIBUTE_REPARSE_POINT | const FILE_ATTRIBUTE_REPARSE_POINT: uint32 = 0x400 | The Windows SDK's FILE_ATTRIBUTE_REPARSE_POINT: a file attribute: the path is a reparse point (a junction or symbolic link) |
CSTR_EQUAL | const CSTR_EQUAL: int32 = 2 | The Windows SDK's CSTR_EQUAL: CompareStringOrdinal's result for two equal texts |
FILE_ATTRIBUTE_NORMAL | const FILE_ATTRIBUTE_NORMAL: uint32 = 0x80 | The Windows SDK's FILE_ATTRIBUTE_NORMAL: a file attribute: none of the others set (SetFileAttributesW's way to clear them all) |
HANDLE_FLAG_INHERIT | const HANDLE_FLAG_INHERIT: uint32 = 0x1 | The Windows SDK's HANDLE_FLAG_INHERIT: SetHandleInformation's flag: a child process started with handle inheritance gets the handle |
MOVEFILE_REPLACE_EXISTING | const MOVEFILE_REPLACE_EXISTING: uint32 = 0x1 | The Windows SDK's MOVEFILE_REPLACE_EXISTING: MoveFileExW: a file at the new name is replaced; the move is on disk before it returns |
MOVEFILE_WRITE_THROUGH | const MOVEFILE_WRITE_THROUGH: uint32 = 0x8 | The Windows SDK's MOVEFILE_WRITE_THROUGH: MoveFileExW: a file at the new name is replaced; the move is on disk before it returns |
MOVEFILE_COPY_ALLOWED | const MOVEFILE_COPY_ALLOWED: uint32 = 0x2 | The Windows SDK's MOVEFILE_COPY_ALLOWED: MoveFileExW: a move to another volume copies the file, then deletes it |
STARTF_USESHOWWINDOW | const STARTF_USESHOWWINDOW: uint32 = 0x1 | The Windows SDK's STARTF_USESHOWWINDOW: STARTUPINFOW's flag: its wShowWindow field is used |
STARTF_USESTDHANDLES | const STARTF_USESTDHANDLES: uint32 = 0x100 | The Windows SDK's STARTF_USESTDHANDLES: STARTUPINFOW's flag: its hStdInput / hStdOutput / hStdError fields are the child's standard handles |
SW_HIDE | const SW_HIDE: uint16 = 0 | The Windows SDK's SW_HIDE: ShowWindow's / STARTUPINFOW's show state: the window is hidden |
NORMAL_PRIORITY_CLASS | const NORMAL_PRIORITY_CLASS: uint32 = 0x20 | The Windows SDK's NORMAL_PRIORITY_CLASS: CreateProcessW's priority class: the normal one |
CREATE_UNICODE_ENVIRONMENT | const CREATE_UNICODE_ENVIRONMENT: uint32 = 0x400 | The Windows SDK's CREATE_UNICODE_ENVIRONMENT: CreateProcessW's flag: the environment block given is UTF-16 |
SW_SHOWNORMAL | const SW_SHOWNORMAL: uint16 = 1 | The Windows SDK's SW_SHOWNORMAL: ShowWindow's / ShellExecuteW's show state: the window is shown at its normal size and place |
GENERIC_READ | const GENERIC_READ: uint32 = 0x80000000 | The Windows SDK's GENERIC_READ: CreateFileW's access right: the handle reads |
FILE_SHARE_READ | const FILE_SHARE_READ: uint32 = 0x1 | The Windows SDK's FILE_SHARE_READ: CreateFileW's share mode: other handles may read the file while this one is open |
FILE_SHARE_WRITE | const FILE_SHARE_WRITE: uint32 = 0x2 | The Windows SDK's FILE_SHARE_WRITE: CreateFileW's share mode: other handles may write the file while this one is open |
OPEN_EXISTING | const OPEN_EXISTING: uint32 = 3 | The Windows SDK's OPEN_EXISTING: CreateFileW's disposition: the file must already exist |
INFINITE | const INFINITE: uint32 = 0xFFFFFFFF | The Windows SDK's INFINITE: a wait with no time limit (WaitForSingleObject and the other wait calls) |
ERROR_FILE_NOT_FOUND | const ERROR_FILE_NOT_FOUND: uint32 = 2 | The Windows SDK's ERROR_FILE_NOT_FOUND: GetLastError's code: the file named is not there |
ERROR_NO_MORE_FILES | const ERROR_NO_MORE_FILES: uint32 = 18 | The Windows SDK's ERROR_NO_MORE_FILES: GetLastError's code after FindNextFileW: the listing has no more entries |
ERROR_ACCESS_DENIED | const ERROR_ACCESS_DENIED: uint32 = 5 | The Windows SDK's ERROR_ACCESS_DENIED: the OS refused the access (with MoveFileExW also: another process holds the file without sharing its deletion) |
ERROR_SHARING_VIOLATION | const ERROR_SHARING_VIOLATION: uint32 = 32 | The Windows SDK's ERROR_SHARING_VIOLATION: another process holds the file in a way the call cannot share |
ERROR_LOCK_VIOLATION | const ERROR_LOCK_VIOLATION: uint32 = 33 | The Windows SDK's ERROR_LOCK_VIOLATION: another process holds a lock on part of the file |
ERROR_PROC_NOT_FOUND | const ERROR_PROC_NOT_FOUND: uint32 = 127 | The Windows SDK's ERROR_PROC_NOT_FOUND: GetLastError's code after GetProcAddress: the module has no routine of that name |
ERROR_NO_UNICODE_TRANSLATION | const ERROR_NO_UNICODE_TRANSLATION: uint32 = 1113 | The Windows SDK's ERROR_NO_UNICODE_TRANSLATION: GetLastError's code: the text is not valid in the code page (MultiByteToWideChar with MB_ERR_INVALID_CHARS) |
GetFileExInfoStandard | const GetFileExInfoStandard: int32 = 0 | The Windows SDK's GetFileExInfoStandard: GET_FILEEX_INFO_LEVELS' GetFileExInfoStandard |
BCRYPT_USE_SYSTEM_PREFERRED_RNG | const BCRYPT_USE_SYSTEM_PREFERRED_RNG: uint32 = 0x2 | The Windows SDK's BCRYPT_USE_SYSTEM_PREFERRED_RNG: BCryptGenRandom's BCRYPT_USE_SYSTEM_PREFERRED_RNG: no algorithm handle, the system's RNG |
ENABLE_VIRTUAL_TERMINAL_PROCESSING | const ENABLE_VIRTUAL_TERMINAL_PROCESSING: uint32 = 0x0004 | The Windows SDK's ENABLE_VIRTUAL_TERMINAL_PROCESSING: SetConsoleMode's ENABLE_VIRTUAL_TERMINAL_PROCESSING (an output handle's mode) |
CP_UTF8 | const CP_UTF8: uint32 = 65001 | The Windows SDK's CP_UTF8: UTF-8's code page (SetConsoleOutputCP, MultiByteToWideChar) |
KEY_EVENT | const KEY_EVENT: uint16 = 0x0001 | The Windows SDK's KEY_EVENT: INPUT_RECORD's EventType for a key |
IMAGE_SIZEOF_FILE_HEADER | const IMAGE_SIZEOF_FILE_HEADER: int32 = 20 | The Windows SDK's IMAGE_SIZEOF_FILE_HEADER: PE / COFF (winnt.h), each in the type of the field it goes in: record sizes (COFF File Header, Section Table, COFF Relocations, COFF Symbol Table) |
IMAGE_SIZEOF_SECTION_HEADER | const IMAGE_SIZEOF_SECTION_HEADER: int32 = 40 | The Windows SDK's IMAGE_SIZEOF_SECTION_HEADER: PE / COFF (winnt.h), each in the type of the field it goes in: record sizes (COFF File Header, Section Table, COFF Relocations, COFF Symbol Table) |
IMAGE_SIZEOF_RELOCATION | const IMAGE_SIZEOF_RELOCATION: int32 = 10 | The Windows SDK's IMAGE_SIZEOF_RELOCATION: PE / COFF (winnt.h), each in the type of the field it goes in: record sizes (COFF File Header, Section Table, COFF Relocations, COFF Symbol Table) |
IMAGE_SIZEOF_SYMBOL | const IMAGE_SIZEOF_SYMBOL: int32 = 18 | The Windows SDK's IMAGE_SIZEOF_SYMBOL: PE / COFF (winnt.h), each in the type of the field it goes in: record sizes (COFF File Header, Section Table, COFF Relocations, COFF Symbol Table) |
IMAGE_SIZEOF_SHORT_NAME | const IMAGE_SIZEOF_SHORT_NAME: int32 = 8 | The Windows SDK's IMAGE_SIZEOF_SHORT_NAME: PE / COFF (winnt.h), each in the type of the field it goes in: record sizes (COFF File Header, Section Table, COFF Relocations, COFF Symbol Table) |
IMAGE_FILE_MACHINE_AMD64 | const IMAGE_FILE_MACHINE_AMD64: uint16 = 0x8664 | The Windows SDK's IMAGE_FILE_MACHINE_AMD64: The Machine field (also StackWalk64's machine) and the x64 relocation types |
IMAGE_REL_AMD64_ADDR64 | const IMAGE_REL_AMD64_ADDR64: uint16 = 0x0001 | The Windows SDK's IMAGE_REL_AMD64_ADDR64: The Machine field (also StackWalk64's machine) and the x64 relocation types |
IMAGE_REL_AMD64_ADDR32NB | const IMAGE_REL_AMD64_ADDR32NB: uint16 = 0x0003 | The Windows SDK's IMAGE_REL_AMD64_ADDR32NB: The Machine field (also StackWalk64's machine) and the x64 relocation types |
IMAGE_REL_AMD64_REL32 | const IMAGE_REL_AMD64_REL32: uint16 = 0x0004 | The Windows SDK's IMAGE_REL_AMD64_REL32: The Machine field (also StackWalk64's machine) and the x64 relocation types |
IMAGE_REL_AMD64_SECTION | const IMAGE_REL_AMD64_SECTION: uint16 = 0x000A | The Windows SDK's IMAGE_REL_AMD64_SECTION: The Machine field (also StackWalk64's machine) and the x64 relocation types |
IMAGE_REL_AMD64_SECREL | const IMAGE_REL_AMD64_SECREL: uint16 = 0x000B | The Windows SDK's IMAGE_REL_AMD64_SECREL: The Machine field (also StackWalk64's machine) and the x64 relocation types |
IMAGE_SCN_CNT_CODE | const IMAGE_SCN_CNT_CODE: uint32 = 0x00000020 | The Windows SDK's IMAGE_SCN_CNT_CODE: Section Flags |
IMAGE_SCN_CNT_INITIALIZED_DATA | const IMAGE_SCN_CNT_INITIALIZED_DATA: uint32 = 0x00000040 | The Windows SDK's IMAGE_SCN_CNT_INITIALIZED_DATA: Section Flags |
IMAGE_SCN_CNT_UNINITIALIZED_DATA | const IMAGE_SCN_CNT_UNINITIALIZED_DATA: uint32 = 0x00000080 | The Windows SDK's IMAGE_SCN_CNT_UNINITIALIZED_DATA: Section Flags |
IMAGE_SCN_LNK_INFO | const IMAGE_SCN_LNK_INFO: uint32 = 0x00000200 | The Windows SDK's IMAGE_SCN_LNK_INFO: An Info section: comments / compiler data no linker puts in an image |
IMAGE_SCN_LNK_REMOVE | const IMAGE_SCN_LNK_REMOVE: uint32 = 0x00000800 | The Windows SDK's IMAGE_SCN_LNK_REMOVE: a section flag: the linker leaves the section out of the image (object files only) |
IMAGE_SCN_LNK_COMDAT | const IMAGE_SCN_LNK_COMDAT: uint32 = 0x00001000 | The Windows SDK's IMAGE_SCN_LNK_COMDAT: a section flag: the section is a COMDAT (one copy kept across objects, by its selection) |
IMAGE_SCN_MEM_16BIT | const IMAGE_SCN_MEM_16BIT: uint32 = 0x00020000 | The Windows SDK's IMAGE_SCN_MEM_16BIT: The 16-bit flag a PDB's section map entries carry |
IMAGE_SCN_LNK_NRELOC_OVFL | const IMAGE_SCN_LNK_NRELOC_OVFL: uint32 = 0x01000000 | The Windows SDK's IMAGE_SCN_LNK_NRELOC_OVFL: a section flag: its relocation count overflowed 16 bits and is in the first relocation |
IMAGE_SCN_MEM_DISCARDABLE | const IMAGE_SCN_MEM_DISCARDABLE: uint32 = 0x02000000 | The Windows SDK's IMAGE_SCN_MEM_DISCARDABLE: a section flag: the loader may discard the section once the image is loaded |
IMAGE_SCN_MEM_EXECUTE | const IMAGE_SCN_MEM_EXECUTE: uint32 = 0x20000000 | The Windows SDK's IMAGE_SCN_MEM_EXECUTE: a section flag: the section's memory can run as code |
IMAGE_SCN_MEM_READ | const IMAGE_SCN_MEM_READ: uint32 = 0x40000000 | The Windows SDK's IMAGE_SCN_MEM_READ: a section flag: the section's memory can be read |
IMAGE_SCN_MEM_WRITE | const IMAGE_SCN_MEM_WRITE: uint32 = 0x80000000 | The Windows SDK's IMAGE_SCN_MEM_WRITE: a section flag: the section's memory can be written |
IMAGE_SYM_CLASS_EXTERNAL | const IMAGE_SYM_CLASS_EXTERNAL: uint8 = 2 | The Windows SDK's IMAGE_SYM_CLASS_EXTERNAL: Storage classes (COFF Symbol Table) |
IMAGE_SYM_CLASS_STATIC | const IMAGE_SYM_CLASS_STATIC: uint8 = 3 | The Windows SDK's IMAGE_SYM_CLASS_STATIC: Storage classes (COFF Symbol Table) |
IMAGE_SYM_CLASS_LABEL | const IMAGE_SYM_CLASS_LABEL: uint8 = 6 | The Windows SDK's IMAGE_SYM_CLASS_LABEL: Storage classes (COFF Symbol Table) |
IMAGE_SYM_CLASS_FILE | const IMAGE_SYM_CLASS_FILE: uint8 = 103 | The Windows SDK's IMAGE_SYM_CLASS_FILE: Storage classes (COFF Symbol Table) |
IMAGE_SYM_CLASS_SECTION | const IMAGE_SYM_CLASS_SECTION: uint8 = 104 | The Windows SDK's IMAGE_SYM_CLASS_SECTION: Storage classes (COFF Symbol Table) |
IMAGE_SYM_CLASS_WEAK_EXTERNAL | const IMAGE_SYM_CLASS_WEAK_EXTERNAL: uint8 = 105 | The Windows SDK's IMAGE_SYM_CLASS_WEAK_EXTERNAL: Storage classes (COFF Symbol Table) |
IMAGE_COMDAT_SELECT_NODUPLICATES | const IMAGE_COMDAT_SELECT_NODUPLICATES: uint8 = 1 | The Windows SDK's IMAGE_COMDAT_SELECT_NODUPLICATES: COMDAT selections (COMDAT Sections) |
IMAGE_COMDAT_SELECT_ANY | const IMAGE_COMDAT_SELECT_ANY: uint8 = 2 | The Windows SDK's IMAGE_COMDAT_SELECT_ANY: COMDAT selections (COMDAT Sections) |
IMAGE_COMDAT_SELECT_SAME_SIZE | const IMAGE_COMDAT_SELECT_SAME_SIZE: uint8 = 3 | The Windows SDK's IMAGE_COMDAT_SELECT_SAME_SIZE: COMDAT selections (COMDAT Sections) |
IMAGE_COMDAT_SELECT_EXACT_MATCH | const IMAGE_COMDAT_SELECT_EXACT_MATCH: uint8 = 4 | The Windows SDK's IMAGE_COMDAT_SELECT_EXACT_MATCH: COMDAT selections (COMDAT Sections) |
IMAGE_COMDAT_SELECT_ASSOCIATIVE | const IMAGE_COMDAT_SELECT_ASSOCIATIVE: uint8 = 5 | The Windows SDK's IMAGE_COMDAT_SELECT_ASSOCIATIVE: COMDAT selections (COMDAT Sections) |
IMAGE_COMDAT_SELECT_LARGEST | const IMAGE_COMDAT_SELECT_LARGEST: uint8 = 6 | The Windows SDK's IMAGE_COMDAT_SELECT_LARGEST: COMDAT selections (COMDAT Sections) |
IMAGE_SYM_UNDEFINED | const IMAGE_SYM_UNDEFINED: int16 = 0 | The Windows SDK's IMAGE_SYM_UNDEFINED: Section Number Values ((SHORT) in winnt.h) |
IMAGE_SYM_ABSOLUTE | const IMAGE_SYM_ABSOLUTE: int16 = -1 | The Windows SDK's IMAGE_SYM_ABSOLUTE: Section Number Values ((SHORT) in winnt.h) |
IMAGE_SYM_DEBUG | const IMAGE_SYM_DEBUG: int16 = -2 | The Windows SDK's IMAGE_SYM_DEBUG: Section Number Values ((SHORT) in winnt.h) |
UNW_FLAG_EHANDLER | const UNW_FLAG_EHANDLER: uint8 = 1 | The Windows SDK's UNW_FLAG_EHANDLER: UNWIND_INFO's flags (x64 exception handling; bits 3-7 of its first byte): its handler runs as an exception is dispatched, as an unwind leaves the frame; its unwind data goes on in another RUNTIME_FUNCTION's (chained) |
UNW_FLAG_UHANDLER | const UNW_FLAG_UHANDLER: uint8 = 2 | The Windows SDK's UNW_FLAG_UHANDLER: UNWIND_INFO's flags (x64 exception handling; bits 3-7 of its first byte): its handler runs as an exception is dispatched, as an unwind leaves the frame; its unwind data goes on in another RUNTIME_FUNCTION's (chained) |
UNW_FLAG_CHAININFO | const UNW_FLAG_CHAININFO: uint8 = 4 | The Windows SDK's UNW_FLAG_CHAININFO: UNWIND_INFO's flags (x64 exception handling; bits 3-7 of its first byte): its handler runs as an exception is dispatched, as an unwind leaves the frame; its unwind data goes on in another RUNTIME_FUNCTION's (chained) |
IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY | const IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY: uint32 = 1 | The Windows SDK's IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY: Weak external search kinds (Auxiliary Format 3's Characteristics) |
IMAGE_WEAK_EXTERN_SEARCH_LIBRARY | const IMAGE_WEAK_EXTERN_SEARCH_LIBRARY: uint32 = 2 | The Windows SDK's IMAGE_WEAK_EXTERN_SEARCH_LIBRARY: Weak external search kinds (Auxiliary Format 3's Characteristics) |
IMAGE_WEAK_EXTERN_SEARCH_ALIAS | const IMAGE_WEAK_EXTERN_SEARCH_ALIAS: uint32 = 3 | The Windows SDK's IMAGE_WEAK_EXTERN_SEARCH_ALIAS: Weak external search kinds (Auxiliary Format 3's Characteristics) |
IMAGE_DOS_SIGNATURE | const IMAGE_DOS_SIGNATURE: uint16 = 0x5A4D | The Windows SDK's IMAGE_DOS_SIGNATURE: Image headers: the MS-DOS and PE signatures, the file header's Characteristics, the optional header's magic (PE32+), its data directories, subsystems and DLL characteristics, a CodeView debug directory entry's Type |
IMAGE_NT_SIGNATURE | const IMAGE_NT_SIGNATURE: uint32 = 0x00004550 | The Windows SDK's IMAGE_NT_SIGNATURE: Image headers: the MS-DOS and PE signatures, the file header's Characteristics, the optional header's magic (PE32+), its data directories, subsystems and DLL characteristics, a CodeView debug directory entry's Type |
IMAGE_FILE_RELOCS_STRIPPED | const IMAGE_FILE_RELOCS_STRIPPED: uint16 = 0x0001 | The Windows SDK's IMAGE_FILE_RELOCS_STRIPPED: Image headers: the MS-DOS and PE signatures, the file header's Characteristics, the optional header's magic (PE32+), its data directories, subsystems and DLL characteristics, a CodeView debug directory entry's Type |
IMAGE_FILE_EXECUTABLE_IMAGE | const IMAGE_FILE_EXECUTABLE_IMAGE: uint16 = 0x0002 | The Windows SDK's IMAGE_FILE_EXECUTABLE_IMAGE: Image headers: the MS-DOS and PE signatures, the file header's Characteristics, the optional header's magic (PE32+), its data directories, subsystems and DLL characteristics, a CodeView debug directory entry's Type |
IMAGE_FILE_LARGE_ADDRESS_AWARE | const IMAGE_FILE_LARGE_ADDRESS_AWARE: uint16 = 0x0020 | The Windows SDK's IMAGE_FILE_LARGE_ADDRESS_AWARE: Image headers: the MS-DOS and PE signatures, the file header's Characteristics, the optional header's magic (PE32+), its data directories, subsystems and DLL characteristics, a CodeView debug directory entry's Type |
IMAGE_FILE_DLL | const IMAGE_FILE_DLL: uint16 = 0x2000 | The Windows SDK's IMAGE_FILE_DLL: Image headers: the MS-DOS and PE signatures, the file header's Characteristics, the optional header's magic (PE32+), its data directories, subsystems and DLL characteristics, a CodeView debug directory entry's Type |
IMAGE_NT_OPTIONAL_HDR64_MAGIC | const IMAGE_NT_OPTIONAL_HDR64_MAGIC: uint16 = 0x20B | The Windows SDK's IMAGE_NT_OPTIONAL_HDR64_MAGIC: Image headers: the MS-DOS and PE signatures, the file header's Characteristics, the optional header's magic (PE32+), its data directories, subsystems and DLL characteristics, a CodeView debug directory entry's Type |
IMAGE_NUMBEROF_DIRECTORY_ENTRIES | const IMAGE_NUMBEROF_DIRECTORY_ENTRIES: int32 = 16 | The Windows SDK's IMAGE_NUMBEROF_DIRECTORY_ENTRIES: Image headers: the MS-DOS and PE signatures, the file header's Characteristics, the optional header's magic (PE32+), its data directories, subsystems and DLL characteristics, a CodeView debug directory entry's Type |
IMAGE_DIRECTORY_ENTRY_EXPORT | const IMAGE_DIRECTORY_ENTRY_EXPORT: int32 = 0 | The Windows SDK's IMAGE_DIRECTORY_ENTRY_EXPORT: Image headers: the MS-DOS and PE signatures, the file header's Characteristics, the optional header's magic (PE32+), its data directories, subsystems and DLL characteristics, a CodeView debug directory entry's Type |
IMAGE_DIRECTORY_ENTRY_IMPORT | const IMAGE_DIRECTORY_ENTRY_IMPORT: int32 = 1 | The Windows SDK's IMAGE_DIRECTORY_ENTRY_IMPORT: Image headers: the MS-DOS and PE signatures, the file header's Characteristics, the optional header's magic (PE32+), its data directories, subsystems and DLL characteristics, a CodeView debug directory entry's Type |
IMAGE_DIRECTORY_ENTRY_RESOURCE | const IMAGE_DIRECTORY_ENTRY_RESOURCE: int32 = 2 | The Windows SDK's IMAGE_DIRECTORY_ENTRY_RESOURCE: Image headers: the MS-DOS and PE signatures, the file header's Characteristics, the optional header's magic (PE32+), its data directories, subsystems and DLL characteristics, a CodeView debug directory entry's Type |
IMAGE_DIRECTORY_ENTRY_EXCEPTION | const IMAGE_DIRECTORY_ENTRY_EXCEPTION: int32 = 3 | The Windows SDK's IMAGE_DIRECTORY_ENTRY_EXCEPTION: Image headers: the MS-DOS and PE signatures, the file header's Characteristics, the optional header's magic (PE32+), its data directories, subsystems and DLL characteristics, a CodeView debug directory entry's Type |
IMAGE_DIRECTORY_ENTRY_BASERELOC | const IMAGE_DIRECTORY_ENTRY_BASERELOC: int32 = 5 | The Windows SDK's IMAGE_DIRECTORY_ENTRY_BASERELOC: Image headers: the MS-DOS and PE signatures, the file header's Characteristics, the optional header's magic (PE32+), its data directories, subsystems and DLL characteristics, a CodeView debug directory entry's Type |
IMAGE_DIRECTORY_ENTRY_DEBUG | const IMAGE_DIRECTORY_ENTRY_DEBUG: int32 = 6 | The Windows SDK's IMAGE_DIRECTORY_ENTRY_DEBUG: Image headers: the MS-DOS and PE signatures, the file header's Characteristics, the optional header's magic (PE32+), its data directories, subsystems and DLL characteristics, a CodeView debug directory entry's Type |
IMAGE_DIRECTORY_ENTRY_TLS | const IMAGE_DIRECTORY_ENTRY_TLS: int32 = 9 | The Windows SDK's IMAGE_DIRECTORY_ENTRY_TLS: Image headers: the MS-DOS and PE signatures, the file header's Characteristics, the optional header's magic (PE32+), its data directories, subsystems and DLL characteristics, a CodeView debug directory entry's Type |
IMAGE_DIRECTORY_ENTRY_IAT | const IMAGE_DIRECTORY_ENTRY_IAT: int32 = 12 | The Windows SDK's IMAGE_DIRECTORY_ENTRY_IAT: Image headers: the MS-DOS and PE signatures, the file header's Characteristics, the optional header's magic (PE32+), its data directories, subsystems and DLL characteristics, a CodeView debug directory entry's Type |
IMAGE_SUBSYSTEM_WINDOWS_GUI | const IMAGE_SUBSYSTEM_WINDOWS_GUI: uint16 = 2 | The Windows SDK's IMAGE_SUBSYSTEM_WINDOWS_GUI: Image headers: the MS-DOS and PE signatures, the file header's Characteristics, the optional header's magic (PE32+), its data directories, subsystems and DLL characteristics, a CodeView debug directory entry's Type |
IMAGE_SUBSYSTEM_WINDOWS_CUI | const IMAGE_SUBSYSTEM_WINDOWS_CUI: uint16 = 3 | The Windows SDK's IMAGE_SUBSYSTEM_WINDOWS_CUI: Image headers: the MS-DOS and PE signatures, the file header's Characteristics, the optional header's magic (PE32+), its data directories, subsystems and DLL characteristics, a CodeView debug directory entry's Type |
IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA | const IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA: uint16 = 0x0020 | The Windows SDK's IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA: Image headers: the MS-DOS and PE signatures, the file header's Characteristics, the optional header's magic (PE32+), its data directories, subsystems and DLL characteristics, a CodeView debug directory entry's Type |
IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE | const IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE: uint16 = 0x0040 | The Windows SDK's IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE: Image headers: the MS-DOS and PE signatures, the file header's Characteristics, the optional header's magic (PE32+), its data directories, subsystems and DLL characteristics, a CodeView debug directory entry's Type |
IMAGE_DLLCHARACTERISTICS_NX_COMPAT | const IMAGE_DLLCHARACTERISTICS_NX_COMPAT: uint16 = 0x0100 | The Windows SDK's IMAGE_DLLCHARACTERISTICS_NX_COMPAT: Image headers: the MS-DOS and PE signatures, the file header's Characteristics, the optional header's magic (PE32+), its data directories, subsystems and DLL characteristics, a CodeView debug directory entry's Type |
IMAGE_DEBUG_TYPE_CODEVIEW | const IMAGE_DEBUG_TYPE_CODEVIEW: uint32 = 2 | The Windows SDK's IMAGE_DEBUG_TYPE_CODEVIEW: Image headers: the MS-DOS and PE signatures, the file header's Characteristics, the optional header's magic (PE32+), its data directories, subsystems and DLL characteristics, a CodeView debug directory entry's Type |
IMAGE_REL_BASED_DIR64 | const IMAGE_REL_BASED_DIR64: uint16 = 10 | The Windows SDK's IMAGE_REL_BASED_DIR64: A base relocation's type (Base Relocation Types) |
IMAGE_ARCHIVE_START | const IMAGE_ARCHIVE_START: string = "!<arch>\n" | The Windows SDK's IMAGE_ARCHIVE_START: Archives (Archive (Library) File Format) and short import headers (Import Library Format) |
IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR | const IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR: int32 = 60 | The Windows SDK's IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR: Archives (Archive (Library) File Format) and short import headers (Import Library Format) |
IMPORT_OBJECT_HDR_SIG2 | const IMPORT_OBJECT_HDR_SIG2: uint16 = 0xFFFF | The Windows SDK's IMPORT_OBJECT_HDR_SIG2: Archives (Archive (Library) File Format) and short import headers (Import Library Format) |
IMPORT_OBJECT_CODE | const IMPORT_OBJECT_CODE: int32 = 0 | The Windows SDK's IMPORT_OBJECT_CODE: Archives (Archive (Library) File Format) and short import headers (Import Library Format) |
IMPORT_OBJECT_DATA | const IMPORT_OBJECT_DATA: int32 = 1 | The Windows SDK's IMPORT_OBJECT_DATA: Archives (Archive (Library) File Format) and short import headers (Import Library Format) |
IMPORT_OBJECT_NAME | const IMPORT_OBJECT_NAME: int32 = 1 | The Windows SDK's IMPORT_OBJECT_NAME: Archives (Archive (Library) File Format) and short import headers (Import Library Format) |
RT_ICON | const RT_ICON: uint16 = 3 | The Windows SDK's RT_ICON: Resources: their types (winuser.h RT_*), the neutral language, the version resource's id and VS_FIXEDFILEINFO fields (winver.h) |
RT_GROUP_ICON | const RT_GROUP_ICON: uint16 = 14 | The Windows SDK's RT_GROUP_ICON: Resources: their types (winuser.h RT_*), the neutral language, the version resource's id and VS_FIXEDFILEINFO fields (winver.h) |
RT_VERSION | const RT_VERSION: uint16 = 16 | The Windows SDK's RT_VERSION: Resources: their types (winuser.h RT_*), the neutral language, the version resource's id and VS_FIXEDFILEINFO fields (winver.h) |
LANG_NEUTRAL | const LANG_NEUTRAL: uint16 = 0 | The Windows SDK's LANG_NEUTRAL: Resources: their types (winuser.h RT_*), the neutral language, the version resource's id and VS_FIXEDFILEINFO fields (winver.h) |
VS_VERSION_INFO | const VS_VERSION_INFO: uint16 = 1 | The Windows SDK's VS_VERSION_INFO: Resources: their types (winuser.h RT_*), the neutral language, the version resource's id and VS_FIXEDFILEINFO fields (winver.h) |
VS_FFI_SIGNATURE | const VS_FFI_SIGNATURE: uint32 = 0xFEEF04BD | The Windows SDK's VS_FFI_SIGNATURE: Resources: their types (winuser.h RT_*), the neutral language, the version resource's id and VS_FIXEDFILEINFO fields (winver.h) |
VS_FFI_STRUCVERSION | const VS_FFI_STRUCVERSION: uint32 = 0x00010000 | The Windows SDK's VS_FFI_STRUCVERSION: Resources: their types (winuser.h RT_*), the neutral language, the version resource's id and VS_FIXEDFILEINFO fields (winver.h) |
VS_FFI_FILEFLAGSMASK | const VS_FFI_FILEFLAGSMASK: uint32 = 0x3F | The Windows SDK's VS_FFI_FILEFLAGSMASK: Resources: their types (winuser.h RT_*), the neutral language, the version resource's id and VS_FIXEDFILEINFO fields (winver.h) |
VOS_NT_WINDOWS32 | const VOS_NT_WINDOWS32: uint32 = 0x00040004 | The Windows SDK's VOS_NT_WINDOWS32: Resources: their types (winuser.h RT_*), the neutral language, the version resource's id and VS_FIXEDFILEINFO fields (winver.h) |
VFT_APP | const VFT_APP: uint32 = 1 | The Windows SDK's VFT_APP: Resources: their types (winuser.h RT_*), the neutral language, the version resource's id and VS_FIXEDFILEINFO fields (winver.h) |
VFT_DLL | const VFT_DLL: uint32 = 2 | The Windows SDK's VFT_DLL: Resources: their types (winuser.h RT_*), the neutral language, the version resource's id and VS_FIXEDFILEINFO fields (winver.h) |
LOAD_LIBRARY_AS_DATAFILE | const LOAD_LIBRARY_AS_DATAFILE: uint32 = 0x00000002 | The Windows SDK's LOAD_LIBRARY_AS_DATAFILE: LoadLibraryExW's flags for an image whose resources are read, never run (libloaderapi.h) |
LOAD_LIBRARY_AS_IMAGE_RESOURCE | const LOAD_LIBRARY_AS_IMAGE_RESOURCE: uint32 = 0x00000020 | The Windows SDK's LOAD_LIBRARY_AS_IMAGE_RESOURCE: LoadLibraryExW's flags for an image whose resources are read, never run (libloaderapi.h) |
WS_CHILD | const WS_CHILD: uint32 = 0x40000000 | The Windows SDK's WS_CHILD: Windows (winuser.h): a child window's style bit; WM_SETICON / WM_GETICON and their wParam (the small or the big icon) |
WS_EX_APPWINDOW | const WS_EX_APPWINDOW: uint32 = 0x00040000 | The Windows SDK's WS_EX_APPWINDOW: The extended style of a window the taskbar shows a button for (winuser.h) |
WM_GETICON | const WM_GETICON: uint32 = 0x007F | The Windows SDK's WM_GETICON: the window message that asks a window for its small or big icon (winuser.h) |
WM_SETICON | const WM_SETICON: uint32 = 0x0080 | The Windows SDK's WM_SETICON: the window message that sets a window's small or big icon (winuser.h) |
ICON_SMALL | const ICON_SMALL: uint64 = 0 | The Windows SDK's ICON_SMALL: WM_GETICON / WM_SETICON's which: the small icon (title bar, Alt+Tab's small list) |
ICON_BIG | const ICON_BIG: uint64 = 1 | The Windows SDK's ICON_BIG: WM_GETICON / WM_SETICON's which: the big icon (Alt+Tab, the taskbar) |
IMAGE_ICON | const IMAGE_ICON: uint32 = 1 | The Windows SDK's IMAGE_ICON: LoadImageW's image type and load flags, GetSystemMetrics' icon sizes (winuser.h) |
LR_DEFAULTCOLOR | const LR_DEFAULTCOLOR: uint32 = 0x00000000 | The Windows SDK's LR_DEFAULTCOLOR: LoadImageW's image type and load flags, GetSystemMetrics' icon sizes (winuser.h) |
SM_CXICON | const SM_CXICON: int32 = 11 | The Windows SDK's SM_CXICON: LoadImageW's image type and load flags, GetSystemMetrics' icon sizes (winuser.h) |
SM_CYICON | const SM_CYICON: int32 = 12 | The Windows SDK's SM_CYICON: LoadImageW's image type and load flags, GetSystemMetrics' icon sizes (winuser.h) |
SM_CXSMICON | const SM_CXSMICON: int32 = 49 | The Windows SDK's SM_CXSMICON: LoadImageW's image type and load flags, GetSystemMetrics' icon sizes (winuser.h) |
SM_CYSMICON | const SM_CYSMICON: int32 = 50 | The Windows SDK's SM_CYSMICON: LoadImageW's image type and load flags, GetSystemMetrics' icon sizes (winuser.h) |
_O_RDONLY | const _O_RDONLY: int32 = 0x0000 | The Windows SDK's _O_RDONLY: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_O_WRONLY | const _O_WRONLY: int32 = 0x0001 | The Windows SDK's _O_WRONLY: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_O_RDWR | const _O_RDWR: int32 = 0x0002 | The Windows SDK's _O_RDWR: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_O_ACCMODE | const _O_ACCMODE: int32 = 0x0003 | The Windows SDK's _O_ACCMODE: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_O_APPEND | const _O_APPEND: int32 = 0x0008 | The Windows SDK's _O_APPEND: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_O_RANDOM | const _O_RANDOM: int32 = 0x0010 | The Windows SDK's _O_RANDOM: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_O_SEQUENTIAL | const _O_SEQUENTIAL: int32 = 0x0020 | The Windows SDK's _O_SEQUENTIAL: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_O_TEMPORARY | const _O_TEMPORARY: int32 = 0x0040 | The Windows SDK's _O_TEMPORARY: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_O_NOINHERIT | const _O_NOINHERIT: int32 = 0x0080 | The Windows SDK's _O_NOINHERIT: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_O_CREAT | const _O_CREAT: int32 = 0x0100 | The Windows SDK's _O_CREAT: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_O_TRUNC | const _O_TRUNC: int32 = 0x0200 | The Windows SDK's _O_TRUNC: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_O_EXCL | const _O_EXCL: int32 = 0x0400 | The Windows SDK's _O_EXCL: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_O_SHORT_LIVED | const _O_SHORT_LIVED: int32 = 0x1000 | The Windows SDK's _O_SHORT_LIVED: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_O_OBTAIN_DIR | const _O_OBTAIN_DIR: int32 = 0x2000 | The Windows SDK's _O_OBTAIN_DIR: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_O_TEXT | const _O_TEXT: int32 = 0x4000 | The Windows SDK's _O_TEXT: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_O_BINARY | const _O_BINARY: int32 = 0x8000 | The Windows SDK's _O_BINARY: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_O_WTEXT | const _O_WTEXT: int32 = 0x10000 | The Windows SDK's _O_WTEXT: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_O_U16TEXT | const _O_U16TEXT: int32 = 0x20000 | The Windows SDK's _O_U16TEXT: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_O_U8TEXT | const _O_U8TEXT: int32 = 0x40000 | The Windows SDK's _O_U8TEXT: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_SH_DENYRW | const _SH_DENYRW: int32 = 0x10 | The Windows SDK's _SH_DENYRW: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_SH_DENYWR | const _SH_DENYWR: int32 = 0x20 | The Windows SDK's _SH_DENYWR: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_SH_DENYRD | const _SH_DENYRD: int32 = 0x30 | The Windows SDK's _SH_DENYRD: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_SH_DENYNO | const _SH_DENYNO: int32 = 0x40 | The Windows SDK's _SH_DENYNO: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_SH_SECURE | const _SH_SECURE: int32 = 0x80 | The Windows SDK's _SH_SECURE: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_S_IFMT | const _S_IFMT: uint16 = 0xF000 | The Windows SDK's _S_IFMT: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_S_IFDIR | const _S_IFDIR: uint16 = 0x4000 | The Windows SDK's _S_IFDIR: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_S_IFCHR | const _S_IFCHR: uint16 = 0x2000 | The Windows SDK's _S_IFCHR: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_S_IFIFO | const _S_IFIFO: uint16 = 0x1000 | The Windows SDK's _S_IFIFO: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_S_IFREG | const _S_IFREG: uint16 = 0x8000 | The Windows SDK's _S_IFREG: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_S_IREAD | const _S_IREAD: uint16 = 0x0100 | The Windows SDK's _S_IREAD: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_S_IWRITE | const _S_IWRITE: uint16 = 0x0080 | The Windows SDK's _S_IWRITE: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
_S_IEXEC | const _S_IEXEC: uint16 = 0x0040 | The Windows SDK's _S_IEXEC: The C runtime's lowio (ucrt fcntl.h, share.h, sys/stat.h, Windows Kits 10.0.26100; mingw-w64's fcntl.h adds _O_ACCMODE): _open's access modes and flags, _sopen's sharing modes, and the stat family's st_mode bits |
W_OK | const W_OK: int32 = 2 | The Windows SDK's W_OK: mingw-w64's io.h: _access' write mode |
_IOFBF | const _IOFBF: int32 = 0x0000 | The Windows SDK's _IOFBF: The C runtime's stdio and limits (ucrt stdio.h, limits.h, stdlib.h, corecrt_stdio_config.h): setvbuf's modes and setbuf's size, the most bytes of one multibyte character, int's and long's largest (long is 32 bits on Windows), the positional parameters a _p print can name, and the options of the printf family's __stdio_common_v* calls |
_IOLBF | const _IOLBF: int32 = 0x0040 | The Windows SDK's _IOLBF: The C runtime's stdio and limits (ucrt stdio.h, limits.h, stdlib.h, corecrt_stdio_config.h): setvbuf's modes and setbuf's size, the most bytes of one multibyte character, int's and long's largest (long is 32 bits on Windows), the positional parameters a _p print can name, and the options of the printf family's __stdio_common_v* calls |
_IONBF | const _IONBF: int32 = 0x0004 | The Windows SDK's _IONBF: The C runtime's stdio and limits (ucrt stdio.h, limits.h, stdlib.h, corecrt_stdio_config.h): setvbuf's modes and setbuf's size, the most bytes of one multibyte character, int's and long's largest (long is 32 bits on Windows), the positional parameters a _p print can name, and the options of the printf family's __stdio_common_v* calls |
BUFSIZ | const BUFSIZ: uint64 = 512u | The Windows SDK's BUFSIZ: The C runtime's stdio and limits (ucrt stdio.h, limits.h, stdlib.h, corecrt_stdio_config.h): setvbuf's modes and setbuf's size, the most bytes of one multibyte character, int's and long's largest (long is 32 bits on Windows), the positional parameters a _p print can name, and the options of the printf family's __stdio_common_v* calls |
MB_LEN_MAX | const MB_LEN_MAX: int32 = 5 | The Windows SDK's MB_LEN_MAX: The C runtime's stdio and limits (ucrt stdio.h, limits.h, stdlib.h, corecrt_stdio_config.h): setvbuf's modes and setbuf's size, the most bytes of one multibyte character, int's and long's largest (long is 32 bits on Windows), the positional parameters a _p print can name, and the options of the printf family's __stdio_common_v* calls |
INT_MAX | const INT_MAX: int32 = 2147483647 | The Windows SDK's INT_MAX: The C runtime's stdio and limits (ucrt stdio.h, limits.h, stdlib.h, corecrt_stdio_config.h): setvbuf's modes and setbuf's size, the most bytes of one multibyte character, int's and long's largest (long is 32 bits on Windows), the positional parameters a _p print can name, and the options of the printf family's __stdio_common_v* calls |
LONG_MAX | const LONG_MAX: int32 = 2147483647 | The Windows SDK's LONG_MAX: The C runtime's stdio and limits (ucrt stdio.h, limits.h, stdlib.h, corecrt_stdio_config.h): setvbuf's modes and setbuf's size, the most bytes of one multibyte character, int's and long's largest (long is 32 bits on Windows), the positional parameters a _p print can name, and the options of the printf family's __stdio_common_v* calls |
_ARGMAX | const _ARGMAX: int32 = 100 | The Windows SDK's _ARGMAX: The C runtime's stdio and limits (ucrt stdio.h, limits.h, stdlib.h, corecrt_stdio_config.h): setvbuf's modes and setbuf's size, the most bytes of one multibyte character, int's and long's largest (long is 32 bits on Windows), the positional parameters a _p print can name, and the options of the printf family's __stdio_common_v* calls |
_CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR | const _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR: uint64 = 2u | The Windows SDK's _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR: The C runtime's stdio and limits (ucrt stdio.h, limits.h, stdlib.h, corecrt_stdio_config.h): setvbuf's modes and setbuf's size, the most bytes of one multibyte character, int's and long's largest (long is 32 bits on Windows), the positional parameters a _p print can name, and the options of the printf family's __stdio_common_v* calls |
_CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS | const _CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS: uint64 = 4u | The Windows SDK's _CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS: The C runtime's stdio and limits (ucrt stdio.h, limits.h, stdlib.h, corecrt_stdio_config.h): setvbuf's modes and setbuf's size, the most bytes of one multibyte character, int's and long's largest (long is 32 bits on Windows), the positional parameters a _p print can name, and the options of the printf family's __stdio_common_v* calls |
_CRT_INTERNAL_PRINTF_LEGACY_MSVCRT_COMPATIBILITY | const _CRT_INTERNAL_PRINTF_LEGACY_MSVCRT_COMPATIBILITY: uint64 = 8u | The Windows SDK's _CRT_INTERNAL_PRINTF_LEGACY_MSVCRT_COMPATIBILITY: The C runtime's stdio and limits (ucrt stdio.h, limits.h, stdlib.h, corecrt_stdio_config.h): setvbuf's modes and setbuf's size, the most bytes of one multibyte character, int's and long's largest (long is 32 bits on Windows), the positional parameters a _p print can name, and the options of the printf family's __stdio_common_v* calls |
HKEY_LOCAL_MACHINE | const HKEY_LOCAL_MACHINE: uint64 = 0x80000002 | The Windows SDK's HKEY_LOCAL_MACHINE (winreg.h): the machine's registry hive, a predefined key |
RRF_RT_REG_SZ | const RRF_RT_REG_SZ: uint32 = 0x00000002 | The Windows SDK's RRF_RT_REG_SZ (winreg.h): RegGetValueW takes a REG_SZ value only |
ALL_PROCESSOR_GROUPS | const ALL_PROCESSOR_GROUPS: uint16 = 0xFFFF | The Windows SDK's ALL_PROCESSOR_GROUPS (winnt.h): GetActiveProcessorCount's every group |
System.XML.Ext
XML documents in Adam, over libxml2's C API (System.XML.C), as easy to use as System.JSON. An XML is a value: a view of one node of a parsed document that every view of it shares (held by a ref, so the document lives while any view does; a view costs no copy). A view that names nothing is a missing value: IsNull, every text "", every Get its default, every walk empty.
Import it with import System.XML.Ext;.
Types
XMLReadOption
type XMLReadOption = choices(
What a read does besides parsing (XML.FromString / FromFile / FromIO and their instance forms, with an XMLReadOptions set).
Members
XMLReadOption.XInclude: Every XInclude element (xi:include) is replaced by the document or text it includes (its xi:fallback when that cannot be read), as the document is read
XMLReadOptions
type XMLReadOptions = set of XMLReadOption
The XMLReadOption set a read takes ([] reads the document as it is).
Example: LBook := XML.FromFile("book.xml", [XMLReadOption.XInclude]);
XMLSchemaKind
type XMLSchemaKind = choices(
What a schema is written in.
Members
XMLSchemaKind.Dtd: A DTD: its declarations, as an external subset holds them.XMLSchemaKind.Xsd: An XML Schema (XSD).XMLSchemaKind.RelaxNG: A RelaxNG schema, in its XML form.
Example: LSchema := XMLSchema.FromFile(XMLSchemaKind.Xsd, "shop.xsd");
XMLFinding
type XMLFinding = record
One thing a validation found: where (the line of the node at fault; column 0 when libxml2 gives none), what, and whether it is only a warning.
Members
Line: int64: The line of the node at faultColumn: int64: The column at fault; 0 when libxml2 gives noneMessage: string: What is wrong, in libxml2's wordsIsWarning: bool: Whether it is only a warning (the document still validates)
Example: for LFinding in LFindings do println("{}: {}", LFinding.Line, LFinding.Message); end;
XMLFindings
type XMLFindings = array of XMLFinding
Every finding of one validation, in the order found.
XMLKind
type XMLKind = choices(
What a node is (XML.Kind).
Members
XMLKind.Missing: A value that names no node: a failed read, a walk past the end, a name not found.XMLKind.Element: An element.XMLKind.Text: Text.XMLKind.CData: A CDATA section.XMLKind.Comment: A comment.XMLKind.Instruction: A processing instruction.XMLKind.EntityReference: An entity reference.XMLKind.Attribute: An attribute.XMLKind.Namespace: A namespace node, as an XPath result holds one.XMLKind.Document: The document node.XMLKind.Other: Any node kind not listed (a DTD ...).
Example: if LNode.Kind() = XMLKind.Element then .. end;
XMLCanonicalForm
type XMLCanonicalForm = choices(
The canonical XML form ToCanonical / SaveCanonicalToFile / SaveCanonicalToIO write.
Members
XMLCanonicalForm.C14N: Canonical XML 1.0.XMLCanonicalForm.ExclusiveC14N: Exclusive XML Canonicalization 1.0: namespaces only where they are used, as XML signatures sign a part of a document.XMLCanonicalForm.C14N11: Canonical XML 1.1.
XMLReaderNode
type XMLReaderNode = choices(
What an XMLReader is on: the node Read moved to.
Members
XMLReaderNode.None: Before the first Read and after the last.XMLReaderNode.Element: An element's start tag.XMLReaderNode.EndElement: An element's end tag.XMLReaderNode.Text: Text.XMLReaderNode.CData: A CDATA section.XMLReaderNode.Comment: A comment.XMLReaderNode.Instruction: A processing instruction.XMLReaderNode.Whitespace: Blank text that is kept, as xml:space="preserve" asks.XMLReaderNode.DocumentType: The document type declaration.XMLReaderNode.EntityReference: An entity reference.XMLReaderNode.Other: Any node kind not listed.
XMLPath
type XMLPath = object
A compiled XPath 1.0 expression with the namespace prefixes and $variables it binds: compiled once (XMLPath.Compile), run on any node of any document any number of times (XML.Select / SelectFirst / Evaluate). A value: a copy shares the compiled code and takes its own copy of the prefixes and variables.
Members
static method Compile(const AExpression: string): XMLPath: Compiles the XPath 1.0 expression AExpression. Parameters:AExpressionthe expression ("//item[@id = 3]", "count(//item)", "$name" ...). Returns: the compiled expression; IsValid false, ErrorText why, when it does not compile Example:LPath := XMLPath.Compile("/config/window/@width");const method IsValid(): bool: Whether the expression compiled. Returns: false for one that did not (ErrorText says why) or a value never compiled Example:if not LPath.IsValid() then println(LPath.ErrorText()); end;const method Expression(): string: The expression as given to Compile. Returns: the expression text Example:println(LPath.Expression());const method ErrorText(): string: Why the expression did not compile, else why its last run failed (a prefix or $variable not bound, a function libxml2 lacks): "<xpath>(1,col): message" for a compile, "<xpath>: message" for a run (a run has no place in the text). Returns: the error; "" when it compiled and its last run worked Example:println(LPath.ErrorText());method RegisterNamespace(const APrefix: string; const ANamespaceURI: string): XMLPath: Binds the namespace prefix APrefix to ANamespaceURI for every run (over a prefix the context node has in scope, or one bound before). Parameters:APrefixthe prefix the expression writes ("p" in "//p:item"); XPath has no default namespace, so an element in one is reached through a prefix bound here;ANamespaceURIthe namespace's URI. Returns: this value, so calls chain; unchanged for an empty prefix or URI Example:LPath.RegisterNamespace("svg", "http://www.w3.org/2000/svg");method SetVariable(const AName: string; const AValue: string): XMLPath: Binds the $variable AName to the string AValue for every run. Parameters:ANamethe name without its $ ("id" for $id);AValuethe value. Returns: this value, so calls chain; unchanged for an empty name Example:LPath.SetVariable("name", "door");method SetVariable(const AName: string; const AValue: int32): XMLPath: Binds the $variable AName to the number AValue for every run. Parameters:ANamethe name without its $;AValuethe value. Returns: this value, so calls chain Example:LPath.SetVariable("id", 7);method SetVariable(const AName: string; const AValue: int64): XMLPath: Binds the $variable AName to the number AValue for every run (XPath numbers are float64: an int64 beyond 2^53 is rounded). Parameters:ANamethe name without its $;AValuethe value. Returns: this value, so calls chain Example:LPath.SetVariable("id", LId);method SetVariable(const AName: string; const AValue: float64): XMLPath: Binds the $variable AName to the number AValue for every run. Parameters:ANamethe name without its $;AValuethe value. Returns: this value, so calls chain Example:LPath.SetVariable("limit", 0.5);method SetVariable(const AName: string; const AValue: bool): XMLPath: Binds the $variable AName to the boolean AValue for every run. Parameters:ANamethe name without its $;AValuethe value. Returns: this value, so calls chain Example:LPath.SetVariable("strict", true);const method EvaluateAt(const ADoc: ptr to xmlDoc; const ANode: ptr to xmlNode): ptr to xmlXPathObject: Runs the expression on ANode of ADoc at libxml2's level (XML.Select / SelectFirst / Evaluate are the easy forms): ANode is the context node, the prefixes in scope on its element and this value's bindings are bound; ErrorText tells why a run failed. Parameters:ADocthe document;ANodethe context node (nil: the document node). Returns: libxml2's result, the caller's to free (xmlXPathFreeObject); nil when the expression did not compile or the run failed Example:LResult := LPath.EvaluateAt(LDoc, xmlDocGetRootElement(LDoc));
Example: LItems := XMLPath.Compile("//p:item[@id = $id]").RegisterNamespace("p", "urn:shop").SetVariable("id", 7);
XMLSchema
type XMLSchema = object
A compiled schema (a DTD, an XML Schema or a RelaxNG schema), compiled once and used to validate any number of documents (XML.Validate). A value: a copy shares it.
Members
static method FromFile(const AKind: XMLSchemaKind; const APath: string): XMLSchema: The schema in the file at APath, read through C's file calls (a HookIO path reads its IO; an XSD's xs:include / xs:import and a RelaxNG's include are read the same way). Parameters:AKindwhat it is written in;APaththe file (an Adam $ path resolved, any other as written). Returns: the schema; IsValid false, ErrorText why ("APath(line,col): message"), when it cannot be read or compiled Example:LSchema := XMLSchema.FromFile(XMLSchemaKind.RelaxNG, "$P:map.rng");static method FromString(const AKind: XMLSchemaKind; const AText: string): XMLSchema: The schema in the text AText (a DTD's declarations, or an XSD / RelaxNG schema's XML). Parameters:AKindwhat it is written in;ATextthe schema. Returns: the schema; IsValid false, ErrorText why ("<text>(line,col): message"), when it does not compile Example:LSchema := XMLSchema.FromString(XMLSchemaKind.Dtd, "<!ELEMENT note (#PCDATA)>");static method FromIO(const AKind: XMLSchemaKind; const AIO: IO): XMLSchema: The schema the IO AIO holds from its place to its end, read in pieces through libxml2's IO callbacks (no copy in a string); the IO stays the caller's, open. Parameters:AKindwhat it is written in;AIOthe IO. Returns: the schema; IsValid false, ErrorText why ("<io>(line,col): message"), when it cannot be read or compiled Example:LSchema := XMLSchema.FromIO(XMLSchemaKind.Xsd, LEntry);const method IsValid(): bool: Whether the schema compiled. Returns: false for one that did not (ErrorText says why) or a value never made Example:if not LSchema.IsValid() then println(LSchema.ErrorText()); end;const method ErrorText(): string: Why the schema did not compile. Returns: "name(line,col): message" (name: the path, "<text>" or "<io>"); "" when it compiled Example:println(LSchema.ErrorText());const method Kind(): XMLSchemaKind: What the schema is written in. Returns: its kind (XMLSchemaKind.Dtd for a value never made) Example:if LSchema.Kind() = XMLSchemaKind.Xsd then println("xsd"); end;const method ValidateAt(const ADoc: ptr to xmlDoc; var AFindings: XMLFindings): bool: Validates the document ADoc against the schema at libxml2's level (XML.Validate is the easy form). Parameters:ADocthe document;AFindingsevery error and warning found, in order (one finding when the schema did not compile or there is no document). Returns: whether the document is valid Example:LOk := LSchema.ValidateAt(LDoc, LFindings);
Example: LSchema := XMLSchema.FromFile(XMLSchemaKind.Xsd, "$P:shop.xsd");
XML
type XML = object
An XML node: a view of one node of a shared parsed document (see the unit header). A value: a copy views the same node, the document lives while any view of it does; a missing value (IsNull) carries why a read failed (ErrorText).
Members
method Parse(const AText: string): bool: Reads the XML text AText as this value's document (its root element from now on). Parameters:ATextthe XML text. Returns: false, ErrorText why ("<text>(line,col): message"), when it is no well-formed XML Example:if not LDoc.Parse("<config/>") then println(LDoc.ErrorText()); end;method Parse(const AText: string; const AOptions: XMLReadOptions): bool: Reads the XML text AText as this value's document, AOptions applied. Parameters:ATextthe XML text;AOptionswhat the read does besides parsing ([XMLReadOption.XInclude] ...). Returns: false, ErrorText why, when it is no well-formed XML or an include fails Example:LDoc.Parse(LText, [XMLReadOption.XInclude]);method LoadFromFile(const APath: string): bool: Reads the XML file at APath, through C's file calls (so a HookIO path reads its IO), as this value's document. Parameters:APaththe file. Returns: false, ErrorText why ("APath(line,col): message", "APath: the file cannot be opened"), on a failure Example:if not LDoc.LoadFromFile("config.xml") then println(LDoc.ErrorText()); end;method LoadFromFile(const APath: string; const AOptions: XMLReadOptions): bool: Reads the XML file at APath as this value's document, AOptions applied (an XInclude's relative href is read from the file's folder). Parameters:APaththe file;AOptionswhat the read does besides parsing. Returns: false, ErrorText why, on a failure Example:LBook.LoadFromFile("book.xml", [XMLReadOption.XInclude]);method LoadFromIO(const AIO: IO): bool: Reads the XML text the IO AIO holds from its place to its end, in pieces through libxml2's IO callbacks, as this value's document; the IO stays the caller's (not closed). Parameters:AIOthe IO. Returns: false, ErrorText why ("<io>(line,col): message"), on a failure Example:LDoc.LoadFromIO(LIO);method LoadFromIO(const AIO: IO; const AOptions: XMLReadOptions): bool: Reads the XML text the IO AIO holds as this value's document, AOptions applied. Parameters:AIOthe IO;AOptionswhat the read does besides parsing. Returns: false, ErrorText why, on a failure Example:LDoc.LoadFromIO(LIO, [XMLReadOption.XInclude]);method ParseHTML(const AText: string): bool: Reads the HTML text AText as this value's document (its html element from now on), with libxml2's forgiving HTML parser. Parameters:ATextthe HTML text. Returns: false, ErrorText why, only when there is no room Example:LPage.ParseHTML("<p>Hello<br>world");method LoadFromHTMLFile(const APath: string): bool: Reads the HTML file at APath, through C's file calls (so a HookIO path reads its IO), as this value's document. Parameters:APaththe file. Returns: false, ErrorText why ("APath: the file cannot be opened"), on a failure Example:if not LPage.LoadFromHTMLFile("index.html") then println(LPage.ErrorText()); end;method LoadFromHTMLIO(const AIO: IO): bool: Reads the HTML text the IO AIO holds from its place to its end as this value's document; the IO stays the caller's (not closed). Parameters:AIOthe IO. Returns: false, ErrorText why ("<io>: the IO cannot be read"), on a failure Example:LPage.LoadFromHTMLIO(LIO);const method ErrorText(): string: Why the last read (Parse, LoadFrom, XML.From, their HTML forms) failed. Returns: the reason; "" when it did not fail Example:println(XML.FromString("<a>").ErrorText());static method FromString(const AText: string): XML: The XML text AText's root element. Parameters:ATextthe XML text. Returns: the root element; a missing value with its ErrorText when it is no well-formed XML Example:LConfig := XML.FromString("<config debug=\"true\"/>");static method FromString(const AText: string; const AOptions: XMLReadOptions): XML: The XML text AText's root element, AOptions applied. Parameters:ATextthe XML text;AOptionswhat the read does besides parsing. Returns: the root element; a missing value with its ErrorText on a failure Example:LDoc := XML.FromString(LText, [XMLReadOption.XInclude]);static method FromFile(const APath: string): XML: The root element of the XML file at APath, read through C's file calls (a HookIO path reads its IO). Parameters:APaththe file. Returns: the root element; a missing value with its ErrorText on a failure Example:LMap := XML.FromFile("maps/overworld.tmx");static method FromFile(const APath: string; const AOptions: XMLReadOptions): XML: The root element of the XML file at APath, AOptions applied. Parameters:APaththe file;AOptionswhat the read does besides parsing. Returns: the root element; a missing value with its ErrorText on a failure Example:LBook := XML.FromFile("book.xml", [XMLReadOption.XInclude]);static method FromIO(const AIO: IO): XML: The root element of the XML text the IO AIO holds from its place to its end. Parameters:AIOthe IO (stays the caller's). Returns: the root element; a missing value with its ErrorText on a failure Example:LDoc := XML.FromIO(LIO);static method FromIO(const AIO: IO; const AOptions: XMLReadOptions): XML: The root element of the XML text the IO AIO holds, AOptions applied. Parameters:AIOthe IO (stays the caller's);AOptionswhat the read does besides parsing. Returns: the root element; a missing value with its ErrorText on a failure Example:LDoc := XML.FromIO(LIO, [XMLReadOption.XInclude]);static method TryFromString(const AText: string; var AXML: XML): bool: The XML text AText's root element into AXML. Parameters:ATextthe XML text;AXMLthe root element; the missing value, its ErrorText why, on a failure. Returns: false when it is no well-formed XML Example:if not XML.TryFromString(LText, LDoc) then println(LDoc.ErrorText()); end;static method TryFromString(const AText: string; const AOptions: XMLReadOptions; var AXML: XML): bool: The XML text AText's root element into AXML, AOptions applied. Parameters:ATextthe XML text;AOptionswhat the read does besides parsing;AXMLthe root element; the missing value, its ErrorText why, on a failure. Returns: false on a failure Example:LOk := XML.TryFromString(LText, [XMLReadOption.XInclude], LDoc);static method FromHTMLString(const AText: string): XML: The HTML text AText's html element, read with libxml2's forgiving HTML parser (missing html / head / body elements implied, tags closed as a browser does). Parameters:ATextthe HTML text. Returns: the html element Example:LTitle := XML.FromHTMLString(LPage).SelectFirst("//title").Text();static method FromHTMLFile(const APath: string): XML: The html element of the HTML file at APath, read through C's file calls (a HookIO path reads its IO). Parameters:APaththe file. Returns: the html element; a missing value with its ErrorText when the file cannot be read Example:LPage := XML.FromHTMLFile("docs/index.html");static method FromHTMLIO(const AIO: IO): XML: The html element of the HTML text the IO AIO holds from its place to its end. Parameters:AIOthe IO (stays the caller's). Returns: the html element; a missing value with its ErrorText when the IO cannot be read Example:LPage := XML.FromHTMLIO(LIO);const method IsNull(): bool: Whether this value names no node (a failed read, a walk past the end, a name not found). Returns: true for a missing value Example:if LDoc.IsNull() then println("{}", LDoc.ErrorText()); end;const method Kind(): XMLKind: What the node is. Returns: its XMLKind; XMLKind.Missing for a missing value Example:if LNode.Kind() = XMLKind.Comment then .. end;const method IsElement(): bool: Whether the node is an element. Returns: true for an element node Example:if LNode.IsElement() then .. end;const method Name(): string: An element's or an attribute's name as written (prefix:local), a processing instruction's target, a namespace node's prefix ("" for the default namespace). Returns: the name; "" for any other node Example:println("{}", LNode.Name());const method LocalName(): string: An element's or an attribute's name without its prefix, a namespace node's prefix. Returns: the local name; "" for any other node Example:LLocal := LNode.LocalName();const method Prefix(): string: An element's or an attribute's namespace prefix. Returns: the prefix; "" when it has none Example:LPrefix := LNode.Prefix();const method NamespaceURI(): string: An element's or an attribute's namespace URI. Returns: the URI; "" when it is in no namespace Example:if LNode.NamespaceURI() = "urn:shop" then .. end;const method Line(): int64: The line the node starts on in its source (an attribute's or a namespace node's: its element's). Returns: the line; 0 for a missing value Example:println("at line {}", LNode.Line());const method Text(): string: The node's own text: an element's text and CDATA children joined (not its descendants'), a text / CDATA / comment / processing instruction / entity reference node's content, an attribute's value, a namespace node's URI. Returns: the text; "" for any other node (a document, a DTD) Example:LTitle := LDoc.FindChild("title").Text();const method InnerText(): string: All the text in and below the node, in document order (entity references expanded). Returns: the text joined Example:LAll := LDoc.InnerText();const method Has(const AName: string): bool: Whether the element has the attribute AName ("local", or "prefix:local" for a namespaced one). Parameters:ANamethe attribute's name. Returns: true when it is there Example:if LItem.Has("id") then .. end;const method Get(const AName: string): string: The attribute AName's value. Parameters:ANamethe attribute's name. Returns: the value; "" when there is none Example:LId := LItem.Get("id");const method Get(const AName: string; const ADefault: string): string: The attribute AName's value, or ADefault. Parameters:ANamethe attribute's name;ADefaultthe value when there is none. Returns: the value or ADefault Example:LColor := LItem.Get("color", "black");const method Get(const AName: string; const ADefault: int32): int32: The attribute AName as an int32, or ADefault. Parameters:ANamethe attribute's name;ADefaultthe value when there is none or it is no int32. Returns: the number or ADefault Example:LCount := LItem.Get("count", int32(0));const method Get(const AName: string; const ADefault: int64): int64: The attribute AName as an int64, or ADefault. Parameters:ANamethe attribute's name;ADefaultthe value when there is none or it is no int64. Returns: the number or ADefault Example:LSize := LItem.Get("size", int64(0));const method Get(const AName: string; const ADefault: float64): float64: The attribute AName as a float64, or ADefault. Parameters:ANamethe attribute's name;ADefaultthe value when there is none or it is no number. Returns: the number or ADefault Example:LPrice := LItem.Get("price", 0.0);const method Get(const AName: string; const ADefault: bool): bool: The attribute AName as a bool (true / 1, false / 0, as XML Schema's boolean), or ADefault. Parameters:ANamethe attribute's name;ADefaultthe value when there is none or it is neither. Returns: the bool or ADefault Example:LOn := LItem.Get("enabled", false);const method TryGet(const AName: string; var AValue: string): bool: The attribute AName's value into AValue. Parameters:ANamethe attribute's name;AValuethe value (unchanged when there is none). Returns: false when there is none Example:if LItem.TryGet("id", LId) then .. end;const method TryGet(const AName: string; var AValue: int64): bool: The attribute AName as an int64 into AValue (spaces around it allowed). Parameters:ANamethe attribute's name;AValuethe number (unchanged on false). Returns: false when there is none or it is no whole number Example:if LItem.TryGet("size", LSize) then .. end;const method TryGet(const AName: string; var AValue: int32): bool: The attribute AName as an int32 into AValue. Parameters:ANamethe attribute's name;AValuethe number (unchanged on false). Returns: false when there is none or it is no whole number in int32's range Example:if LItem.TryGet("count", LCount) then .. end;const method TryGet(const AName: string; var AValue: float64): bool: The attribute AName as a float64 into AValue. Parameters:ANamethe attribute's name;AValuethe number (unchanged on false). Returns: false when there is none or it is no number Example:if LItem.TryGet("price", LPrice) then .. end;const method TryGet(const AName: string; var AValue: bool): bool: The attribute AName as a bool into AValue (true / 1, false / 0). Parameters:ANamethe attribute's name;AValuethe bool (unchanged on false). Returns: false when there is none or it is neither Example:if LItem.TryGet("enabled", LOn) then .. end;const method AttributeCount(): int64: How many attributes the element has. Returns: the count; 0 for any other node Example:LCount := LItem.AttributeCount();const method AttributeNames(): StringArray: The element's attribute names as written, in document order. Returns: the names Example:for LName in LItem.AttributeNames() do .. end;const method Attributes(): sequence of XMLAttribute: The element's attributes (name as written and value), in document order. Returns: a sequence of XMLAttribute Example:for LAttr in LItem.Attributes() do println("{}={}", LAttr.Name, LAttr.Value); end;const method Parent(): XML: The node's parent (the root element's is the document node; an attribute's its element; a namespace node's the element it is in scope on). Returns: the parent; missing for the document Example:LOwner := LAttr.Parent();const method Next(): XML: The next sibling node. Returns: the sibling; missing for the last Example:LNode := LNode.Next();const method Previous(): XML: The previous sibling node. Returns: the sibling; missing for the first Example:LNode := LNode.Previous();const method NextElement(): XML: The next sibling element. Returns: the element; missing when there is none Example:LItem := LItem.NextElement();const method PreviousElement(): XML: The previous sibling element. Returns: the element; missing when there is none Example:LItem := LItem.PreviousElement();const method FirstChild(): XML: The first child node. Returns: the child; missing when there is none Example:LNode := LDoc.FirstChild();const method FirstElement(): XML: The first child element. Returns: the element; missing when there is none Example:LItem := LDoc.FirstElement();const method LastElement(): XML: The last child element. Returns: the element; missing when there is none Example:LItem := LDoc.LastElement();const method Root(): XML: The document's root element, from any node of it. Returns: the root element Example:LRoot := LItem.Root();const method ChildCount(): int64: How many child nodes the node has. Returns: the count Example:LCount := LDoc.ChildCount();const method ElementCount(): int64: How many child elements the node has. Returns: the count Example:LCount := LDoc.ElementCount();const method FindChild(const AName: string): XML: The first child element named AName (prefix:local as written). Parameters:ANamethe element's name. Returns: the element; missing when none is Example:LTitle := LDoc.FindChild("title");const method Children(): sequence of XML: Every child node, in document order. Returns: a sequence of the children Example:for LNode in LDoc.Children() do .. end;const method Elements(): sequence of XML: Every child element, in document order. Returns: a sequence of the child elements Example:for LItem in LDoc.Elements() do .. end;const method Elements(const AName: string): sequence of XML: Every child element named AName (prefix:local as written), in document order. Parameters:ANamethe elements' name. Returns: a sequence of the matching child elements Example:for LItem in LDoc.Elements("item") do .. end;const method FindAll(const AName: string): sequence of XML: Every element below the node named AName (prefix:local as written), the node itself not included, in document order. Parameters:ANamethe elements' name. Returns: a sequence of the matching elements Example:for LPrice in LDoc.FindAll("price") do .. end;const method Select(const APath: XMLPath): sequence of XML: Every node the XPath expression APath selects from this node, in document order (elements, attributes, texts, namespace nodes ...). Parameters:APaththe compiled expression (its ErrorText says why a run failed). Returns: the nodes as afor .. insequence; empty for a missing value, an expression that failed, or one whose result is no node-set (count(..), a string) Example:for LItem in LShop.Select(LItems) do println(LItem.Get("name")); end;const method Select(const AExpression: string): sequence of XML: Every node the XPath expression AExpression selects from this node (compiled for this call; XMLPath.Compile once for a run repeated). Parameters:AExpressionthe expression ("item[@price > 10]", "//p:title", "@*" ...). Returns: the nodes as afor .. insequence; empty for a missing value, an expression that does not compile or fails, or a result that is no node-set Example:for LLayer in LMap.Select("layer[@visible != 0]") do println(LLayer.Get("name")); end;const method SelectFirst(const APath: XMLPath): XML: The first node, in document order, the XPath expression APath selects from this node. Parameters:APaththe compiled expression. Returns: the node; a missing value when it selects none, fails, or gives no node-set Example:LTitle := LBook.SelectFirst(LTitlePath);const method SelectFirst(const AExpression: string): XML: The first node, in document order, the XPath expression AExpression selects from this node. Parameters:AExpressionthe expression. Returns: the node; a missing value when it selects none, does not compile, fails, or gives no node-set Example:LWidth := LConfig.SelectFirst("window/@width").Text();const method Evaluate(const APath: XMLPath; const ADefault: string): string: The XPath expression APath's result from this node as a string (XPath's string(): a node-set's first node's text, a number as XPath writes it, true / false). Parameters:APaththe compiled expression;ADefaultwhat a missing value or a failed run gives. Returns: the result's string; ADefault on a failure Example:LName := LRoot.Evaluate(LNamePath, "unnamed");const method Evaluate(const APath: XMLPath): string: The XPath expression APath's result from this node as a string. Parameters:APaththe compiled expression. Returns: the result's string; "" on a failure Example:println(LRoot.Evaluate(LTitlePath));const method Evaluate(const APath: XMLPath; const ADefault: float64): float64: The XPath expression APath's result from this node as a number (XPath's number()). Parameters:APaththe compiled expression;ADefaultwhat a failure or a NaN (a text that is no number) gives. Returns: the number (an infinity included); ADefault on a failure or a NaN Example:LTotal := LCart.Evaluate(LSumPath, 0.0);const method Evaluate(const APath: XMLPath; const ADefault: int64): int64: The XPath expression APath's result from this node as a whole number. Parameters:APaththe compiled expression;ADefaultwhat a failure, a NaN, an infinity, a fraction or a number outside int64 gives. Returns: the number; ADefault when it does not fit Example:LCount := LShop.Evaluate(LCountPath, int64(0));const method Evaluate(const APath: XMLPath; const ADefault: int32): int32: The XPath expression APath's result from this node as a whole number in int32. Parameters:APaththe compiled expression;ADefaultwhat a failure, a NaN, an infinity, a fraction or a number outside int32 gives. Returns: the number; ADefault when it does not fit Example:LCount := LShop.Evaluate(LCountPath, 0);const method Evaluate(const APath: XMLPath; const ADefault: bool): bool: The XPath expression APath's result from this node as a boolean (XPath's boolean(): a node-set is true when not empty, a number when not 0 / NaN, a string when not ""). Parameters:APaththe compiled expression;ADefaultwhat a failure gives. Returns: the boolean; ADefault on a failure Example:if LDoc.Evaluate(LHasErrors, false) then println("errors"); end;const method Evaluate(const AExpression: string): string: The XPath expression AExpression's result from this node as a string. Parameters:AExpressionthe expression ("string(@id)", "concat(first, ' ', last)" ...). Returns: the result's string; "" on a failure Example:println(LBook.Evaluate("normalize-space(title)"));const method Evaluate(const AExpression: string; const ADefault: string): string: The XPath expression AExpression's result from this node as a string. Parameters:AExpressionthe expression;ADefaultwhat a failure gives. Returns: the result's string; ADefault on a failure Example:LName := LRoot.Evaluate("string(@name)", "unnamed");const method Evaluate(const AExpression: string; const ADefault: float64): float64: The XPath expression AExpression's result from this node as a number. Parameters:AExpressionthe expression ("sum(item/@price)" ...);ADefaultwhat a failure or a NaN gives. Returns: the number; ADefault on a failure or a NaN Example:LTotal := LCart.Evaluate("sum(item/@price)", 0.0);const method Evaluate(const AExpression: string; const ADefault: int64): int64: The XPath expression AExpression's result from this node as a whole number. Parameters:AExpressionthe expression ("count(item)" ...);ADefaultwhat a failure or a number that is no int64 gives. Returns: the number; ADefault when it does not fit Example:LCount := LShop.Evaluate("count(item)", int64(0));const method Evaluate(const AExpression: string; const ADefault: int32): int32: The XPath expression AExpression's result from this node as a whole number in int32. Parameters:AExpressionthe expression;ADefaultwhat a failure or a number that is no int32 gives. Returns: the number; ADefault when it does not fit Example:LCount := LShop.Evaluate("count(item)", 0);const method Evaluate(const AExpression: string; const ADefault: bool): bool: The XPath expression AExpression's result from this node as a boolean. Parameters:AExpressionthe expression ("boolean(item[@sold])" ...);ADefaultwhat a failure gives. Returns: the boolean; ADefault on a failure Example:if LShop.Evaluate("item[@price > 100]", false) then println("pricey"); end;const method Validate(var AFindings: XMLFindings): bool: Validates the document this value is in against its own DTD (its DOCTYPE's internal subset and the external one it names, read through C's file calls), listing every error and warning. Parameters:AFindingsevery finding, in order ("no DTD found" when it declares none). Returns: whether the document is valid Example:if not LDoc.Validate(LFindings) then println(LFindings[0].Message); end;const method Validate(): bool: Whether the document this value is in is valid against its own DTD. Returns: false for a missing value, a document with no DTD, or one not valid Example:if LDoc.Validate() then println("valid"); end;const method Validate(const ASchema: XMLSchema; var AFindings: XMLFindings): bool: Validates the document this value is in against ASchema, listing every error and warning. Parameters:ASchemathe schema (a DTD, an XSD or a RelaxNG one);AFindingsevery finding, in order (one when the schema did not compile). Returns: whether the document is valid Example:if not LOrder.Validate(LSchema, LFindings) then println(LFindings[0].Line); end;const method Validate(const ASchema: XMLSchema): bool: Whether the document this value is in is valid against ASchema. Parameters:ASchemathe schema. Returns: false for a missing value, a schema that did not compile, or a document not valid Example:if LOrder.Validate(LSchema) then println("valid"); end;static method New(const AName: string): XML: A new document whose root element is AName, in no namespace. Parameters:ANamethe root element's name ("local"; a "prefix:local" one needs the namespace URI form). Returns: the root element; a missing value with its ErrorText when AName is no XML name Example:LConfig := XML.New("config").SetAttribute("version", 2);SeeXML.SaveToFile.static method New(const AName: string; const ANamespaceURI: string): XML: A new document whose root element AName is in the namespace ANamespaceURI: a "prefix:local" name declares the prefix for it, a bare "local" makes it the default namespace (inherited by the unprefixed elements added below). Parameters:ANamethe root element's name, "local" or "prefix:local";ANamespaceURIthe namespace URI ("" for none, then AName takes no prefix). Returns: the root element; a missing value with its ErrorText ("<new>: ...") when AName is no XML name or names a prefix with no URI Example:LSVG := XML.New("svg", "http://www.w3.org/2000/svg");method DeclareNamespace(const APrefix: string; const ANamespaceURI: string): XML: Declares the namespace ANamespaceURI on this element under APrefix, for it and everything below to name by "prefix:local"; APrefix "" declares the default namespace, which this element (when unprefixed and in none) and the unprefixed elements added below then are in. Parameters:APrefixthe prefix ("" for the default namespace);ANamespaceURIthe namespace URI. Returns: this value; nothing changes when it is no element, APrefix is no XML name or already declared here, or ANamespaceURI is "" Example:LRoot.DeclareNamespace("xlink", "http://www.w3.org/1999/xlink");method AddElement(const AName: string): XML: Appends a new element AName as this element's last child. Parameters:AName"local" (in the default namespace in scope) or "prefix:local" (a prefix declared here or above). Returns: the new element; a missing value when this is no element, AName is no XML name or its prefix is not declared Example:LItem := LList.AddElement("item").SetAttribute("id", 1);method AddElement(const AName: string; const AText: string): XML: Appends a new element AName holding the text AText as this element's last child. Parameters:ANameas AddElement takes it;ATextthe new element's text (written escaped). Returns: the new element (a missing value as AddElement's) Example:LBook.AddElement("title", "Dune");method AddText(const AText: string): XML: Appends the text AText to this element (beside a text before it, it joins it). Parameters:ATextthe text, as is (written escaped: & < > as entities). Returns: this value; nothing changes when it is no element or AText is "" Example:LNote.AddText("a & b");method SetText(const AText: string): XML: Replaces this element's children with the one text AText (none for ""). Parameters:ATextthe new text (written escaped). Returns: this value; nothing changes when it is no element Example:LTitle.SetText("Dune Messiah");method AddComment(const AText: string): XML: Appends the comment AText (written <!--AText-->) to this element. Parameters:ATextthe comment's text. Returns: this value; nothing changes when it is no element or AText holds "--" or ends in "-" (no well-formed comment can) Example:LRoot.AddComment(" generated ");method AddCData(const AText: string): XML: Appends the CDATA section AText (written <![CDATA[AText]]>, its text as is) to this element. Parameters:ATextthe section's text. Returns: this value; nothing changes when it is no element or AText holds "]]>" Example:LScript.AddCData("if (a < b) run();");method SetAttribute(const AName: string; const AValue: string): XML: Sets the attribute AName of this element to AValue (added, or its value replaced). Parameters:AName"local" (in no namespace) or "prefix:local" (a prefix declared here or above); "xmlns" is DeclareNamespace's;AValuethe value (written escaped). Returns: this value; nothing changes when it is no element, AName is no XML name or its prefix is not declared Example:LItem.SetAttribute("name", "Ada").SetAttribute("age", 36);method SetAttribute(const AName: string; const AValue: int32): XML: Sets the attribute AName to the whole number AValue. Parameters:ANameas the string form takes it;AValuethe value. Returns: this value (unchanged as the string form's) Example:LMap.SetAttribute("width", int32(30));method SetAttribute(const AName: string; const AValue: int64): XML: Sets the attribute AName to the whole number AValue. Parameters:ANameas the string form takes it;AValuethe value. Returns: this value (unchanged as the string form's) Example:LFile.SetAttribute("size", LSize);method SetAttribute(const AName: string; const AValue: float64): XML: Sets the attribute AName to the number AValue. Parameters:ANameas the string form takes it;AValuethe value. Returns: this value (unchanged as the string form's) Example:LSound.SetAttribute("volume", 0.8);method SetAttribute(const AName: string; const AValue: bool): XML: Sets the attribute AName to AValue as "true" / "false". Parameters:ANameas the string form takes it;AValuethe value. Returns: this value (unchanged as the string form's) Example:LWindow.SetAttribute("fullscreen", false);method RemoveAttribute(const AName: string): bool: Removes the attribute AName from this element. Parameters:AName"local" or "prefix:local", as Get takes it. Returns: false when it has no such attribute Example:LItem.RemoveAttribute("draft");method Remove(): bool: Takes this node out of its document (with everything below it). The node is kept until the document goes, so this value and every other view of it stay readable. Returns: false for a missing value or a node already taken out Example:LMap.FindChild("debug").Remove();const method ToString(): string: The node's own markup, compact (no XML declaration; an element with everything below it; an attribute as name="value"). Returns: the markup; "" for a missing value or a namespace node (an XPath result with no markup of its own: its Name and Text are the prefix and URI) Example:println(LItem.ToString());const method ToPrettyString(): string: The node's own markup, an element per line, 2 spaces a level (an element holding text stays on its line). Returns: the markup; "" for a missing value Example:println(LDoc.ToPrettyString());const method SaveToFile(const APath: string): bool: Writes the whole document this value is in to the file at APath, pretty, in UTF-8, through C's file calls (a HookIO path writes its IO). Parameters:APaththe file (an Adam $ path resolved, any other as written). Returns: false for a missing value or when it cannot be written Example:LConfig.SaveToFile("$D:config.xml");const method SaveToFile(const APath: string; const APretty: bool): bool: SaveToFile, pretty when APretty, else compact. Parameters:APaththe file;APrettywhether a line per element. Returns: false for a missing value or when it cannot be written Example:LDoc.SaveToFile("out.xml", false);const method SaveToFile(const APath: string; const APretty: bool; const AEncoding: string): bool: SaveToFile in the encoding AEncoding (declared in the XML declaration; an HTML document, XML.FromHTML*, is written as HTML, the encoding in its meta charset). Parameters:APaththe file;APrettywhether a line per element;AEncodinglibxml2's name for it ("UTF-8", "UTF-16", "ISO-8859-1" ...). Returns: false for a missing value, an encoding libxml2 lacks, or when it cannot be written Example:LDoc.SaveToFile("latin1.xml", true, "ISO-8859-1");const method SaveToIO(const AIO: IO): bool: Writes the whole document this value is in to the IO AIO at its place, pretty, in UTF-8, through libxml2's IO callbacks (no copy in a string). Parameters:AIOthe IO written (it stays the caller's, open). Returns: false for a missing value or when not all of it could be written Example:LDoc.SaveToIO(LMemory);const method SaveToIO(const AIO: IO; const APretty: bool): bool: SaveToIO, pretty when APretty, else compact. Parameters:AIOthe IO written;APrettywhether a line per element. Returns: false for a missing value or when not all of it could be written Example:LDoc.SaveToIO(LMemory, false);const method SaveToIO(const AIO: IO; const APretty: bool; const AEncoding: string): bool: SaveToIO in the encoding AEncoding (declared in the XML declaration; an HTML document is written as HTML, the encoding in its meta charset). Parameters:AIOthe IO written;APrettywhether a line per element;AEncodinglibxml2's name for it ("UTF-8", "UTF-16", "ISO-8859-1" ...). Returns: false for a missing value, an encoding libxml2 lacks, or when not all of it could be written Example:LDoc.SaveToIO(LMemory, true, "ISO-8859-1");const method ToCanonical(): string: This node and everything below it as Canonical XML 1.0, comments left out (the document's Root().Parent() gives the whole document). Returns: the canonical text (UTF-8); "" for a missing value or a namespace node Example:if LA.ToCanonical() = LB.ToCanonical() then println("same XML"); end;const method ToCanonical(const AForm: XMLCanonicalForm; const AWithComments: bool): string: This node and everything below it in the canonical form AForm. Parameters:AFormC14N, ExclusiveC14N or C14N11;AWithCommentswhether comments are kept. Returns: the canonical text (UTF-8); "" for a missing value or when it cannot be made Example:LSigned := LBody.ToCanonical(XMLCanonicalForm.ExclusiveC14N, false);const method SaveCanonicalToFile(const APath: string): bool: Writes this node and everything below it as Canonical XML 1.0 to the file APath, through C's file calls (a HookIO path writes its IO). Parameters:APaththe file. Returns: false for a missing value or when it cannot be written Example:LDoc.Root().Parent().SaveCanonicalToFile("signed.xml");const method SaveCanonicalToFile(const APath: string; const AForm: XMLCanonicalForm; const AWithComments: bool): bool: SaveCanonicalToFile in the canonical form AForm. Parameters:APaththe file;AFormC14N, ExclusiveC14N or C14N11;AWithCommentswhether comments are kept. Returns: false for a missing value or when it cannot be written Example:LDoc.SaveCanonicalToFile("c.xml", XMLCanonicalForm.C14N11, true);const method SaveCanonicalToIO(const AIO: IO): bool: Writes this node and everything below it as Canonical XML 1.0 to the IO AIO at its place, through libxml2's IO callbacks (the IO stays the caller's, open). Parameters:AIOthe IO written. Returns: false for a missing value or when not all of it could be written Example:LDoc.Root().SaveCanonicalToIO(LMemory);const method SaveCanonicalToIO(const AIO: IO; const AForm: XMLCanonicalForm; const AWithComments: bool): bool: SaveCanonicalToIO in the canonical form AForm. Parameters:AIOthe IO written;AFormC14N, ExclusiveC14N or C14N11;AWithCommentswhether comments are kept. Returns: false for a missing value or when not all of it could be written Example:LBody.SaveCanonicalToIO(LMemory, XMLCanonicalForm.ExclusiveC14N, false);static method TakeDocument(const ADoc: ptr to xmlDoc): XML: libxml2 level: the document ADoc (one nothing else frees) as an XML that owns it from now on, freed when the last value of it goes. Parameters:ADocthe document (XMLReader.ReadSubtree hands its copies over so). Returns: its root element; a missing value for nil or a document with none Example:LXML := XML.TakeDocument(xmlReadMemory(..));
Example: LDoc := XML.FromFile("shop.xml"); for LItem in LDoc.Elements("item") do println("{}", LItem.Get("id")); end;
XMLAttribute
type XMLAttribute = object
An attribute as XML.Attributes gives it: its name as written and its value.
Members
Name: string: The attribute's name as written (prefix:local)Value: string: The attribute's value
Example: for LAttr in LItem.Attributes() do println("{}", LAttr.Name); end;
XMLReader
type XMLReader = object
A pull reader: a document read one node at a time (Read), from a file, a text or an IO, holding only the node it is on, for documents too big to hold whole. A value: a copy reads the same stream. ReadSubtree takes the element it is on as an XML.
Members
static method FromFile(const APath: string): XMLReader: A reader of the XML file at APath, read through C's file calls (a HookIO path reads its IO). Parameters:APaththe file. Returns: the reader; IsValid false, ErrorText why ("APath: the file cannot be opened"), when the file cannot be opened Example:LReader := XMLReader.FromFile("maps/overworld.tmx");static method FromFile(const APath: string; const AOptions: XMLReadOptions): XMLReader: A reader of the XML file at APath, AOptions applied ([XMLReadOption.XInclude] reads what each xi:include includes in its place). Parameters:APaththe file;AOptionswhat the read does besides parsing. Returns: the reader; IsValid false, ErrorText why, when it cannot start Example:LReader := XMLReader.FromFile("book.xml", [XMLReadOption.XInclude]);static method FromString(const AText: string): XMLReader: A reader of the XML text AText (read in place, no copy). Parameters:ATextthe XML text. Returns: the reader Example:LReader := XMLReader.FromString("<list><item/></list>");static method FromString(const AText: string; const AOptions: XMLReadOptions): XMLReader: A reader of the XML text AText, AOptions applied. Parameters:ATextthe XML text;AOptionswhat the read does besides parsing. Returns: the reader; IsValid false when the text is too large (over 2 GB) Example:LReader := XMLReader.FromString(LText, [XMLReadOption.XInclude]);static method FromIO(const AIO: IO): XMLReader: A reader of the XML text the IO AIO holds from its place to its end, read in pieces through libxml2's IO callbacks; the IO stays the caller's (open while the reader reads, not closed by it). Parameters:AIOthe IO. Returns: the reader; IsValid false ("<io>: no IO") for nil Example:LReader := XMLReader.FromIO(LEntry);static method FromIO(const AIO: IO; const AOptions: XMLReadOptions): XMLReader: A reader of the XML text the IO AIO holds, AOptions applied. Parameters:AIOthe IO;AOptionswhat the read does besides parsing. Returns: the reader; IsValid false ("<io>: no IO") for nil Example:LReader := XMLReader.FromIO(LEntry, [XMLReadOption.XInclude]);const method IsValid(): bool: Whether the reader has met no error (a file that cannot be opened, XML that is not well-formed, a failed include). Returns: false once an error came; ErrorText says what Example:if not LReader.IsValid() then println(LReader.ErrorText()); end;const method ErrorText(): string: Why the reader stopped: "name(line,col): message" as a read's ErrorText. Returns: the reason; "" while there is none Example:println(LReader.ErrorText());const method Read(): bool: Moves to the next node in document order (an element's start, then what is in it, then its end). Returns: true on a node; false at the end of the document or on an error (IsValid then false) Example:while LReader.Read() do println(LReader.Name()); end;const method Skip(): bool: Moves past the node it is on and everything below it, to the node after. Returns: true on a node; false at the end or on an error Example:if LReader.Name() = "skipme" then LReader.Skip(); end;const method Kind(): XMLReaderNode: What the reader is on. Returns: the node's kind; XMLReaderNode.None before the first Read and after the last Example:if LReader.Kind() = XMLReaderNode.EndElement then .. end;const method Name(): string: The node's name as written ("prefix:local" for a prefixed one; "#text" for a text). Returns: the name; "" when it is on no node Example:if LReader.Name() = "item" then .. end;const method LocalName(): string: The node's name without its prefix. Returns: the local name; "" when it is on no node Example:LLocal := LReader.LocalName();const method Prefix(): string: The node's namespace prefix. Returns: the prefix; "" when it has none Example:LPrefix := LReader.Prefix();const method NamespaceURI(): string: The node's namespace URI. Returns: the URI; "" when it is in no namespace Example:if LReader.NamespaceURI() = "urn:shop" then .. end;const method Value(): string: The node's text: a text's, a CDATA section's, a comment's, an instruction's content. Returns: the text; "" for an element or when it is on no node Example:if LReader.Kind() = XMLReaderNode.Text then println(LReader.Value()); end;const method Depth(): int64: How deep the node is (the root element 0, its children 1, ...). Returns: the depth; 0 when it is on no node Example:println(Spaces(LReader.Depth() * 2) + LReader.Name());const method IsEmptyElement(): bool: Whether the element it is on is written empty (<item/>), so no EndElement follows. Returns: true for an empty element Example:if LReader.IsEmptyElement() then .. end;const method Line(): int64: The line the node it is on starts on (an element's start tag; for a node libxml2 keeps no line of, such as an end tag, the line the reader has read up to). Returns: the 1-based line; 0 when it is on no node Example:println("item on line {}", LReader.Line());const method AttributeCount(): int64: How many attributes the element it is on has. Returns: the count; 0 for any other node Example:LCount := LReader.AttributeCount();const method TryGet(const AName: string; var AValue: string): bool: The attribute AName of the element it is on into AValue. Parameters:ANamethe attribute's name as written ("id", "xlink:href");AValueits value (unchanged when there is none). Returns: false when the element has no such attribute Example:if LReader.TryGet("id", LId) then .. end;const method Has(const AName: string): bool: Whether the element it is on has the attribute AName. Parameters:ANamethe attribute's name as written. Returns: true when it has it Example:if LReader.Has("visible") then .. end;const method Get(const AName: string): string: The attribute AName of the element it is on. Parameters:ANamethe attribute's name as written. Returns: its value; "" when there is none Example:LName := LReader.Get("name");const method Get(const AName: string; const ADefault: int32): int32: The attribute AName as an int32. Parameters:ANamethe attribute's name as written;ADefaultwhat a missing attribute or one that is no int32 gives. Returns: the value; ADefault when it does not fit Example:LWidth := LReader.Get("width", 0);const method Get(const AName: string; const ADefault: int64): int64: The attribute AName as an int64. Parameters:ANamethe attribute's name as written;ADefaultwhat a missing attribute or one that is no int64 gives. Returns: the value; ADefault when it does not fit Example:LSize := LReader.Get("size", int64(0));const method Get(const AName: string; const ADefault: float64): float64: The attribute AName as a float64. Parameters:ANamethe attribute's name as written;ADefaultwhat a missing attribute or one that is no number gives. Returns: the value; ADefault when it does not fit Example:LPrice := LReader.Get("price", 0.0);const method Get(const AName: string; const ADefault: bool): bool: The attribute AName as a bool (true / 1, false / 0). Parameters:ANamethe attribute's name as written;ADefaultwhat a missing attribute or one that is neither gives. Returns: the value; ADefault when it does not fit Example:if LReader.Get("visible", true) then .. end;const method ReadInnerXML(): string: The markup inside the element it is on (its content, not its own tags); the reader stays where it is. Returns: the markup; "" for an empty element or any other node Example:LBody := LReader.ReadInnerXML();const method ReadOuterXML(): string: The markup of the element it is on, its own tags included; the reader stays where it is. Returns: the markup; "" when it is on no node Example:LItem := LReader.ReadOuterXML();const method ReadSubtree(): XML: The element it is on and everything below it, read in and copied into a document of its own (so it lives on as the reader moves); the reader stays where it is: Skip moves past it. Returns: the copy's root element; a missing value when it is on no element or on an error Example:LItem := LReader.ReadSubtree(); println(LItem.Get("id")); LReader.Skip();
Example: LReader := XMLReader.FromFile("big.xml"); while LReader.Read() do .. end;
XMLWriter
type XMLWriter = object
A streaming writer: XML written start tag by start tag to a file, an IO or a text, never held whole (for big documents). Calls chain; the first failing call makes the writer invalid (ErrorText says why) and every later one write nothing. A value: a copy writes the same stream.
Members
static method ToFile(const APath: string): XMLWriter: A writer to the file APath (created or replaced), through C's file calls (a HookIO path writes its IO), indented two spaces a level. Parameters:APaththe file. Returns: the writer; IsValid false ("APath: the file cannot be created") on a failure Example:LOut := XMLWriter.ToFile("save.xml");static method ToFile(const APath: string; const APretty: bool): XMLWriter: A writer to the file APath, indented when APretty, else compact. Parameters:APaththe file;APrettywhether a line per element. Returns: the writer; IsValid false on a failure Example:LOut := XMLWriter.ToFile("save.xml", false);static method ToIO(const AIO: IO): XMLWriter: A writer to the IO AIO at its place, through libxml2's IO callbacks (the IO stays the caller's, open), indented two spaces a level. Parameters:AIOthe IO written. Returns: the writer; IsValid false ("<io>: no IO") for nil Example:LOut := XMLWriter.ToIO(LMemory);static method ToIO(const AIO: IO; const APretty: bool): XMLWriter: A writer to the IO AIO, indented when APretty, else compact. Parameters:AIOthe IO written;APrettywhether a line per element. Returns: the writer; IsValid false for nil Example:LOut := XMLWriter.ToIO(LMemory, false);static method ToText(): XMLWriter: A writer to a text kept in memory (Text gives it), indented two spaces a level. Returns: the writer Example:LOut := XMLWriter.ToText(); .. println(LOut.Text());static method ToText(const APretty: bool): XMLWriter: A writer to a text kept in memory, indented when APretty, else compact. Parameters:APrettywhether a line per element. Returns: the writer Example:LOut := XMLWriter.ToText(false);const method IsValid(): bool: Whether every call so far wrote what it was asked to. Returns: false once a call failed; ErrorText says why Example:if not LOut.IsValid() then println(LOut.ErrorText()); end;const method ErrorText(): string: Why a call failed ("name: message", name the path, "<io>" or "<text>"). Returns: the reason; "" while none has Example:println(LOut.ErrorText());const method StartDocument(): XMLWriter: Writes the XML declaration in UTF-8 (<?xml version="1.0" encoding="UTF-8"?>). Returns: this writer Example:LOut.StartDocument().StartElement("config");const method StartDocument(const AEncoding: string): XMLWriter: Writes the XML declaration in the encoding AEncoding (what follows is written in it). Parameters:AEncodinglibxml2's name for it ("UTF-8", "ISO-8859-1" ...). Returns: this writer Example:LOut.StartDocument("ISO-8859-1");const method EndDocument(): XMLWriter: Ends the document: every element still open is ended. Returns: this writer Example:LOut.EndDocument();const method StartElement(const AName: string): XMLWriter: Starts the element AName (its attributes follow, then its content, then EndElement). Parameters:ANamethe name as written ("item", or "prefix:local" for a prefix declared with the namespace form or an xmlns:prefix attribute). Returns: this writer Example:LOut.StartElement("item").WriteAttribute("id", 7);const method StartElement(const AName: string; const ANamespaceURI: string): XMLWriter: Starts the element AName in the namespace ANamespaceURI, declaring it: a "prefix:local" name declares the prefix (xmlns:prefix="uri"), a bare "local" the default namespace (xmlns="uri"). Parameters:AName"local" or "prefix:local";ANamespaceURIthe namespace URI. Returns: this writer Example:LOut.StartElement("svg", "http://www.w3.org/2000/svg");const method EndElement(): XMLWriter: Ends the element started last (<item/> when nothing was written in it). Returns: this writer; a failure when no element is open Example:LOut.StartElement("list").EndElement();const method WriteElement(const AName: string; const AText: string): XMLWriter: Writes the element AName holding the text AText (escaped), start to end. Parameters:ANamethe name as written;ATextits text. Returns: this writer Example:LOut.WriteElement("title", "Tom & Jerry");const method WriteAttribute(const AName: string; const AValue: string): XMLWriter: Writes the attribute AName="AValue" (escaped) on the element just started. Parameters:ANamethe name as written ("id", "xmlns:p", "p:kind");AValueits value. Returns: this writer; a failure after the element's content has begun Example:LOut.StartElement("item").WriteAttribute("name", "a<b");const method WriteAttribute(const AName: string; const AValue: int32): XMLWriter: Writes the attribute AName as a whole number. Parameters:ANamethe name as written;AValuethe value. Returns: this writer Example:LOut.WriteAttribute("width", 640);const method WriteAttribute(const AName: string; const AValue: int64): XMLWriter: Writes the attribute AName as a whole number. Parameters:ANamethe name as written;AValuethe value. Returns: this writer Example:LOut.WriteAttribute("size", int64(9000000000));const method WriteAttribute(const AName: string; const AValue: float64): XMLWriter: Writes the attribute AName as a number. Parameters:ANamethe name as written;AValuethe value. Returns: this writer Example:LOut.WriteAttribute("ratio", 0.5);const method WriteAttribute(const AName: string; const AValue: bool): XMLWriter: Writes the attribute AName as "true" / "false". Parameters:ANamethe name as written;AValuethe value. Returns: this writer Example:LOut.WriteAttribute("visible", true);const method WriteText(const AText: string): XMLWriter: Writes the text AText (escaped: & < > as entities) in the open element. Parameters:ATextthe text. Returns: this writer Example:LOut.StartElement("p").WriteText("1 < 2").EndElement();const method WriteCData(const AText: string): XMLWriter: Writes a CDATA section holding AText as it is. Parameters:ATextthe text (it must not hold "]]>"). Returns: this writer Example:LOut.WriteCData("<raw>");const method WriteComment(const AText: string): XMLWriter: Writes the comment <!--AText-->. Parameters:ATextthe comment's text. Returns: this writer Example:LOut.WriteComment("generated");const method WriteInstruction(const ATarget: string; const AContent: string): XMLWriter: Writes the processing instruction <?ATarget AContent?>. Parameters:ATargetits target ("xml-stylesheet" ...);AContentits content. Returns: this writer Example:LOut.WriteInstruction("xml-stylesheet", "href=\"s.css\"");const method WriteDocType(const AName: string; const APublicId: string; const ASystemId: string): XMLWriter: Writes the document type <!DOCTYPE AName PUBLIC "APublicId" "ASystemId"> ("" leaves an id out). Parameters:ANamethe root element's name;APublicIdthe public id; "" for none;ASystemIdthe system id (the DTD's URL); "" for none. Returns: this writer Example:LOut.WriteDocType("note", "", "note.dtd");const method WriteRaw(const AText: string): XMLWriter: Writes AText as it is (no escaping): markup made elsewhere. Parameters:ATextthe markup. Returns: this writer Example:LOut.WriteRaw(LItem.ToString());const method Flush(): bool: Writes out what the writer holds so far (to the file, the IO or the text). Returns: false when it could not be written or the writer has failed Example:LOut.Flush();const method Close(): bool: Ends the document (every element still open is ended), writes out the rest and closes the file / lets the IO go (it stays open); a text writer's Text stays readable. Later calls write nothing. Returns: whether everything was written Example:if not LOut.Close() then println(LOut.ErrorText()); end;const method Text(): string: What a ToText writer has written so far (flushed first). Returns: the text; "" for a writer to a file or an IO Example:println(XMLWriter.ToText().WriteElement("a", "b").Text());
Example: XMLWriter.ToFile("out.xml").StartDocument().WriteElement("item", "a").Close();
System.Zlib.Ext
deflate, inflate and crc32 in Adam, over zlib's C API (System.Zlib.C): whole byte arrays in, whole byte arrays out. ZlibFormat picks the framing: Raw (a zip entry's deflate data), Zlib (RFC 1950) or Gzip (RFC 1952). ZlibDeflate / ZlibInflate return false on a failure and leave the reason in AErrorText; nothing they hand back needs freeing.
Import it with import System.Zlib.Ext;.
Types
ZlibFormat
type ZlibFormat = choices(
The framing around the deflate data.
Members
ZlibFormat.Raw: None: bare deflate data, as a zip entry holds it.ZlibFormat.Zlib: zlib's (RFC 1950): a 2-byte header and an Adler-32 check.ZlibFormat.Gzip: gzip's (RFC 1952): a .gz file's header and a CRC-32 check.
Routines
ZlibCRC32
func cpplink ZlibCRC32(const ACRC: uint32; const AData: ByteArray): uint32
The CRC-32 of some bytes, carried on from an earlier one: a zip entry's and gzip's check.
Parameters
ACRC: the CRC so far (0 to start)AData: the bytes
Returns: the CRC-32 with AData added
Example: LCRC := ZlibCRC32(0, LBytes);
ZlibDeflate
func cpplink ZlibDeflate(const AData: ByteArray; const AFormat: ZlibFormat; const ALevel: int32; var AOut: ByteArray; var AErrorText: string): bool
Compresses bytes with deflate.
Parameters
AData: the bytesAFormat: the framing written around the dataALevel: Z_DEFAULT_COMPRESSION, or 0 (none) .. 9 (best)AOut: the compressed bytesAErrorText: why it failed ("" on a success)
Returns: true when AOut holds the compressed bytes
Example: if ZlibDeflate(LData, ZlibFormat.Gzip, 9, LOut, LError) then WriteAllBytes("data.gz", LOut); end;
ZlibInflate
func cpplink ZlibInflate(const AData: ByteArray; const AFormat: ZlibFormat; var AOut: ByteArray; var AErrorText: string): bool
Decompresses one deflate stream; bytes after the stream's end are not read.
Parameters
AData: the streamAFormat: the framing around itAOut: the decompressed bytesAErrorText: why it failed: bad data, a stream that ends early, one that needs a dictionary ("" on a success)
Returns: true when AOut holds the decompressed bytes