Skip to content
Adam
Libraries

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):

stdlib_collections.adam
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.
output on x86_64-windows-gnu and x86_64-linux-gnu
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

text
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

text
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

text
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;

text
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 text
  • ADecoded: 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

text
type BenchKernel = ref func(): int64

A benchmark kernel: does the work once and returns a checksum of what it computed.

BenchResult

text
type BenchResult = record

What BenchRun measured for one kernel.

Members

  • Name: string: The kernel's name, as given to BenchRun.
  • 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

text
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 computed
  • ARuns: 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

text
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: what BenchRun measured

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

text
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: AItem the 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: AIndex where it goes (Count adds it at the end); AItem the 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: AIndex the item's index.
  • method RemoveLast(): T: Takes the last item off the list; raises code 14 when it is empty. Returns: the item taken off
  • method Clear(): Empties the list (its storage kept for the items added next).
  • const method IndexOf(const AItem: T): int64: Finds an item. Parameters: AItem the item looked for (compared with =). Returns: the index of the first equal item; -1 when there is none
  • const method Contains(const AItem: T): bool: Whether the list holds an item. Parameters: AItem the item looked for (compared with =). Returns: true when an item equals it
  • method Remove(const AItem: T): bool: Takes the first item equal to one out. Parameters: AItem the item looked for (compared with =). Returns: false when there is none
  • method 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

text
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: AKey the key; AValue its value.
  • const method Get(const AKey: K): V: The value of a key; raises code 1 when the map does not hold it. Parameters: AKey the key. Returns: its value
  • const method TryGet(const AKey: K; var AValue: V): bool: The value of a key, when the map holds it. Parameters: AKey the key; AValue its value (left as it was when the map does not hold the key). Returns: true when the map holds the key
  • const method Has(const AKey: K): bool: Whether the map holds a key. Parameters: AKey the key. Returns: true when it does
  • method Remove(const AKey: K): bool: Takes a key and its value out; the last key out empties the map. Parameters: AKey the key. Returns: false when the map does not hold it
  • method 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 put
  • const 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

text
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: AItem the 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: AItem the item. Returns: true when it does
  • method Remove(const AItem: T): bool: Takes an item out. Parameters: AItem the item. Returns: false when the set did not hold it
  • method 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

NameDeclarationDescription
ADAM_COLLECTIONS_EXC_INDEXconst ADAM_COLLECTIONS_EXC_INDEX: int32 = 14The 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_CAPACITYconst ADAM_COLLECTIONS_FIRST_CAPACITY: int64 = 4A list's first storage, doubled each time it is full.
ADAM_COLLECTIONS_EXC_KEYconst ADAM_COLLECTIONS_EXC_KEY: int32 = 1The code a map's Get of a key it does not hold raises with.
ADAM_COLLECTIONS_FIRST_INDEXconst ADAM_COLLECTIONS_FIRST_INDEX: int64 = 8A map index's first size (a power of two, doubled while it is more than half used after a rebuild).
ADAM_COLLECTIONS_SLOT_EMPTYconst ADAM_COLLECTIONS_SLOT_EMPTY: int64 = 0A map index slot no entry has used (any other slot holds its entry's position + 1).
ADAM_COLLECTIONS_SLOT_REMOVEDconst ADAM_COLLECTIONS_SLOT_REMOVED: int64 = -1A 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

text
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

text
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

text
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

text
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 .. 255
  • G: uint8: The green component, 0 .. 255
  • B: uint8: The blue component, 0 .. 255
  • init(): Black (0, 0, 0).
  • init(const AR: uint8; const AG: uint8; const AB: uint8): The colour (AR, AG, AB). Parameters: AR red, 0-255; AG green, 0-255; AB blue, 0-255.

Example: LGold: RGB(255, 215, 0);

Constants

NameDeclarationDescription
CsiEscconst CsiEsc: string = "\x1b"The escape character (ESC, 0x1B), the start of every sequence.
CsiCrconst CsiCr: string = "\r"A carriage return: the cursor to the start of its line.
CsiLfconst CsiLf: string = "\n"A line feed, the line break WriteLn writes.
CsiCrLfconst CsiCrLf: string = "\r\n"A carriage return and a line feed.
CsiSaveCursorPositionconst 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).
CsiRestoreCursorPositionconst 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).
CsiShowCursorconst 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.
CsiHideCursorconst 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.
CsiBlinkCursorconst 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.
CsiSteadyCursorconst 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.
CsiClearScreenconst 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).
CsiClearScrollbackconst 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.
CsiClearLineconst 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).
CsiClearToEndOfLineconst 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.
CsiBoldconst 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.
CsiDimconst 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.
CsiItalicconst 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.
CsiUnderlineconst 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.
CsiBlinkconst 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.
CsiInvertColorsconst 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.
CsiStrikeconst 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.
CsiNormalColorsconst 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.
CsiFramedconst 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.
CsiEncircledconst 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.
CsiResetFormatconst 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.
CsiResetForegroundconst 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.
CsiResetBackgroundconst 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.
CsiFgBlackconst 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).
CsiFgRedconst 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).
CsiFgGreenconst 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).
CsiFgYellowconst 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).
CsiFgBlueconst 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).
CsiFgMagentaconst 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).
CsiFgCyanconst 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).
CsiFgWhiteconst 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).
CsiBgBlackconst 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).
CsiBgRedconst 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).
CsiBgGreenconst 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).
CsiBgYellowconst 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).
CsiBgBlueconst 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).
CsiBgMagentaconst 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).
CsiBgCyanconst 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).
CsiBgWhiteconst 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).
CsiFgBrightBlackconst 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).
CsiFgBrightRedconst 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).
CsiFgBrightGreenconst 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).
CsiFgBrightYellowconst 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).
CsiFgBrightBlueconst 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).
CsiFgBrightMagentaconst 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).
CsiFgBrightCyanconst 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).
CsiFgBrightWhiteconst 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).
CsiBgBrightBlackconst 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).
CsiBgBrightRedconst 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).
CsiBgBrightGreenconst 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).
CsiBgBrightYellowconst 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).
CsiBgBrightBlueconst 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).
CsiBgBrightMagentaconst 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).
CsiBgBrightCyanconst 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).
CsiBgBrightWhiteconst 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).
CsiBgDarkGreyconst 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.
KeyEnterconst KeyEnter: string = "\r"What ReadKey gives for Enter, on every target.
KeyEscapeconst KeyEscape: string = "\x1b"What ReadKey gives for Escape, on every target.
KeyBackspaceconst KeyBackspace: string = "\x08"What ReadKey gives for Backspace, on every target.

Routines

CsiCursorPosition

text
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 column
  • AY: the line

Returns: the sequence (CSI is 1-based, row first: (4, 2) is ESC[3;5H)

CsiCursorColumn

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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)

text
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)

text
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

text
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

text
func cpplink SetEscapeMode(const AMode: EscapeMode)

Sets when escape sequences are written (Auto by default).

Parameters

  • AMode: the new mode

GetEscapeMode

text
func cpplink GetEscapeMode(): EscapeMode

The escape mode now.

Returns: the mode SetEscapeMode set last (Auto at start)

IsTerminal

text
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

text
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

text
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

text
func cpplink WriteEscape(const ASequence: string)

Writes an escape sequence to standard output while EscapesEnabled, else nothing.

Parameters

  • ASequence: the sequence

SetCursorPosition

text
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 column
  • AY: the line

SetCursorColumn

text
func cpplink SetCursorColumn(const AX: int32)

Puts the cursor at column AX of its line (0-based).

Parameters

  • AX: the column

MoveCursorUp

text
func cpplink MoveCursorUp()

Moves the cursor up one line.

text
func cpplink MoveCursorUp(const ALines: int32)

Moves the cursor up ALines lines (<= 0: not at all).

Parameters

  • ALines: how far

MoveCursorDown

text
func cpplink MoveCursorDown()

Moves the cursor down one line.

text
func cpplink MoveCursorDown(const ALines: int32)

Moves the cursor down ALines lines (<= 0: not at all).

Parameters

  • ALines: how far

MoveCursorForward

text
func cpplink MoveCursorForward()

Moves the cursor right one column.

text
func cpplink MoveCursorForward(const AColumns: int32)

Moves the cursor right AColumns columns (<= 0: not at all).

Parameters

  • AColumns: how far

MoveCursorBack

text
func cpplink MoveCursorBack()

Moves the cursor left one column.

text
func cpplink MoveCursorBack(const AColumns: int32)

Moves the cursor left AColumns columns (<= 0: not at all).

Parameters

  • AColumns: how far

SaveCursorPosition

text
func cpplink SaveCursorPosition()

Saves the cursor's position.

RestoreCursorPosition

text
func cpplink RestoreCursorPosition()

Puts the cursor back where SaveCursorPosition saved it.

HideCursor

text
func cpplink HideCursor()

Hides the cursor.

ShowCursor

text
func cpplink ShowCursor()

Shows the cursor.

ClearScreen

text
func cpplink ClearScreen()

Clears the screen and its scrollback and puts the cursor at the top left.

ClearLine

text
func cpplink ClearLine()

Clears the cursor's line; the cursor stays where it is.

text
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

text
func cpplink ClearToEndOfLine()

Clears from the cursor to the end of its line.

InsertLines

text
func cpplink InsertLines()

Inserts one blank line at the cursor.

text
func cpplink InsertLines(const ALines: int32)

Inserts ALines blank lines at the cursor (<= 0: none).

Parameters

  • ALines: how many

DeleteLines

text
func cpplink DeleteLines()

Deletes the cursor's line.

text
func cpplink DeleteLines(const ALines: int32)

Deletes ALines lines at the cursor (<= 0: none).

Parameters

  • ALines: how many

ScrollUp

text
func cpplink ScrollUp()

Scrolls the screen up one line.

text
func cpplink ScrollUp(const ALines: int32)

Scrolls the screen up ALines lines (<= 0: not at all).

Parameters

  • ALines: how far

ScrollDown

text
func cpplink ScrollDown()

Scrolls the screen down one line.

text
func cpplink ScrollDown(const ALines: int32)

Scrolls the screen down ALines lines (<= 0: not at all).

Parameters

  • ALines: how far

InsertChars

text
func cpplink InsertChars()

Inserts one blank at the cursor.

text
func cpplink InsertChars(const ACount: int32)

Inserts ACount blanks at the cursor (<= 0: none).

Parameters

  • ACount: how many

DeleteChars

text
func cpplink DeleteChars()

Deletes the character at the cursor.

text
func cpplink DeleteChars(const ACount: int32)

Deletes ACount characters at the cursor (<= 0: none).

Parameters

  • ACount: how many

EraseChars

text
func cpplink EraseChars()

Blanks the character at the cursor.

text
func cpplink EraseChars(const ACount: int32)

Blanks ACount characters at the cursor (<= 0: none).

Parameters

  • ACount: how many

SetBold

text
func cpplink SetBold()

Bold text from here (until ResetFormat or the next Write's reset).

ResetFormat

text
func cpplink ResetFormat()

Resets bold, the colours and every other attribute.

SetForegroundColor

text
func cpplink SetForegroundColor(const AColor: TextColor)

The text colour from here, a standard colour.

Parameters

  • AColor: the colour
text
func cpplink SetForegroundColor(const AColor: RGB)

The text colour from here, a 24-bit colour.

Parameters

  • AColor: the colour

SetBackgroundColor

text
func cpplink SetBackgroundColor(const AColor: TextColor)

The background colour from here, a standard colour.

Parameters

  • AColor: the colour
text
func cpplink SetBackgroundColor(const AColor: RGB)

The background colour from here, a 24-bit colour.

Parameters

  • AColor: the colour

TextColorAt

text
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

text
func cpplink GetTerminalWidth(): int32

The terminal's visible width in columns; 80 when standard output is not a terminal.

Returns: the width

GetTerminalHeight

text
func cpplink GetTerminalHeight(): int32

The terminal's visible height in lines; 25 when standard output is not a terminal.

Returns: the height

DisplayWidth

text
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

text
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 text
  • AWidth: the columns to fill

Returns: the padded text

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 text
  • AWidth: the columns to fill
  • APad: the pad character

Returns: the padded text

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 text
  • AWidth: the columns to fill
  • APad: the pad character
  • AAlign: where the text sits

Returns: the padded text

Example: PadText("ab", 7, ".", TextAlign.Center) is "..ab..."

RuleText

text
func cpplink RuleText(const AChar: string; const AWidth: int32): string

AWidth columns of AChar, filled as PadText fills.

Parameters

  • AChar: the character
  • AWidth: the columns; <= 0 gives ""

Returns: the rule

ProgressBarText

text
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 done
  • ATotal: all the work
  • AWidth: the bar's columns between the brackets (below 0 counts as 0)

Returns: the bar text

SpinnerFrame

text
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

text
func cpplink HorizontalRule()

A line of "-" as wide as the terminal, then a line break.

text
func cpplink HorizontalRule(const AChar: string)

A line of AChar as wide as the terminal, then a line break.

Parameters

  • AChar: the character
text
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 character
  • AWidth: the columns

WritePadded

text
func cpplink WritePadded(const AText: string; const AWidth: int32)

Writes PadText(AText, AWidth).

Parameters

  • AText: the text
  • AWidth: the columns to fill
text
func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string)

Writes PadText(AText, AWidth, APad).

Parameters

  • AText: the text
  • AWidth: the columns to fill
  • APad: the pad character
text
func cpplink WritePadded(const AText: string; const AWidth: int32; const APad: string; const AAlign: TextAlign)

Writes PadText(AText, AWidth, APad, AAlign).

Parameters

  • AText: the text
  • AWidth: the columns to fill
  • APad: the pad character
  • AAlign: where the text sits

ProgressBar

text
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 done
  • ATotal: all the work
text
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 done
  • ATotal: all the work
  • AWidth: the bar's columns
text
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 done
  • ATotal: all the work
  • AWidth: the bar's columns
  • AColor: the bar's colour
text
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 done
  • ATotal: all the work
  • AWidth: the bar's columns
  • AColor: the bar's colour

WaitForAnyKey

text
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

text
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

text
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 always
  • AColor: the message's colour
  • AMessage: the message; "" gives "Press any key to continue... "
text
func cpplink Pause()

Pause(false, TextColor.White, "Press any key to continue... ").

text
func cpplink Pause(const AForce: bool)

Pause(AForce, TextColor.White, "Press any key to continue... ").

Parameters

  • AForce: true to pause always
text
func cpplink Pause(const AForce: bool; const AColor: TextColor)

Pause(AForce, AColor, "Press any key to continue... ").

Parameters

  • AForce: true to pause always
  • AColor: the message's colour

SetTitle

text
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

text
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

text
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

text
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

text
func cpplink IsEscapeKey(const AKey: string): bool

Whether a ReadKey result is Escape.

Parameters

  • AKey: a ReadKey result

Returns: true for Escape

WaitForKey

text
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" ...)
text
func cpplink WaitForKey()

Waits until ReadKey gives Enter; returns at once with no keyboard.

WaitForEnter

text
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;

text
func cpplink WaitForEnter(): bool

WaitForEnter("Press ENTER to continue...", "").

Returns: false

text
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

text
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

text
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

text
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

text
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

text
func cpplink ConsolePlatformKeyboard(): bool

True when standard input is a terminal (a keyboard to read)

Returns: true for a terminal standard input

ConsolePlatformDropKeys

text
func cpplink ConsolePlatformDropKeys()

The keys typed so far dropped (those already read and the terminal's queue)

ConsolePlatformClosesWithProgram

text
func cpplink ConsolePlatformClosesWithProgram(): bool

A terminal outlives the program that runs in it: never true on linux

Returns: false, always

ConsolePlatformWaitKey

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
func cpplink ConsolePlatformWidth(): int32

The console window's visible columns; 0 when standard output is no console

Returns: the columns, or 0

ConsolePlatformHeight

text
func cpplink ConsolePlatformHeight(): int32

The console window's visible lines; 0 when standard output is no console

Returns: the lines, or 0

ConsolePlatformKeyboard

text
func cpplink ConsolePlatformKeyboard(): bool

True when standard input is a console (a keyboard to read)

Returns: true for a terminal standard input

ConsolePlatformDropKeys

text
func cpplink ConsolePlatformDropKeys()

The keys typed so far dropped

ConsolePlatformClosesWithProgram

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
type IOSeekCallback = func(const AUserData: ptr; const AOffset: int64;

An IO's Seek: returns the new position, or -1.

IOTellCallback

text
type IOTellCallback = func(const AUserData: ptr): int64

An IO's Tell: returns the position, or -1.

IOSizeCallback

text
type IOSizeCallback = func(const AUserData: ptr): int64

An IO's Size: returns the size in bytes, or -1 when the stream has none.

IOFlushCallback

text
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

text
type IOCloseCallback = func(const AUserData: ptr): bool

An IO's Close: releases the stream's own resources; false when that failed.

IOTruncateCallback

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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 at APath, replacing a file there; its folder must exist. Parameters: APath the archive's path. Returns: false (the reason in ErrorText) when an archive is open already, the file cannot be created or there is no room
  • method AddFile(const APath: string; const AName: string; const AMethod: ZipEntryMethod; const AUnixMode: uint32; const APassword: string; const AProgress: ZipProgress): bool: Adds the file APath as the entry AName: its CRC read in a first pass, then its bytes. Parameters: APath the file; AName the entry's name in the archive (UTF-8, / between folders); AMethod Deflate or Store; AUnixMode 0: an entry made by MS-DOS with no attributes; else the Unix permission bits of a regular file (0x1ED = octal 755; at most 0xFFF = octal 7777), the entry made by Unix, so unzip on Linux gives the file that mode; APassword ZipCrypto's password ("" for none); AProgress called for the entry's progress (ZipProgress, a closure), nil for none. Returns: false (the reason in ErrorText) 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: Close it)
  • method AddFile(const APath: string; const AName: string): bool: Adds the file APath as the entry AName, deflated, no mode, no password, no progress. Parameters: APath the file; AName the entry's name in the archive. Returns: false (the reason in ErrorText) as the full AddFile
  • method Close(): bool: Finishes the open archive: its central directory written, the file closed. Returns: false (the reason in ErrorText) when no archive is open, or the directory or the file cannot be finished (the archive is then incomplete); the writer is closed either way
  • done: Closes an archive still open (its result lost: call Close to know it).
  • const method IsOpen(): bool: True while an archive is open (between a good Open and Close). Returns: true while open
  • const method ErrorText(): string: Why the last Open, AddFile or Close failed: the step and the path; "" after a success. Returns: the reason, or ""
  • const method EntryCRC(): uint32: The CRC-32 of the file the last good AddFile wrote (0 before any). Returns: the CRC-32
  • const method EntrySize(): int64: The size in bytes of the file the last good AddFile wrote (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

text
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 callbacks
  • AUserData: the pointer every callback receives

Returns: the IO, or nil when there is no room

IORead

text
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 IO
  • ABuffer: where the bytes go
  • ASize: the most bytes to read

Returns: the count read

IOWrite

text
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 IO
  • ABuffer: the bytes
  • ASize: how many to write

Returns: the count written

IOSeek

text
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 IO
  • AOffset: the offset
  • AOrigin: where it counts from

Returns: the new position, or -1

IOTell

text
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

text
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

text
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

text
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 IO
  • ASize: the new size in bytes (>= 0)

Returns: false on failure

IOClose

text
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

text
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

text
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

text
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

text
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 IO
  • ABuffer: where the bytes go
  • ASize: how many to read

Returns: the count read

IOWriteFull

text
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 IO
  • ABuffer: the bytes
  • ASize: how many to write

Returns: the count written

IOReadAll

text
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 IO
  • AData: receives the bytes

Returns: false on a failure

Example: if IOReadAll(LIO, LText) then println("{} bytes", len(LText)); end;

IOSameContent

text
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 IO
  • ARight: the other

Returns: true when their bytes are the same

IOCopy

text
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 read
  • ADest: the IO written

Returns: the count copied

CreateMemoryIO

text
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 bytes
  • AReadOnly: true for a read-only IO

Returns: the IO, or nil

text
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

text
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

text
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 file
  • AMode: how it opens

Returns: the IO, or nil

Example: LIO := CreateFileIO("$P:save.dat", FileMode.Write);

CreateIOSource

text
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 callbacks
  • AUserData: the pointer every callback receives

Returns: the source, or nil

IOSourceOpen

text
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 source
  • APath: the entry
  • AMode: how it opens

Returns: the IO, or nil

text
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 source
  • APath: the entry

Returns: the IO, or nil

IOSourceExists

text
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 source
  • APath: the entry

Returns: true when it has the entry

IOSourceFolderExists

text
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 source
  • APath: the folder

Returns: true for a folder of the source

Example: if IOSourceFolderExists(LZip, "res/assets/models") then ... end;

IOSourceSize

text
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 source
  • APath: the entry

Returns: the size in bytes, or -1

IOSourceRemove

text
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 source
  • APath: the entry

Returns: true when deleted

IOSourceCanRemove

text
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

text
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

text
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

text
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 seeked
  • APassword: the encrypted entries' password ("" for none)

Returns: the source, or nil

text
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

text
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 file
  • APassword: the encrypted entries' password ("" for none)

Returns: the source, or nil

Example: LZip := CreateZipIOSource("$P:assets.zip", "Adam");

text
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

text
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 seeked
  • AEntry: the entry
  • APassword: the password ("" for none)

Returns: the IO, or nil

text
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 seeked
  • AEntry: the entry

Returns: the IO, or nil

text
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 file
  • AEntry: the entry
  • APassword: the password ("" for none)

Returns: the IO, or nil

text
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 file
  • AEntry: the entry

Returns: the IO, or nil

GetZipEntryInfo

text
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 file
  • AEntry: the entry
  • APassword: 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

text
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 write
  • AFolder: the folder to pack
  • APassword: 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

text
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 write
  • AFolder: the folder to pack
  • APassword: ZipCrypto's password ("" for none)
  • ARoot: the folder entry names start below ("" for AFolder)

Returns: false (the reason in ZipLastError) on a failure

text
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 write
  • AFolder: the folder to pack
  • APassword: ZipCrypto's password ("" for none)

Returns: false (the reason in ZipLastError) on a failure

text
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 write
  • AFolder: 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

text
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

text
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, as CreateFileIO takes 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

text
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 Stop
  • method ElapsedTicks(): int64: The ticks elapsed (Frequency per second): the total, and the running span so far. Returns: the elapsed ticks
  • method ElapsedMilliseconds(): int64: The whole milliseconds elapsed (ElapsedTicks scaled by Frequency, rounded down). Returns: the elapsed milliseconds
  • method Frequency(): int64: The clock's ticks per second. Returns: the ticks per second (above 0)

Example: LWatch := StartNew(); Work(); println("{} ms", LWatch.ElapsedMilliseconds());

Constants

NameDeclarationDescription
ADAM_DIAGNOSTICS_MS_PER_SECONDconst ADAM_DIAGNOSTICS_MS_PER_SECOND: int64 = 1000Milliseconds in a second (ElapsedMilliseconds' scale).

Routines

StartNew

text
func cpplink StartNew(): Stopwatch

A new Stopwatch, already running.

Returns: the running stopwatch

Example: LWatch := StartNew();

GetTimeStamp

text
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

NameDeclarationDescription
EI_NIDENTconst EI_NIDENT: int32 = 16The 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
ELFMAG0const ELFMAG0: uint8 = 0x7FThe 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
ELFMAG1const ELFMAG1: uint8 = 0x45The 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
ELFMAG2const ELFMAG2: uint8 = 0x4CThe 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
ELFMAG3const ELFMAG3: uint8 = 0x46The 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_CLASSconst EI_CLASS: int32 = 4The 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_DATAconst EI_DATA: int32 = 5The 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_VERSIONconst EI_VERSION: int32 = 6The 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_OSABIconst EI_OSABI: int32 = 7The 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_ABIVERSIONconst EI_ABIVERSION: int32 = 8The 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
ELFCLASS64const ELFCLASS64: uint8 = 2The 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
ELFDATA2LSBconst ELFDATA2LSB: uint8 = 1The 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_SYSVconst ELFOSABI_SYSV: uint8 = 0The 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_CURRENTconst EV_CURRENT: uint32 = 1The 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_NONEconst ET_NONE: uint16 = 0The ELF format's ET_NONE: e_type and e_machine
ET_RELconst ET_REL: uint16 = 1The ELF format's ET_REL: e_type and e_machine
ET_EXECconst ET_EXEC: uint16 = 2The ELF format's ET_EXEC: e_type and e_machine
ET_DYNconst ET_DYN: uint16 = 3The ELF format's ET_DYN: e_type and e_machine
EM_X86_64const EM_X86_64: uint16 = 0x3EThe ELF format's EM_X86_64: e_type and e_machine
SHT_NULLconst SHT_NULL: uint32 = 0The ELF format's SHT_NULL: sh_type
SHT_PROGBITSconst SHT_PROGBITS: uint32 = 1The ELF format's SHT_PROGBITS: sh_type
SHT_SYMTABconst SHT_SYMTAB: uint32 = 2The ELF format's SHT_SYMTAB: sh_type
SHT_STRTABconst SHT_STRTAB: uint32 = 3The ELF format's SHT_STRTAB: sh_type
SHT_RELAconst SHT_RELA: uint32 = 4The ELF format's SHT_RELA: sh_type
SHT_HASHconst SHT_HASH: uint32 = 5The ELF format's SHT_HASH: sh_type
SHT_DYNAMICconst SHT_DYNAMIC: uint32 = 6The ELF format's SHT_DYNAMIC: sh_type
SHT_NOTEconst SHT_NOTE: uint32 = 7The ELF format's SHT_NOTE: sh_type
SHT_NOBITSconst SHT_NOBITS: uint32 = 8The ELF format's SHT_NOBITS: sh_type
SHT_RELconst SHT_REL: uint32 = 9The ELF format's SHT_REL: sh_type
SHT_DYNSYMconst SHT_DYNSYM: uint32 = 11The ELF format's SHT_DYNSYM: sh_type
SHT_INIT_ARRAYconst SHT_INIT_ARRAY: uint32 = 14The ELF format's SHT_INIT_ARRAY: sh_type
SHT_FINI_ARRAYconst SHT_FINI_ARRAY: uint32 = 15The ELF format's SHT_FINI_ARRAY: sh_type
SHT_PREINIT_ARRAYconst SHT_PREINIT_ARRAY: uint32 = 16The ELF format's SHT_PREINIT_ARRAY: sh_type
SHT_GROUPconst SHT_GROUP: uint32 = 17The ELF format's SHT_GROUP: sh_type
SHT_SYMTAB_SHNDXconst SHT_SYMTAB_SHNDX: uint32 = 18The ELF format's SHT_SYMTAB_SHNDX: sh_type
SHT_GNU_HASHconst SHT_GNU_HASH: uint32 = 0x6FFFFFF6The ELF format's SHT_GNU_HASH: sh_type
SHT_GNU_verdefconst SHT_GNU_verdef: uint32 = 0x6FFFFFFDThe ELF format's SHT_GNU_verdef: sh_type
SHT_GNU_verneedconst SHT_GNU_verneed: uint32 = 0x6FFFFFFEThe ELF format's SHT_GNU_verneed: sh_type
SHT_GNU_versymconst SHT_GNU_versym: uint32 = 0x6FFFFFFFThe ELF format's SHT_GNU_versym: sh_type
SHT_X86_64_UNWINDconst SHT_X86_64_UNWIND: uint32 = 0x70000001The ELF format's SHT_X86_64_UNWIND: sh_type
SHF_WRITEconst SHF_WRITE: uint64 = 0x1The ELF format's SHF_WRITE: sh_flags
SHF_ALLOCconst SHF_ALLOC: uint64 = 0x2The ELF format's SHF_ALLOC: sh_flags
SHF_EXECINSTRconst SHF_EXECINSTR: uint64 = 0x4The ELF format's SHF_EXECINSTR: sh_flags
SHF_MERGEconst SHF_MERGE: uint64 = 0x10The ELF format's SHF_MERGE: sh_flags
SHF_STRINGSconst SHF_STRINGS: uint64 = 0x20The ELF format's SHF_STRINGS: sh_flags
SHF_INFO_LINKconst SHF_INFO_LINK: uint64 = 0x40The ELF format's SHF_INFO_LINK: sh_flags
SHF_LINK_ORDERconst SHF_LINK_ORDER: uint64 = 0x80The ELF format's SHF_LINK_ORDER: sh_flags
SHF_GROUPconst SHF_GROUP: uint64 = 0x200The ELF format's SHF_GROUP: sh_flags
SHF_TLSconst SHF_TLS: uint64 = 0x400The ELF format's SHF_TLS: sh_flags
SHF_COMPRESSEDconst SHF_COMPRESSED: uint64 = 0x800The ELF format's SHF_COMPRESSED: sh_flags
SHF_EXCLUDEconst SHF_EXCLUDE: uint64 = 0x80000000The ELF format's SHF_EXCLUDE: sh_flags
GRP_COMDATconst GRP_COMDAT: uint32 = 0x1The ELF format's GRP_COMDAT: A section group's flag word: a COMDAT group
SHN_UNDEFconst SHN_UNDEF: uint16 = 0The ELF format's SHN_UNDEF: The special section indices (st_shndx, e_shstrndx)
SHN_LORESERVEconst SHN_LORESERVE: uint16 = 0xFF00The ELF format's SHN_LORESERVE: The special section indices (st_shndx, e_shstrndx)
SHN_ABSconst SHN_ABS: uint16 = 0xFFF1The ELF format's SHN_ABS: The special section indices (st_shndx, e_shstrndx)
SHN_COMMONconst SHN_COMMON: uint16 = 0xFFF2The ELF format's SHN_COMMON: The special section indices (st_shndx, e_shstrndx)
SHN_XINDEXconst SHN_XINDEX: uint16 = 0xFFFFThe ELF format's SHN_XINDEX: The special section indices (st_shndx, e_shstrndx)
STB_LOCALconst STB_LOCAL: uint8 = 0The 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_GLOBALconst STB_GLOBAL: uint8 = 1The 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_WEAKconst STB_WEAK: uint8 = 2The 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_UNIQUEconst STB_GNU_UNIQUE: uint8 = 10The 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_NOTYPEconst STT_NOTYPE: uint8 = 0The 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_OBJECTconst STT_OBJECT: uint8 = 1The 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_FUNCconst STT_FUNC: uint8 = 2The 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_SECTIONconst STT_SECTION: uint8 = 3The 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_FILEconst STT_FILE: uint8 = 4The 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_COMMONconst STT_COMMON: uint8 = 5The 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_TLSconst STT_TLS: uint8 = 6The 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_IFUNCconst STT_GNU_IFUNC: uint8 = 10The 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_DEFAULTconst STV_DEFAULT: uint8 = 0The 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_INTERNALconst STV_INTERNAL: uint8 = 1The 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_HIDDENconst STV_HIDDEN: uint8 = 2The 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_PROTECTEDconst STV_PROTECTED: uint8 = 3The 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_NONEconst R_X86_64_NONE: uint32 = 0The ELF format's R_X86_64_NONE: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_64const R_X86_64_64: uint32 = 1The ELF format's R_X86_64_64: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_PC32const R_X86_64_PC32: uint32 = 2The ELF format's R_X86_64_PC32: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_GOT32const R_X86_64_GOT32: uint32 = 3The ELF format's R_X86_64_GOT32: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_PLT32const R_X86_64_PLT32: uint32 = 4The ELF format's R_X86_64_PLT32: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_COPYconst R_X86_64_COPY: uint32 = 5The ELF format's R_X86_64_COPY: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_GLOB_DATconst R_X86_64_GLOB_DAT: uint32 = 6The ELF format's R_X86_64_GLOB_DAT: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_JUMP_SLOTconst R_X86_64_JUMP_SLOT: uint32 = 7The ELF format's R_X86_64_JUMP_SLOT: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_RELATIVEconst R_X86_64_RELATIVE: uint32 = 8The ELF format's R_X86_64_RELATIVE: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_GOTPCRELconst R_X86_64_GOTPCREL: uint32 = 9The ELF format's R_X86_64_GOTPCREL: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_32const R_X86_64_32: uint32 = 10The ELF format's R_X86_64_32: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_32Sconst R_X86_64_32S: uint32 = 11The ELF format's R_X86_64_32S: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_16const R_X86_64_16: uint32 = 12The ELF format's R_X86_64_16: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_PC16const R_X86_64_PC16: uint32 = 13The ELF format's R_X86_64_PC16: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_8const R_X86_64_8: uint32 = 14The ELF format's R_X86_64_8: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_PC8const R_X86_64_PC8: uint32 = 15The ELF format's R_X86_64_PC8: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_DTPMOD64const R_X86_64_DTPMOD64: uint32 = 16The ELF format's R_X86_64_DTPMOD64: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_DTPOFF64const R_X86_64_DTPOFF64: uint32 = 17The ELF format's R_X86_64_DTPOFF64: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_TPOFF64const R_X86_64_TPOFF64: uint32 = 18The ELF format's R_X86_64_TPOFF64: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_TLSGDconst R_X86_64_TLSGD: uint32 = 19The ELF format's R_X86_64_TLSGD: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_TLSLDconst R_X86_64_TLSLD: uint32 = 20The ELF format's R_X86_64_TLSLD: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_DTPOFF32const R_X86_64_DTPOFF32: uint32 = 21The ELF format's R_X86_64_DTPOFF32: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_GOTTPOFFconst R_X86_64_GOTTPOFF: uint32 = 22The ELF format's R_X86_64_GOTTPOFF: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_TPOFF32const R_X86_64_TPOFF32: uint32 = 23The ELF format's R_X86_64_TPOFF32: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_PC64const R_X86_64_PC64: uint32 = 24The ELF format's R_X86_64_PC64: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_GOTOFF64const R_X86_64_GOTOFF64: uint32 = 25The ELF format's R_X86_64_GOTOFF64: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_GOTPC32const R_X86_64_GOTPC32: uint32 = 26The ELF format's R_X86_64_GOTPC32: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_SIZE32const R_X86_64_SIZE32: uint32 = 32The ELF format's R_X86_64_SIZE32: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_SIZE64const R_X86_64_SIZE64: uint32 = 33The ELF format's R_X86_64_SIZE64: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_GOTPC32_TLSDESCconst R_X86_64_GOTPC32_TLSDESC: uint32 = 34The ELF format's R_X86_64_GOTPC32_TLSDESC: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_TLSDESC_CALLconst R_X86_64_TLSDESC_CALL: uint32 = 35The ELF format's R_X86_64_TLSDESC_CALL: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_TLSDESCconst R_X86_64_TLSDESC: uint32 = 36The ELF format's R_X86_64_TLSDESC: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_IRELATIVEconst R_X86_64_IRELATIVE: uint32 = 37The ELF format's R_X86_64_IRELATIVE: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_RELATIVE64const R_X86_64_RELATIVE64: uint32 = 38The ELF format's R_X86_64_RELATIVE64: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_GOTPCRELXconst R_X86_64_GOTPCRELX: uint32 = 41The ELF format's R_X86_64_GOTPCRELX: The x86_64 relocation types (r_info's low 32 bits)
R_X86_64_REX_GOTPCRELXconst R_X86_64_REX_GOTPCRELX: uint32 = 42The ELF format's R_X86_64_REX_GOTPCRELX: The x86_64 relocation types (r_info's low 32 bits)
PT_NULLconst PT_NULL: uint32 = 0The ELF format's PT_NULL: p_type and p_flags
PT_LOADconst PT_LOAD: uint32 = 1The ELF format's PT_LOAD: p_type and p_flags
PT_DYNAMICconst PT_DYNAMIC: uint32 = 2The ELF format's PT_DYNAMIC: p_type and p_flags
PT_INTERPconst PT_INTERP: uint32 = 3The ELF format's PT_INTERP: p_type and p_flags
PT_NOTEconst PT_NOTE: uint32 = 4The ELF format's PT_NOTE: p_type and p_flags
PT_PHDRconst PT_PHDR: uint32 = 6The ELF format's PT_PHDR: p_type and p_flags
PT_TLSconst PT_TLS: uint32 = 7The ELF format's PT_TLS: p_type and p_flags
PT_GNU_EH_FRAMEconst PT_GNU_EH_FRAME: uint32 = 0x6474E550The ELF format's PT_GNU_EH_FRAME: p_type and p_flags
PT_GNU_STACKconst PT_GNU_STACK: uint32 = 0x6474E551The ELF format's PT_GNU_STACK: p_type and p_flags
PT_GNU_RELROconst PT_GNU_RELRO: uint32 = 0x6474E552The ELF format's PT_GNU_RELRO: p_type and p_flags
PT_GNU_PROPERTYconst PT_GNU_PROPERTY: uint32 = 0x6474E553The ELF format's PT_GNU_PROPERTY: p_type and p_flags
PF_Xconst PF_X: uint32 = 0x1The ELF format's PF_X: p_type and p_flags
PF_Wconst PF_W: uint32 = 0x2The ELF format's PF_W: p_type and p_flags
PF_Rconst PF_R: uint32 = 0x4The ELF format's PF_R: p_type and p_flags
DT_NULLconst DT_NULL: int64 = 0The ELF format's DT_NULL: d_tag
DT_NEEDEDconst DT_NEEDED: int64 = 1The ELF format's DT_NEEDED: d_tag
DT_PLTRELSZconst DT_PLTRELSZ: int64 = 2The ELF format's DT_PLTRELSZ: d_tag
DT_PLTGOTconst DT_PLTGOT: int64 = 3The ELF format's DT_PLTGOT: d_tag
DT_HASHconst DT_HASH: int64 = 4The ELF format's DT_HASH: d_tag
DT_STRTABconst DT_STRTAB: int64 = 5The ELF format's DT_STRTAB: d_tag
DT_SYMTABconst DT_SYMTAB: int64 = 6The ELF format's DT_SYMTAB: d_tag
DT_RELAconst DT_RELA: int64 = 7The ELF format's DT_RELA: d_tag
DT_RELASZconst DT_RELASZ: int64 = 8The ELF format's DT_RELASZ: d_tag
DT_RELAENTconst DT_RELAENT: int64 = 9The ELF format's DT_RELAENT: d_tag
DT_STRSZconst DT_STRSZ: int64 = 10The ELF format's DT_STRSZ: d_tag
DT_SYMENTconst DT_SYMENT: int64 = 11The ELF format's DT_SYMENT: d_tag
DT_INITconst DT_INIT: int64 = 12The ELF format's DT_INIT: d_tag
DT_FINIconst DT_FINI: int64 = 13The ELF format's DT_FINI: d_tag
DT_SONAMEconst DT_SONAME: int64 = 14The ELF format's DT_SONAME: d_tag
DT_RPATHconst DT_RPATH: int64 = 15The ELF format's DT_RPATH: d_tag
DT_SYMBOLICconst DT_SYMBOLIC: int64 = 16The ELF format's DT_SYMBOLIC: d_tag
DT_PLTRELconst DT_PLTREL: int64 = 20The ELF format's DT_PLTREL: d_tag
DT_DEBUGconst DT_DEBUG: int64 = 21The ELF format's DT_DEBUG: d_tag
DT_TEXTRELconst DT_TEXTREL: int64 = 22The ELF format's DT_TEXTREL: d_tag
DT_JMPRELconst DT_JMPREL: int64 = 23The ELF format's DT_JMPREL: d_tag
DT_BIND_NOWconst DT_BIND_NOW: int64 = 24The ELF format's DT_BIND_NOW: d_tag
DT_INIT_ARRAYconst DT_INIT_ARRAY: int64 = 25The ELF format's DT_INIT_ARRAY: d_tag
DT_FINI_ARRAYconst DT_FINI_ARRAY: int64 = 26The ELF format's DT_FINI_ARRAY: d_tag
DT_INIT_ARRAYSZconst DT_INIT_ARRAYSZ: int64 = 27The ELF format's DT_INIT_ARRAYSZ: d_tag
DT_FINI_ARRAYSZconst DT_FINI_ARRAYSZ: int64 = 28The ELF format's DT_FINI_ARRAYSZ: d_tag
DT_RUNPATHconst DT_RUNPATH: int64 = 29The ELF format's DT_RUNPATH: d_tag
DT_FLAGSconst DT_FLAGS: int64 = 30The ELF format's DT_FLAGS: d_tag
DT_PREINIT_ARRAYconst DT_PREINIT_ARRAY: int64 = 32The ELF format's DT_PREINIT_ARRAY: d_tag
DT_PREINIT_ARRAYSZconst DT_PREINIT_ARRAYSZ: int64 = 33The ELF format's DT_PREINIT_ARRAYSZ: d_tag
DT_GNU_HASHconst DT_GNU_HASH: int64 = 0x6FFFFEF5The ELF format's DT_GNU_HASH: d_tag
DT_VERSYMconst DT_VERSYM: int64 = 0x6FFFFFF0The ELF format's DT_VERSYM: d_tag
DT_RELACOUNTconst DT_RELACOUNT: int64 = 0x6FFFFFF9The ELF format's DT_RELACOUNT: d_tag
DT_FLAGS_1const DT_FLAGS_1: int64 = 0x6FFFFFFBThe ELF format's DT_FLAGS_1: d_tag
DT_VERNEEDconst DT_VERNEED: int64 = 0x6FFFFFFEThe ELF format's DT_VERNEED: d_tag
DT_VERNEEDNUMconst DT_VERNEEDNUM: int64 = 0x6FFFFFFFThe ELF format's DT_VERNEEDNUM: d_tag
DF_ORIGINconst DF_ORIGIN: uint64 = 0x1The ELF format's DF_ORIGIN: DT_FLAGS / DT_FLAGS_1 bits, the version records' values
DF_SYMBOLICconst DF_SYMBOLIC: uint64 = 0x2The ELF format's DF_SYMBOLIC: DT_FLAGS / DT_FLAGS_1 bits, the version records' values
DF_TEXTRELconst DF_TEXTREL: uint64 = 0x4The ELF format's DF_TEXTREL: DT_FLAGS / DT_FLAGS_1 bits, the version records' values
DF_BIND_NOWconst DF_BIND_NOW: uint64 = 0x8The ELF format's DF_BIND_NOW: DT_FLAGS / DT_FLAGS_1 bits, the version records' values
DF_STATIC_TLSconst DF_STATIC_TLS: uint64 = 0x10The ELF format's DF_STATIC_TLS: DT_FLAGS / DT_FLAGS_1 bits, the version records' values
DF_1_NOWconst DF_1_NOW: uint64 = 0x1The ELF format's DF_1_NOW: DT_FLAGS / DT_FLAGS_1 bits, the version records' values
DF_1_ORIGINconst DF_1_ORIGIN: uint64 = 0x80The ELF format's DF_1_ORIGIN: DT_FLAGS / DT_FLAGS_1 bits, the version records' values
DF_1_PIEconst DF_1_PIE: uint64 = 0x08000000The ELF format's DF_1_PIE: DT_FLAGS / DT_FLAGS_1 bits, the version records' values
VER_NEED_CURRENTconst VER_NEED_CURRENT: uint16 = 1The ELF format's VER_NEED_CURRENT: DT_FLAGS / DT_FLAGS_1 bits, the version records' values
VER_FLG_WEAKconst VER_FLG_WEAK: uint16 = 0x2The ELF format's VER_FLG_WEAK: DT_FLAGS / DT_FLAGS_1 bits, the version records' values
VER_NDX_LOCALconst VER_NDX_LOCAL: uint16 = 0The ELF format's VER_NDX_LOCAL: DT_FLAGS / DT_FLAGS_1 bits, the version records' values
VER_NDX_GLOBALconst VER_NDX_GLOBAL: uint16 = 1The 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

text
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

text
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 for AKind with no input yet. Parameters: AKind the digest to make.
  • const method Kind(): HashKind: The digest this hasher makes. Returns: its kind
  • method Update(const ABytes: ByteArray): The bytes of ABytes added to the input. Parameters: ABytes the next piece (empty adds nothing).
  • method Update(const AText: string): The UTF-8 bytes of AText added to the input (no terminating zero). Parameters: AText the next piece ("" adds nothing).
  • method Update(const AData: ptr to const; const ACount: int64): ACount bytes of memory at AData added to the input: a buffer a C library or a file read filled. Parameters: AData the first byte (nil only with ACount 0); ACount how 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

text
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 make
  • ABytes: the input

Returns: the digest's bytes

Example: LDigest := ComputeHash(HashKind.MD5, LBytes);

text
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 make
  • AText: the input

Returns: the digest's bytes

Example: println(DigestToHex(ComputeHash(HashKind.SHA256, "abc")));

DigestToHex

text
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

text
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

NameDeclarationDescription
ADAM_HOOK_EINVALconst ADAM_HOOK_EINVAL: int32 = ADAM_ERRNO_EINVALHookErrno's EINVAL: a name or argument refused.
ADAM_HOOK_EEXISTconst ADAM_HOOK_EEXIST: int32 = ADAM_ERRNO_EEXISTHookErrno's EEXIST: the hook or the name is already installed.
ADAM_HOOK_ENOENTconst ADAM_HOOK_ENOENT: int32 = ADAM_ERRNO_ENOENTHookErrno's ENOENT: no loaded module defines the name.
ADAM_HOOK_EACCESconst ADAM_HOOK_EACCES: int32 = ADAM_ERRNO_EACCESHookErrno's EACCES: an import slot could not be written.
ADAM_HOOK_ENOMEMconst ADAM_HOOK_ENOMEM: int32 = ADAM_ERRNO_ENOMEMHookErrno's ENOMEM: out of memory.

Routines

HookReal

text
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 function
  • AName: the function's C name

Returns: the function, or nil

text
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 function
  • ALibrary: the library's file name ("kernel32.dll")
  • AName: the function's C name

Returns: the function, or nil

HookErrno

text
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

text
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 installed
  • AName: the C name, a compile-time constant
  • AReplacement: 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

text
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

NameDeclarationDescription
ADAM_HOOKIO_EOFconst ADAM_HOOKIO_EOF: int32 = System.HookIO.Core.ADAM_HOOKIO_EOFC's EOF: what the hooked stream calls return on a failure or at the end
ADAM_HOOKIO_SEEK_SETconst ADAM_HOOKIO_SEEK_SET: int32 = System.HookIO.Core.ADAM_HOOKIO_SEEK_SETC's SEEK_SET: fseek from the start.
ADAM_HOOKIO_SEEK_CURconst ADAM_HOOKIO_SEEK_CUR: int32 = System.HookIO.Core.ADAM_HOOKIO_SEEK_CURC's SEEK_CUR: fseek from the current position.
ADAM_HOOKIO_SEEK_ENDconst ADAM_HOOKIO_SEEK_END: int32 = System.HookIO.Core.ADAM_HOOKIO_SEEK_ENDC's SEEK_END: fseek from the end.
ADAM_HOOKIO_WEOFconst ADAM_HOOKIO_WEOF: int32 = System.HookIO.Win64.ADAM_HOOKIO_WEOFC's WEOF (the target's wint_t): what the hooked wide calls return on a failure.

Routines

RegisterIO

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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

NameDeclarationDescription
ADAM_HOOKIO_EOFconst ADAM_HOOKIO_EOF: int32 = -1C's EOF: what the hooked stream calls return on a failure or at the end
ADAM_HOOKIO_SEEK_SETconst ADAM_HOOKIO_SEEK_SET: int32 = 0C's SEEK_SET: fseek from the start.
ADAM_HOOKIO_SEEK_CURconst ADAM_HOOKIO_SEEK_CUR: int32 = 1C's SEEK_CUR: fseek from the current position.
ADAM_HOOKIO_SEEK_ENDconst ADAM_HOOKIO_SEEK_END: int32 = 2C's SEEK_END: fseek from the end.

Variables

NameDeclarationDescription
GLockvar GLock: mutexThe 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

text
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

text
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

text
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

text
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

text
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 path
  • AFrom: where to look

Returns: true when the scheme starts there

HookIOParse

text
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 path
  • AFrom: where it starts
  • AId: receives the prefix number
  • ARest: receives what follows it

Returns: true for a virtual path

HookIOSkipCurrentFolder

text
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

text
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

text
func cpplink HookIOWorkFolder(): string

The working folder a hooked chdir set ("" for none: the C runtime's applies)

Returns: the folder, or ""

HookIOClearWorkFolder

text
func cpplink HookIOClearWorkFolder()

The C runtime's working folder applies again (a real chdir succeeded)

HookIOIsVirtual

text
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

text
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 number
  • AEntry: receives the entry

Returns: false when none is registered

HookIORegisterWithId

text
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 nil
  • ASource: the source, or nil
  • AId: receives the prefix number

Returns: the prefix, or ""

HookIORegister

text
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 nil
  • ASource: the source, or nil

Returns: the prefix, or ""

HookIOUnregisterId

text
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

text
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

text
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 none
  • AId: receives the prefix number

Returns: false when there is no room

HookIOSetPathSource

text
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

text
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

text
func cpplink HookIOThreadPathSource(): IOSource

The source this thread's own path source was set from (nil: none set)

Returns: the source, or nil

HookIOResetPathSourceIf

text
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

text
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

text
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

text
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

text
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

text
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 path
  • AId: receives the prefix number
  • ARest: receives the rest

Returns: false when the C runtime gets it

HookIOFindEntryUse

text
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 source
  • AEntry: the entry

Returns: the place, or -1

HookIODropEntryUseAt

text
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

text
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 source
  • AEntry: the entry
  • ATemporary: true for a D open

Returns: false with errno set

HookIOReleaseEntry

text
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 source
  • AEntry: the entry
  • ATemporary: true for a D use
  • ARemove: true when the removal may happen

Returns: true when the caller removes the entry

HookIOFinishRemove

text
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 source
  • AEntry: the entry

HookIOGiveBackEntry

text
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 handle
  • ARemove: true when the removal may happen

HookIOEntryName

text
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

text
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 entry
  • ARest: the rest after its prefix

Returns: true when it exists

HookIOEmptyIO

text
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

text
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 source
  • AEntry: the entry
  • AParsed: the open's mode

Returns: false with errno set

HookIOTemporaryAllowed

text
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 source
  • AEntry: the entry
  • AParsed: the open's mode

Returns: false with errno set

HookIOOpenShared

text
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 entry
  • AParsed: the open's mode
  • AHandle: the handle to fill

Returns: false with errno set

HookIOOpenEntryIO

text
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 source
  • AEntry: the entry
  • AParsed: the open's mode
  • AHandle: the handle to fill

Returns: false with errno set

HookIOOpenEntry

text
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 source
  • ARest: the rest after its prefix
  • AParsed: the open's mode
  • AHandle: the handle to fill

Returns: false with errno set

HookIOCloseOwnedSource

text
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

text
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 path
  • AQuery: receives the answer

Returns: false when the C runtime answers it

HookIOEnterPathWork

text
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

text
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

NameDeclarationDescription
ADAM_HOOKIO_WEOFconst ADAM_HOOKIO_WEOF: int32 = -1C's WEOF (glibc's wint_t is 32 bits, WEOF 0xFFFFFFFF): what the hooked wide calls return on a failure

Routines

HookIOStreamOf

text
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

text
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's fopen takes it
  • AMode: as C's fopen takes it

Returns: as C's fopen returns it

fopen64

text
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's fopen64 takes it
  • AMode: as C's fopen64 takes it

Returns: as C's fopen64 returns it

freopen

text
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's freopen takes it
  • AMode: as C's freopen takes it
  • AFile: as C's freopen takes it

Returns: as C's freopen returns it

freopen64

text
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's freopen64 takes it
  • AMode: as C's freopen64 takes it
  • AFile: as C's freopen64 takes it

Returns: as C's freopen64 returns it

fclose

text
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's fclose takes it

Returns: as C's fclose returns it

pclose

text
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's pclose takes it

Returns: as C's pclose returns it

fread

text
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's fread takes it
  • ASize: as C's fread takes it
  • ACount: as C's fread takes it
  • AFile: as C's fread takes it

Returns: as C's fread returns it

fread_unlocked

text
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's fread_unlocked takes it
  • ASize: as C's fread_unlocked takes it
  • ACount: as C's fread_unlocked takes it
  • AFile: as C's fread_unlocked takes it

Returns: as C's fread_unlocked returns it

__fread_chk

text
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_chk takes it
  • ABufferSize: as C's __fread_chk takes it
  • ASize: as C's __fread_chk takes it
  • ACount: as C's __fread_chk takes it
  • AFile: as C's __fread_chk takes it

Returns: as C's __fread_chk returns it

__fread_unlocked_chk

text
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_chk takes it
  • ABufferSize: as C's __fread_unlocked_chk takes it
  • ASize: as C's __fread_unlocked_chk takes it
  • ACount: as C's __fread_unlocked_chk takes it
  • AFile: as C's __fread_unlocked_chk takes it

Returns: as C's __fread_unlocked_chk returns it

fwrite

text
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's fwrite takes it
  • ASize: as C's fwrite takes it
  • ACount: as C's fwrite takes it
  • AFile: as C's fwrite takes it

Returns: as C's fwrite returns it

fwrite_unlocked

text
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's fwrite_unlocked takes it
  • ASize: as C's fwrite_unlocked takes it
  • ACount: as C's fwrite_unlocked takes it
  • AFile: as C's fwrite_unlocked takes it

Returns: as C's fwrite_unlocked returns it

fgetc

text
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's fgetc takes it

Returns: as C's fgetc returns it

getc

text
func getc(const AFile: ptr): int32

C's getc, hooked.

Parameters

  • AFile: as C's getc takes it

Returns: as C's getc returns it

fgetc_unlocked

text
func fgetc_unlocked(const AFile: ptr): int32

C's fgetc_unlocked, hooked.

Parameters

  • AFile: as C's fgetc_unlocked takes it

Returns: as C's fgetc_unlocked returns it

getc_unlocked

text
func getc_unlocked(const AFile: ptr): int32

C's getc_unlocked, hooked.

Parameters

  • AFile: as C's getc_unlocked takes it

Returns: as C's getc_unlocked returns it

_IO_getc

text
func _IO_getc(const AFile: ptr): int32

C's _IO_getc, hooked.

Parameters

  • AFile: as C's _IO_getc takes it

Returns: as C's _IO_getc returns it

getw

text
func getw(const AFile: ptr): int32

C's getw, hooked: an int's bytes (EOF when fewer came)

Parameters

  • AFile: as C's getw takes it

Returns: as C's getw returns it

_IO_peekc_locked

text
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_locked takes it

Returns: as C's _IO_peekc_locked returns it

__uflow

text
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 __uflow takes it

Returns: as C's __uflow returns it

__underflow

text
func __underflow(const AFile: ptr): int32

C's __underflow, hooked.

Parameters

  • AFile: as C's __underflow takes it

Returns: as C's __underflow returns it

fgets

text
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's fgets takes it
  • ACount: as C's fgets takes it
  • AFile: as C's fgets takes it

Returns: as C's fgets returns it

fgets_unlocked

text
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's fgets_unlocked takes it
  • ACount: as C's fgets_unlocked takes it
  • AFile: as C's fgets_unlocked takes it

Returns: as C's fgets_unlocked returns it

__fgets_chk

text
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_chk takes it
  • ASize: as C's __fgets_chk takes it
  • ACount: as C's __fgets_chk takes it
  • AFile: as C's __fgets_chk takes it

Returns: as C's __fgets_chk returns it

__fgets_unlocked_chk

text
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_chk takes it
  • ASize: as C's __fgets_unlocked_chk takes it
  • ACount: as C's __fgets_unlocked_chk takes it
  • AFile: as C's __fgets_unlocked_chk takes it

Returns: as C's __fgets_unlocked_chk returns it

getdelim

text
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's getdelim takes it
  • ASize: as C's getdelim takes it
  • ADelim: as C's getdelim takes it
  • AFile: as C's getdelim takes it

Returns: as C's getdelim returns it

__getdelim

text
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 __getdelim takes it
  • ASize: as C's __getdelim takes it
  • ADelim: as C's __getdelim takes it
  • AFile: as C's __getdelim takes it

Returns: as C's __getdelim returns it

getline

text
func getline(const ALine: ptr to ptr; const ASize: ptr to uint64; const AFile: ptr): int64

C's getline, hooked.

Parameters

  • ALine: as C's getline takes it
  • ASize: as C's getline takes it
  • AFile: as C's getline takes it

Returns: as C's getline returns it

ungetc

text
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's ungetc takes it
  • AFile: as C's ungetc takes it

Returns: as C's ungetc returns it

fputc

text
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's fputc takes it
  • AFile: as C's fputc takes it

Returns: as C's fputc returns it

putc

text
func putc(const AChar: int32; const AFile: ptr): int32

C's putc, hooked.

Parameters

  • AChar: as C's putc takes it
  • AFile: as C's putc takes it

Returns: as C's putc returns it

fputc_unlocked

text
func fputc_unlocked(const AChar: int32; const AFile: ptr): int32

C's fputc_unlocked, hooked.

Parameters

  • AChar: as C's fputc_unlocked takes it
  • AFile: as C's fputc_unlocked takes it

Returns: as C's fputc_unlocked returns it

putc_unlocked

text
func putc_unlocked(const AChar: int32; const AFile: ptr): int32

C's putc_unlocked, hooked.

Parameters

  • AChar: as C's putc_unlocked takes it
  • AFile: as C's putc_unlocked takes it

Returns: as C's putc_unlocked returns it

_IO_putc

text
func _IO_putc(const AChar: int32; const AFile: ptr): int32

C's _IO_putc, hooked.

Parameters

  • AChar: as C's _IO_putc takes it
  • AFile: as C's _IO_putc takes it

Returns: as C's _IO_putc returns it

putw

text
func putw(const AWord: int32; const AFile: ptr): int32

C's putw, hooked: an int's bytes (0, or EOF)

Parameters

  • AWord: as C's putw takes it
  • AFile: as C's putw takes it

Returns: as C's putw returns it

__overflow

text
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 __overflow takes it
  • AChar: as C's __overflow takes it

Returns: as C's __overflow returns it

fputs

text
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's fputs takes it
  • AFile: as C's fputs takes it

Returns: as C's fputs returns it

fputs_unlocked

text
func fputs_unlocked(const AText: ptr to const char; const AFile: ptr): int32

C's fputs_unlocked, hooked.

Parameters

  • AText: as C's fputs_unlocked takes it
  • AFile: as C's fputs_unlocked takes it

Returns: as C's fputs_unlocked returns it

feof

text
func feof(const AFile: ptr): int32

C's feof, hooked. The flags: feof / ferror and their forms, clearerr

Parameters

  • AFile: as C's feof takes it

Returns: as C's feof returns it

feof_unlocked

text
func feof_unlocked(const AFile: ptr): int32

C's feof_unlocked, hooked.

Parameters

  • AFile: as C's feof_unlocked takes it

Returns: as C's feof_unlocked returns it

_IO_feof

text
func _IO_feof(const AFile: ptr): int32

C's _IO_feof, hooked.

Parameters

  • AFile: as C's _IO_feof takes it

Returns: as C's _IO_feof returns it

ferror

text
func ferror(const AFile: ptr): int32

C's ferror, hooked.

Parameters

  • AFile: as C's ferror takes it

Returns: as C's ferror returns it

ferror_unlocked

text
func ferror_unlocked(const AFile: ptr): int32

C's ferror_unlocked, hooked.

Parameters

  • AFile: as C's ferror_unlocked takes it

Returns: as C's ferror_unlocked returns it

_IO_ferror

text
func _IO_ferror(const AFile: ptr): int32

C's _IO_ferror, hooked.

Parameters

  • AFile: as C's _IO_ferror takes it

Returns: as C's _IO_ferror returns it

clearerr

text
func clearerr(const AFile: ptr)

C's clearerr, hooked.

Parameters

  • AFile: as C's clearerr takes it

clearerr_unlocked

text
func clearerr_unlocked(const AFile: ptr)

C's clearerr_unlocked, hooked.

Parameters

  • AFile: as C's clearerr_unlocked takes it

fseek

text
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's fseek takes it
  • AOffset: as C's fseek takes it
  • AOrigin: as C's fseek takes it

Returns: as C's fseek returns it

fseeko

text
func fseeko(const AFile: ptr; const AOffset: int64; const AOrigin: int32): int32

C's fseeko, hooked.

Parameters

  • AFile: as C's fseeko takes it
  • AOffset: as C's fseeko takes it
  • AOrigin: as C's fseeko takes it

Returns: as C's fseeko returns it

fseeko64

text
func fseeko64(const AFile: ptr; const AOffset: int64; const AOrigin: int32): int32

C's fseeko64, hooked.

Parameters

  • AFile: as C's fseeko64 takes it
  • AOffset: as C's fseeko64 takes it
  • AOrigin: as C's fseeko64 takes it

Returns: as C's fseeko64 returns it

ftell

text
func ftell(const AFile: ptr): clong

C's ftell, hooked. The tells: ftell, ftello, ftello64

Parameters

  • AFile: as C's ftell takes it

Returns: as C's ftell returns it

ftello

text
func ftello(const AFile: ptr): int64

C's ftello, hooked.

Parameters

  • AFile: as C's ftello takes it

Returns: as C's ftello returns it

ftello64

text
func ftello64(const AFile: ptr): int64

C's ftello64, hooked.

Parameters

  • AFile: as C's ftello64 takes it

Returns: as C's ftello64 returns it

rewind

text
func rewind(const AFile: ptr)

C's rewind, hooked: a seek to 0, then both flags cleared

Parameters

  • AFile: as C's rewind takes it

fgetpos

text
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's fgetpos takes it
  • APos: as C's fgetpos takes it

Returns: as C's fgetpos returns it

fgetpos64

text
func fgetpos64(const AFile: ptr; const APos: ptr to fpos_t): int32

C's fgetpos64, hooked.

Parameters

  • AFile: as C's fgetpos64 takes it
  • APos: as C's fgetpos64 takes it

Returns: as C's fgetpos64 returns it

fsetpos

text
func fsetpos(const AFile: ptr; const APos: ptr to fpos_t): int32

C's fsetpos, hooked.

Parameters

  • AFile: as C's fsetpos takes it
  • APos: as C's fsetpos takes it

Returns: as C's fsetpos returns it

fsetpos64

text
func fsetpos64(const AFile: ptr; const APos: ptr to fpos_t): int32

C's fsetpos64, hooked.

Parameters

  • AFile: as C's fsetpos64 takes it
  • APos: as C's fsetpos64 takes it

Returns: as C's fsetpos64 returns it

fflush

text
func fflush(const AFile: ptr): int32

C's fflush, hooked.

Parameters

  • AFile: as C's fflush takes it

Returns: as C's fflush returns it

fflush_unlocked

text
func fflush_unlocked(const AFile: ptr): int32

C's fflush_unlocked, hooked.

Parameters

  • AFile: as C's fflush_unlocked takes it

Returns: as C's fflush_unlocked returns it

setvbuf

text
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's setvbuf takes it
  • ABuffer: as C's setvbuf takes it
  • AMode: as C's setvbuf takes it
  • ASize: as C's setvbuf takes it

Returns: as C's setvbuf returns it

setbuffer

text
func setbuffer(const AFile: ptr; const ABuffer: ptr to char; const ASize: uint64)

C's setbuffer, hooked.

Parameters

  • AFile: as C's setbuffer takes it
  • ABuffer: as C's setbuffer takes it
  • ASize: as C's setbuffer takes it

setbuf

text
func setbuf(const AFile: ptr; const ABuffer: ptr to char)

C's setbuf, hooked.

Parameters

  • AFile: as C's setbuf takes it
  • ABuffer: as C's setbuf takes it

setlinebuf

text
func setlinebuf(const AFile: ptr)

C's setlinebuf, hooked: setvbuf(_IOLBF) with no array

Parameters

  • AFile: as C's setlinebuf takes it

fileno

text
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's fileno takes it

Returns: as C's fileno returns it

fileno_unlocked

text
func fileno_unlocked(const AFile: ptr): int32

C's fileno_unlocked, hooked.

Parameters

  • AFile: as C's fileno_unlocked takes it

Returns: as C's fileno_unlocked returns it

flockfile

text
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's flockfile takes it

funlockfile

text
func funlockfile(const AFile: ptr)

C's funlockfile, hooked.

Parameters

  • AFile: as C's funlockfile takes it

ftrylockfile

text
func ftrylockfile(const AFile: ptr): int32

C's ftrylockfile, hooked.

Parameters

  • AFile: as C's ftrylockfile takes it

Returns: as C's ftrylockfile returns it

fwide

text
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's fwide takes it
  • AMode: as C's fwide takes it

Returns: as C's fwide returns it

__fpending

text
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 __fpending takes it

Returns: as C's __fpending returns it

__freading

text
func __freading(const AFile: ptr): int32

C's __freading, hooked.

Parameters

  • AFile: as C's __freading takes it

Returns: as C's __freading returns it

__fwriting

text
func __fwriting(const AFile: ptr): int32

C's __fwriting, hooked.

Parameters

  • AFile: as C's __fwriting takes it

Returns: as C's __fwriting returns it

__freadable

text
func __freadable(const AFile: ptr): int32

C's __freadable, hooked.

Parameters

  • AFile: as C's __freadable takes it

Returns: as C's __freadable returns it

__fwritable

text
func __fwritable(const AFile: ptr): int32

C's __fwritable, hooked.

Parameters

  • AFile: as C's __fwritable takes it

Returns: as C's __fwritable returns it

__flbf

text
func __flbf(const AFile: ptr): int32

C's __flbf, hooked.

Parameters

  • AFile: as C's __flbf takes it

Returns: as C's __flbf returns it

__fbufsize

text
func __fbufsize(const AFile: ptr): uint64

C's __fbufsize, hooked.

Parameters

  • AFile: as C's __fbufsize takes it

Returns: as C's __fbufsize returns it

__fpurge

text
func __fpurge(const AFile: ptr)

C's __fpurge, hooked.

Parameters

  • AFile: as C's __fpurge takes it

__fsetlocking

text
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 __fsetlocking takes it
  • AType: as C's __fsetlocking takes it

Returns: as C's __fsetlocking returns it

fprintf

text
func fprintf(const AFile: ptr; const AFormat: ptr to const char; ...): int32

C's fprintf, hooked.

Parameters

  • AFile: as C's fprintf takes it
  • AFormat: as C's fprintf takes it
  • ...: as C's fprintf takes them

Returns: as C's fprintf returns it

vfprintf

text
func vfprintf(const AFile: ptr; const AFormat: ptr to const char; const AArgs: ptr): int32

C's vfprintf, hooked.

Parameters

  • AFile: as C's vfprintf takes it
  • AFormat: as C's vfprintf takes it
  • AArgs: as C's vfprintf takes it

Returns: as C's vfprintf returns it

__fprintf_chk

text
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_chk takes it
  • AFlag: as C's __fprintf_chk takes it
  • AFormat: as C's __fprintf_chk takes it
  • ...: as C's __fprintf_chk takes them

Returns: as C's __fprintf_chk returns it

__vfprintf_chk

text
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_chk takes it
  • AFlag: as C's __vfprintf_chk takes it
  • AFormat: as C's __vfprintf_chk takes it
  • AArgs: as C's __vfprintf_chk takes it

Returns: as C's __vfprintf_chk returns it

fwprintf

text
func fwprintf(const AFile: ptr; const AFormat: ptr to const uint32; ...): int32

C's fwprintf, hooked.

Parameters

  • AFile: as C's fwprintf takes it
  • AFormat: as C's fwprintf takes it
  • ...: as C's fwprintf takes them

Returns: as C's fwprintf returns it

vfwprintf

text
func vfwprintf(const AFile: ptr; const AFormat: ptr to const uint32; const AArgs: ptr): int32

C's vfwprintf, hooked.

Parameters

  • AFile: as C's vfwprintf takes it
  • AFormat: as C's vfwprintf takes it
  • AArgs: as C's vfwprintf takes it

Returns: as C's vfwprintf returns it

__fwprintf_chk

text
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_chk takes it
  • AFlag: as C's __fwprintf_chk takes it
  • AFormat: as C's __fwprintf_chk takes it
  • ...: as C's __fwprintf_chk takes them

Returns: as C's __fwprintf_chk returns it

__vfwprintf_chk

text
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_chk takes it
  • AFlag: as C's __vfwprintf_chk takes it
  • AFormat: as C's __vfwprintf_chk takes it
  • AArgs: as C's __vfwprintf_chk takes it

Returns: as C's __vfwprintf_chk returns it

fscanf

text
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's fscanf takes it
  • AFormat: as C's fscanf takes it
  • ...: as C's fscanf takes them

Returns: as C's fscanf returns it

vfscanf

text
func vfscanf(const AFile: ptr; const AFormat: ptr to const char; const AArgs: ptr): int32

C's vfscanf, hooked.

Parameters

  • AFile: as C's vfscanf takes it
  • AFormat: as C's vfscanf takes it
  • AArgs: as C's vfscanf takes it

Returns: as C's vfscanf returns it

__isoc99_fscanf

text
func __isoc99_fscanf(const AFile: ptr; const AFormat: ptr to const char; ...): int32

C's __isoc99_fscanf, hooked.

Parameters

  • AFile: as C's __isoc99_fscanf takes it
  • AFormat: as C's __isoc99_fscanf takes it
  • ...: as C's __isoc99_fscanf takes them

Returns: as C's __isoc99_fscanf returns it

__isoc99_vfscanf

text
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_vfscanf takes it
  • AFormat: as C's __isoc99_vfscanf takes it
  • AArgs: as C's __isoc99_vfscanf takes it

Returns: as C's __isoc99_vfscanf returns it

fwscanf

text
func fwscanf(const AFile: ptr; const AFormat: ptr to const uint32; ...): int32

C's fwscanf, hooked.

Parameters

  • AFile: as C's fwscanf takes it
  • AFormat: as C's fwscanf takes it
  • ...: as C's fwscanf takes them

Returns: as C's fwscanf returns it

vfwscanf

text
func vfwscanf(const AFile: ptr; const AFormat: ptr to const uint32; const AArgs: ptr): int32

C's vfwscanf, hooked.

Parameters

  • AFile: as C's vfwscanf takes it
  • AFormat: as C's vfwscanf takes it
  • AArgs: as C's vfwscanf takes it

Returns: as C's vfwscanf returns it

__isoc99_fwscanf

text
func __isoc99_fwscanf(const AFile: ptr; const AFormat: ptr to const uint32; ...): int32

C's __isoc99_fwscanf, hooked.

Parameters

  • AFile: as C's __isoc99_fwscanf takes it
  • AFormat: as C's __isoc99_fwscanf takes it
  • ...: as C's __isoc99_fwscanf takes them

Returns: as C's __isoc99_fwscanf returns it

__isoc99_vfwscanf

text
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_vfwscanf takes it
  • AFormat: as C's __isoc99_vfwscanf takes it
  • AArgs: as C's __isoc99_vfwscanf takes it

Returns: as C's __isoc99_vfwscanf returns it

fgetwc

text
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's fgetwc takes it

Returns: as C's fgetwc returns it

getwc

text
func getwc(const AFile: ptr): uint32

C's getwc, hooked.

Parameters

  • AFile: as C's getwc takes it

Returns: as C's getwc returns it

fgetwc_unlocked

text
func fgetwc_unlocked(const AFile: ptr): uint32

C's fgetwc_unlocked, hooked.

Parameters

  • AFile: as C's fgetwc_unlocked takes it

Returns: as C's fgetwc_unlocked returns it

getwc_unlocked

text
func getwc_unlocked(const AFile: ptr): uint32

C's getwc_unlocked, hooked.

Parameters

  • AFile: as C's getwc_unlocked takes it

Returns: as C's getwc_unlocked returns it

fgetws

text
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's fgetws takes it
  • ACount: as C's fgetws takes it
  • AFile: as C's fgetws takes it

Returns: as C's fgetws returns it

fgetws_unlocked

text
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's fgetws_unlocked takes it
  • ACount: as C's fgetws_unlocked takes it
  • AFile: as C's fgetws_unlocked takes it

Returns: as C's fgetws_unlocked returns it

__fgetws_chk

text
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_chk takes it
  • ASize: as C's __fgetws_chk takes it
  • ACount: as C's __fgetws_chk takes it
  • AFile: as C's __fgetws_chk takes it

Returns: as C's __fgetws_chk returns it

__fgetws_unlocked_chk

text
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_chk takes it
  • ASize: as C's __fgetws_unlocked_chk takes it
  • ACount: as C's __fgetws_unlocked_chk takes it
  • AFile: as C's __fgetws_unlocked_chk takes it

Returns: as C's __fgetws_unlocked_chk returns it

ungetwc

text
func ungetwc(const AChar: uint32; const AFile: ptr): uint32

C's ungetwc, hooked: a character kept back

Parameters

  • AChar: as C's ungetwc takes it
  • AFile: as C's ungetwc takes it

Returns: as C's ungetwc returns it

fputwc

text
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's fputwc takes it
  • AFile: as C's fputwc takes it

Returns: as C's fputwc returns it

putwc

text
func putwc(const AChar: uint32; const AFile: ptr): uint32

C's putwc, hooked.

Parameters

  • AChar: as C's putwc takes it
  • AFile: as C's putwc takes it

Returns: as C's putwc returns it

fputwc_unlocked

text
func fputwc_unlocked(const AChar: uint32; const AFile: ptr): uint32

C's fputwc_unlocked, hooked.

Parameters

  • AChar: as C's fputwc_unlocked takes it
  • AFile: as C's fputwc_unlocked takes it

Returns: as C's fputwc_unlocked returns it

putwc_unlocked

text
func putwc_unlocked(const AChar: uint32; const AFile: ptr): uint32

C's putwc_unlocked, hooked.

Parameters

  • AChar: as C's putwc_unlocked takes it
  • AFile: as C's putwc_unlocked takes it

Returns: as C's putwc_unlocked returns it

fputws

text
func fputws(const AText: ptr to const uint32; const AFile: ptr): int32

C's fputws, hooked.

Parameters

  • AText: as C's fputws takes it
  • AFile: as C's fputws takes it

Returns: as C's fputws returns it

fputws_unlocked

text
func fputws_unlocked(const AText: ptr to const uint32; const AFile: ptr): int32

C's fputws_unlocked, hooked.

Parameters

  • AText: as C's fputws_unlocked takes it
  • AFile: as C's fputws_unlocked takes it

Returns: as C's fputws_unlocked returns it

chdir

text
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's chdir takes it

Returns: as C's chdir returns it

getcwd

text
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's getcwd takes it
  • ASize: as C's getcwd takes it

Returns: as C's getcwd returns it

__getcwd_chk

text
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_chk takes it
  • ASize: as C's __getcwd_chk takes it
  • ABufferSize: as C's __getcwd_chk takes it

Returns: as C's __getcwd_chk returns it

access

text
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's access takes it
  • AMode: as C's access takes it

Returns: as C's access returns it

stat

text
func stat(const APath: ptr to const char; const ABuf: ptr): int32

C's stat, hooked.

Parameters

  • APath: as C's stat takes it
  • ABuf: as C's stat takes it

Returns: as C's stat returns it

stat64

text
func stat64(const APath: ptr to const char; const ABuf: ptr): int32

C's stat64, hooked.

Parameters

  • APath: as C's stat64 takes it
  • ABuf: as C's stat64 takes it

Returns: as C's stat64 returns it

lstat

text
func lstat(const APath: ptr to const char; const ABuf: ptr): int32

C's lstat, hooked.

Parameters

  • APath: as C's lstat takes it
  • ABuf: as C's lstat takes it

Returns: as C's lstat returns it

lstat64

text
func lstat64(const APath: ptr to const char; const ABuf: ptr): int32

C's lstat64, hooked.

Parameters

  • APath: as C's lstat64 takes it
  • ABuf: as C's lstat64 takes it

Returns: as C's lstat64 returns it

__xstat

text
func __xstat(const AVersion: int32; const APath: ptr to const char; const ABuf: ptr): int32

C's __xstat, hooked.

Parameters

  • AVersion: as C's __xstat takes it
  • APath: as C's __xstat takes it
  • ABuf: as C's __xstat takes it

Returns: as C's __xstat returns it

__xstat64

text
func __xstat64(const AVersion: int32; const APath: ptr to const char; const ABuf: ptr): int32

C's __xstat64, hooked.

Parameters

  • AVersion: as C's __xstat64 takes it
  • APath: as C's __xstat64 takes it
  • ABuf: as C's __xstat64 takes it

Returns: as C's __xstat64 returns it

__lxstat

text
func __lxstat(const AVersion: int32; const APath: ptr to const char; const ABuf: ptr): int32

C's __lxstat, hooked.

Parameters

  • AVersion: as C's __lxstat takes it
  • APath: as C's __lxstat takes it
  • ABuf: as C's __lxstat takes it

Returns: as C's __lxstat returns it

__lxstat64

text
func __lxstat64(const AVersion: int32; const APath: ptr to const char; const ABuf: ptr): int32

C's __lxstat64, hooked.

Parameters

  • AVersion: as C's __lxstat64 takes it
  • APath: as C's __lxstat64 takes it
  • ABuf: as C's __lxstat64 takes it

Returns: as C's __lxstat64 returns it

open

text
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's open takes it
  • AFlags: as C's open takes it
  • ...: as C's open takes them

Returns: as C's open returns it

open64

text
func open64(const APath: ptr to const char; const AFlags: int32; ...): int32

C's open64, hooked.

Parameters

  • APath: as C's open64 takes it
  • AFlags: as C's open64 takes it
  • ...: as C's open64 takes them

Returns: as C's open64 returns it

__open_2

text
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_2 takes it
  • AFlags: as C's __open_2 takes it

Returns: as C's __open_2 returns it

__open64_2

text
func __open64_2(const APath: ptr to const char; const AFlags: int32): int32

C's __open64_2, hooked.

Parameters

  • APath: as C's __open64_2 takes it
  • AFlags: as C's __open64_2 takes it

Returns: as C's __open64_2 returns it

read

text
func read(const AFile: int32; const ABuffer: ptr; const ACount: uint64): int64

C's read, hooked.

Parameters

  • AFile: as C's read takes it
  • ABuffer: as C's read takes it
  • ACount: as C's read takes it

Returns: as C's read returns it

__read_chk

text
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_chk takes it
  • ABuffer: as C's __read_chk takes it
  • ACount: as C's __read_chk takes it
  • ABufferSize: as C's __read_chk takes it

Returns: as C's __read_chk returns it

pread

text
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's pread takes it
  • ABuffer: as C's pread takes it
  • ACount: as C's pread takes it
  • AOffset: as C's pread takes it

Returns: as C's pread returns it

pread64

text
func pread64(const AFile: int32; const ABuffer: ptr; const ACount: uint64; const AOffset: int64): int64

C's pread64, hooked.

Parameters

  • AFile: as C's pread64 takes it
  • ABuffer: as C's pread64 takes it
  • ACount: as C's pread64 takes it
  • AOffset: as C's pread64 takes it

Returns: as C's pread64 returns it

__pread_chk

text
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_chk takes it
  • ABuffer: as C's __pread_chk takes it
  • ACount: as C's __pread_chk takes it
  • AOffset: as C's __pread_chk takes it
  • ABufferSize: as C's __pread_chk takes it

Returns: as C's __pread_chk returns it

__pread64_chk

text
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_chk takes it
  • ABuffer: as C's __pread64_chk takes it
  • ACount: as C's __pread64_chk takes it
  • AOffset: as C's __pread64_chk takes it
  • ABufferSize: as C's __pread64_chk takes it

Returns: as C's __pread64_chk returns it

write

text
func write(const AFile: int32; const ABuffer: ptr to const; const ACount: uint64): int64

C's write, hooked.

Parameters

  • AFile: as C's write takes it
  • ABuffer: as C's write takes it
  • ACount: as C's write takes it

Returns: as C's write returns it

pwrite

text
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's pwrite takes it
  • ABuffer: as C's pwrite takes it
  • ACount: as C's pwrite takes it
  • AOffset: as C's pwrite takes it

Returns: as C's pwrite returns it

pwrite64

text
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's pwrite64 takes it
  • ABuffer: as C's pwrite64 takes it
  • ACount: as C's pwrite64 takes it
  • AOffset: as C's pwrite64 takes it

Returns: as C's pwrite64 returns it

lseek

text
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's lseek takes it
  • AOffset: as C's lseek takes it
  • AWhence: as C's lseek takes it

Returns: as C's lseek returns it

lseek64

text
func lseek64(const AFile: int32; const AOffset: int64; const AWhence: int32): int64

C's lseek64, hooked.

Parameters

  • AFile: as C's lseek64 takes it
  • AOffset: as C's lseek64 takes it
  • AWhence: as C's lseek64 takes it

Returns: as C's lseek64 returns it

mmap

text
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's mmap takes it
  • ALength: as C's mmap takes it
  • AProt: as C's mmap takes it
  • AFlags: as C's mmap takes it
  • AFile: as C's mmap takes it
  • AOffset: as C's mmap takes it

Returns: as C's mmap returns it

mmap64

text
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's mmap64 takes it
  • ALength: as C's mmap64 takes it
  • AProt: as C's mmap64 takes it
  • AFlags: as C's mmap64 takes it
  • AFile: as C's mmap64 takes it
  • AOffset: as C's mmap64 takes it

Returns: as C's mmap64 returns it

close

text
func close(const AFile: int32): int32

C's close, hooked.

Parameters

  • AFile: as C's close takes it

Returns: as C's close returns it

dup

text
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's dup takes it

Returns: as C's dup returns it

dup2

text
func dup2(const AFile: int32; const ATarget: int32): int32

C's dup2, hooked.

Parameters

  • AFile: as C's dup2 takes it
  • ATarget: as C's dup2 takes it

Returns: as C's dup2 returns it

dup3

text
func dup3(const AFile: int32; const ATarget: int32; const AFlags: int32): int32

C's dup3, hooked.

Parameters

  • AFile: as C's dup3 takes it
  • ATarget: as C's dup3 takes it
  • AFlags: as C's dup3 takes it

Returns: as C's dup3 returns it

fcntl

text
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's fcntl takes it
  • ACommand: as C's fcntl takes it
  • ...: as C's fcntl takes them

Returns: as C's fcntl returns it

fcntl64

text
func fcntl64(const AFile: int32; const ACommand: int32; ...): int32

C's fcntl64, hooked.

Parameters

  • AFile: as C's fcntl64 takes it
  • ACommand: as C's fcntl64 takes it
  • ...: as C's fcntl64 takes them

Returns: as C's fcntl64 returns it

fdopen

text
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's fdopen takes it
  • AMode: as C's fdopen takes it

Returns: as C's fdopen returns it

fstat

text
func fstat(const AFile: int32; const ABuf: ptr): int32

C's fstat, hooked.

Parameters

  • AFile: as C's fstat takes it
  • ABuf: as C's fstat takes it

Returns: as C's fstat returns it

fstat64

text
func fstat64(const AFile: int32; const ABuf: ptr): int32

C's fstat64, hooked.

Parameters

  • AFile: as C's fstat64 takes it
  • ABuf: as C's fstat64 takes it

Returns: as C's fstat64 returns it

__fxstat

text
func __fxstat(const AVersion: int32; const AFile: int32; const ABuf: ptr): int32

C's __fxstat, hooked.

Parameters

  • AVersion: as C's __fxstat takes it
  • AFile: as C's __fxstat takes it
  • ABuf: as C's __fxstat takes it

Returns: as C's __fxstat returns it

__fxstat64

text
func __fxstat64(const AVersion: int32; const AFile: int32; const ABuf: ptr): int32

C's __fxstat64, hooked.

Parameters

  • AVersion: as C's __fxstat64 takes it
  • AFile: as C's __fxstat64 takes it
  • ABuf: as C's __fxstat64 takes 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

NameDeclarationDescription
ADAM_HOOKIO_WEOFconst ADAM_HOOKIO_WEOF: int32 = 0xFFFFC's WEOF (Windows' wint_t is 16 bits): what the hooked wide calls return on a failure

Routines

HookIOStreamOf

text
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

text
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's fopen takes it
  • AMode: as C's fopen takes it

Returns: as C's fopen returns it

fopen_s

text
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's fopen_s takes it
  • APath: as C's fopen_s takes it
  • AMode: as C's fopen_s takes it

Returns: as C's fopen_s returns it

_wfopen

text
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 _wfopen takes it
  • AMode: as C's _wfopen takes it

Returns: as C's _wfopen returns it

_access

text
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 _access takes it
  • AMode: as C's _access takes it

Returns: as C's _access returns it

access

text
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's access takes it
  • AMode: as C's access takes it

Returns: as C's access returns it

_chdir

text
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 _chdir takes it

Returns: as C's _chdir returns it

chdir

text
func chdir(const APath: ptr to const char): int32

C's chdir, hooked. mingw's oldnames chdir: _chdir's answer

Parameters

  • APath: as C's chdir takes it

Returns: as C's chdir returns it

_wchdir

text
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 _wchdir takes it

Returns: as C's _wchdir returns it

_getcwd

text
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 _getcwd takes it
  • ASize: as C's _getcwd takes it

Returns: as C's _getcwd returns it

getcwd

text
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's getcwd takes it
  • ASize: as C's getcwd takes it

Returns: as C's getcwd returns it

_wgetcwd

text
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 _wgetcwd takes it
  • ASize: as C's _wgetcwd takes it

Returns: as C's _wgetcwd returns it

stat64i32

text
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's stat64i32 takes it
  • ABuf: as C's stat64i32 takes it

Returns: as C's stat64i32 returns it

GetFileAttributesA

text
func GetFileAttributesA(const APath: ptr to const char): uint32

Windows' GetFileAttributesA, hooked: a virtual path answered, anything else kernel32's

Parameters

  • APath: as Windows' GetFileAttributesA takes it

Returns: as Windows' GetFileAttributesA returns it

fclose

text
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's fclose takes it

Returns: as C's fclose returns it

freopen

text
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's freopen takes it
  • AMode: as C's freopen takes it
  • AFile: as C's freopen takes it

Returns: as C's freopen returns it

fread

text
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's fread takes it
  • ASize: as C's fread takes it
  • ACount: as C's fread takes it
  • AFile: as C's fread takes it

Returns: as C's fread returns it

_fread_nolock

text
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_nolock takes it
  • ASize: as C's _fread_nolock takes it
  • ACount: as C's _fread_nolock takes it
  • AFile: as C's _fread_nolock takes it

Returns: as C's _fread_nolock returns it

fwrite

text
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's fwrite takes it
  • ASize: as C's fwrite takes it
  • ACount: as C's fwrite takes it
  • AFile: as C's fwrite takes it

Returns: as C's fwrite returns it

_fwrite_nolock

text
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_nolock takes it
  • ASize: as C's _fwrite_nolock takes it
  • ACount: as C's _fwrite_nolock takes it
  • AFile: as C's _fwrite_nolock takes it

Returns: as C's _fwrite_nolock returns it

fgetc

text
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's fgetc takes it

Returns: as C's fgetc returns it

getc

text
func getc(const AFile: ptr): int32

C's getc, hooked.

Parameters

  • AFile: as C's getc takes it

Returns: as C's getc returns it

_fgetc_nolock

text
func _fgetc_nolock(const AFile: ptr): int32

C's _fgetc_nolock, hooked.

Parameters

  • AFile: as C's _fgetc_nolock takes it

Returns: as C's _fgetc_nolock returns it

_getc_nolock

text
func _getc_nolock(const AFile: ptr): int32

C's _getc_nolock, hooked.

Parameters

  • AFile: as C's _getc_nolock takes it

Returns: as C's _getc_nolock returns it

fgets

text
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's fgets takes it
  • ACount: as C's fgets takes it
  • AFile: as C's fgets takes it

Returns: as C's fgets returns it

ungetc

text
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's ungetc takes it
  • AFile: as C's ungetc takes it

Returns: as C's ungetc returns it

_ungetc_nolock

text
func _ungetc_nolock(const AChar: int32; const AFile: ptr): int32

C's _ungetc_nolock, hooked.

Parameters

  • AChar: as C's _ungetc_nolock takes it
  • AFile: as C's _ungetc_nolock takes it

Returns: as C's _ungetc_nolock returns it

feof

text
func feof(const AFile: ptr): int32

C's feof, hooked. feof / ferror: 1 when the flag is set, else 0

Parameters

  • AFile: as C's feof takes it

Returns: as C's feof returns it

ferror

text
func ferror(const AFile: ptr): int32

C's ferror, hooked.

Parameters

  • AFile: as C's ferror takes it

Returns: as C's ferror returns it

clearerr

text
func clearerr(const AFile: ptr)

C's clearerr, hooked: both flags cleared

Parameters

  • AFile: as C's clearerr takes it

fseek

text
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's fseek takes it
  • AOffset: as C's fseek takes it
  • AOrigin: as C's fseek takes it

Returns: as C's fseek returns it

_fseek_nolock

text
func _fseek_nolock(const AFile: ptr; const AOffset: clong; const AOrigin: int32): int32

C's _fseek_nolock, hooked.

Parameters

  • AFile: as C's _fseek_nolock takes it
  • AOffset: as C's _fseek_nolock takes it
  • AOrigin: as C's _fseek_nolock takes it

Returns: as C's _fseek_nolock returns it

_fseeki64

text
func _fseeki64(const AFile: ptr; const AOffset: int64; const AOrigin: int32): int32

C's _fseeki64, hooked.

Parameters

  • AFile: as C's _fseeki64 takes it
  • AOffset: as C's _fseeki64 takes it
  • AOrigin: as C's _fseeki64 takes it

Returns: as C's _fseeki64 returns it

_fseeki64_nolock

text
func _fseeki64_nolock(const AFile: ptr; const AOffset: int64; const AOrigin: int32): int32

C's _fseeki64_nolock, hooked.

Parameters

  • AFile: as C's _fseeki64_nolock takes it
  • AOffset: as C's _fseeki64_nolock takes it
  • AOrigin: as C's _fseeki64_nolock takes it

Returns: as C's _fseeki64_nolock returns it

ftell

text
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's ftell takes it

Returns: as C's ftell returns it

_ftell_nolock

text
func _ftell_nolock(const AFile: ptr): clong

C's _ftell_nolock, hooked.

Parameters

  • AFile: as C's _ftell_nolock takes it

Returns: as C's _ftell_nolock returns it

_ftelli64

text
func _ftelli64(const AFile: ptr): int64

C's _ftelli64, hooked.

Parameters

  • AFile: as C's _ftelli64 takes it

Returns: as C's _ftelli64 returns it

_ftelli64_nolock

text
func _ftelli64_nolock(const AFile: ptr): int64

C's _ftelli64_nolock, hooked.

Parameters

  • AFile: as C's _ftelli64_nolock takes it

Returns: as C's _ftelli64_nolock returns it

rewind

text
func rewind(const AFile: ptr)

C's rewind, hooked: to the start, both flags cleared

Parameters

  • AFile: as C's rewind takes it

fileno

text
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's fileno takes it

Returns: as C's fileno returns it

_fileno

text
func _fileno(const AFile: ptr): int32

C's _fileno, hooked.

Parameters

  • AFile: as C's _fileno takes it

Returns: as C's _fileno returns it

_lock_file

text
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_file takes it

_unlock_file

text
func _unlock_file(const AFile: ptr)

C's _unlock_file, hooked.

Parameters

  • AFile: as C's _unlock_file takes it

_pclose

text
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 _pclose takes it

Returns: as C's _pclose returns it

fputc

text
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's fputc takes it
  • AFile: as C's fputc takes it

Returns: as C's fputc returns it

putc

text
func putc(const AChar: int32; const AFile: ptr): int32

C's putc, hooked.

Parameters

  • AChar: as C's putc takes it
  • AFile: as C's putc takes it

Returns: as C's putc returns it

_fputc_nolock

text
func _fputc_nolock(const AChar: int32; const AFile: ptr): int32

C's _fputc_nolock, hooked.

Parameters

  • AChar: as C's _fputc_nolock takes it
  • AFile: as C's _fputc_nolock takes it

Returns: as C's _fputc_nolock returns it

_putc_nolock

text
func _putc_nolock(const AChar: int32; const AFile: ptr): int32

C's _putc_nolock, hooked.

Parameters

  • AChar: as C's _putc_nolock takes it
  • AFile: as C's _putc_nolock takes it

Returns: as C's _putc_nolock returns it

fputs

text
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's fputs takes it
  • AFile: as C's fputs takes it

Returns: as C's fputs returns it

fputwc

text
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's fputwc takes it
  • AFile: as C's fputwc takes it

Returns: as C's fputwc returns it

putwc

text
func putwc(const AChar: wchar; const AFile: ptr): uint16

C's putwc, hooked.

Parameters

  • AChar: as C's putwc takes it
  • AFile: as C's putwc takes it

Returns: as C's putwc returns it

_fputwc_nolock

text
func _fputwc_nolock(const AChar: wchar; const AFile: ptr): uint16

C's _fputwc_nolock, hooked.

Parameters

  • AChar: as C's _fputwc_nolock takes it
  • AFile: as C's _fputwc_nolock takes it

Returns: as C's _fputwc_nolock returns it

_putwc_nolock

text
func _putwc_nolock(const AChar: wchar; const AFile: ptr): uint16

C's _putwc_nolock, hooked.

Parameters

  • AChar: as C's _putwc_nolock takes it
  • AFile: as C's _putwc_nolock takes it

Returns: as C's _putwc_nolock returns it

fputws

text
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's fputws takes it
  • AFile: as C's fputws takes it

Returns: as C's fputws returns it

fgetwc

text
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's fgetwc takes it

Returns: as C's fgetwc returns it

getwc

text
func getwc(const AFile: ptr): uint16

C's getwc, hooked.

Parameters

  • AFile: as C's getwc takes it

Returns: as C's getwc returns it

_fgetwc_nolock

text
func _fgetwc_nolock(const AFile: ptr): uint16

C's _fgetwc_nolock, hooked.

Parameters

  • AFile: as C's _fgetwc_nolock takes it

Returns: as C's _fgetwc_nolock returns it

_getwc_nolock

text
func _getwc_nolock(const AFile: ptr): uint16

C's _getwc_nolock, hooked.

Parameters

  • AFile: as C's _getwc_nolock takes it

Returns: as C's _getwc_nolock returns it

fgetws

text
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's fgetws takes it
  • ACount: as C's fgetws takes it
  • AFile: as C's fgetws takes it

Returns: as C's fgetws returns it

ungetwc

text
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's ungetwc takes it
  • AFile: as C's ungetwc takes it

Returns: as C's ungetwc returns it

_ungetwc_nolock

text
func _ungetwc_nolock(const AChar: wchar; const AFile: ptr): uint16

C's _ungetwc_nolock, hooked.

Parameters

  • AChar: as C's _ungetwc_nolock takes it
  • AFile: as C's _ungetwc_nolock takes it

Returns: as C's _ungetwc_nolock returns it

__stdio_common_vfprintf

text
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_vfprintf takes it
  • AFile: as C's __stdio_common_vfprintf takes it
  • AFormat: as C's __stdio_common_vfprintf takes it
  • ALocale: as C's __stdio_common_vfprintf takes it
  • AArgs: as C's __stdio_common_vfprintf takes it

Returns: as C's __stdio_common_vfprintf returns it

__stdio_common_vfprintf_s

text
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_s takes it
  • AFile: as C's __stdio_common_vfprintf_s takes it
  • AFormat: as C's __stdio_common_vfprintf_s takes it
  • ALocale: as C's __stdio_common_vfprintf_s takes it
  • AArgs: as C's __stdio_common_vfprintf_s takes it

Returns: as C's __stdio_common_vfprintf_s returns it

__stdio_common_vfprintf_p

text
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_p takes it
  • AFile: as C's __stdio_common_vfprintf_p takes it
  • AFormat: as C's __stdio_common_vfprintf_p takes it
  • ALocale: as C's __stdio_common_vfprintf_p takes it
  • AArgs: as C's __stdio_common_vfprintf_p takes it

Returns: as C's __stdio_common_vfprintf_p returns it

__stdio_common_vfscanf

text
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_vfscanf takes it
  • AFile: as C's __stdio_common_vfscanf takes it
  • AFormat: as C's __stdio_common_vfscanf takes it
  • ALocale: as C's __stdio_common_vfscanf takes it
  • AArgs: as C's __stdio_common_vfscanf takes it

Returns: as C's __stdio_common_vfscanf returns it

__stdio_common_vfwprintf

text
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_vfwprintf takes it
  • AFile: as C's __stdio_common_vfwprintf takes it
  • AFormat: as C's __stdio_common_vfwprintf takes it
  • ALocale: as C's __stdio_common_vfwprintf takes it
  • AArgs: as C's __stdio_common_vfwprintf takes it

Returns: as C's __stdio_common_vfwprintf returns it

__stdio_common_vfwprintf_s

text
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_s takes it
  • AFile: as C's __stdio_common_vfwprintf_s takes it
  • AFormat: as C's __stdio_common_vfwprintf_s takes it
  • ALocale: as C's __stdio_common_vfwprintf_s takes it
  • AArgs: as C's __stdio_common_vfwprintf_s takes it

Returns: as C's __stdio_common_vfwprintf_s returns it

__stdio_common_vfwprintf_p

text
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_p takes it
  • AFile: as C's __stdio_common_vfwprintf_p takes it
  • AFormat: as C's __stdio_common_vfwprintf_p takes it
  • ALocale: as C's __stdio_common_vfwprintf_p takes it
  • AArgs: as C's __stdio_common_vfwprintf_p takes it

Returns: as C's __stdio_common_vfwprintf_p returns it

__stdio_common_vfwscanf

text
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_vfwscanf takes it
  • AFile: as C's __stdio_common_vfwscanf takes it
  • AFormat: as C's __stdio_common_vfwscanf takes it
  • ALocale: as C's __stdio_common_vfwscanf takes it
  • AArgs: as C's __stdio_common_vfwscanf takes it

Returns: as C's __stdio_common_vfwscanf returns it

setvbuf

text
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's setvbuf takes it
  • ABuffer: as C's setvbuf takes it
  • AMode: as C's setvbuf takes it
  • ASize: as C's setvbuf takes it

Returns: as C's setvbuf returns it

setbuf

text
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's setbuf takes it
  • ABuffer: as C's setbuf takes it

fflush

text
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's fflush takes it

Returns: as C's fflush returns it

_fflush_nolock

text
func _fflush_nolock(const AFile: ptr): int32

C's _fflush_nolock, hooked: fflush

Parameters

  • AFile: as C's _fflush_nolock takes it

Returns: as C's _fflush_nolock returns it

_fclose_nolock

text
func _fclose_nolock(const AFile: ptr): int32

C's _fclose_nolock, hooked: fclose

Parameters

  • AFile: as C's _fclose_nolock takes it

Returns: as C's _fclose_nolock returns it

fgetpos

text
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's fgetpos takes it
  • APosition: as C's fgetpos takes it

Returns: as C's fgetpos returns it

fsetpos

text
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's fsetpos takes it
  • APosition: as C's fsetpos takes it

Returns: as C's fsetpos returns it

clearerr_s

text
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's clearerr_s takes it

Returns: as C's clearerr_s returns it

_getw

text
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 _getw takes it

Returns: as C's _getw returns it

_putw

text
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 _putw takes it
  • AFile: as C's _putw takes it

Returns: as C's _putw returns it

freopen_s

text
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's freopen_s takes it
  • APath: as C's freopen_s takes it
  • AMode: as C's freopen_s takes it
  • AFile: as C's freopen_s takes it

Returns: as C's freopen_s returns it

_wfreopen

text
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 _wfreopen takes it
  • AMode: as C's _wfreopen takes it
  • AFile: as C's _wfreopen takes it

Returns: as C's _wfreopen returns it

_wfreopen_s

text
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_s takes it
  • APath: as C's _wfreopen_s takes it
  • AMode: as C's _wfreopen_s takes it
  • AFile: as C's _wfreopen_s takes it

Returns: as C's _wfreopen_s returns it

fread_s

text
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's fread_s takes it
  • ARoom: as C's fread_s takes it
  • ASize: as C's fread_s takes it
  • ACount: as C's fread_s takes it
  • AFile: as C's fread_s takes it

Returns: as C's fread_s returns it

_fread_nolock_s

text
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_s takes it
  • ARoom: as C's _fread_nolock_s takes it
  • ASize: as C's _fread_nolock_s takes it
  • ACount: as C's _fread_nolock_s takes it
  • AFile: as C's _fread_nolock_s takes it

Returns: as C's _fread_nolock_s returns it

_open

text
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 _open takes it
  • AFlags: as C's _open takes it
  • ...: as C's _open takes them

Returns: as C's _open returns it

_wopen

text
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 _wopen takes it
  • AFlags: as C's _wopen takes it
  • ...: as C's _wopen takes them

Returns: as C's _wopen returns it

_sopen

text
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 _sopen takes it
  • AFlags: as C's _sopen takes it
  • AShare: as C's _sopen takes it
  • ...: as C's _sopen takes them

Returns: as C's _sopen returns it

_wsopen

text
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 _wsopen takes it
  • AFlags: as C's _wsopen takes it
  • AShare: as C's _wsopen takes it
  • ...: as C's _wsopen takes them

Returns: as C's _wsopen returns it

_sopen_s

text
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_s takes it
  • APath: as C's _sopen_s takes it
  • AFlags: as C's _sopen_s takes it
  • AShare: as C's _sopen_s takes it
  • APMode: as C's _sopen_s takes it

Returns: as C's _sopen_s returns it

_wsopen_s

text
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_s takes it
  • APath: as C's _wsopen_s takes it
  • AFlags: as C's _wsopen_s takes it
  • AShare: as C's _wsopen_s takes it
  • APMode: as C's _wsopen_s takes it

Returns: as C's _wsopen_s returns it

_creat

text
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 _creat takes it
  • APMode: as C's _creat takes it

Returns: as C's _creat returns it

_wcreat

text
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 _wcreat takes it
  • APMode: as C's _wcreat takes it

Returns: as C's _wcreat returns it

_read

text
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 _read takes it
  • ABuffer: as C's _read takes it
  • ACount: as C's _read takes it

Returns: as C's _read returns it

_write

text
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 _write takes it
  • ABuffer: as C's _write takes it
  • ACount: as C's _write takes it

Returns: as C's _write returns it

_lseek

text
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 _lseek takes it
  • AOffset: as C's _lseek takes it
  • AOrigin: as C's _lseek takes it

Returns: as C's _lseek returns it

_lseeki64

text
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 _lseeki64 takes it
  • AOffset: as C's _lseeki64 takes it
  • AOrigin: as C's _lseeki64 takes it

Returns: as C's _lseeki64 returns it

_tell

text
func _tell(const AFile: int32): clong

C's _tell, hooked: ucrt's _lseek(AFile, 0, SEEK_CUR)

Parameters

  • AFile: as C's _tell takes it

Returns: as C's _tell returns it

_telli64

text
func _telli64(const AFile: int32): int64

C's _telli64, hooked: ucrt's _lseeki64(AFile, 0, SEEK_CUR)

Parameters

  • AFile: as C's _telli64 takes it

Returns: as C's _telli64 returns it

_eof

text
func _eof(const AFile: int32): int32

C's _eof, hooked: a handle's descriptor at its IO's end

Parameters

  • AFile: as C's _eof takes it

Returns: as C's _eof returns it

_filelength

text
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 _filelength takes it

Returns: as C's _filelength returns it

_filelengthi64

text
func _filelengthi64(const AFile: int32): int64

C's _filelengthi64, hooked: a handle's descriptor's length

Parameters

  • AFile: as C's _filelengthi64 takes it

Returns: as C's _filelengthi64 returns it

_commit

text
func _commit(const AFile: int32): int32

C's _commit, hooked: a handle's descriptor flushes its IO

Parameters

  • AFile: as C's _commit takes it

Returns: as C's _commit returns it

_close

text
func _close(const AFile: int32): int32

C's _close, hooked: a handle's descriptor closes

Parameters

  • AFile: as C's _close takes it

Returns: as C's _close returns it

_fstat32

text
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 _fstat32 takes it
  • ABuf: as C's _fstat32 takes it

Returns: as C's _fstat32 returns it

_fstat32i64

text
func _fstat32i64(const AFile: int32; const ABuf: ptr): int32

C's _fstat32i64, hooked.

Parameters

  • AFile: as C's _fstat32i64 takes it
  • ABuf: as C's _fstat32i64 takes it

Returns: as C's _fstat32i64 returns it

_fstat64i32

text
func _fstat64i32(const AFile: int32; const ABuf: ptr): int32

C's _fstat64i32, hooked.

Parameters

  • AFile: as C's _fstat64i32 takes it
  • ABuf: as C's _fstat64i32 takes it

Returns: as C's _fstat64i32 returns it

_fstat64

text
func _fstat64(const AFile: int32; const ABuf: ptr): int32

C's _fstat64, hooked.

Parameters

  • AFile: as C's _fstat64 takes it
  • ABuf: as C's _fstat64 takes it

Returns: as C's _fstat64 returns it

_setmode

text
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 _setmode takes it
  • AMode: as C's _setmode takes it

Returns: as C's _setmode returns it

_chsize_s

text
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_s takes it
  • ASize: as C's _chsize_s takes it

Returns: as C's _chsize_s returns it

_chsize

text
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 _chsize takes it
  • ASize: as C's _chsize takes it

Returns: as C's _chsize returns it

_get_osfhandle

text
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_osfhandle takes it

Returns: as C's _get_osfhandle returns it

_dup

text
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 _dup takes it

Returns: as C's _dup returns it

_dup2

text
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 _dup2 takes it
  • ATarget: as C's _dup2 takes it

Returns: as C's _dup2 returns it

_fdopen

text
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 _fdopen takes it
  • AMode: as C's _fdopen takes it

Returns: as C's _fdopen returns it

_wfdopen

text
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 _wfdopen takes it
  • AMode: as C's _wfdopen takes it

Returns: as C's _wfdopen returns it

_stat32

text
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 _stat32 takes it
  • ABuf: as C's _stat32 takes it

Returns: as C's _stat32 returns it

_stat32i64

text
func _stat32i64(const APath: ptr to const char; const ABuf: ptr): int32

C's _stat32i64, hooked.

Parameters

  • APath: as C's _stat32i64 takes it
  • ABuf: as C's _stat32i64 takes it

Returns: as C's _stat32i64 returns it

_stat64i32

text
func _stat64i32(const APath: ptr to const char; const ABuf: ptr): int32

C's _stat64i32, hooked.

Parameters

  • APath: as C's _stat64i32 takes it
  • ABuf: as C's _stat64i32 takes it

Returns: as C's _stat64i32 returns it

_stat64

text
func _stat64(const APath: ptr to const char; const ABuf: ptr): int32

C's _stat64, hooked.

Parameters

  • APath: as C's _stat64 takes it
  • ABuf: as C's _stat64 takes it

Returns: as C's _stat64 returns it

_wstat32

text
func _wstat32(const APath: ptr to const wchar; const ABuf: ptr): int32

C's _wstat32, hooked.

Parameters

  • APath: as C's _wstat32 takes it
  • ABuf: as C's _wstat32 takes it

Returns: as C's _wstat32 returns it

_wstat32i64

text
func _wstat32i64(const APath: ptr to const wchar; const ABuf: ptr): int32

C's _wstat32i64, hooked.

Parameters

  • APath: as C's _wstat32i64 takes it
  • ABuf: as C's _wstat32i64 takes it

Returns: as C's _wstat32i64 returns it

_wstat64i32

text
func _wstat64i32(const APath: ptr to const wchar; const ABuf: ptr): int32

C's _wstat64i32, hooked.

Parameters

  • APath: as C's _wstat64i32 takes it
  • ABuf: as C's _wstat64i32 takes it

Returns: as C's _wstat64i32 returns it

_wstat64

text
func _wstat64(const APath: ptr to const wchar; const ABuf: ptr): int32

C's _wstat64, hooked.

Parameters

  • APath: as C's _wstat64 takes it
  • ABuf: as C's _wstat64 takes 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

text
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

text
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

text
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

text
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

text
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

text
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 read
  • ABytes: receives the bytes (empty on failure)

Returns: false when it is a folder, is missing, or cannot be opened or read

ReadAllText

text
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 read
  • AText: 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

text
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 write
  • ABytes: its new contents

Returns: false when the path is a folder, its folder is missing, or it cannot be fully written

WriteAllText

text
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 write
  • AText: 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

text
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 file
  • ATargetPath: the file it replaces

Returns: true when the target now holds the source

DeleteFile

text
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

text
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

text
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

text
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 folder
  • AList: receives the names (no path)

Returns: false when the folder cannot be read

GetDirectories

text
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 folder
  • AList: receives the names (no path)

Returns: false when the folder cannot be read

text
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 folder
  • AMask: one or more MatchesGlob masks split by ; ("*.png;*.jpg"), matched to the name alone with ASCII case aside (*.png takes A.PNG); "" takes every file
  • ARecursive: true to look in every folder below it as well
  • AList: 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

text
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 resolve
  • ABaseDir: 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", "")

text
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

text
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 path
  • ASecond: the other path

Returns: true for the same file

SystemDir

text
func cpplink SystemDir(): string

The OS's own library folder (where its system libraries are).

Returns: the folder

UserCacheDir

text
func cpplink UserCacheDir(): string

The user's cache folder for Adam.

Returns: the folder, or "" when the OS gives none

SecureRandomBytes

text
func cpplink SecureRandomBytes(const ACount: int64; var ABytes: ByteArray): bool

ACount bytes from the OS's secure random generator.

Parameters

  • ACount: how many bytes
  • ABytes: receives them

Returns: false when the generator fails

TickCountMs

text
func cpplink TickCountMs(): int64

Milliseconds since a start the OS chooses: for timing, never a date.

Returns: the count

Delay

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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 file
  • ANewPath: its new path

Returns: false when AOldPath is not a file, ANewPath exists, its folder is missing or the OS refuses it

SetFileReadOnly

text
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 file
  • AReadOnly: true to make it read-only, false to make it writable again

Returns: false for a folder or a missing path

SetFileExecutable

text
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

text
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

text
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 variable
  • AValue: its value ("" leaves it empty, which GetEnvironmentVariable reads as not set)

Returns: true when it holds the asked value afterwards

IsFileHidden

text
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

text
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

text
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

text
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

text
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 copied
  • ATargetPath: the new file (its folder must exist)
  • AOverwrite: true to replace a file already at ATargetPath

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

text
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 format
  • AArgs: 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

text
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: as ResolvePath takes it
  • ABaseDir: as ResolvePath takes it

Returns: as ResolvePath returns it

text
func cpplink IOPlatformResolvePath(const APath: string): string

System.IO's ResolvePath against the working folder.

Parameters

  • APath: as ResolvePath takes it

Returns: as ResolvePath returns it

IOPlatformFileExists

text
func cpplink IOPlatformFileExists(const APath: string): bool

System.IO's FileExists: a file, a link followed.

Parameters

  • APath: as FileExists takes it

Returns: as FileExists returns it

IOPlatformDirectoryExists

text
func cpplink IOPlatformDirectoryExists(const APath: string): bool

System.IO's DirectoryExists: a folder, a link followed.

Parameters

  • APath: as DirectoryExists takes it

Returns: as DirectoryExists returns it

IOPlatformFileSize

text
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: as FileSize takes it

Returns: as FileSize returns it

IOPlatformFileWriteTime

text
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: as FileWriteTime takes it

Returns: as FileWriteTime returns it

IOPlatformNowNanos

text
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

text
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: as ReplaceFile takes it
  • ATargetPath: as ReplaceFile takes it

Returns: as ReplaceFile returns it

IOPlatformDeleteFile

text
func cpplink IOPlatformDeleteFile(const APath: string): bool

System.IO's DeleteFile: a file only, never a folder.

Parameters

  • APath: as DeleteFile takes it

Returns: as DeleteFile returns it

IOPlatformCreateDir

text
func cpplink IOPlatformCreateDir(const APath: string): bool

System.IO's CreateDir: one folder, its parent there already; false when the name exists.

Parameters

  • APath: as CreateDir takes it

Returns: as CreateDir returns it

IOPlatformForceDirectories

text
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: as ForceDirectories takes it

Returns: as ForceDirectories returns it

IOPlatformGetFiles

text
func cpplink IOPlatformGetFiles(const ADir: string; var AList: StringArray): bool

System.IO's GetFiles: the files in ADir, sorted by their bytes.

Parameters

  • ADir: as GetFiles takes it
  • AList: as GetFiles takes it

Returns: as GetFiles returns it

IOPlatformGetDirectories

text
func cpplink IOPlatformGetDirectories(const ADir: string; var AList: StringArray): bool

System.IO's GetDirectories: the folders in ADir, sorted by their bytes.

Parameters

  • ADir: as GetDirectories takes it
  • AList: as GetDirectories takes it

Returns: as GetDirectories returns it

IOPlatformSamePath

text
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: as SamePath takes it
  • ASecond: as SamePath takes it

Returns: as SamePath returns it

IOPlatformSystemDir

text
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

text
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

text
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: as SecureRandomBytes takes it
  • ABytes: as SecureRandomBytes takes it

Returns: as SecureRandomBytes returns it

IOPlatformTickCountMs

text
func cpplink IOPlatformTickCountMs(): int64

System.IO's TickCountMs: CLOCK_MONOTONIC in milliseconds.

Returns: as TickCountMs returns it

IOPlatformDelay

text
func cpplink IOPlatformDelay(const AMilliseconds: int32)

System.IO's Delay: nanosleep(2), the time left slept again when a signal woke it.

Parameters

  • AMilliseconds: as Delay takes it

IOPlatformPerformanceCounter

text
func cpplink IOPlatformPerformanceCounter(): int64

System.IO's PerformanceCounter: CLOCK_MONOTONIC in nanoseconds.

Returns: as PerformanceCounter returns it

IOPlatformPerformanceFrequency

text
func cpplink IOPlatformPerformanceFrequency(): int64

System.IO's PerformanceFrequency: nanoseconds, 10^9 counts a second.

Returns: as PerformanceFrequency returns it

IOPlatformExeDir

text
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

text
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

text
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: as RemoveDir takes it

Returns: as RemoveDir returns it

IOPlatformRemoveDir

text
func cpplink IOPlatformRemoveDir(const APath: string): bool

System.IO's RemoveDir: rmdir(2), an empty folder only.

Parameters

  • APath: as RemoveDir takes it

Returns: as RemoveDir returns it

IOPlatformRenameFile

text
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: as RenameFile takes it
  • ANewPath: as RenameFile takes it

Returns: as RenameFile returns it

IOPlatformSetFileReadOnly

text
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: as SetFileReadOnly takes it
  • AReadOnly: as SetFileReadOnly takes it

Returns: as SetFileReadOnly returns it

IOPlatformSetFileExecutable

text
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: as SetFileExecutable takes it

Returns: as SetFileExecutable returns it

IOPlatformGetEnvironmentVariable

text
func cpplink IOPlatformGetEnvironmentVariable(const AName: string): string

System.IO's GetEnvironmentVariable: getenv(3); "" when it is not set or AName is "".

Parameters

  • AName: as GetEnvironmentVariable takes it

Returns: as GetEnvironmentVariable returns it

IOPlatformSetEnvironmentVariable

text
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: as SetEnvironmentVariable takes it
  • AValue: as SetEnvironmentVariable takes it

Returns: as SetEnvironmentVariable returns it

IOPlatformFormatCList

text
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: as FormatCList takes it
  • AArgs: as FormatCList takes it

Returns: as FormatCList returns it

IOPlatformIsFileHidden

text
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: as IsFileHidden takes it

Returns: as IsFileHidden returns it

IOPlatformIsPathAbsolute

text
func cpplink IOPlatformIsPathAbsolute(const APath: string): bool

System.IO's IsPathAbsolute by Linux's rule, as text: rooted at '/' ('\' read as '/').

Parameters

  • APath: as IsPathAbsolute takes it

Returns: as IsPathAbsolute returns it

IOPlatformSetCurrentDir

text
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: as SetCurrentDir takes it

Returns: as SetCurrentDir returns it

IOPlatformCopyFile

text
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: as CopyFile takes it
  • ATargetPath: as CopyFile takes it
  • AOverwrite: as CopyFile takes 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

text
func cpplink IOPlatformFileExists(const APath: string): bool

System.IO's FileExists: System.Windows' Win* routine of the same job.

Parameters

  • APath: as FileExists takes it

Returns: as FileExists returns it

IOPlatformDirectoryExists

text
func cpplink IOPlatformDirectoryExists(const APath: string): bool

System.IO's DirectoryExists: System.Windows' Win* routine of the same job.

Parameters

  • APath: as DirectoryExists takes it

Returns: as DirectoryExists returns it

IOPlatformFileSize

text
func cpplink IOPlatformFileSize(const APath: string): int64

System.IO's FileSize: System.Windows' Win* routine of the same job.

Parameters

  • APath: as FileSize takes it

Returns: as FileSize returns it

IOPlatformFileWriteTime

text
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: as FileWriteTime takes it

Returns: as FileWriteTime returns it

IOPlatformNowNanos

text
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

text
func cpplink IOPlatformReplaceFile(const ASourcePath: string; const ATargetPath: string): bool

System.IO's ReplaceFile: System.Windows' Win* routine of the same job.

Parameters

  • ASourcePath: as ReplaceFile takes it
  • ATargetPath: as ReplaceFile takes it

Returns: as ReplaceFile returns it

IOPlatformDeleteFile

text
func cpplink IOPlatformDeleteFile(const APath: string): bool

System.IO's DeleteFile: System.Windows' Win* routine of the same job.

Parameters

  • APath: as DeleteFile takes it

Returns: as DeleteFile returns it

IOPlatformCreateDir

text
func cpplink IOPlatformCreateDir(const APath: string): bool

System.IO's CreateDir: System.Windows' Win* routine of the same job.

Parameters

  • APath: as CreateDir takes it

Returns: as CreateDir returns it

IOPlatformForceDirectories

text
func cpplink IOPlatformForceDirectories(const APath: string): bool

System.IO's ForceDirectories: System.Windows' Win* routine of the same job.

Parameters

  • APath: as ForceDirectories takes it

Returns: as ForceDirectories returns it

IOPlatformGetFiles

text
func cpplink IOPlatformGetFiles(const ADir: string; var AList: StringArray): bool

System.IO's GetFiles: System.Windows' Win* routine of the same job.

Parameters

  • ADir: as GetFiles takes it
  • AList: as GetFiles takes it

Returns: as GetFiles returns it

IOPlatformGetDirectories

text
func cpplink IOPlatformGetDirectories(const ADir: string; var AList: StringArray): bool

System.IO's GetDirectories: System.Windows' Win* routine of the same job.

Parameters

  • ADir: as GetDirectories takes it
  • AList: as GetDirectories takes it

Returns: as GetDirectories returns it

IOPlatformResolvePath

text
func cpplink IOPlatformResolvePath(const APath: string; const ABaseDir: string): string

System.IO's ResolvePath: System.Windows' Win* routine of the same job.

Parameters

  • APath: as ResolvePath takes it
  • ABaseDir: as ResolvePath takes it

Returns: as ResolvePath returns it

text
func cpplink IOPlatformResolvePath(const APath: string): string

System.IO's ResolvePath: System.Windows' Win* routine of the same job.

Parameters

  • APath: as ResolvePath takes it

Returns: as ResolvePath returns it

IOPlatformSamePath

text
func cpplink IOPlatformSamePath(const AFirst: string; const ASecond: string): bool

System.IO's SamePath: System.Windows' Win* routine of the same job.

Parameters

  • AFirst: as SamePath takes it
  • ASecond: as SamePath takes it

Returns: as SamePath returns it

IOPlatformSystemDir

text
func cpplink IOPlatformSystemDir(): string

System.IO's SystemDir: System.Windows' Win* routine of the same job.

Returns: as SystemDir returns it

IOPlatformUserCacheDir

text
func cpplink IOPlatformUserCacheDir(): string

System.IO's UserCacheDir: System.Windows' Win* routine of the same job.

Returns: as UserCacheDir returns it

IOPlatformSecureRandomBytes

text
func cpplink IOPlatformSecureRandomBytes(const ACount: int64; var ABytes: ByteArray): bool

System.IO's SecureRandomBytes: System.Windows' Win* routine of the same job.

Parameters

  • ACount: as SecureRandomBytes takes it
  • ABytes: as SecureRandomBytes takes it

Returns: as SecureRandomBytes returns it

IOPlatformTickCountMs

text
func cpplink IOPlatformTickCountMs(): int64

System.IO's TickCountMs: System.Windows' Win* routine of the same job.

Returns: as TickCountMs returns it

IOPlatformDelay

text
func cpplink IOPlatformDelay(const AMilliseconds: int32)

System.IO's Delay: System.Windows' Win* routine of the same job.

Parameters

  • AMilliseconds: as Delay takes it

IOPlatformPerformanceCounter

text
func cpplink IOPlatformPerformanceCounter(): int64

System.IO's PerformanceCounter: System.Windows' Win* routine of the same job.

Returns: as PerformanceCounter returns it

IOPlatformPerformanceFrequency

text
func cpplink IOPlatformPerformanceFrequency(): int64

System.IO's PerformanceFrequency: System.Windows' Win* routine of the same job.

Returns: as PerformanceFrequency returns it

IOPlatformExeDir

text
func cpplink IOPlatformExeDir(): string

System.IO's ExeDir: System.Windows' Win* routine of the same job.

Returns: as ExeDir returns it

IOPlatformTempDir

text
func cpplink IOPlatformTempDir(): string

System.IO's TempDir: System.Windows' Win* routine of the same job.

Returns: as TempDir returns it

IOPlatformRemoveDir

text
func cpplink IOPlatformRemoveDir(const APath: string): bool

System.IO's RemoveDir: System.Windows' Win* routine of the same job.

Parameters

  • APath: as RemoveDir takes it

Returns: as RemoveDir returns it

IOPlatformRemoveTree

text
func cpplink IOPlatformRemoveTree(const APath: string): bool

System.IO's recursive RemoveDir: System.Windows' Win* routine of the same job.

Parameters

  • APath: as RemoveDir takes it

Returns: as RemoveDir returns it

IOPlatformRenameFile

text
func cpplink IOPlatformRenameFile(const AOldPath: string; const ANewPath: string): bool

System.IO's RenameFile: System.Windows' Win* routine of the same job.

Parameters

  • AOldPath: as RenameFile takes it
  • ANewPath: as RenameFile takes it

Returns: as RenameFile returns it

IOPlatformSetFileReadOnly

text
func cpplink IOPlatformSetFileReadOnly(const APath: string; const AReadOnly: bool): bool

System.IO's SetFileReadOnly: System.Windows' Win* routine of the same job.

Parameters

  • APath: as SetFileReadOnly takes it
  • AReadOnly: as SetFileReadOnly takes it

Returns: as SetFileReadOnly returns it

IOPlatformSetFileExecutable

text
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: as SetFileExecutable takes it

Returns: as SetFileExecutable returns it

IOPlatformGetEnvironmentVariable

text
func cpplink IOPlatformGetEnvironmentVariable(const AName: string): string

System.IO's GetEnvironmentVariable: System.Windows' Win* routine of the same job.

Parameters

  • AName: as GetEnvironmentVariable takes it

Returns: as GetEnvironmentVariable returns it

IOPlatformSetEnvironmentVariable

text
func cpplink IOPlatformSetEnvironmentVariable(const AName: string; const AValue: string): bool

System.IO's SetEnvironmentVariable: System.Windows' Win* routine of the same job.

Parameters

  • AName: as SetEnvironmentVariable takes it
  • AValue: as SetEnvironmentVariable takes it

Returns: as SetEnvironmentVariable returns it

IOPlatformFormatCList

text
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: as FormatCList takes it
  • AArgs: as FormatCList takes it

Returns: as FormatCList returns it

IOPlatformIsFileHidden

text
func cpplink IOPlatformIsFileHidden(const APath: string): bool

System.IO's IsFileHidden: System.Windows' Win* routine of the same job (the hidden attribute).

Parameters

  • APath: as IsFileHidden takes it

Returns: as IsFileHidden returns it

IOPlatformIsPathAbsolute

text
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: as IsPathAbsolute takes it

Returns: as IsPathAbsolute returns it

IOPlatformSetCurrentDir

text
func cpplink IOPlatformSetCurrentDir(const APath: string): bool

System.IO's SetCurrentDir: System.Windows' Win* routine of the same job.

Parameters

  • APath: as SetCurrentDir takes it

Returns: as SetCurrentDir returns it

IOPlatformCopyFile

text
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: as CopyFile takes it
  • ATargetPath: as CopyFile takes it
  • AOverwrite: as CopyFile takes 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

text
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

text
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: AText the JSON text. Returns: false with ErrorText (<text>(line,col): message) when it is no valid JSON
  • method 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: APath the 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: AIO the 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 fail
  • static method FromString(const AText: string): JSON: A JSON value parsed from text. Parameters: AText the 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: APath the file. Returns: the value; a missing value with its ErrorText on a failure
  • static method FromIO(const AIO: IO): JSON: A JSON value read from the text an IO holds, from its place to its end. Parameters: AIO the IO. Returns: the value; a missing value with its ErrorText on a failure
  • static method TryFromString(const AText: string; var AJSON: JSON): bool: A JSON value parsed from text, the outcome as a result. Parameters: AText the JSON text; AJSON receives the value (a missing value, its ErrorText why, on a failure). Returns: false when it is no valid JSON
  • const 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 text
  • const method ToPrettyString(const AIndent: int32): string: The value as JSON text, a line per member. Parameters: AIndent the spaces per level. Returns: the text
  • method 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: APath the file. Returns: false when it cannot be written
  • method SaveToFile(const APath: string; const APretty: bool): bool: Writes the value to a file, through C's file calls. Parameters: APath the file; APretty true for 2 spaces a level, false for compact text. Returns: false when it cannot be written
  • method SaveToIO(const AIO: IO): bool: Writes the value's text to an IO at its place, pretty (2 spaces). Parameters: AIO the IO. Returns: false when not all of it could be written
  • method SaveToIO(const AIO: IO; const APretty: bool): bool: Writes the value's text to an IO at its place. Parameters: AIO the IO; APretty true for 2 spaces a level, false for compact text. Returns: false when not all of it could be written
  • method 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: AKey the key; AValue the value. Returns: this value, so calls chain
  • method 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: AKey the key; AValue the value. Returns: this value, so calls chain
  • method 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: AKey the key; AValue the value. Returns: this value, so calls chain
  • method 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: AKey the key; AValue the value. Returns: this value, so calls chain
  • method 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: AKey the key; AValue the value. Returns: this value, so calls chain
  • method 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: AKey the key; AValue the value. Returns: this value, so calls chain
  • method 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: AKey the key; AValue the value. Returns: this value, so calls chain
  • method 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: AKey the key; AValue the value copied. Returns: this value, so calls chain
  • method AddNull(const AKey: string): JSON: Adds null under a key to the open object. Parameters: AKey the key. Returns: this value, so calls chain
  • method 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: AKey the key; AJSONText the JSON text. Returns: this value, so calls chain
  • method Add(const AValue: string): JSON: Appends a string to the open array (nothing changes in an object). Parameters: AValue the value. Returns: this value, so calls chain
  • method Add(const AValue: int32): JSON: Appends a signed number to the open array (nothing changes in an object). Parameters: AValue the value. Returns: this value, so calls chain
  • method Add(const AValue: int64): JSON: Appends a signed number to the open array (nothing changes in an object). Parameters: AValue the value. Returns: this value, so calls chain
  • method Add(const AValue: uint32): JSON: Appends an unsigned number to the open array (nothing changes in an object). Parameters: AValue the value. Returns: this value, so calls chain
  • method Add(const AValue: uint64): JSON: Appends an unsigned number to the open array (nothing changes in an object). Parameters: AValue the value. Returns: this value, so calls chain
  • method Add(const AValue: float64): JSON: Appends a number to the open array (nothing changes in an object). Parameters: AValue the value. Returns: this value, so calls chain
  • method Add(const AValue: bool): JSON: Appends true or false to the open array (nothing changes in an object). Parameters: AValue the value. Returns: this value, so calls chain
  • method Add(const AValue: JSON): JSON: Appends a copy of a value's tree to the open array. Parameters: AValue the value copied. Returns: this value, so calls chain
  • method AddNull(): JSON: Appends null to the open array. Returns: this value, so calls chain
  • method AddStrings(const AKey: string; const AValues: StringArray): JSON: Adds an array of strings under a key to the open object. Parameters: AKey the key; AValues the strings. Returns: this value, so calls chain
  • method AddIntegers(const AKey: string; const AValues: Int64Array): JSON: Adds an array of whole numbers under a key to the open object. Parameters: AKey the key; AValues the numbers. Returns: this value, so calls chain
  • method AddDoubles(const AKey: string; const AValues: array of float64): JSON: Adds an array of numbers under a key to the open object. Parameters: AKey the key; AValues the numbers. Returns: this value, so calls chain
  • method BeginObject(const AKey: string): JSON: Opens an object under a key in the open object: the next Adds go into it until EndObject. Parameters: AKey the 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 chain
  • method EndObject(): JSON: Closes the object BeginObject opened. Returns: this value, so calls chain
  • method BeginArray(const AKey: string): JSON: Opens an array under a key in the open object: the next Adds go into it until EndArray. Parameters: AKey the key. Returns: this value, so calls chain
  • method BeginArray(): JSON: Opens an array appended to the open array: the next Adds go into it until EndArray. Returns: this value, so calls chain
  • method EndArray(): JSON: Closes the array BeginArray opened. Returns: this value, so calls chain
  • const method Get(const APath: string): JSON: The value a path names, a view sharing this tree. Parameters: APath the 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: APath the path (keys joined by ., an item as [N]; "" the value itself). Returns: true when it does
  • const method Get(const APath: string; const ALiteral: bool): JSON: The value a path (or one key) names, a view sharing this tree. Parameters: APath the path (keys joined by ., an item as [N]; "" the value itself); ALiteral true to take APath as one key of this object (no . or [N] split). Returns: the value; a missing value when it names none
  • const method Has(const APath: string; const ALiteral: bool): bool: Whether a path (or one key) names a value. Parameters: APath the path (keys joined by ., an item as [N]; "" the value itself); ALiteral true to take APath as one key of this object (no . or [N] split). Returns: true when it does
  • const 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: APath the path (keys joined by ., an item as [N]; "" the value itself); AValue receives the value; "" when the kind differs. Returns: true when the value is of this kind
  • const 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: APath the path (keys joined by ., an item as [N]; "" the value itself); AValue receives the value; "" when the kind differs; ALiteral true to take APath as one key of this object (no . or [N] split). Returns: true when the value is of this kind
  • const 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: APath the path (keys joined by ., an item as [N]; "" the value itself); AValue receives the value; 0 when the kind differs. Returns: true when the value is of this kind
  • const 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: APath the path (keys joined by ., an item as [N]; "" the value itself); AValue receives the value; 0 when the kind differs; ALiteral true to take APath as one key of this object (no . or [N] split). Returns: true when the value is of this kind
  • const 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: APath the path (keys joined by ., an item as [N]; "" the value itself); AValue receives the value; 0 when the kind differs. Returns: true when the value is of this kind
  • const 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: APath the path (keys joined by ., an item as [N]; "" the value itself); AValue receives the value; 0 when the kind differs; ALiteral true to take APath as one key of this object (no . or [N] split). Returns: true when the value is of this kind
  • const 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: APath the path (keys joined by ., an item as [N]; "" the value itself); AValue receives the value; false when the kind differs. Returns: true when the value is of this kind
  • const 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: APath the path (keys joined by ., an item as [N]; "" the value itself); AValue receives the value; false when the kind differs; ALiteral true to take APath as one key of this object (no . or [N] split). Returns: true when the value is of this kind
  • const 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: APath the path (keys joined by ., an item as [N]; "" the value itself); AValue receives the value; an empty JSON when the kind differs. Returns: true when the value is of this kind
  • const 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: APath the path (keys joined by ., an item as [N]; "" the value itself); AValue receives the value; an empty JSON when the kind differs; ALiteral true to take APath as one key of this object (no . or [N] split). Returns: true when the value is of this kind
  • const 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: APath the path (keys joined by ., an item as [N]; "" the value itself); AValue receives the value; an empty JSON when the kind differs. Returns: true when the value is of this kind
  • const 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: APath the path (keys joined by ., an item as [N]; "" the value itself); AValue receives the value; an empty JSON when the kind differs; ALiteral true to take APath as one key of this object (no . or [N] split). Returns: true when the value is of this kind
  • const method Count(): int64: How many items an array or members an object holds. Returns: the count; 0 for any other value
  • const method Keys(): StringArray: An object's keys, in order. Returns: the keys; none for any other value
  • const method Items(): array of JSON: An array's items or an object's values, in order, each a view (for .. in walks 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 value
  • const method First(): JSON: An array's first item. Returns: the item; a missing value for an empty array or any other value
  • const method Last(): JSON: An array's last item. Returns: the item; a missing value for an empty array or any other value
  • const method Contains(const AValue: string): bool: Whether the value is an array holding a string. Parameters: AValue the string. Returns: true when it holds it
  • const method Contains(const AValue: int64): bool: Whether the value is an array holding a whole number. Parameters: AValue the number. Returns: true when it holds it
  • const 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 none
  • const 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: ADefault the result when the value gives none. Returns: the value, or ADefault
  • const 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 none
  • const method AsBoolean(const ADefault: bool): bool: true / false, a number (not 0), or the string "true" (any case). Parameters: ADefault the result when the value gives none. Returns: the value, or ADefault
  • const 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 none
  • const method AsInt64(const ADefault: int64): int64: A number (a real one truncated toward 0) or a decimal string, when int64 holds it. Parameters: ADefault the result when the value gives none. Returns: the value, or ADefault
  • const method AsInt32(): int32: AsInt64's number, when int32 holds it. Returns: the value; the kind's zero when the value gives none
  • const method AsInt32(const ADefault: int32): int32: AsInt64's number, when int32 holds it. Parameters: ADefault the result when the value gives none. Returns: the value, or ADefault
  • const 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 none
  • const method AsUInt64(const ADefault: uint64): uint64: A whole number of 0 or more (beyond int64 too), when uint64 holds it. Parameters: ADefault the result when the value gives none. Returns: the value, or ADefault
  • const method AsUInt32(): uint32: AsUInt64's number, when uint32 holds it. Returns: the value; the kind's zero when the value gives none
  • const method AsUInt32(const ADefault: uint32): uint32: AsUInt64's number, when uint32 holds it. Parameters: ADefault the result when the value gives none. Returns: the value, or ADefault
  • const method AsDouble(): float64: A number or a decimal string, as a float64. Returns: the value; the kind's zero when the value gives none
  • const method AsDouble(const ADefault: float64): float64: A number or a decimal string, as a float64. Parameters: ADefault the result when the value gives none. Returns: the value, or ADefault
  • const 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 none
  • const method AsSingle(const ADefault: float32): float32: AsDouble's number as a float32 (past its range: an infinity). Parameters: ADefault the result when the value gives none. Returns: the value, or ADefault
  • const method AsStringArray(): StringArray: An array's items as strings (AsString each). Returns: the strings; none for any other value
  • const method AsInt32Array(): array of int32: An array's items as int32 numbers (AsInt32 each). Returns: the numbers; none for any other value
  • const method AsInt64Array(): Int64Array: An array's items as int64 numbers (AsInt64 each). Returns: the numbers; none for any other value
  • const method AsDoubleArray(): array of float64: An array's items as float64 numbers (AsDouble each). Returns: the numbers; none for any other value
  • const method IsNull(): bool: Whether the value is null (a missing value is). Returns: true for null
  • const method IsObject(): bool: Whether the value is an object (a fresh value is). Returns: true for an object
  • const method IsArray(): bool: Whether the value is an array. Returns: true for an array
  • const method IsNumber(): bool: Whether the value is a number. Returns: true for a number
  • const method IsString(): bool: Whether the value is a string. Returns: true for a string
  • const method IsBoolean(): bool: Whether the value is true or false. Returns: true for a boolean
  • method ForEach(const ACallback: JSONCallback; const AUserData: ptr): JSON: Calls a routine with each of Items. Parameters: ACallback the routine; AUserData the pointer it is given. Returns: this value, so calls chain
  • method Remove(const AKey: string): JSON: Removes an object's members of a key. Parameters: AKey the key. Returns: this value, so calls chain
  • method Merge(const AOther: JSON): JSON: Copies another object's members in, each replacing this one's of its key (both objects). Parameters: AOther the object copied from. Returns: this value, so calls chain
  • const 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

text
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

text
type timespec = record

Linux's timespec: struct timespec (time.h): seconds and nanoseconds

Members

  • tv_sec: int64: Linux's timespec.tv_sec.
  • tv_nsec: int64: Linux's timespec.tv_nsec.

itimerspec

text
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's itimerspec.it_interval.
  • it_value: timespec: Linux's itimerspec.it_value.

sigevent

text
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's sigevent.sigev_value.
  • sigev_signo: int32: Linux's sigevent.sigev_signo.
  • sigev_notify: int32: Linux's sigevent.sigev_notify.
  • sigev_notify_function: func(ptr): Linux's sigevent.sigev_notify_function.
  • sigev_notify_attributes: ptr: Linux's sigevent.sigev_notify_attributes.
  • pad0: array[0..7] of int32: Linux's sigevent.pad0.

stat

text
type stat = record

Linux's stat: struct stat (x86_64, 144 bytes; bits/struct_stat.h)

Members

  • st_dev: uint64: Linux's stat.st_dev.
  • st_ino: uint64: Linux's stat.st_ino.
  • st_nlink: uint64: Linux's stat.st_nlink.
  • st_mode: uint32: Linux's stat.st_mode.
  • st_uid: uint32: Linux's stat.st_uid.
  • st_gid: uint32: Linux's stat.st_gid.
  • pad0: int32: Linux's stat.pad0.
  • st_rdev: uint64: Linux's stat.st_rdev.
  • st_size: int64: Linux's stat.st_size.
  • st_blksize: int64: Linux's stat.st_blksize.
  • st_blocks: int64: Linux's stat.st_blocks.
  • st_atim: timespec: Linux's stat.st_atim.
  • st_mtim: timespec: Linux's stat.st_mtim.
  • st_ctim: timespec: Linux's stat.st_ctim.
  • reserved: array[0..2] of int64: Linux's stat.reserved.

termios

text
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's termios.c_iflag.
  • c_oflag: uint32: Linux's termios.c_oflag.
  • c_cflag: uint32: Linux's termios.c_cflag.
  • c_lflag: uint32: Linux's termios.c_lflag.
  • c_line: uint8: Linux's termios.c_line.
  • c_cc: array[0..31] of uint8: Linux's termios.c_cc.
  • c_ispeed: uint32: Linux's termios.c_ispeed.
  • c_ospeed: uint32: Linux's termios.c_ospeed.

winsize

text
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's winsize.ws_row.
  • ws_col: uint16: Linux's winsize.ws_col.
  • ws_xpixel: uint16: Linux's winsize.ws_xpixel.
  • ws_ypixel: uint16: Linux's winsize.ws_ypixel.

pollfd

text
type pollfd = record

Linux's pollfd: struct pollfd (sys/poll.h): one descriptor, the events asked for, the events seen

Members

  • fd: int32: Linux's pollfd.fd.
  • events: int16: Linux's pollfd.events.
  • revents: int16: Linux's pollfd.revents.

sigset_t

text
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's sigset_t.val.

sched_param

text
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's sched_param.sched_priority.

posix_spawn_file_actions_t

text
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's posix_spawn_file_actions_t.allocated.
  • used: int32: Linux's posix_spawn_file_actions_t.used.
  • actions: ptr: Linux's posix_spawn_file_actions_t.actions.
  • pad: array[0..15] of int32: Linux's posix_spawn_file_actions_t.pad.

posix_spawnattr_t

text
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's posix_spawnattr_t.flags.
  • pgrp: int32: Linux's posix_spawnattr_t.pgrp.
  • sd: sigset_t: Linux's posix_spawnattr_t.sd.
  • ss: sigset_t: Linux's posix_spawnattr_t.ss.
  • sp: sched_param: Linux's posix_spawnattr_t.sp.
  • policy: int32: Linux's posix_spawnattr_t.policy.
  • pad: array[0..15] of int32: Linux's posix_spawnattr_t.pad.

utsname

text
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's utsname.sysname: the kernel's name ("Linux").
  • nodename: array[0..64] of char: Linux's utsname.nodename.
  • release: array[0..64] of char: Linux's utsname.release: the kernel's release ("6.6.87.2-microsoft-standard-WSL2").
  • version: array[0..64] of char: Linux's utsname.version.
  • machine: array[0..64] of char: Linux's utsname.machine.
  • domainname: array[0..64] of char: Linux's utsname.domainname.

Constants

NameDeclarationDescription
_SC_PAGESIZEconst _SC_PAGESIZE: int32 = 30Linux's _SC_PAGESIZE: unistd.h: sysconf's page size in bytes
_SC_PHYS_PAGESconst _SC_PHYS_PAGES: int32 = 85Linux's _SC_PHYS_PAGES: unistd.h: sysconf's count of physical memory pages
_SC_NPROCESSORS_ONLNconst _SC_NPROCESSORS_ONLN: int32 = 84Linux's _SC_NPROCESSORS_ONLN: unistd.h: sysconf's count of processors online
_STAT_VERconst _STAT_VER: int32 = 1Linux'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_IFMTconst S_IFMT: uint32 = 0xF000Linux'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_IFDIRconst S_IFDIR: uint32 = 0x4000Linux'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_IFREGconst S_IFREG: uint32 = 0x8000Linux'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_IFLNKconst S_IFLNK: uint32 = 0xA000Linux'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_IFIFOconst S_IFIFO: uint32 = 0x1000Linux'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_IRUSRconst S_IRUSR: uint32 = 0x100Linux's S_IRUSR: sys/stat.h: st_mode's permission bits (the owner's read and write, the group's, others')
S_IWUSRconst S_IWUSR: uint32 = 0x80Linux's S_IWUSR: sys/stat.h: st_mode's permission bits (the owner's read and write, the group's, others')
S_IRGRPconst S_IRGRP: uint32 = 0x20Linux's S_IRGRP: sys/stat.h: st_mode's permission bits (the owner's read and write, the group's, others')
S_IWGRPconst S_IWGRP: uint32 = 0x10Linux's S_IWGRP: sys/stat.h: st_mode's permission bits (the owner's read and write, the group's, others')
S_IROTHconst S_IROTH: uint32 = 0x4Linux's S_IROTH: sys/stat.h: st_mode's permission bits (the owner's read and write, the group's, others')
S_IWOTHconst S_IWOTH: uint32 = 0x2Linux's S_IWOTH: sys/stat.h: st_mode's permission bits (the owner's read and write, the group's, others')
S_IXUSRconst S_IXUSR: uint32 = 0x40Linux'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_IXGRPconst S_IXGRP: uint32 = 0x8Linux'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_IXOTHconst S_IXOTH: uint32 = 0x1Linux'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)
ALLPERMSconst ALLPERMS: uint32 = 0xFFFLinux'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_ACCMODEconst O_ACCMODE: int32 = 3Linux'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_RDONLYconst O_RDONLY: int32 = 0Linux'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_WRONLYconst O_WRONLY: int32 = 1Linux'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_RDWRconst O_RDWR: int32 = 2Linux'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_CREATconst O_CREAT: int32 = 0x40Linux'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_EXCLconst O_EXCL: int32 = 0x80Linux'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_NOCTTYconst O_NOCTTY: int32 = 0x100Linux'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_TRUNCconst O_TRUNC: int32 = 0x200Linux'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_APPENDconst O_APPEND: int32 = 0x400Linux'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_DIRECTORYconst O_DIRECTORY: int32 = 0x10000Linux'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_CLOEXECconst O_CLOEXEC: int32 = 0x80000Linux'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_TMPFILEconst O_TMPFILE: int32 = 0x410000Linux'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_DUPFDconst F_DUPFD: int32 = 0Linux'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_GETFLconst F_GETFL: int32 = 3Linux'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_SETFLconst F_SETFL: int32 = 4Linux'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_CLOEXECconst F_DUPFD_CLOEXEC: int32 = 1030Linux'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_OKconst F_OK: int32 = 0Linux's F_OK: unistd.h: access's modes (there, executable, writable, readable)
X_OKconst X_OK: int32 = 1Linux's X_OK: unistd.h: access's modes (there, executable, writable, readable)
W_OKconst W_OK: int32 = 2Linux's W_OK: unistd.h: access's modes (there, executable, writable, readable)
R_OKconst R_OK: int32 = 4Linux's R_OK: unistd.h: access's modes (there, executable, writable, readable)
PROT_WRITEconst PROT_WRITE: int32 = 2Linux'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_SHAREDconst MAP_SHARED: int32 = 1Linux'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_PRIVATEconst MAP_PRIVATE: int32 = 2Linux'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_ANONYMOUSconst MAP_ANONYMOUS: int32 = 0x20Linux'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_FAILEDconst MAP_FAILED: uint64 = 18446744073709551615uLinux'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_MAXconst SSIZE_MAX: int64 = 9223372036854775807Linux's SSIZE_MAX: limits.h (bits/posix1_lim.h, x86_64): the largest ssize_t, the most one read(2) moves
_IOFBFconst _IOFBF: int32 = 0Linux's _IOFBF: stdio.h: setvbuf's modes (full, line, no buffering) and setbuf's buffer size
_IOLBFconst _IOLBF: int32 = 1Linux's _IOLBF: stdio.h: setvbuf's modes (full, line, no buffering) and setbuf's buffer size
_IONBFconst _IONBF: int32 = 2Linux's _IONBF: stdio.h: setvbuf's modes (full, line, no buffering) and setbuf's buffer size
BUFSIZconst BUFSIZ: uint64 = 8192uLinux's BUFSIZ: stdio.h: setvbuf's modes (full, line, no buffering) and setbuf's buffer size
CODESETconst CODESET: int32 = 14Linux's CODESET: langinfo.h: nl_langinfo's item for the locale's character set name
P_tmpdirconst P_tmpdir: string = "/tmp"Linux's P_tmpdir: stdio.h: the folder for temporary files when $TMPDIR names none
CLOCK_REALTIMEconst CLOCK_REALTIME: int32 = 0Linux's CLOCK_REALTIME: time.h: the wall clock, seconds since 1970-01-01 UTC (st_mtim's clock)
CLOCK_MONOTONICconst CLOCK_MONOTONIC: int32 = 1Linux's CLOCK_MONOTONIC: time.h: the clock from a fixed point, never going back
SIGEV_THREADconst SIGEV_THREAD: int32 = 2Linux's SIGEV_THREAD: signal.h: a sigevent's notification on a thread glibc starts (sigev_notify_function)
SYS_chdirconst SYS_chdir: int64 = 80Linux's SYS_chdir: sys/syscall.h (x86_64): the kernel's chdir (System.IO's SetCurrentDir: no hook between)
EINTRconst EINTR: int32 = 4Linux'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
EXDEVconst EXDEV: int32 = 18Linux'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
E2BIGconst E2BIG: int32 = 7Linux'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
EAGAINconst EAGAIN: int32 = 11Linux'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
ENODEVconst ENODEV: int32 = 19Linux'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
ENOTDIRconst ENOTDIR: int32 = 20Linux'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
EMFILEconst EMFILE: int32 = 24Linux'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
ESPIPEconst ESPIPE: int32 = 29Linux'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_FILENOconst STDIN_FILENO: int32 = 0Linux's STDIN_FILENO: unistd.h: the standard descriptors
STDOUT_FILENOconst STDOUT_FILENO: int32 = 1Linux's STDOUT_FILENO: unistd.h: the standard descriptors
STDERR_FILENOconst STDERR_FILENO: int32 = 2Linux's STDERR_FILENO: unistd.h: the standard descriptors
WNOHANGconst WNOHANG: int32 = 1Linux's WNOHANG: sys/wait.h: waitpid returns at once when no child has changed state
POSIX_SPAWN_SETSIGDEFconst POSIX_SPAWN_SETSIGDEF: int16 = 0x4Linux's POSIX_SPAWN_SETSIGDEF: spawn.h: posix_spawnattr_setflags' flags (the signal defaults and mask set; a new session)
POSIX_SPAWN_SETSIGMASKconst POSIX_SPAWN_SETSIGMASK: int16 = 0x8Linux's POSIX_SPAWN_SETSIGMASK: spawn.h: posix_spawnattr_setflags' flags (the signal defaults and mask set; a new session)
POSIX_SPAWN_SETSIDconst POSIX_SPAWN_SETSID: int16 = 0x80Linux's POSIX_SPAWN_SETSID: spawn.h: posix_spawnattr_setflags' flags (the signal defaults and mask set; a new session)
TCSANOWconst TCSANOW: int32 = 0Linux'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)
TCIFLUSHconst TCIFLUSH: int32 = 0Linux'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)
NCCSconst NCCS: int32 = 32Linux'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)
VTIMEconst VTIME: int32 = 5Linux'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)
VMINconst VMIN: int32 = 6Linux'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)
ICRNLconst ICRNL: uint32 = 0x100Linux'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)
IXONconst IXON: uint32 = 0x400Linux'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)
ISIGconst ISIG: uint32 = 0x1Linux'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)
ICANONconst ICANON: uint32 = 0x2Linux'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)
ECHOconst ECHO: uint32 = 0x8Linux'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)
IEXTENconst IEXTEN: uint32 = 0x8000Linux'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)
TIOCGWINSZconst TIOCGWINSZ: uint64 = 0x5413Linux's TIOCGWINSZ: asm-generic/ioctls.h: a terminal's size read / set (struct winsize)
TIOCSWINSZconst TIOCSWINSZ: uint64 = 0x5414Linux's TIOCSWINSZ: asm-generic/ioctls.h: a terminal's size read / set (struct winsize)
POLLINconst POLLIN: int16 = 0x1Linux's POLLIN: poll.h: data to read

Variables

NameDeclarationDescription
environvar environ: ptr to ptr to charLinux's environ: glibc (unistd.h): the process's environment as it is now (setenv changes it), NULL-ended

Routines

__xstat

text
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 __xstat takes it
  • APath: as Linux's __xstat takes it
  • AStat: as Linux's __xstat takes it

Returns: as Linux's __xstat returns it

mkdir

text
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's mkdir takes it
  • AMode: as Linux's mkdir takes it

Returns: as Linux's mkdir returns it

rename

text
func rename(const AOldPath: ptr to const char; const ANewPath: ptr to const char): int32

Linux's rename.

Parameters

  • AOldPath: as Linux's rename takes it
  • ANewPath: as Linux's rename takes it

Returns: as Linux's rename returns it

text
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's symlink takes it
  • ALinkPath: as Linux's symlink takes it

Returns: as Linux's symlink returns it

rmdir

text
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's rmdir takes it

Returns: as Linux's rmdir returns it

chmod

text
func chmod(const APath: ptr to const char; const AMode: uint32): int32

Linux's chmod.

Parameters

  • APath: as Linux's chmod takes it
  • AMode: as Linux's chmod takes it

Returns: as Linux's chmod returns it

getenv

text
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's getenv takes it

Returns: as Linux's getenv returns it

setenv

text
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's setenv takes it
  • AValue: as Linux's setenv takes it
  • AOverwrite: as Linux's setenv takes it

Returns: as Linux's setenv returns it

vasprintf

text
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's vasprintf takes it
  • AFormat: as Linux's vasprintf takes it
  • AArgs: as Linux's vasprintf takes it

Returns: as Linux's vasprintf returns it

free

text
func free(const APointer: ptr)

Linux's free: glibc: memory malloc, realloc or vasprintf gave, given back

Parameters

  • APointer: as Linux's free takes it

getrandom

text
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's getrandom takes it
  • ACount: as Linux's getrandom takes it
  • AFlags: as Linux's getrandom takes it

Returns: as Linux's getrandom returns it

clock_gettime

text
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's clock_gettime takes it
  • ATime: as Linux's clock_gettime takes it

Returns: as Linux's clock_gettime returns it

nanosleep

text
func nanosleep(const ATime: ptr to const timespec; const ARemaining: ptr to timespec): int32

Linux's nanosleep.

Parameters

  • ATime: as Linux's nanosleep takes it
  • ARemaining: as Linux's nanosleep takes it

Returns: as Linux's nanosleep returns it

read

text
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's read takes it
  • ABuffer: as Linux's read takes it
  • ACount: as Linux's read takes it

Returns: as Linux's read returns it

write

text
func write(const AFile: int32; const ABuffer: ptr to const; const ACount: uint64): int64

Linux's write.

Parameters

  • AFile: as Linux's write takes it
  • ABuffer: as Linux's write takes it
  • ACount: as Linux's write takes it

Returns: as Linux's write returns it

open

text
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's open takes it
  • AFlags: as Linux's open takes it
  • ...: as Linux's open takes them

Returns: as Linux's open returns it

close

text
func close(const AFile: int32): int32

Linux's close.

Parameters

  • AFile: as Linux's close takes it

Returns: as Linux's close returns it

dup2

text
func dup2(const AFile: int32; const ATarget: int32): int32

Linux's dup2.

Parameters

  • AFile: as Linux's dup2 takes it
  • ATarget: as Linux's dup2 takes it

Returns: as Linux's dup2 returns it

fcntl

text
func fcntl(const AFile: int32; const ACommand: int32; ...): int32

Linux's fcntl.

Parameters

  • AFile: as Linux's fcntl takes it
  • ACommand: as Linux's fcntl takes it
  • ...: as Linux's fcntl takes them

Returns: as Linux's fcntl returns it

pipe2

text
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's pipe2 takes it
  • AFlags: as Linux's pipe2 takes it

Returns: as Linux's pipe2 returns it

isatty

text
func isatty(const AFile: int32): int32

Linux's isatty: glibc: true (1) when a descriptor is a terminal

Parameters

  • AFile: as Linux's isatty takes it

Returns: as Linux's isatty returns it

tcgetattr

text
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's tcgetattr takes it
  • ATerm: as Linux's tcgetattr takes it

Returns: as Linux's tcgetattr returns it

tcsetattr

text
func tcsetattr(const AFile: int32; const AWhen: int32; const ATerm: ptr to const termios): int32

Linux's tcsetattr.

Parameters

  • AFile: as Linux's tcsetattr takes it
  • AWhen: as Linux's tcsetattr takes it
  • ATerm: as Linux's tcsetattr takes it

Returns: as Linux's tcsetattr returns it

tcflush

text
func tcflush(const AFile: int32; const AQueue: int32): int32

Linux's tcflush.

Parameters

  • AFile: as Linux's tcflush takes it
  • AQueue: as Linux's tcflush takes it

Returns: as Linux's tcflush returns it

ioctl

text
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's ioctl takes it
  • ARequest: as Linux's ioctl takes it
  • ...: as Linux's ioctl takes them

Returns: as Linux's ioctl returns it

poll

text
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's poll takes it
  • ACount: as Linux's poll takes it
  • ATimeout: as Linux's poll takes it

Returns: as Linux's poll returns it

posix_openpt

text
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's posix_openpt takes it

Returns: as Linux's posix_openpt returns it

grantpt

text
func grantpt(const AFile: int32): int32

Linux's grantpt.

Parameters

  • AFile: as Linux's grantpt takes it

Returns: as Linux's grantpt returns it

unlockpt

text
func unlockpt(const AFile: int32): int32

Linux's unlockpt.

Parameters

  • AFile: as Linux's unlockpt takes it

Returns: as Linux's unlockpt returns it

ptsname

text
func ptsname(const AFile: int32): ptr to char

Linux's ptsname.

Parameters

  • AFile: as Linux's ptsname takes it

Returns: as Linux's ptsname returns it

ptsname_r

text
func ptsname_r(const AFile: int32; const ABuffer: ptr to char; const ASize: uint64): int32

Linux's ptsname_r.

Parameters

  • AFile: as Linux's ptsname_r takes it
  • ABuffer: as Linux's ptsname_r takes it
  • ASize: as Linux's ptsname_r takes it

Returns: as Linux's ptsname_r returns it

sigemptyset

text
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's sigemptyset takes it

Returns: as Linux's sigemptyset returns it

sigfillset

text
func sigfillset(var ASet: sigset_t): int32

Linux's sigfillset.

Parameters

  • ASet: as Linux's sigfillset takes it

Returns: as Linux's sigfillset returns it

posix_spawn

text
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's posix_spawn takes it
  • APath: as Linux's posix_spawn takes it
  • AActions: as Linux's posix_spawn takes it
  • AAttributes: as Linux's posix_spawn takes it
  • AArgv: as Linux's posix_spawn takes it
  • AEnvp: as Linux's posix_spawn takes it

Returns: as Linux's posix_spawn returns it

posix_spawn_file_actions_init

text
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's posix_spawn_file_actions_init takes it

Returns: as Linux's posix_spawn_file_actions_init returns it

posix_spawn_file_actions_destroy

text
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's posix_spawn_file_actions_destroy takes it

Returns: as Linux's posix_spawn_file_actions_destroy returns it

posix_spawn_file_actions_adddup2

text
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's posix_spawn_file_actions_adddup2 takes it
  • AFile: as Linux's posix_spawn_file_actions_adddup2 takes it
  • ATarget: as Linux's posix_spawn_file_actions_adddup2 takes it

Returns: as Linux's posix_spawn_file_actions_adddup2 returns it

posix_spawn_file_actions_addopen

text
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's posix_spawn_file_actions_addopen takes it
  • ATarget: as Linux's posix_spawn_file_actions_addopen takes it
  • APath: as Linux's posix_spawn_file_actions_addopen takes it
  • AFlags: as Linux's posix_spawn_file_actions_addopen takes it
  • AMode: as Linux's posix_spawn_file_actions_addopen takes it

Returns: as Linux's posix_spawn_file_actions_addopen returns it

posix_spawn_file_actions_addclose

text
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's posix_spawn_file_actions_addclose takes it
  • AFile: as Linux's posix_spawn_file_actions_addclose takes it

Returns: as Linux's posix_spawn_file_actions_addclose returns it

posix_spawn_file_actions_addchdir_np

text
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's posix_spawn_file_actions_addchdir_np takes it
  • APath: as Linux's posix_spawn_file_actions_addchdir_np takes it

Returns: as Linux's posix_spawn_file_actions_addchdir_np returns it

posix_spawnattr_init

text
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's posix_spawnattr_init takes it

Returns: as Linux's posix_spawnattr_init returns it

posix_spawnattr_destroy

text
func posix_spawnattr_destroy(var AAttributes: posix_spawnattr_t): int32

Linux's posix_spawnattr_destroy.

Parameters

  • AAttributes: as Linux's posix_spawnattr_destroy takes it

Returns: as Linux's posix_spawnattr_destroy returns it

posix_spawnattr_setflags

text
func posix_spawnattr_setflags(var AAttributes: posix_spawnattr_t; const AFlags: int16): int32

Linux's posix_spawnattr_setflags.

Parameters

  • AAttributes: as Linux's posix_spawnattr_setflags takes it
  • AFlags: as Linux's posix_spawnattr_setflags takes it

Returns: as Linux's posix_spawnattr_setflags returns it

posix_spawnattr_setsigmask

text
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's posix_spawnattr_setsigmask takes it
  • AMask: as Linux's posix_spawnattr_setsigmask takes it

Returns: as Linux's posix_spawnattr_setsigmask returns it

posix_spawnattr_setsigdefault

text
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's posix_spawnattr_setsigdefault takes it
  • ADefault: as Linux's posix_spawnattr_setsigdefault takes it

Returns: as Linux's posix_spawnattr_setsigdefault returns it

waitpid

text
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's waitpid takes it
  • AStatus: as Linux's waitpid takes it
  • AOptions: as Linux's waitpid takes it

Returns: as Linux's waitpid returns it

syscall

text
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's syscall takes it
  • ...: as Linux's syscall takes them

Returns: as Linux's syscall returns it

pthread_create

text
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's pthread_create takes it
  • AAttributes: as Linux's pthread_create takes it
  • AStart: as Linux's pthread_create takes it
  • AArgument: as Linux's pthread_create takes it

Returns: as Linux's pthread_create returns it

pthread_join

text
func pthread_join(const AThread: uint64; const AResult: ptr): int32

Linux's pthread_join.

Parameters

  • AThread: as Linux's pthread_join takes it
  • AResult: as Linux's pthread_join takes it

Returns: as Linux's pthread_join returns it

timer_create

text
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's timer_create takes it
  • AEvent: as Linux's timer_create takes it
  • ATimer: as Linux's timer_create takes it

Returns: as Linux's timer_create returns it

timer_settime

text
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's timer_settime takes it
  • AFlags: as Linux's timer_settime takes it
  • AValue: as Linux's timer_settime takes it
  • AOld: as Linux's timer_settime takes it

Returns: as Linux's timer_settime returns it

timer_delete

text
func timer_delete(const ATimer: ptr): int32

Linux's timer_delete.

Parameters

  • ATimer: as Linux's timer_delete takes it

Returns: as Linux's timer_delete returns it

sysconf

text
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's sysconf takes it

Returns: as Linux's sysconf returns it

uname

text
func uname(var ABuffer: utsname): int32

Linux's uname: sys/utsname.h: the kernel's name, release and machine

Parameters

  • ABuffer: as Linux's uname takes 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

text
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

text
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

text
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

text
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

text
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

text
func cpplink MachinePlatformCPUCount(): int64

System.Machine's CPUCount on x86_64-linux-gnu (sysconf's processors online).

Returns: the count, at least 1

MachinePlatformOSName

text
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

text
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

text
func cpplink MachinePlatformCPUName(): string

System.Machine's CPUName on x86_64-windows-gnu (WinCPUName).

Returns: the processor's name, or ""

MachinePlatformCPUCount

text
func cpplink MachinePlatformCPUCount(): int64

System.Machine's CPUCount on x86_64-windows-gnu (WinCPUCount).

Returns: the count, at least 1

MachinePlatformOSName

text
func cpplink MachinePlatformOSName(): string

System.Machine's OSName on x86_64-windows-gnu (WinOSVersion).

Returns: "Windows <major>.<minor>.<build>"

MachinePlatformMemoryTotal

text
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

text
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

text
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() true
  • SeedValue: uint32: The seed the sequence started from, as Seed() returns it
  • init(): A generator seeded from the system's entropy source. See Randomize.
  • init(const ASeed: uint32): A generator that gives the sequence of ASeed. Parameters: ASeed the seed.
  • method SetSeed(const ASeed: uint32): Starts the sequence of ASeed again. Parameters: ASeed the seed.
  • const method Seed(): uint32: The seed the sequence started from (the last one set). Returns: the seed
  • method 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(); See SetSeed, Seed, SetRandomSeed.
  • method NextInt(const AMin: int32; const AMax: int32): int32: A whole number from AMin to AMax, both included. Parameters: AMin one end; AMax the other end. Returns: the number
  • method NextInt64(const AMin: int64; const AMax: int64): int64: NextInt for int64 bounds (a method name has one form per object). Parameters: AMin one end; AMax the other end. Returns: the number
  • method NextFloat(const AMin: float64; const AMax: float64): float64: A number from AMin (included) to AMax (left out); equal bounds give AMin. Parameters: AMin the low end, included; AMax the high end, left out. Returns: the number
  • method NextFloat32(const AMin: float32; const AMax: float32): float32: NextFloat for float32 bounds: AMin (included) to AMax (left out). Parameters: AMin the low end, included; AMax the high end, left out. Returns: the number
  • method 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

text
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: AX the X part; AY the Y part.
  • const method Length(): float32: Its length. Returns: the length
  • const method LengthSquared(): float32: Its length squared (no square root: for comparing lengths). Returns: the length squared
  • const method Distance(const AOther: Vector2): float32: The distance between this point and AOther. Parameters: AOther the other point. Returns: the distance
  • const method Dot(const AOther: Vector2): float32: The dot product with AOther. Parameters: AOther the other vector. Returns: X x AOther.X + Y x AOther.Y
  • const 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: AOther the other vector. Returns: X x AOther.Y - Y x AOther.X
  • const method Normalized(): Vector2: The same direction at length 1; a zero vector stays zero. Returns: the unit vector
  • const 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: AMax the longest length. Returns: the vector, at most AMax long
  • const 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: AOnto the vector projected onto. Returns: the projection
  • const method Perpendicular(): Vector2: The vector turned 90 degrees the way the angles grow: (-Y, X), as SFML. Returns: the perpendicular vector
  • const method Rotated(const ADegrees: float32): Vector2: The vector turned by ADegrees (positive turns the way the angles grow); computed in float64. Parameters: ADegrees the turn, in degrees. Returns: the turned vector
  • const 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 degrees
  • const 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: ADegrees the heading, in degrees; ASpeed the distance moved. Returns: the moved point
  • const 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: ATo the end point; AT the fraction of the way. Returns: the point between
  • operator +(const A: Vector2; const B: Vector2): Vector2: The sum, component by component. Parameters: A the first vector; B the 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: A the vector subtracted from; B the 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: A the vector. Returns: (-A.X, -A.Y)
  • operator *(const A: Vector2; const AScale: float32): Vector2: The vector scaled. Parameters: A the vector; AScale the factor. Returns: (A.X * AScale, A.Y * AScale)
  • operator *(const AScale: float32; const A: Vector2): Vector2: The vector scaled, the factor written first. Parameters: AScale the factor; A the 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: A the vector; AScale the 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: A the first vector; B the second vector. Returns: true when A.X = B.X and A.Y = B.Y
  • operator <>(const A: Vector2; const B: Vector2): bool: Whether two vectors differ in any component: the opposite of =. Parameters: A the first vector; B the 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

text
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 X
  • Height: float32: The height; negative spans above Y
  • init(): 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: AX the corner's X; AY the corner's Y; AWidth the width; AHeight the height.
  • const method Contains(const APoint: Vector2): bool: True when APoint is inside: [left, right) x [top, bottom). Parameters: APoint the point. Returns: whether the rectangle holds it
  • const 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: AOther the other rectangle; AResult the overlap. Returns: whether they overlap
  • const method Overlaps(const AOther: Rect): bool: True when the rectangles share an area (touching is not enough). Parameters: AOther the other rectangle. Returns: whether they overlap
  • const 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

text
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: AMinX the smallest X; AMinY the smallest Y; AMaxX the largest X; AMaxY the 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

text
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

text
type LineHit = object

Where two line segments meet: Kind, and Point when Kind is Point.

Members

  • Kind: LineHitKind: How the segments meet
  • Point: Vector2: The point where they meet; read it only when Kind is Point
  • init(): No meeting: Kind Miss, Point (0, 0).

Since: 0.2

See also: LineIntersection

Obb

text
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 centre
  • HalfSize: 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: ACenter the centre; AHalfSize half the width and height; ADegrees the turn, in degrees.

Since: 0.2

See also: ObbsOverlap

Constants

NameDeclarationDescription
Piconst Pi: float64 = 3.141592653589793The ratio of a circle's circumference to its diameter.
DegToRadconst DegToRad: float64 = 0.017453292519943295Degrees times DegToRad are radians: 90.0 * DegToRad is Pi / 2. See RadToDeg.
RadToDegconst RadToDeg: float64 = 57.29577951308232Radians times RadToDeg are degrees: Pi * RadToDeg is 180. See DegToRad.
Epsilon32const Epsilon32: float32 = 0.00001fThe float32 tolerance SameValue uses when none is given (scaled by the values' size past 1). See SameValue.
Epsilon64const Epsilon64: float64 = 0.000000000001The float64 tolerance SameValue uses when none is given (scaled by the values' size past 1). See SameValue.
NaNconst NaN: float64 = 0.0 / 0.0Not a number. It compares unequal to everything, itself included: test a value with X <> X.

Routines

PerceivedVolume

text
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));

text
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));

text
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 1
  • ARangeDb: the loudness range in decibels the level spans

Returns: the linear volume, 0 to AMax

Since: 0.2

text
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

text
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 volume
  • AMax: the volume at level 1
  • ARangeDb: 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);

text
func cpplink PerceivedLevel(const AVolume: float64; const AMax: float64): float64

PerceivedLevel over the default 50 dB range.

Parameters

  • AVolume: the linear volume
  • AMax: the volume at level 1

Returns: the level, 0 to 1

Since: 0.2

See also: PerceivedVolume

text
func cpplink PerceivedLevel(const AVolume: float32; const AMax: float32; const ARangeDb: float32): float32

PerceivedLevel for float32 values (computed in float64).

Parameters

  • AVolume: the linear volume
  • AMax: the volume at level 1
  • ARangeDb: the loudness range in decibels the level spans

Returns: the level, 0 to 1

Since: 0.2

text
func cpplink PerceivedLevel(const AVolume: float32; const AMax: float32): float32

PerceivedLevel for float32 values over the default 50 dB range.

Parameters

  • AVolume: the linear volume
  • AMax: the volume at level 1

Returns: the level, 0 to 1

Since: 0.2

Sin

text
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);

text
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

text
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);

text
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

text
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);

text
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

text
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 base
  • AExponent: 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

text
func cpplink Power(const ABase: float32; const AExponent: float32): float32

Power for float32 values, computed in float32.

Parameters

  • ABase: the base
  • AExponent: the exponent

Returns: ABase to the AExponent

Since: 0.4

Exp

text
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);

text
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

text
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

See also: Exp, Log2, Log10

Example: LOctaves := Ln(LRatio) / Ln(2.0);

text
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

text
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;

text
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

text
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);

text
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

text
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);

text
func cpplink Abs(const AValue: float32): float32

Abs for a float32 value.

Parameters

  • AValue: the value

Returns: |AValue|

Since: 0.3

text
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

text
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

text
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)));

text
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

text
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);

text
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

text
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);

text
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

text
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);

text
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

text
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 value
  • AMin: one bound
  • AMax: the other bound

Returns: AValue inside [AMin, AMax]

Since: 0.2

See also: Wrap

Example: LHealth := Clamp(LHealth - LDamage, 0, 100);

text
func cpplink Clamp(const AValue: float32; const AMin: float32; const AMax: float32): float32

Clamp for float32 values.

Parameters

  • AValue: the value
  • AMin: one bound
  • AMax: the other bound

Returns: AValue inside [AMin, AMax]

Since: 0.2

text
func cpplink Clamp(const AValue: int64; const AMin: int64; const AMax: int64): int64

Clamp for int64 values.

Parameters

  • AValue: the value
  • AMin: one bound
  • AMax: the other bound

Returns: AValue inside [AMin, AMax]

Since: 0.2

text
func cpplink Clamp(const AValue: int32; const AMin: int32; const AMax: int32): int32

Clamp for int32 values.

Parameters

  • AValue: the value
  • AMin: one bound
  • AMax: the other bound

Returns: AValue inside [AMin, AMax]

Since: 0.2

Min

text
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 value
  • AB: the other value

Returns: the smaller of AA and AB

Since: 0.3

See also: Max

Example: LZoom := Min(LFitX, LFitY);

text
func cpplink Min(const AA: float32; const AB: float32): float32

Min for float32 values.

Parameters

  • AA: one value
  • AB: the other value

Returns: the smaller of AA and AB

Since: 0.3

text
func cpplink Min(const AA: int64; const AB: int64): int64

Min for int64 values.

Parameters

  • AA: one value
  • AB: the other value

Returns: the smaller of AA and AB

Since: 0.3

text
func cpplink Min(const AA: int32; const AB: int32): int32

Min for int32 values.

Parameters

  • AA: one value
  • AB: the other value

Returns: the smaller of AA and AB

Since: 0.3

Max

text
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 value
  • AB: the other value

Returns: the larger of AA and AB

Since: 0.3

See also: Min

Example: LWidth := Max(LWidth, 1);

text
func cpplink Max(const AA: float32; const AB: float32): float32

Max for float32 values.

Parameters

  • AA: one value
  • AB: the other value

Returns: the larger of AA and AB

Since: 0.3

text
func cpplink Max(const AA: int64; const AB: int64): int64

Max for int64 values.

Parameters

  • AA: one value
  • AB: the other value

Returns: the larger of AA and AB

Since: 0.3

text
func cpplink Max(const AA: int32; const AB: int32): int32

Max for int32 values.

Parameters

  • AA: one value
  • AB: the other value

Returns: the larger of AA and AB

Since: 0.3

Wrap

text
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 value
  • AMin: the bottom of the range, included
  • AMax: 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);

text
func cpplink Wrap(const AValue: float32; const AMin: float32; const AMax: float32): float32

Wrap for float32 values.

Parameters

  • AValue: the value
  • AMin: the bottom of the range, included
  • AMax: the top of the range, left out

Returns: AValue inside [AMin, AMax)

Since: 0.2

text
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 value
  • AMin: one end of the range, included
  • AMax: the other end, included

Returns: AValue inside [AMin, AMax]

Since: 0.2

Example: LFrame := Wrap(LFrame + 1, 0, LFrameCount - 1);

text
func cpplink Wrap(const AValue: int32; const AMin: int32; const AMax: int32): int32

Wrap for int32 values (both ends included).

Parameters

  • AValue: the value
  • AMin: one end of the range, included
  • AMax: the other end, included

Returns: AValue inside [AMin, AMax]

Since: 0.2

SameSign

text
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 value
  • AValue2: the second value

Returns: whether their signs match

Since: 0.2

text
func cpplink SameSign(const AValue1: int32; const AValue2: int32): bool

SameSign for int32 values.

Parameters

  • AValue1: the first value
  • AValue2: the second value

Returns: whether their signs match

Since: 0.2

text
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 value
  • AValue2: the second value

Returns: whether their signs match

Since: 0.2

text
func cpplink SameSign(const AValue1: float32; const AValue2: float32): bool

SameSign for float32 values.

Parameters

  • AValue1: the first value
  • AValue2: the second value

Returns: whether their signs match

Since: 0.2

SameValue

text
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 value
  • B: the second value
  • AEpsilon: 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;

text
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 value
  • B: the second value

Returns: whether A and B are the same

Since: 0.2

text
func cpplink SameValue(const A: float32; const B: float32; const AEpsilon: float32): bool

SameValue for float32 values.

Parameters

  • A: the first value
  • B: the second value
  • AEpsilon: the largest difference still counted as the same

Returns: whether A and B are the same within AEpsilon

Since: 0.2

text
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 value
  • B: the second value

Returns: whether A and B are the same

Since: 0.2

Lerp

text
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 start
  • ATo: the end
  • AT: the fraction of the way

Returns: AFrom + (ATo - AFrom) x AT

Since: 0.2

See also: EaseBetween

Example: LX := Lerp(LStartX, LEndX, LElapsed / LDuration);

text
func cpplink Lerp(const AFrom: float32; const ATo: float32; const AT: float32): float32

Lerp for float32 values.

Parameters

  • AFrom: the start
  • ATo: the end
  • AT: the fraction of the way

Returns: AFrom + (ATo - AFrom) x AT

Since: 0.2

InverseLerp

text
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 0
  • ATo: the value that gives 1
  • AValue: 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

text
func cpplink InverseLerp(const AFrom: float32; const ATo: float32; const AValue: float32): float32

InverseLerp's float32 form.

Parameters

  • AFrom: the value that gives 0
  • ATo: the value that gives 1
  • AValue: the value placed

Returns: its fraction; 0 when AFrom = ATo

Remap

text
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 value
  • AFromLow: the first range's start
  • AFromHigh: the first range's end
  • AToLow: the second range's start
  • AToHigh: 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

text
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 value
  • AFromLow: the first range's start
  • AFromHigh: the first range's end
  • AToLow: the second range's start
  • AToHigh: the second range's end

Returns: the value in the second range

AngleDifference

text
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 degrees
  • ADest: the angle turned to, in degrees

Returns: the turn, in [-180, 180)

Since: 0.2

text
func cpplink AngleDifference(const ASource: float32; const ADest: float32): float32

AngleDifference for float32 values.

Parameters

  • ASource: the angle turned from, in degrees
  • ADest: the angle turned to, in degrees

Returns: the turn, in [-180, 180)

Since: 0.2

SmoothMove

text
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 now
  • AAmount: the push this update, 0 for none
  • AMax: the largest speed either way
  • ADrag: 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);

text
func cpplink SmoothMove(const AValue: float32; const AAmount: float32; const AMax: float32; const ADrag: float32): float32

SmoothMove for float32 values.

Parameters

  • AValue: the speed now
  • AAmount: the push this update, 0 for none
  • AMax: the largest speed either way
  • ADrag: how much the speed falls per update with no push

Returns: the new speed

Since: 0.2

Ease

text
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 curve
  • AFraction: 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);

text
func cpplink Ease(const AKind: Easing; const AFraction: float32): float32

Ease for a float32 fraction (computed in float64).

Parameters

  • AKind: the curve
  • AFraction: how far along, 0 to 1

Returns: the eased fraction, 0 to 1

Since: 0.2

EaseBetween

text
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 curve
  • AFrom: the start value
  • ATo: the end value
  • AFraction: 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);

text
func cpplink EaseBetween(const AKind: Easing; const AFrom: float32; const ATo: float32; const AFraction: float32): float32

EaseBetween for float32 values.

Parameters

  • AKind: the curve
  • AFrom: the start value
  • ATo: the end value
  • AFraction: how far along, 0 to 1

Returns: the eased value between AFrom and ATo

Since: 0.2

RandomInt

text
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 end
  • AMax: the other end

Returns: the number

Since: 0.2

See also: RandomGenerator

Example: LDie := RandomInt(1, 6);

text
func cpplink RandomInt(const AMin: int64; const AMax: int64): int64

RandomInt for int64 bounds.

Parameters

  • AMin: one end
  • AMax: the other end

Returns: the number

Since: 0.2

RandomFloat

text
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, included
  • AMax: the high end, left out

Returns: the number

Since: 0.2

Example: LX := RandomFloat(0.0, 640.0);

text
func cpplink RandomFloat(const AMin: float32; const AMax: float32): float32

RandomFloat for float32 bounds.

Parameters

  • AMin: the low end, included
  • AMax: the high end, left out

Returns: the number

Since: 0.2

RandomBool

text
func cpplink RandomBool(): bool

True or false, each half the time, from the unit's own generator.

Returns: the value

Since: 0.2

RandomSeed

text
func cpplink RandomSeed(): uint32

The seed the unit's own generator started from (the last one set).

Returns: the seed

Since: 0.2

SetRandomSeed

text
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

text
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

text
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 point
  • ACenter: the circle's centre
  • ARadius: the circle's radius

Returns: whether the circle holds the point

Since: 0.2

PointInTriangle

text
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 point
  • A: a corner
  • B: a corner
  • C: a corner

Returns: whether the triangle holds the point

Since: 0.2

CirclesOverlap

text
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 centre
  • ARadius1: the first circle's radius
  • ACenter2: the second circle's centre
  • ARadius2: the second circle's radius

Returns: whether they overlap

Since: 0.2

CircleOverlapsRect

text
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 centre
  • ARadius: the circle's radius
  • ARect: the rectangle

Returns: whether they overlap

Since: 0.2

LineIntersection

text
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 start
  • A2: the first segment's end
  • B1: the second segment's start
  • B2: the second segment's end

Returns: the kind of meeting and, for Point, where

Since: 0.2

RadiusOverlap

text
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 radius
  • ACenter1: the first centre
  • ARadius2: the second radius
  • ACenter2: the second centre
  • AShrink: the scale both radii take

Returns: whether they overlap

Since: 0.2

ObbsOverlap

text
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 box
  • B: the other box

Returns: whether they overlap

Since: 0.2

ExtentOf

text
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

text
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 vector
  • ASecond: 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);

text
func cpplink CosineSimilarity(const AFirst: array of float64; const ASecond: array of float64): float64

CosineSimilarity for float64 vectors.

Parameters

  • AFirst: the first vector
  • ASecond: 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

text
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 folders
  • ArchiveName: string: Its entry name in the archive: its path below its source's folder, / between folders, the source's prefix first
  • Method: ZipEntryMethod: Store when a store glob matches its name, else Deflate
  • UnixMode: uint32: The permission bits the first matching unix_mode glob gives it, 0 when none matches

PackEntries

text
type PackEntries = array of PackEntry

The files of one archive, in its order

PackProgress

text
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

text
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:

text
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: APath the spec file (.toml). Returns: false (the reason in ErrorText, at the spec's line and column) when it cannot be read or is no valid spec; no spec is held then
  • const 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: AIndex the archive (0-based). Returns: its output path ("" when there is no such archive)
  • const method SpecName(): string: The spec's name. Returns: the name ("" when the spec has none)
  • const method SpecVersion(): string: The spec's version. Returns: the version ("" when the spec has none)
  • method Discover(const AIndex: int64; var AEntries: PackEntries): bool: The files archive AIndex takes, in its order (byte order of the entry names), each with its method and Unix mode; nothing is written. Parameters: AIndex the archive (0-based); AEntries the files (empty on a failure). Returns: false (the reason in ErrorText) 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 packed
  • method BuildArchive(const AIndex: int64; const AProgress: PackProgress): bool: Writes archive AIndex: its files found (Discover), its folder made, an old .sha256 / .minisig beside 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 .sha256 when the spec asks and its .minisig when the spec has a [sign] table. Parameters: AIndex the archive (0-based); AProgress called before each entry (PackProgress, a closure), nil for none. Returns: false (the reason in ErrorText) at the first step that fails
  • method Build(const AProgress: PackProgress): bool: Writes every archive of the loaded spec in its order (BuildArchive for each). Parameters: AProgress called before each entry (PackProgress, a closure), nil for none. Returns: false (the reason in ErrorText) at the first archive that fails
  • const method EntryCount(const AIndex: int64): int64: The entries the last good build of an archive wrote. Parameters: AIndex the 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 as file(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

text
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: AText the line or chunk, UTF-8 (a chunk holds whole characters only).

Example: RunPE(LExe, LArgs, LDir, LCode, LSink, ProcessCapture.Pipes, nil);

ProcessTerminal

text
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: AText the keys, UTF-8. Returns: false when the program is gone
  • method Resize(const ACols: int32; const ARows: int32): bool: Gives the terminal a new size; each side is held to 1 .. 32767. Parameters: ACols the columns; ARows the lines. Returns: false when the size is refused

ProcessHost

text
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: ACols receives the columns; ARows receives the lines. Returns: false to take this program's console size
  • method StdInput(): uint64: A handle the program reads as its standard input (its end of input, as prog < 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: ATerminal the run's console. Returns: false when the host cannot serve: the program is then not started
  • method Stop(): The program ended (or never started after Start): no more keys or sizes.

ProcessCapture

text
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

text
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 program
  • AArgs: its arguments
  • AWorkDir: the folder it runs in
  • AOutput: receives everything it wrote
  • AExitCode: receives its exit code

Returns: false when it cannot start

Example: if RunProcess("git", ["--version"], ".", LText, LCode) then println("{}", LText); end;

RunAttached

text
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 program
  • AArgs: its arguments
  • AWorkDir: the folder it runs in
  • AExitCode: receives its exit code

Returns: false when it cannot start

RunPE

text
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 path
  • AArgs: its arguments
  • AWorkDir: the folder it runs in
  • AWait: true to wait for it to end
  • AExitCode: 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

text
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 path
  • AArgs: its arguments
  • AWorkDir: the folder it runs in
  • AExitCode: receives its exit code (0 when it never ran)
  • AOutput: gets the output, line by line or chunk by chunk
  • ACapture: pipes or a terminal
  • AHost: 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

text
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 file
  • AArgs: its arguments
  • AWorkDir: the folder it runs in
  • AExitCode: receives its exit code (0 when it never ran)
  • AOutput: gets the output, line by line or chunk by chunk
  • ACapture: pipes or a terminal
  • AHost: 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);

text
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 file
  • AArgs: its arguments
  • AWorkDir: the folder it runs in
  • AExitCode: receives its exit code (0 when it never ran)

Returns: false when it cannot start there (as the capture form's)

ELFCommand

text
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 file
  • AArgs: its arguments
  • AWorkDir: the folder it runs in
  • AJoinErrors: true to join its stderr to its stdout (a pipe read as one stream)
  • AExe: receives the program to start
  • AArgsOut: receives that program's arguments

Returns: false when it cannot be started there (as RunELF's)

ELFPath

text
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

text
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

text
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

text
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: ATerminal true for a terminal run, false for pipes; ACols the terminal's columns (0 with ARows 0: this process's size); ARows the terminal's lines; AHasHost true when a host types the keys; AStdin the host's standard input, or 0. Returns: false when the system refuses
  • method 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: AExe the program, its full path; AArgs its arguments; AWorkDir the folder it runs in; "" for this process's. Returns: false when it does not start
  • method 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: ABytes gets the output appended. Returns: false once all of it was handed over
  • method Exited(): bool: A terminal run's program has ended (its last output may still come from Next) Returns: true once the program has ended
  • method 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: AText the keys, UTF-8. Returns: false for a pipes run or when it is gone
  • method 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: ACols the columns; ARows the lines. Returns: false for a pipes run or when refused
  • method 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: ACode receives the exit code. Returns: false when it never started or its exit code cannot be read
  • method 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 ends
  • done: Closes whatever the run still holds open (as Close).

Routines

ProcessPlatformRunProcess

text
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: as RunProcess takes it
  • AArgs: as RunProcess takes it
  • AWorkDir: as RunProcess takes it
  • AOutput: as RunProcess takes it
  • AExitCode: as RunProcess takes it

Returns: as RunProcess returns it

ProcessPlatformRunAttached

text
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: as RunAttached takes it
  • AArgs: as RunAttached takes it
  • AWorkDir: as RunAttached takes it
  • AExitCode: as RunAttached takes it

Returns: as RunAttached returns it

ProcessPlatformRunPE

text
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: as RunPE takes it
  • AArgs: as RunPE takes it
  • AWorkDir: as RunPE takes it
  • AWait: as RunPE takes it
  • AExitCode: as RunPE takes it

Returns: as RunPE returns it

ProcessPlatformCanRunPE

text
func cpplink ProcessPlatformCanRunPE(): bool

False: no PE runs here (System.Process' RunPE forms)

Returns: false, always

ProcessPlatformDecodeLine

text
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

text
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: as ELFCommand takes it
  • AArgs: as ELFCommand takes it
  • AWorkDir: as ELFCommand takes it
  • APipes: as ELFCommand's AJoinErrors (changes nothing here)
  • AExe: as ELFCommand takes it
  • AArgsOut: as ELFCommand takes it

Returns: as ELFCommand returns it

ProcessPlatformELFPath

text
func cpplink ProcessPlatformELFPath(const APath: string): string

System.Process's ELFPath on linux64: APath resolved (an ELF shares this file system)

Parameters

  • APath: as ELFPath takes it

Returns: as ELFPath returns it

ProcessPlatformCanRunELF

text
func cpplink ProcessPlatformCanRunELF(): bool

System.Process's CanRunELF on linux64: an ELF runs natively

Returns: as CanRunELF returns it

ProcessPlatformOpenURL

text
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: as OpenURL takes 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

text
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: ATerminal true for a terminal run, false for pipes; ACols the terminal's columns (0 with ARows 0: this process's size); ARows the terminal's lines; AHasHost true when a host types the keys; AStdin the host's standard input, or 0. Returns: false when the system refuses
  • method 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: AExe the program, its full path; AArgs its arguments; AWorkDir the folder it runs in; "" for this process's. Returns: false when it does not start
  • method 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: ABytes gets the output appended. Returns: false once all of it was handed over
  • method Exited(): bool: A terminal run's program has ended (its last output may still come from Next) Returns: true once the program has ended
  • method WriteKeys(const AText: string): bool: AText typed into a terminal run's program. False for a pipes run or when it is gone Parameters: AText the keys, UTF-8. Returns: false for a pipes run or when it is gone
  • method Resize(const ACols: int32; const ARows: int32): bool: A terminal run's new size. False for a pipes run or when refused Parameters: ACols the columns; ARows the lines. Returns: false for a pipes run or when refused
  • method 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: ACode receives the exit code. Returns: false when it never started or its exit code cannot be read
  • method Close(): Every handle closed (a pseudo console still open closed with its last output dropped); it may be prepared again
  • done: Closes whatever the run still holds open (as Close).

Routines

ProcessPlatformRunProcess

text
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: as RunProcess takes it
  • AArgs: as RunProcess takes it
  • AWorkDir: as RunProcess takes it
  • AOutput: as RunProcess takes it
  • AExitCode: as RunProcess takes it

Returns: as RunProcess returns it

ProcessPlatformRunAttached

text
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: as RunAttached takes it
  • AArgs: as RunAttached takes it
  • AWorkDir: as RunAttached takes it
  • AExitCode: as RunAttached takes it

Returns: as RunAttached returns it

ProcessPlatformRunPE

text
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: as RunPE takes it
  • AArgs: as RunPE takes it
  • AWorkDir: as RunPE takes it
  • AWait: as RunPE takes it
  • AExitCode: as RunPE takes it

Returns: as RunPE returns it

ProcessPlatformCanRunPE

text
func cpplink ProcessPlatformCanRunPE(): bool

True: a PE runs here (System.Process' RunPE forms)

Returns: true, always

ProcessPlatformDecodeLine

text
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

text
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: as ELFPath takes it

Returns: as ELFPath returns it

ProcessPlatformELFCommand

text
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: as ELFCommand takes it
  • AArgs: as ELFCommand takes it
  • AWorkDir: as ELFCommand takes it
  • APipes: as ELFCommand's AJoinErrors
  • AExe: as ELFCommand takes it
  • AArgsOut: as ELFCommand takes it

Returns: as ELFCommand returns it

ProcessPlatformCanRunELF

text
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

text
func cpplink ProcessPlatformOpenURL(const AURL: string): bool

System.Process's OpenURL: System.Windows' Win* routine of the same job (the scheme checked)

Parameters

  • AURL: as OpenURL takes 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

text
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_DEFAULT
  • UIBackend.Vulkan: Built-in Vulkan renderer. C: R_BACKEND_VULKAN
  • UIBackend.Null: Renders nothing. Used for headless runs and unit tests. C: R_BACKEND_NULL
  • UIBackend.Custom: Backend supplied with Rbackend_register (see raven_backend.h). C: R_BACKEND_CUSTOM
  • UIBackend.WebGL: Browser renderer (Emscripten, WebGL 2). C: R_BACKEND_WEBGL
  • UIBackend.Metal: Built-in Metal renderer (macOS, iOS). C: R_BACKEND_METAL

UIErrorCode

text
type UIErrorCode = choices(

An error Raven reports (R_NO_ERROR, R_ERROR_*).

Members

  • UIErrorCode.None: No error. C: R_NO_ERROR
  • UIErrorCode.InvalidId: The invalid id error. C: R_ERROR_INVALID_ID
  • UIErrorCode.InvalidEnum: The invalid enum error. C: R_ERROR_INVALID_ENUM
  • UIErrorCode.InvalidValue: The invalid value error. C: R_ERROR_INVALID_VALUE
  • UIErrorCode.InvalidOperation: The invalid operation error. C: R_ERROR_INVALID_OPERATION
  • UIErrorCode.Backend: The backend error. C: R_ERROR_BACKEND
  • UIErrorCode.Platform: The platform error. C: R_ERROR_PLATFORM
  • UIErrorCode.OutOfMemory: The out of memory error. C: R_ERROR_OUT_OF_MEMORY
  • UIErrorCode.InvalidFileFormat: The invalid file format error. C: R_ERROR_INVALID_FILE_FORMAT
  • UIErrorCode.FileNotFound: The file not found error. C: R_ERROR_FILE_NOT_FOUND
  • UIErrorCode.XML: The XML error. C: R_ERROR_XML
  • UIErrorCode.WrongThread: The wrong thread error. C: R_ERROR_WRONG_THREAD
  • UIErrorCode.Script: A diagnostic of Raven Script (raven_script.h): the text is the whole message, "error[RS102]: ...". C: R_ERROR_SCRIPT

UISeverity

text
type UISeverity = choices(

How bad a reported error is (R_SEVERITY_*).

Members

  • UISeverity.WeakWarning: Weak warning. C: R_SEVERITY_WEAK_WARNING
  • UISeverity.Warning: Warning. C: R_SEVERITY_WARNING
  • UISeverity.Error: Error. C: R_SEVERITY_ERROR
  • UISeverity.Fatal: Fatal. C: R_SEVERITY_FATAL

UIAppEvent

text
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_PAUSE
  • UIAppEvent.DidPause: The application is in the background: Raven has stopped drawing, and waited until the GPU was idle. C: R_APP_DID_PAUSE
  • UIAppEvent.WillResume: The application is coming back to the front: Raven draws again. C: R_APP_WILL_RESUME
  • UIAppEvent.DidResume: The application is in front and takes input again. C: R_APP_DID_RESUME
  • UIAppEvent.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_MEMORY
  • UIAppEvent.WillTerminate: The application is about to end (Android: the activity is finishing; its window is closed right after). C: R_APP_WILL_TERMINATE

UIWindowFlag

text
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_RESIZE
  • UIWindowFlag.Hidden: Made hidden. C: R_WINDOW_HIDDEN
  • UIWindowFlag.Borderless: No system frame or title bar. C: R_WINDOW_BORDERLESS
  • UIWindowFlag.Maximized: Made maximized. C: R_WINDOW_MAXIMIZED
  • UIWindowFlag.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_HEADER
  • UIWindowFlag.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_TRANSPARENT
  • UIWindowFlag.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

text
type UIWindowFlags = set of UIWindowFlag

A set of UIWindowFlag (Raven's RWindowFlags).

UIWindowSystem

text
type UIWindowSystem = choices(

The OS windowing system a window runs on (R_WINDOW_SYSTEM_*).

Members

  • UIWindowSystem.None: None. C: R_WINDOW_SYSTEM_NONE
  • UIWindowSystem.Win32: Win32. C: R_WINDOW_SYSTEM_WIN32
  • UIWindowSystem.X11: X11. C: R_WINDOW_SYSTEM_X11
  • UIWindowSystem.Wayland: Wayland. C: R_WINDOW_SYSTEM_WAYLAND
  • UIWindowSystem.Cocoa: Cocoa (macOS). C: R_WINDOW_SYSTEM_COCOA
  • UIWindowSystem.Emscripten: Emscripten. C: R_WINDOW_SYSTEM_EMSCRIPTEN
  • UIWindowSystem.Android: Android. C: R_WINDOW_SYSTEM_ANDROID
  • UIWindowSystem.UIKit: UIKit (iOS). C: R_WINDOW_SYSTEM_UIKIT

UIPipCorner

text
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_RIGHT
  • UIPipCorner.BottomLeft: The bottom left corner. C: R_PIP_BOTTOM_LEFT
  • UIPipCorner.TopRight: The top right corner. C: R_PIP_TOP_RIGHT
  • UIPipCorner.TopLeft: The top left corner. C: R_PIP_TOP_LEFT

UIBackdrop

text
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_NONE
  • UIBackdrop.Transparent: The screen behind the window, as it is. C: R_BACKDROP_TRANSPARENT
  • UIBackdrop.Blur: The screen behind the window, blurred by the OS. C: R_BACKDROP_BLUR
  • UIBackdrop.Acrylic: Blurred, tinted and grained by the OS (the acrylic of Windows). C: R_BACKDROP_ACRYLIC
  • UIBackdrop.Mica: A soft tint taken from the wallpaper of the desktop (the mica of Windows 11). C: R_BACKDROP_MICA

UIInputType

text
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_TEXT
  • UIInputType.Email: An email address. C: R_TEXT_INPUT_TYPE_EMAIL
  • UIInputType.Number: Digits. C: R_TEXT_INPUT_TYPE_NUMBER
  • UIInputType.Decimal: Digits and a decimal separator. C: R_TEXT_INPUT_TYPE_DECIMAL
  • UIInputType.Phone: A phone number. C: R_TEXT_INPUT_TYPE_PHONE
  • UIInputType.URL: A URL. C: R_TEXT_INPUT_TYPE_URL
  • UIInputType.Search: A search. C: R_TEXT_INPUT_TYPE_SEARCH

UITextAlign

text
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_LEFT
  • UITextAlign.Center: Centred. C: R_TEXT_ALIGN_CENTER
  • UITextAlign.Right: Lined up on the right. C: R_TEXT_ALIGN_RIGHT

UIReturnKey

text
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_DEFAULT
  • UIReturnKey.Done: The return key reads "Done". C: R_RETURN_KEY_DONE
  • UIReturnKey.Go: The return key reads "Go". C: R_RETURN_KEY_GO
  • UIReturnKey.Next: The return key reads "Next". C: R_RETURN_KEY_NEXT
  • UIReturnKey.Search: The return key reads "Search". C: R_RETURN_KEY_SEARCH
  • UIReturnKey.Send: The return key reads "Send". C: R_RETURN_KEY_SEND

UIEdge

text
type UIEdge = choices(

A window edge or corner, for resizing (R_EDGE_*).

Members

  • UIEdge.Left: The left edge. C: R_EDGE_LEFT
  • UIEdge.Right: The right edge. C: R_EDGE_RIGHT
  • UIEdge.Top: The top edge. C: R_EDGE_TOP
  • UIEdge.Bottom: The bottom edge. C: R_EDGE_BOTTOM
  • UIEdge.TopLeft: The top-left corner. C: R_EDGE_TOP_LEFT
  • UIEdge.TopRight: The top-right corner. C: R_EDGE_TOP_RIGHT
  • UIEdge.BottomLeft: The bottom-left corner. C: R_EDGE_BOTTOM_LEFT
  • UIEdge.BottomRight: The bottom-right corner. C: R_EDGE_BOTTOM_RIGHT

UIPointerButton

text
type UIPointerButton = choices(

A mouse button (R_MOUSE_*).

Members

  • UIPointerButton.Left: The left mouse button. C: R_MOUSE_LEFT
  • UIPointerButton.Right: The right mouse button. C: R_MOUSE_RIGHT
  • UIPointerButton.Middle: The middle mouse button. C: R_MOUSE_MIDDLE
  • UIPointerButton.X1: The X1 mouse button. C: R_MOUSE_X1
  • UIPointerButton.X2: The X2 mouse button. C: R_MOUSE_X2

UIModifier

text
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_SHIFT
  • UIModifier.Ctrl: The Ctrl key. C: R_MOD_CTRL
  • UIModifier.Alt: The Alt key. C: R_MOD_ALT
  • UIModifier.Super: The Super key. C: R_MOD_SUPER

UIModifiers

text
type UIModifiers = set of UIModifier

A set of UIModifier (Raven's RModifier).

UICursor

text
type UICursor = choices(

A mouse cursor shape (R_CURSOR_*).

Members

  • UICursor.Arrow: The arrow cursor. C: R_CURSOR_ARROW
  • UICursor.IBeam: The I-beam (text) cursor. C: R_CURSOR_IBEAM
  • UICursor.Hand: The hand cursor. C: R_CURSOR_HAND
  • UICursor.Crosshair: The crosshair cursor. C: R_CURSOR_CROSSHAIR
  • UICursor.ResizeH: The left-right resize cursor. C: R_CURSOR_RESIZE_H
  • UICursor.ResizeV: The up-down resize cursor. C: R_CURSOR_RESIZE_V
  • UICursor.ResizeNWSE: The top-left to bottom-right resize cursor. C: R_CURSOR_RESIZE_NWSE
  • UICursor.ResizeNESW: The top-right to bottom-left resize cursor. C: R_CURSOR_RESIZE_NESW
  • UICursor.Move: The move cursor. C: R_CURSOR_MOVE
  • UICursor.NotAllowed: The not allowed cursor. C: R_CURSOR_NOT_ALLOWED
  • UICursor.None: No pointer at all (a game that hides it). Windows; elsewhere the arrow. C: R_CURSOR_NONE

UIKey

text
type UIKey = choices(

A keyboard key (R_KEY_*; the digit keys Key0 .. Key9).

Members

  • UIKey.Unknown: The unknown key. C: R_KEY_UNKNOWN
  • UIKey.Space: The space key. C: R_KEY_SPACE
  • UIKey.Apostrophe: The apostrophe key. C: R_KEY_APOSTROPHE
  • UIKey.Comma: The comma key. C: R_KEY_COMMA
  • UIKey.Minus: The minus key. C: R_KEY_MINUS
  • UIKey.Period: The period key. C: R_KEY_PERIOD
  • UIKey.Slash: The slash key. C: R_KEY_SLASH
  • UIKey.Key0: The 0 key. C: R_KEY_0
  • UIKey.Key1: The 1 key. C: R_KEY_1
  • UIKey.Key2: The 2 key. C: R_KEY_2
  • UIKey.Key3: The 3 key. C: R_KEY_3
  • UIKey.Key4: The 4 key. C: R_KEY_4
  • UIKey.Key5: The 5 key. C: R_KEY_5
  • UIKey.Key6: The 6 key. C: R_KEY_6
  • UIKey.Key7: The 7 key. C: R_KEY_7
  • UIKey.Key8: The 8 key. C: R_KEY_8
  • UIKey.Key9: The 9 key. C: R_KEY_9
  • UIKey.Semicolon: The semicolon key. C: R_KEY_SEMICOLON
  • UIKey.Equal: The equal key. C: R_KEY_EQUAL
  • UIKey.A: The A key. C: R_KEY_A
  • UIKey.B: The B key. C: R_KEY_B
  • UIKey.C: The C key. C: R_KEY_C
  • UIKey.D: The D key. C: R_KEY_D
  • UIKey.E: The E key. C: R_KEY_E
  • UIKey.F: The F key. C: R_KEY_F
  • UIKey.G: The G key. C: R_KEY_G
  • UIKey.H: The H key. C: R_KEY_H
  • UIKey.I: The I key. C: R_KEY_I
  • UIKey.J: The J key. C: R_KEY_J
  • UIKey.K: The K key. C: R_KEY_K
  • UIKey.L: The L key. C: R_KEY_L
  • UIKey.M: The M key. C: R_KEY_M
  • UIKey.N: The N key. C: R_KEY_N
  • UIKey.O: The O key. C: R_KEY_O
  • UIKey.P: The P key. C: R_KEY_P
  • UIKey.Q: The Q key. C: R_KEY_Q
  • UIKey.R: The R key. C: R_KEY_R
  • UIKey.S: The S key. C: R_KEY_S
  • UIKey.T: The T key. C: R_KEY_T
  • UIKey.U: The U key. C: R_KEY_U
  • UIKey.V: The V key. C: R_KEY_V
  • UIKey.W: The W key. C: R_KEY_W
  • UIKey.X: The X key. C: R_KEY_X
  • UIKey.Y: The Y key. C: R_KEY_Y
  • UIKey.Z: The Z key. C: R_KEY_Z
  • UIKey.LeftBracket: The left bracket key. C: R_KEY_LEFT_BRACKET
  • UIKey.Backslash: The backslash key. C: R_KEY_BACKSLASH
  • UIKey.RightBracket: The right bracket key. C: R_KEY_RIGHT_BRACKET
  • UIKey.Grave: The grave key. C: R_KEY_GRAVE
  • UIKey.Escape: The escape key. C: R_KEY_ESCAPE
  • UIKey.Enter: The enter key. C: R_KEY_ENTER
  • UIKey.Tab: The tab key. C: R_KEY_TAB
  • UIKey.Backspace: The backspace key. C: R_KEY_BACKSPACE
  • UIKey.Insert: The insert key. C: R_KEY_INSERT
  • UIKey.Delete: The delete key. C: R_KEY_DELETE
  • UIKey.Right: The right key. C: R_KEY_RIGHT
  • UIKey.Left: The left key. C: R_KEY_LEFT
  • UIKey.Down: The down key. C: R_KEY_DOWN
  • UIKey.Up: The up key. C: R_KEY_UP
  • UIKey.PageUp: The page up key. C: R_KEY_PAGE_UP
  • UIKey.PageDown: The page down key. C: R_KEY_PAGE_DOWN
  • UIKey.Home: The home key. C: R_KEY_HOME
  • UIKey.End: The end key. C: R_KEY_END
  • UIKey.CapsLock: The caps lock key. C: R_KEY_CAPS_LOCK
  • UIKey.PrintScreen: The print screen key. C: R_KEY_PRINT_SCREEN
  • UIKey.Pause: The pause key. C: R_KEY_PAUSE
  • UIKey.F1: The F1 key. C: R_KEY_F1
  • UIKey.F2: The F2 key. C: R_KEY_F2
  • UIKey.F3: The F3 key. C: R_KEY_F3
  • UIKey.F4: The F4 key. C: R_KEY_F4
  • UIKey.F5: The F5 key. C: R_KEY_F5
  • UIKey.F6: The F6 key. C: R_KEY_F6
  • UIKey.F7: The F7 key. C: R_KEY_F7
  • UIKey.F8: The F8 key. C: R_KEY_F8
  • UIKey.F9: The F9 key. C: R_KEY_F9
  • UIKey.F10: The F10 key. C: R_KEY_F10
  • UIKey.F11: The F11 key. C: R_KEY_F11
  • UIKey.F12: The F12 key. C: R_KEY_F12
  • UIKey.Kp0: The keypad 0 key. C: R_KEY_KP_0
  • UIKey.Kp1: The keypad 1 key. C: R_KEY_KP_1
  • UIKey.Kp2: The keypad 2 key. C: R_KEY_KP_2
  • UIKey.Kp3: The keypad 3 key. C: R_KEY_KP_3
  • UIKey.Kp4: The keypad 4 key. C: R_KEY_KP_4
  • UIKey.Kp5: The keypad 5 key. C: R_KEY_KP_5
  • UIKey.Kp6: The keypad 6 key. C: R_KEY_KP_6
  • UIKey.Kp7: The keypad 7 key. C: R_KEY_KP_7
  • UIKey.Kp8: The keypad 8 key. C: R_KEY_KP_8
  • UIKey.Kp9: The keypad 9 key. C: R_KEY_KP_9
  • UIKey.KpDecimal: The keypad decimal key. C: R_KEY_KP_DECIMAL
  • UIKey.KpDivide: The keypad divide key. C: R_KEY_KP_DIVIDE
  • UIKey.KpMultiply: The keypad multiply key. C: R_KEY_KP_MULTIPLY
  • UIKey.KpSubtract: The keypad subtract key. C: R_KEY_KP_SUBTRACT
  • UIKey.KpAdd: The keypad add key. C: R_KEY_KP_ADD
  • UIKey.KpEnter: The keypad enter key. C: R_KEY_KP_ENTER
  • UIKey.LeftShift: The left shift key. C: R_KEY_LEFT_SHIFT
  • UIKey.LeftCtrl: The left Ctrl key. C: R_KEY_LEFT_CTRL
  • UIKey.LeftAlt: The left alt key. C: R_KEY_LEFT_ALT
  • UIKey.LeftSuper: The left super key. C: R_KEY_LEFT_SUPER
  • UIKey.RightShift: The right shift key. C: R_KEY_RIGHT_SHIFT
  • UIKey.RightCtrl: The right Ctrl key. C: R_KEY_RIGHT_CTRL
  • UIKey.RightAlt: The right alt key. C: R_KEY_RIGHT_ALT
  • UIKey.RightSuper: The right super key. C: R_KEY_RIGHT_SUPER
  • UIKey.Menu: The menu key. C: R_KEY_MENU

UIEventKind

text
type UIEventKind = choices(

The kind of a widget input event (R_EVENT_*).

Members

  • UIEventKind.None: No event. C: R_EVENT_NONE
  • UIEventKind.MouseMove: A mouse move event. C: R_EVENT_MOUSE_MOVE
  • UIEventKind.MouseDown: A mouse down event. C: R_EVENT_MOUSE_DOWN
  • UIEventKind.MouseUp: A mouse up event. C: R_EVENT_MOUSE_UP
  • UIEventKind.MouseWheel: A mouse wheel event. C: R_EVENT_MOUSE_WHEEL
  • UIEventKind.MouseEnter: A mouse enter event. C: R_EVENT_MOUSE_ENTER
  • UIEventKind.MouseLeave: A mouse leave event. C: R_EVENT_MOUSE_LEAVE
  • UIEventKind.KeyDown: A key down event. C: R_EVENT_KEY_DOWN
  • UIEventKind.KeyUp: A key up event. C: R_EVENT_KEY_UP
  • UIEventKind.Text: A character was typed. codepoint holds the Unicode scalar value. C: R_EVENT_TEXT
  • UIEventKind.FocusGained: A focus gained event. C: R_EVENT_FOCUS_GAINED
  • UIEventKind.FocusLost: A focus lost event. C: R_EVENT_FOCUS_LOST

UIDropPhase

text
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_ENTER
  • UIDropPhase.Move: It moves over the target. C: R_DROP_MOVE
  • UIDropPhase.Leave: It left the target without dropping. C: R_DROP_LEAVE
  • UIDropPhase.Dropped: The user dropped: paths and text hold what was dropped. C: R_DROP_DROPPED

UITouchMode

text
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_AUTO
  • UITouchMode.Scroll: A finger moving on the widget always scrolls what contains it, even over a control that drags. C: R_TOUCH_MODE_SCROLL
  • UITouchMode.Mouse: The finger is a mouse on the widget: pressing presses at once, moving drags, nothing scrolls. C: R_TOUCH_MODE_MOUSE
  • UITouchMode.None: Fingers are ignored on the widget (only its touch callback sees them): a surface for the pen. C: R_TOUCH_MODE_NONE

UITouchPhase

text
type UITouchPhase = choices(

The stage of a touch (R_TOUCH_*).

Members

  • UITouchPhase.Down: A finger came down. C: R_TOUCH_DOWN
  • UITouchPhase.Move: The touch moved. C: R_TOUCH_MOVE
  • UITouchPhase.Up: The finger was lifted. C: R_TOUCH_UP
  • UITouchPhase.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

text
type UIPenPhase = choices(

The stage of a pen (stylus) input (R_PEN_*).

Members

  • UIPenPhase.Down: The tip touched the screen. C: R_PEN_DOWN
  • UIPenPhase.Move: The pen moves while touching. C: R_PEN_MOVE
  • UIPenPhase.Up: The tip left the screen. C: R_PEN_UP
  • UIPenPhase.Hover: The pen moves near the screen without touching it. C: R_PEN_HOVER
  • UIPenPhase.Leave: The pen went out of reach. C: R_PEN_LEAVE

UIPenButton

text
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_BARREL
  • UIPenButton.Barrel2: The pen's second barrel button. C: R_PEN_BUTTON_BARREL2

UIPenButtons

text
type UIPenButtons = set of UIPenButton

A set of UIPenButton (Raven's RPenButton).

UIGesturePhase

text
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_BEGIN
  • UIGesturePhase.Update: The gesture went on. C: R_GESTURE_UPDATE
  • UIGesturePhase.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

text
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_PINCH
  • UIGestureKind.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

text
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_TOUCHSCREEN
  • UIGestureDevice.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

text
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_DARK
  • UILook.RavenLight: The light variant of RavenDark. C: R_LOOK_RAVEN_LIGHT
  • UILook.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_DARK
  • UILook.RavenGlassLight: The light variant of RavenGlassDark. C: R_LOOK_RAVEN_GLASS_LIGHT
  • UILook.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_DARK
  • UILook.RavenHighContrastLight: The light variant of RavenHighContrastDark. C: R_LOOK_RAVEN_HIGH_CONTRAST_LIGHT
  • UILook.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_DARK
  • UILook.WindowsLight: The light variant of WindowsDark. C: R_LOOK_WINDOWS_LIGHT
  • UILook.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_DARK
  • UILook.MacosLight: The light variant of MacosDark. C: R_LOOK_MACOS_LIGHT
  • UILook.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_DARK
  • UILook.GnomeLight: The light variant of GnomeDark. C: R_LOOK_GNOME_LIGHT
  • UILook.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_DARK
  • UILook.NativeLight: The light variant of NativeDark. C: R_LOOK_NATIVE_LIGHT
  • UILook.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_DARK
  • UILook.MacosGlassLight: The light variant of MacosGlassDark. C: R_LOOK_MACOS_GLASS_LIGHT

UIThemeKind

text
type UIThemeKind = choices(

A built-in theme (R_THEME_*).

Members

  • UIThemeKind.Dark: Flat, dense themes for tools. C: R_THEME_DARK
  • UIThemeKind.Light: The light variant of Dark. C: R_THEME_LIGHT
  • UIThemeKind.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_DARK
  • UIThemeKind.GlassLight: The light variant of GlassDark. C: R_THEME_GLASS_LIGHT
  • UIThemeKind.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_DARK
  • UIThemeKind.HighContrastLight: The light variant of HighContrastDark. C: R_THEME_HIGH_CONTRAST_LIGHT

UIMaterial

text
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_SOLID
  • UIMaterial.Glass: Clear glass: what is behind stays sharp enough to be recognized, strongly bent at the rim. C: R_MATERIAL_GLASS
  • UIMaterial.FrostedGlass: Frosted glass: what is behind is blurred into soft colors. The material of the glass themes. C: R_MATERIAL_FROSTED_GLASS
  • UIMaterial.TintedGlass: Frosted glass colored by the accent color of the theme (or of the widget): for what must stand out. C: R_MATERIAL_TINTED_GLASS
  • UIMaterial.Default: Not a material: "the one of the theme". Removes the material given to a widget. C: R_MATERIAL_DEFAULT

UIColorRole

text
type UIColorRole = choices(

A theme colour's role (R_COLOR_*).

Members

  • UIColorRole.Window: Window clear color. C: R_COLOR_WINDOW
  • UIColorRole.Panel: Border background. C: R_COLOR_PANEL
  • UIColorRole.Border: Border outline, list and input outlines. C: R_COLOR_BORDER
  • UIColorRole.Text: Text. Inherited by the children of the widget it is set on. C: R_COLOR_TEXT
  • UIColorRole.TextDisabled: Text on a disabled widget. C: R_COLOR_TEXT_DISABLED
  • UIColorRole.TextPlaceholder: The text placeholder colour. C: R_COLOR_TEXT_PLACEHOLDER
  • UIColorRole.Accent: Primary buttons, checked boxes, slider fill, progress fill. C: R_COLOR_ACCENT
  • UIColorRole.AccentHovered: Accent while hovered. C: R_COLOR_ACCENT_HOVERED
  • UIColorRole.AccentPressed: Accent while pressed. C: R_COLOR_ACCENT_PRESSED
  • UIColorRole.AccentText: Text and marks drawn on top of the accent color. C: R_COLOR_ACCENT_TEXT
  • UIColorRole.Control: Button, combo box, check box background. C: R_COLOR_CONTROL
  • UIColorRole.ControlHovered: Control while hovered. C: R_COLOR_CONTROL_HOVERED
  • UIColorRole.ControlPressed: Control while pressed. C: R_COLOR_CONTROL_PRESSED
  • UIColorRole.ControlBorder: Control as its border. C: R_COLOR_CONTROL_BORDER
  • UIColorRole.Input: Text input, spin box, list and tree background. C: R_COLOR_INPUT
  • UIColorRole.Focus: Keyboard focus outline. C: R_COLOR_FOCUS
  • UIColorRole.Selection: Selected rows and selected text. C: R_COLOR_SELECTION
  • UIColorRole.RowHovered: The row hovered colour. C: R_COLOR_ROW_HOVERED
  • UIColorRole.Track: Slider track, progress background, scrollbar track. C: R_COLOR_TRACK
  • UIColorRole.Handle: Scrollbar thumb, slider handle. C: R_COLOR_HANDLE
  • UIColorRole.HandleHovered: Handle while hovered. C: R_COLOR_HANDLE_HOVERED
  • UIColorRole.Separator: The separator colour. C: R_COLOR_SEPARATOR
  • UIColorRole.Header: Menu bar, tab bar, expander header. C: R_COLOR_HEADER
  • UIColorRole.HeaderHovered: Header while hovered. C: R_COLOR_HEADER_HOVERED
  • UIColorRole.TabActive: Active tab. C: R_COLOR_TAB_ACTIVE
  • UIColorRole.Popup: Menus, combo box lists. C: R_COLOR_POPUP
  • UIColorRole.PopupBorder: Popup as its border. C: R_COLOR_POPUP_BORDER
  • UIColorRole.Shadow: The shadow colour. C: R_COLOR_SHADOW
  • UIColorRole.Tooltip: The tooltip colour. C: R_COLOR_TOOLTIP
  • UIColorRole.TooltipText: The tooltip text colour. C: R_COLOR_TOOLTIP_TEXT
  • UIColorRole.Switch: Track of a switch that is on. C: R_COLOR_SWITCH
  • UIColorRole.Success: What went well, what needs attention, what is wrong or destroys something (markers, badges, classes). C: R_COLOR_SUCCESS
  • UIColorRole.Warning: The warning colour. C: R_COLOR_WARNING
  • UIColorRole.Danger: The danger colour. C: R_COLOR_DANGER
  • UIColorRole.Link: Links of formatted text. C: R_COLOR_LINK
  • UIColorRole.Code: Background of code in formatted text. C: R_COLOR_CODE

UIColorFilter

text
type UIColorFilter = choices(

A colour filter over the whole output, for accessibility (R_COLOR_FILTER_*).

Members

  • UIColorFilter.None: No filter. C: R_COLOR_FILTER_NONE
  • UIColorFilter.Protanopia: Red is weak. C: R_COLOR_FILTER_PROTANOPIA
  • UIColorFilter.Deuteranopia: Green is weak (the most frequent). C: R_COLOR_FILTER_DEUTERANOPIA
  • UIColorFilter.Tritanopia: Blue is weak. C: R_COLOR_FILTER_TRITANOPIA
  • UIColorFilter.Grayscale: Grayscale. C: R_COLOR_FILTER_GRAYSCALE
  • UIColorFilter.Invert: The colours inverted. C: R_COLOR_FILTER_INVERT
  • UIColorFilter.SimulateProtanopia: Simulations, to see an interface as the color blind see it. C: R_COLOR_FILTER_SIMULATE_PROTANOPIA
  • UIColorFilter.SimulateDeuteranopia: Shows the output as a person with deuteranopia sees it. C: R_COLOR_FILTER_SIMULATE_DEUTERANOPIA
  • UIColorFilter.SimulateTritanopia: Shows the output as a person with tritanopia sees it. C: R_COLOR_FILTER_SIMULATE_TRITANOPIA
  • UIColorFilter.SimulateAchromatopsia: Shows the output as a person with achromatopsia sees it. C: R_COLOR_FILTER_SIMULATE_ACHROMATOPSIA

UIMetric

text
type UIMetric = choices(

A theme size's role (R_METRIC_*).

Members

  • UIMetric.FontSize: The font size. C: R_METRIC_FONT_SIZE
  • UIMetric.CornerRadius: The corner radius. C: R_METRIC_CORNER_RADIUS
  • UIMetric.BorderWidth: The border width. C: R_METRIC_BORDER_WIDTH
  • UIMetric.ControlHeight: Height of buttons, inputs, combo boxes, tabs, menu bars. C: R_METRIC_CONTROL_HEIGHT
  • UIMetric.PaddingX: Horizontal / vertical padding inside controls. C: R_METRIC_PADDING_X
  • UIMetric.PaddingY: The vertical padding. C: R_METRIC_PADDING_Y
  • UIMetric.Spacing: Gap between an icon or a check mark and its text. C: R_METRIC_SPACING
  • UIMetric.ScrollbarSize: The scrollbar size. C: R_METRIC_SCROLLBAR_SIZE
  • UIMetric.RowHeight: Height of list, tree and menu rows. C: R_METRIC_ROW_HEIGHT
  • UIMetric.Indent: Indentation per tree level. C: R_METRIC_INDENT
  • UIMetric.SplitterSize: The splitter size. C: R_METRIC_SPLITTER_SIZE
  • UIMetric.CheckSize: The check size. C: R_METRIC_CHECK_SIZE
  • UIMetric.SliderHandleSize: The slider handle size. C: R_METRIC_SLIDER_HANDLE_SIZE
  • UIMetric.PopupRadius: Corner radius of menus, drop-down lists and tooltips. C: R_METRIC_POPUP_RADIUS
  • UIMetric.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_FROST
  • UIMetric.GlassRefraction: The glass refraction. C: R_METRIC_GLASS_REFRACTION
  • UIMetric.GlassSaturation: The glass saturation. C: R_METRIC_GLASS_SATURATION
  • UIMetric.GlassRim: The glass rim. C: R_METRIC_GLASS_RIM
  • UIMetric.GlassShadow: The glass shadow. C: R_METRIC_GLASS_SHADOW
  • UIMetric.BlurRadius: Radius of the blur of a BackgroundBlur that was not given one. C: R_METRIC_BLUR_RADIUS

UIFontStyle

text
type UIFontStyle = choices(

A font's style (R_FONT_*).

Members

  • UIFontStyle.Regular: Regular. C: R_FONT_REGULAR
  • UIFontStyle.Bold: Bold. C: R_FONT_BOLD
  • UIFontStyle.Italic: Italic. C: R_FONT_ITALIC
  • UIFontStyle.BoldItalic: Bold italic. C: R_FONT_BOLD_ITALIC

UIFilter

text
type UIFilter = choices(

How a texture is sampled when scaled (R_FILTER_*).

Members

  • UIFilter.Linear: Linear smoothing. C: R_FILTER_LINEAR
  • UIFilter.Nearest: No smoothing: keeps pixel art sharp. C: R_FILTER_NEAREST
  • UIFilter.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

text
type UITextureFormat = choices(

A texture's pixel format (R_TEXTURE_*).

Members

  • UITextureFormat.RGBA8: 4 bytes per pixel: R, G, B, A. C: R_TEXTURE_RGBA8
  • UITextureFormat.Alpha8: 1 byte per pixel, sampled as (1, 1, 1, value). Used by the glyph atlas. C: R_TEXTURE_ALPHA8

UIWidgetKind

text
type UIWidgetKind = choices(

The kind of a widget (R_WIDGET_*).

Members

  • UIWidgetKind.VBox: Stacks children top to bottom. C: R_WIDGET_VBOX
  • UIWidgetKind.HBox: Stacks children left to right. C: R_WIDGET_HBOX
  • UIWidgetKind.Grid: Rows and columns with spans and fill coefficients. C: R_WIDGET_GRID
  • UIWidgetKind.UniformGrid: Grid whose cells all have the same size. C: R_WIDGET_UNIFORM_GRID
  • UIWidgetKind.Overlay: Draws children on top of each other. C: R_WIDGET_OVERLAY
  • UIWidgetKind.Border: One child with a background, an outline and inner padding. C: R_WIDGET_BORDER
  • UIWidgetKind.SizeBox: One child with size constraints or a fixed aspect ratio. C: R_WIDGET_SIZE_BOX
  • UIWidgetKind.Spacer: Empty space. C: R_WIDGET_SPACER
  • UIWidgetKind.ScrollBox: Scrollable stack of children. C: R_WIDGET_SCROLL_BOX
  • UIWidgetKind.Splitter: Children separated by draggable handles. C: R_WIDGET_SPLITTER
  • UIWidgetKind.WrapBox: Flows children and wraps to the next line. C: R_WIDGET_WRAP_BOX
  • UIWidgetKind.Canvas: Children placed with anchors and offsets. C: R_WIDGET_CANVAS
  • UIWidgetKind.Switcher: Shows one child at a time. C: R_WIDGET_SWITCHER
  • UIWidgetKind.TabView: Tab bar + one page per child. C: R_WIDGET_TAB_VIEW
  • UIWidgetKind.Expander: Collapsible header + one child. C: R_WIDGET_EXPANDER
  • UIWidgetKind.Label: ---- controls (raven_controls.h) ----. C: R_WIDGET_LABEL
  • UIWidgetKind.Button: A button. C: R_WIDGET_BUTTON
  • UIWidgetKind.CheckBox: A check box. C: R_WIDGET_CHECKBOX
  • UIWidgetKind.Slider: A slider. C: R_WIDGET_SLIDER
  • UIWidgetKind.ProgressBar: A progress bar. C: R_WIDGET_PROGRESSBAR
  • UIWidgetKind.Image: An image. C: R_WIDGET_IMAGE
  • UIWidgetKind.TextInput: A text input. C: R_WIDGET_TEXT_INPUT
  • UIWidgetKind.SpinBox: A spin box. C: R_WIDGET_SPIN_BOX
  • UIWidgetKind.ComboBox: A combo box. C: R_WIDGET_COMBO_BOX
  • UIWidgetKind.Separator: A separator. C: R_WIDGET_SEPARATOR
  • UIWidgetKind.ListView: A list view. C: R_WIDGET_LIST_VIEW
  • UIWidgetKind.TreeView: A tree view. C: R_WIDGET_TREE_VIEW
  • UIWidgetKind.MenuBar: A menu bar. C: R_WIDGET_MENU_BAR
  • UIWidgetKind.Menu: A menu. C: R_WIDGET_MENU
  • UIWidgetKind.MenuItem: A menu item. C: R_WIDGET_MENU_ITEM
  • UIWidgetKind.Viewport: Area showing content rendered by the application. C: R_WIDGET_VIEWPORT
  • UIWidgetKind.Custom: Widget painted and measured by application callbacks. C: R_WIDGET_CUSTOM
  • UIWidgetKind.TextEditor: Multi-line text editor. C: R_WIDGET_TEXT_EDITOR
  • UIWidgetKind.HeaderBar: Title bar of a window with a custom header, holding any widget. C: R_WIDGET_HEADER_BAR
  • UIWidgetKind.DockArea: Panels docked side by side or behind tabs, that the user rearranges. C: R_WIDGET_DOCK_AREA
  • UIWidgetKind.Island: A capsule that unfolds into a panel, at the top of a window. C: R_WIDGET_ISLAND
  • UIWidgetKind.FileBrowser: Explorer of the files of the computer. C: R_WIDGET_FILE_BROWSER
  • UIWidgetKind.BackgroundBlur: One child over a blurred view of what is behind it. C: R_WIDGET_BACKGROUND_BLUR
  • UIWidgetKind.ColorPicker: Chooses a color: hue, saturation, value, opacity, by hand or by numbers. C: R_WIDGET_COLOR_PICKER
  • UIWidgetKind.Timeline: Tracks of clips and keys along a time ruler. C: R_WIDGET_TIMELINE
  • UIWidgetKind.NodeGraph: Nodes linked by wires, on a canvas that pans and zooms. C: R_WIDGET_NODE_GRAPH
  • UIWidgetKind.TileView: Grid of tiles (an icon over a name), virtualized. C: R_WIDGET_TILE_VIEW
  • UIWidgetKind.BlockEditor: Blocks that snap into each other, in the style of Scratch. C: R_WIDGET_BLOCK_EDITOR
  • UIWidgetKind.Table: Rows of cells under columns that can be resized and sorted, virtualized. C: R_WIDGET_TABLE
  • UIWidgetKind.DatePicker: A date, chosen in a calendar that drops down. C: R_WIDGET_DATE_PICKER
  • UIWidgetKind.TimePicker: A time of the day: hours, minutes, optionally seconds. C: R_WIDGET_TIME_PICKER
  • UIWidgetKind.Toast: A short message that rises for a few seconds, with an optional action ("Undo"). C: R_WIDGET_TOAST
  • UIWidgetKind.Breadcrumb: The path to the current place: links separated by chevrons. C: R_WIDGET_BREADCRUMB
  • UIWidgetKind.Rating: A score shown and chosen with stars. C: R_WIDGET_RATING
  • UIWidgetKind.Pagination: Page numbers with previous and next. C: R_WIDGET_PAGINATION
  • UIWidgetKind.Plot: Curves of X / Y data: legend, line styles, markers, log axes, a second X and Y axis, pan and zoom. C: R_WIDGET_PLOT
  • UIWidgetKind.PDFView: The pages of a PDF document, scrolled and zoomed (drawn by PDFium, loaded at run time). C: R_WIDGET_PDF_VIEW
  • UIWidgetKind.Chart: The charts of dashboards: pie, donut, gauge, heatmap, sparkline (RChartKind). C: R_WIDGET_CHART
  • UIWidgetKind.MapView: A map of slippy-map tiles given by the application (or read from files): panned, zoomed, with markers. C: R_WIDGET_MAP_VIEW
  • UIWidgetKind.Carousel: Pages shown one at a time and swiped (a page view), with dots and arrows. C: R_WIDGET_CAROUSEL

UIWidgetKinds

text
type UIWidgetKinds = set of UIWidgetKind

A set of UIWidgetKind (the kinds a widget type views: UIWidget.Kinds).

UIHAlign

text
type UIHAlign = choices(

How a widget lines up across its slot (R_HALIGN_*).

Members

  • UIHAlign.Fill: Fills the slot across. C: R_HALIGN_FILL
  • UIHAlign.Left: At the left. C: R_HALIGN_LEFT
  • UIHAlign.Center: Centred across the slot. C: R_HALIGN_CENTER
  • UIHAlign.Right: At the right. C: R_HALIGN_RIGHT

UIVAlign

text
type UIVAlign = choices(

How a widget lines up down its slot (R_VALIGN_*).

Members

  • UIVAlign.Fill: Fills the slot down. C: R_VALIGN_FILL
  • UIVAlign.Top: At the top. C: R_VALIGN_TOP
  • UIVAlign.Center: Centred down the slot. C: R_VALIGN_CENTER
  • UIVAlign.Bottom: At the bottom. C: R_VALIGN_BOTTOM

UIVisibility

text
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_VISIBLE
  • UIVisibility.Hidden: Not drawn, but still takes its space in the layout. C: R_HIDDEN
  • UIVisibility.Collapsed: Not drawn and takes no space. C: R_COLLAPSED

UIOrientation

text
type UIOrientation = choices(

A direction of layout (R_HORIZONTAL, R_VERTICAL).

Members

  • UIOrientation.Horizontal: Horizontal. C: R_HORIZONTAL
  • UIOrientation.Vertical: Vertical. C: R_VERTICAL

UITransition

text
type UITransition = choices(

How a widget's content changes over (R_TRANSITION_*).

Members

  • UITransition.None: No transition. C: R_TRANSITION_NONE
  • UITransition.Fade: Becomes opaque. C: R_TRANSITION_FADE
  • UITransition.Pop: Grows from a smaller size and bounces a little past its own. C: R_TRANSITION_POP
  • UITransition.Zoom: Shrinks from a larger size. C: R_TRANSITION_ZOOM
  • UITransition.FlyUp: Flies in from below / above / the right / the left, and settles with a bounce. C: R_TRANSITION_FLY_UP
  • UITransition.FlyDown: The new content flies in downwards. C: R_TRANSITION_FLY_DOWN
  • UITransition.FlyLeft: The new content flies in to the left. C: R_TRANSITION_FLY_LEFT
  • UITransition.FlyRight: The new content flies in to the right. C: R_TRANSITION_FLY_RIGHT
  • UITransition.Drop: Falls from above, squashes on landing and wobbles. C: R_TRANSITION_DROP
  • UITransition.SlideLeft: Short slide from the right / from the left, without bounce: pages that replace one another. C: R_TRANSITION_SLIDE_LEFT
  • UITransition.SlideRight: The new content slides in to the right. C: R_TRANSITION_SLIDE_RIGHT

UIBlurStyle

text
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_PLAIN
  • UIBlurStyle.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_FROSTED
  • UIBlurStyle.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_GLASS
  • UIBlurStyle.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

text
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_INHERIT
  • UIDirection.LTR: Left to right. C: R_DIRECTION_LTR
  • UIDirection.RTL: Right to left. C: R_DIRECTION_RTL
  • UIDirection.Auto: The windows: the direction of the language. C: R_DIRECTION_AUTO

UIToastKind

text
type UIToastKind = choices(

A toast's kind (R_TOAST_INFO ..).

Members

  • UIToastKind.Info: A neutral message (the accent of the theme). C: R_TOAST_INFO
  • UIToastKind.Success: A success toast. C: R_TOAST_SUCCESS
  • UIToastKind.Warning: A warning toast. C: R_TOAST_WARNING
  • UIToastKind.Error: An error toast. C: R_TOAST_ERROR

UIToastQueue

text
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_REPLACE
  • UIToastQueue.Sequence: The messages are shown one after the other, each for its own time. C: R_TOAST_SEQUENCE
  • UIToastQueue.Stack: Up to Rtoast_set_max_visible messages are shown at once, one above the other; the others wait. C: R_TOAST_STACK

UIButtonStyle

text
type UIButtonStyle = choices(

A button's style (R_BUTTON_*).

Members

  • UIButtonStyle.Default: Filled with R_COLOR_CONTROL. C: R_BUTTON_DEFAULT
  • UIButtonStyle.Primary: Filled with R_COLOR_ACCENT. C: R_BUTTON_PRIMARY
  • UIButtonStyle.Flat: No background until hovered (toolbars). C: R_BUTTON_FLAT

UICheckStyle

text
type UICheckStyle = choices(

A check box's style (R_CHECKBOX_*).

Members

  • UICheckStyle.Check: A check box. C: R_CHECKBOX_CHECK
  • UICheckStyle.Radio: Round mark. Checking one unchecks the other radio boxes of the same parent. C: R_CHECKBOX_RADIO
  • UICheckStyle.Switch: On / off switch. C: R_CHECKBOX_SWITCH

UIStretch

text
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_FILL
  • UIStretch.Fit: Largest size that fits entirely, keeping the aspect ratio. C: R_STRETCH_FIT
  • UIStretch.Cover: Smallest size that covers the widget, keeping the aspect ratio (cropped). C: R_STRETCH_COVER
  • UIStretch.None: Original size, centered. C: R_STRETCH_NONE

UIAxis

text
type UIAxis = choices(

A plot axis (R_PLOT_X ..).

Members

  • UIAxis.X: The horizontal axis under the data. C: R_PLOT_X
  • UIAxis.Y: The vertical axis on the left. C: R_PLOT_Y
  • UIAxis.X2: A second horizontal axis, over the data: shown when a series or a drag line uses it. C: R_PLOT_X2
  • UIAxis.Y2: A second vertical axis, on the right: shown when a series or a drag line uses it. C: R_PLOT_Y2

UIAxisScale

text
type UIAxisScale = choices(

A plot axis's scale (R_PLOT_SCALE_*).

Members

  • UIAxisScale.Linear: A linear scale. C: R_PLOT_SCALE_LINEAR
  • UIAxisScale.Log: Powers of ten at even distances; only values above zero are shown. C: R_PLOT_SCALE_LOG
  • UIAxisScale.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

text
type UILineStyle = choices(

A plot line's style (R_PLOT_LINE_*).

Members

  • UILineStyle.Solid: Solid lines. C: R_PLOT_LINE_SOLID
  • UILineStyle.Dashed: Dashed lines. C: R_PLOT_LINE_DASHED
  • UILineStyle.Dotted: Dotted lines. C: R_PLOT_LINE_DOTTED
  • UILineStyle.DashDot: Dash-dot lines. C: R_PLOT_LINE_DASH_DOT
  • UILineStyle.None: No line: only the markers (a scatter plot). C: R_PLOT_LINE_NONE

UIMarkerShape

text
type UIMarkerShape = choices(

A plot point's marker (R_PLOT_MARKER_*).

Members

  • UIMarkerShape.None: No marker. C: R_PLOT_MARKER_NONE
  • UIMarkerShape.Circle: A circle marker. C: R_PLOT_MARKER_CIRCLE
  • UIMarkerShape.Square: A square marker. C: R_PLOT_MARKER_SQUARE
  • UIMarkerShape.Diamond: A diamond marker. C: R_PLOT_MARKER_DIAMOND
  • UIMarkerShape.TriangleUp: A triangle up marker. C: R_PLOT_MARKER_TRIANGLE_UP
  • UIMarkerShape.TriangleDown: A triangle down marker. C: R_PLOT_MARKER_TRIANGLE_DOWN
  • UIMarkerShape.Cross: A cross marker. C: R_PLOT_MARKER_CROSS
  • UIMarkerShape.Plus: A plus marker. C: R_PLOT_MARKER_PLUS
  • UIMarkerShape.Asterisk: An asterisk marker. C: R_PLOT_MARKER_ASTERISK

UILegendPlace

text
type UILegendPlace = choices(

Where a plot's legend goes (R_PLOT_LEGEND_*).

Members

  • UILegendPlace.Hidden: No legend. C: R_PLOT_LEGEND_HIDDEN
  • UILegendPlace.TopLeft: At the top left. C: R_PLOT_LEGEND_TOP_LEFT
  • UILegendPlace.Top: At the top. C: R_PLOT_LEGEND_TOP
  • UILegendPlace.TopRight: At the top right. C: R_PLOT_LEGEND_TOP_RIGHT
  • UILegendPlace.Right: At the right. C: R_PLOT_LEGEND_RIGHT
  • UILegendPlace.BottomRight: At the bottom right. C: R_PLOT_LEGEND_BOTTOM_RIGHT
  • UILegendPlace.Bottom: At the bottom. C: R_PLOT_LEGEND_BOTTOM
  • UILegendPlace.BottomLeft: At the bottom left. C: R_PLOT_LEGEND_BOTTOM_LEFT
  • UILegendPlace.Left: At the left. C: R_PLOT_LEGEND_LEFT
  • UILegendPlace.Outside: To the right of the data, outside it. C: R_PLOT_LEGEND_OUTSIDE

UIPDFFit

text
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_WIDTH
  • UIPDFFit.Page: The largest page fits whole in the view. C: R_PDF_FIT_PAGE
  • UIPDFFit.None: The zoom of Rpdf_view_set_zoom; zooming with the wheel or the keys switches to it. C: R_PDF_FIT_NONE

UIPDFStatus

text
type UIPDFStatus = choices(

A PDF view's state (R_PDF_EMPTY ..).

Members

  • UIPDFStatus.Empty: No document. C: R_PDF_EMPTY
  • UIPDFStatus.Loaded: A document is shown. C: R_PDF_LOADED
  • UIPDFStatus.NeedsPassword: The document needs a password, or the one given is wrong: load it again with one. C: R_PDF_NEEDS_PASSWORD
  • UIPDFStatus.Error: The file could not be read, or is not a PDF document. C: R_PDF_ERROR
  • UIPDFStatus.Unavailable: The PDFium library was not found (see Rpdf_is_available). C: R_PDF_UNAVAILABLE

UIPDFFont

text
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_SANS
  • UIPDFFont.Mono: Roboto Mono. C: R_PDF_FONT_MONO

UIPDFPaint

text
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_FILL
  • UIPDFPaint.Stroke: Outlined with the stroke color and the line width. C: R_PDF_STROKE

UIPDFPaints

text
type UIPDFPaints = set of UIPDFPaint

A set of UIPDFPaint (Raven's RPdfPaint).

UIPDFText

text
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_BOLD
  • UIPDFText.Italic: Italic. C: R_PDF_TEXT_ITALIC
  • UIPDFText.Underline: Underline. C: R_PDF_TEXT_UNDERLINE

UIPDFTexts

text
type UIPDFTexts = set of UIPDFText

A set of UIPDFText (Raven's RPdfTextStyle).

UIPrintFlag

text
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

text
type UIPrintFlags = set of UIPrintFlag

A set of UIPrintFlag (Raven's RPdfPrintFlags).

UITileState

text
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_NONE
  • UITileState.Pending: Asked for (the tile callback was called, or the file is being read): waiting for its pixels. C: R_MAP_TILE_PENDING
  • UITileState.Loaded: Its pixels are in the cache. C: R_MAP_TILE_LOADED
  • UITileState.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

text
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_PIE
  • UIChartKind.Donut: Slices of a whole, as parts of a ring; its middle shows the total, or the slice under the pointer. C: R_CHART_DONUT
  • UIChartKind.Gauge: One value within a range, on an arc; bands color parts of the range. C: R_CHART_GAUGE
  • UIChartKind.Heatmap: A grid of values, each cell colored from the low color to the high one. C: R_CHART_HEATMAP
  • UIChartKind.Sparkline: A small line of values without axes, to sit in a tile or a cell of a table. C: R_CHART_SPARKLINE

UISyntax

text
type UISyntax = choices(

A text editor's built-in highlighting (R_SYNTAX_*).

Members

  • UISyntax.None: No highlighting. C: R_SYNTAX_NONE
  • UISyntax.XML: XML highlighting. C: R_SYNTAX_XML
  • UISyntax.C: C highlighting. C: R_SYNTAX_C

UILanguageFlag

text
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_MARKUP
  • UILanguageFlag.StyleSheet: Selectors, properties and values: CSS. C: R_LANGUAGE_STYLE_SHEET
  • UILanguageFlag.NestedComments: A block comment may hold another one (Rust). C: R_LANGUAGE_NESTED_COMMENTS
  • UILanguageFlag.CharLiterals: Between single quotes there is one character; any other single quote is not a text (C, Java, Rust). C: R_LANGUAGE_CHAR_LITERALS
  • UILanguageFlag.IndentOnColon: A line that ends with ':' indents the next one (Python). C: R_LANGUAGE_INDENT_ON_COLON
  • UILanguageFlag.IgnoreCase: The words of the language are recognized whatever their case. C: R_LANGUAGE_IGNORE_CASE
  • UILanguageFlag.Embeds: Markup that holds JavaScript in script elements and CSS in style elements (HTML). C: R_LANGUAGE_EMBEDS
  • UILanguageFlag.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

text
type UILanguageFlags = set of UILanguageFlag

A set of UILanguageFlag (Raven's RLanguageFlags).

UITokenKind

text
type UITokenKind = choices(

A highlighted token's kind (R_TOKEN_*).

Members

  • UITokenKind.Text: Plain text. C: R_TOKEN_TEXT
  • UITokenKind.Comment: A comment. C: R_TOKEN_COMMENT
  • UITokenKind.String: A string. C: R_TOKEN_STRING
  • UITokenKind.Number: A number. C: R_TOKEN_NUMBER
  • UITokenKind.Keyword: A keyword. C: R_TOKEN_KEYWORD
  • UITokenKind.Type: A type, or a name that is always there. C: R_TOKEN_TYPE
  • UITokenKind.Function: A name followed by an opening parenthesis. C: R_TOKEN_FUNCTION
  • UITokenKind.Tag: The name of an element, in markup and in the selectors of a style sheet. C: R_TOKEN_TAG
  • UITokenKind.Attribute: The name of an attribute (markup), of a class or of a property (style sheets), of a key (JSON). C: R_TOKEN_ATTRIBUTE
  • UITokenKind.Punctuation: Punctuation. C: R_TOKEN_PUNCTUATION
  • UITokenKind.Directive: A line for the preprocessor, an annotation, a declaration of a document. C: R_TOKEN_DIRECTIVE
  • UITokenKind.Heading: Formatted text (the Markdown language): a title, strong text, emphasized text, a link. C: R_TOKEN_HEADING
  • UITokenKind.Strong: Strong (bold) text. C: R_TOKEN_STRONG
  • UITokenKind.Emphasis: Emphasized (italic) text. C: R_TOKEN_EMPHASIS
  • UITokenKind.Link: A link. C: R_TOKEN_LINK

UIMarkKind

text
type UIMarkKind = choices(

A text editor line mark's kind (R_MARKER_*).

Members

  • UIMarkKind.Error: An error mark. C: R_MARKER_ERROR
  • UIMarkKind.Warning: A warning mark. C: R_MARKER_WARNING
  • UIMarkKind.Info: An info mark. C: R_MARKER_INFO

UIHeaderButton

text
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_CLOSE
  • UIHeaderButton.Minimize: The minimize button. C: R_HEADER_MINIMIZE
  • UIHeaderButton.Maximize: The maximize button. C: R_HEADER_MAXIMIZE

UIHeaderButtons

text
type UIHeaderButtons = set of UIHeaderButton

A set of UIHeaderButton (Raven's RHeaderButtons).

UITaskbarProgress

text
type UITaskbarProgress = choices(

The state of a taskbar progress (R_TASKBAR_PROGRESS_*).

Members

  • UITaskbarProgress.None: No progress shown. C: R_TASKBAR_PROGRESS_NONE
  • UITaskbarProgress.Normal: Progress shown as it goes. C: R_TASKBAR_PROGRESS_NORMAL
  • UITaskbarProgress.Paused: Shown as paused (yellow on Windows). C: R_TASKBAR_PROGRESS_PAUSED
  • UITaskbarProgress.Error: Shown as failed (red on Windows). C: R_TASKBAR_PROGRESS_ERROR
  • UITaskbarProgress.Indeterminate: Something goes on, without knowing how far it is. C: R_TASKBAR_PROGRESS_INDETERMINATE

UIDockSide

text
type UIDockSide = choices(

Where a docked panel goes (R_DOCK_*).

Members

  • UIDockSide.Left: The left side. C: R_DOCK_LEFT
  • UIDockSide.Right: The right side. C: R_DOCK_RIGHT
  • UIDockSide.Top: The top side. C: R_DOCK_TOP
  • UIDockSide.Bottom: The bottom side. C: R_DOCK_BOTTOM
  • UIDockSide.Tab: Behind the same tabs as the other panel. C: R_DOCK_TAB

UIDockFloat

text
type UIDockFloat = choices(

Where an undocked panel floats (R_DOCK_FLOAT_*).

Members

  • UIDockFloat.Window: In a window of its own. C: R_DOCK_FLOAT_WINDOW
  • UIDockFloat.InWindow: Inside the window. C: R_DOCK_FLOAT_IN_WINDOW

UIPreset

text
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_AUTO
  • UIPreset.Modern: Cards with soft shadows, few lines (follows dark or light). C: R_PRESET_MODERN
  • UIPreset.Blueprint: Headers in gradients, a grid of lines, thick links that glow; pins of the type "exec" are arrows. C: R_PRESET_BLUEPRINT
  • UIPreset.Blender: Compact nodes, flat headers in muted colors, thin links. C: R_PRESET_BLENDER
  • UIPreset.Neon: Almost black, outlines and links of light. C: R_PRESET_NEON

UITimelineItemKind

text
type UITimelineItemKind = choices(

A timeline item's kind (R_TIMELINE_*).

Members

  • UITimelineItemKind.None: No item. C: R_TIMELINE_NONE
  • UITimelineItemKind.Clip: A clip. C: R_TIMELINE_CLIP
  • UITimelineItemKind.Key: A key. C: R_TIMELINE_KEY
  • UITimelineItemKind.Marker: A marker. C: R_TIMELINE_MARKER

UIBlockShape

text
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_STATEMENT
  • UIBlockShape.Hat: Starts a script ("when the game starts"): nothing goes above it. C: R_BLOCK_HAT
  • UIBlockShape.Cap: Ends a script ("stop"): nothing goes under it. C: R_BLOCK_CAP
  • UIBlockShape.C: Wraps stacks in its mouths ("repeat", "if ... else"). C: R_BLOCK_C
  • UIBlockShape.Reporter: A rounded value that goes into a slot. C: R_BLOCK_REPORTER
  • UIBlockShape.Boolean: A hexagonal condition that goes into a %b slot (or a %r one). C: R_BLOCK_BOOLEAN

UIBlockPart

text
type UIBlockPart = choices(

Where a block joins another (R_BLOCK_NEXT ..).

Members

  • UIBlockPart.Next: After it, as the next block. C: R_BLOCK_NEXT
  • UIBlockPart.Body: Inside its body. C: R_BLOCK_BODY
  • UIBlockPart.Input: In one of its inputs. C: R_BLOCK_INPUT

UIUrgency

text
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_LOW
  • UIUrgency.Normal: Normal urgency. C: R_NOTIFICATION_NORMAL
  • UIUrgency.Critical: Stays until the user dismisses it, where the system allows it. C: R_NOTIFICATION_CRITICAL

UIFileDialogFlag

text
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_MULTIPLE
  • UIFileDialogFlag.Raven: Never the dialog of the OS: the file browser of Raven, in a dialog of the parent window. C: R_FILE_DIALOG_RAVEN
  • UIFileDialogFlag.ShowHidden: Hidden files shown. C: R_FILE_DIALOG_SHOW_HIDDEN

UIFileDialogFlags

text
type UIFileDialogFlags = set of UIFileDialogFlag

A set of UIFileDialogFlag (Raven's RFileDialogFlags).

UIBrowserMode

text
type UIBrowserMode = choices(

A file browser's mode (R_FILE_BROWSER_*).

Members

  • UIBrowserMode.Open: Choose an existing file. C: R_FILE_BROWSER_OPEN
  • UIBrowserMode.Save: Choose where to save: a name is typed; an existing file must be confirmed. C: R_FILE_BROWSER_SAVE
  • UIBrowserMode.Folder: Choose a folder. C: R_FILE_BROWSER_FOLDER

UIMessageButtons

text
type UIMessageButtons = choices(

The buttons of a message box (R_MESSAGE_OK ..).

Members

  • UIMessageButtons.Ok: An OK button. C: R_MESSAGE_OK
  • UIMessageButtons.OkCancel: OK and Cancel. C: R_MESSAGE_OK_CANCEL
  • UIMessageButtons.YesNo: Yes and No. C: R_MESSAGE_YES_NO
  • UIMessageButtons.YesNoCancel: Yes, No and Cancel. C: R_MESSAGE_YES_NO_CANCEL

UIMessageResult

text
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_CANCEL
  • UIMessageResult.Ok: OK. C: R_MESSAGE_RESULT_OK
  • UIMessageResult.Yes: Yes. C: R_MESSAGE_RESULT_YES
  • UIMessageResult.No: No. C: R_MESSAGE_RESULT_NO

UIMotion

text
type UIMotion = choices(

An animation's feel (R_MOTION_*).

Members

  • UIMotion.Snappy: Fast, no bounce: hover, highlights. C: R_MOTION_SNAPPY
  • UIMotion.Smooth: Slower, no bounce: scrolling, fades, sizes. C: R_MOTION_SMOOTH
  • UIMotion.Bouncy: Runs a little past the target and comes back: switches, popups, pressed buttons. C: R_MOTION_BOUNCY
  • UIMotion.Wobbly: Swings several times around the target: things that fly in or get dropped. C: R_MOTION_WOBBLY

UIEffect

text
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_AURORA
  • UIEffect.Shimmer: A band of light that sweeps across (loading placeholders): color = base, color2 = light; params: speed, width, angle, -. Animated. C: R_EFFECT_SHIMMER
  • UIEffect.Neon: A glowing edge whose colors run around the shape: color, color2; params: speed, width, glow, -. Animated. C: R_EFFECT_NEON
  • UIEffect.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_RIPPLE
  • UIEffect.Plasma: Bands of color that flow into each other: color, color2; params: speed, scale, contrast, -. Animated. C: R_EFFECT_PLASMA
  • UIEffect.Grain: A gradient with the fine grain of film: color (top left) to color2 (bottom right); params: grain, angle, -, -. Animated grain. C: R_EFFECT_GRAIN
  • UIEffect.Spotlight: A soft light that follows a point: color = light, color2 = background; params: x, y (0..1), radius (0..1), -. C: R_EFFECT_SPOTLIGHT
  • UIEffect.Mesh: Four colors blended across the surface, slowly moving: color, color2 and their mix; params: speed, -, -, -. Animated. C: R_EFFECT_MESH

UIShaderFlag

text
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_BACKDROP
  • UIShaderFlag.Animated: The effect changes with time: the window keeps drawing frames while it is shown. C: R_SHADER_ANIMATED

UIShaderFlags

text
type UIShaderFlags = set of UIShaderFlag

A set of UIShaderFlag (Raven's RShaderFlags).

UIXMLAttrKind

text
type UIXMLAttrKind = choices(

The kind of value an XML attribute takes (R_XML_*).

Members

  • UIXMLAttrKind.Text: Text. C: R_XML_TEXT
  • UIXMLAttrKind.Bool: "true" or "false". C: R_XML_BOOL
  • UIXMLAttrKind.Number: A number. C: R_XML_NUMBER
  • UIXMLAttrKind.Choice: One of the words of choices. C: R_XML_CHOICE
  • UIXMLAttrKind.Color: "#RGB", "#RRGGBB", "#RRGGBBAA", or a name: white, black, red, transparent. C: R_XML_COLOR
  • UIXMLAttrKind.Action: The name of an action (Raction_bind). C: R_XML_ACTION
  • UIXMLAttrKind.File: The path of a file. C: R_XML_FILE
  • UIXMLAttrKind.Numbers: Several numbers separated by commas: "8,4", "0,0,1,1". C: R_XML_NUMBERS
  • UIXMLAttrKind.List: Texts separated by '|': "One|Two|Three". C: R_XML_LIST

UIRole

text
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_AUTO
  • UIRole.None: Not exposed: its children are seen as the children of its parent. C: R_ROLE_NONE
  • UIRole.Window: A window. C: R_ROLE_WINDOW
  • UIRole.Group: A group. C: R_ROLE_GROUP
  • UIRole.Text: Text. C: R_ROLE_TEXT
  • UIRole.Heading: A heading. C: R_ROLE_HEADING
  • UIRole.Link: A link. C: R_ROLE_LINK
  • UIRole.Button: A button. C: R_ROLE_BUTTON
  • UIRole.ToggleButton: A toggle button. C: R_ROLE_TOGGLE_BUTTON
  • UIRole.CheckBox: A check box. C: R_ROLE_CHECKBOX
  • UIRole.RadioButton: A radio button. C: R_ROLE_RADIO_BUTTON
  • UIRole.Slider: A slider. C: R_ROLE_SLIDER
  • UIRole.ProgressBar: A progress bar. C: R_ROLE_PROGRESS_BAR
  • UIRole.SpinButton: A spin button. C: R_ROLE_SPIN_BUTTON
  • UIRole.TextField: A text field. C: R_ROLE_TEXT_FIELD
  • UIRole.Document: A document. C: R_ROLE_DOCUMENT
  • UIRole.ComboBox: A combo box. C: R_ROLE_COMBO_BOX
  • UIRole.List: A list. C: R_ROLE_LIST
  • UIRole.ListItem: A list item. C: R_ROLE_LIST_ITEM
  • UIRole.Tree: A tree. C: R_ROLE_TREE
  • UIRole.TreeItem: A tree item. C: R_ROLE_TREE_ITEM
  • UIRole.Table: A table. C: R_ROLE_TABLE
  • UIRole.MenuBar: A menu bar. C: R_ROLE_MENU_BAR
  • UIRole.Menu: A menu. C: R_ROLE_MENU
  • UIRole.MenuItem: A menu item. C: R_ROLE_MENU_ITEM
  • UIRole.TabList: A tab list. C: R_ROLE_TAB_LIST
  • UIRole.Tab: A tab. C: R_ROLE_TAB
  • UIRole.TabPanel: A tab panel. C: R_ROLE_TAB_PANEL
  • UIRole.Toolbar: A toolbar. C: R_ROLE_TOOLBAR
  • UIRole.StatusBar: A status bar. C: R_ROLE_STATUS_BAR
  • UIRole.Dialog: A dialog. C: R_ROLE_DIALOG
  • UIRole.Alert: An alert. C: R_ROLE_ALERT
  • UIRole.Image: An image. C: R_ROLE_IMAGE
  • UIRole.Canvas: A canvas. C: R_ROLE_CANVAS
  • UIRole.Separator: A separator. C: R_ROLE_SEPARATOR
  • UIRole.ScrollBar: A scroll bar. C: R_ROLE_SCROLL_BAR
  • UIRole.Pane: A pane. C: R_ROLE_PANE

UIColor

text
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

text
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

text
type UISize = record

A size in logical units.

Members

  • w: float32: The width.
  • h: float32: The height.

UIRect

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
type UIFrameFunc = ref func(const ADelta: float64)

What UIApp.OnFrame runs each frame: the seconds since the frame before.

UIAppEventFunc

text
type UIAppEventFunc = ref func(const AEvent: UIAppEvent)

What UIApp.OnAppEvent runs on a life-cycle event.

UITaskFunc

text
type UITaskFunc = ref func()

A routine with no arguments: a posted task (UIApp.Post), UIApp.OnDeviceReset, UIApp.OnNotifyClicked.

UINotifyFunc

text
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

text
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

text
type UITimerFunc = ref func(const ATimer: UITimerRes)

What a timer runs each time it fires (UITimerRes): the timer.

UIEventFunc

text
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

text
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

text
type UITouchFunc = ref func(const AEvent: RTouchEvent): bool

What UIWidget.OnTouch runs for each touch on the widget: true when it handled it.

UIPenFunc

text
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

text
type UIGestureFunc = ref func(const AEvent: RGestureEvent): bool

What UIWidget.OnGesture runs for each gesture on the widget: true when it handled it.

UIAskFunc

text
type UIAskFunc = ref func(): bool

What UIWindow.OnBack / OnClose run: true when the back is handled / the window may close.

UIKeyboardFunc

text
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

text
type UIResizeFunc = ref func(const AWidth: int32; const AHeight: int32)

What UIWindow.OnResize runs: the window's new size in logical units.

UIClosedFunc

text
type UIClosedFunc = ref func(const AResult: int32)

What a popup's or dialog's AOnClosed runs once when it closes: its result.

UIToggleFunc

text
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

text
type UIIndexFunc = ref func(const AIndex: int32)

A control's index closure: the tab, item or page chosen.

UIValueFunc

text
type UIValueFunc = ref func(const AValue: float32)

A control's value closure: a slider's or a rating's value.

UIValue64Func

text
type UIValue64Func = ref func(const AValue: float64)

A spin box's value closure.

UITextFunc

text
type UITextFunc = ref func(const AText: string)

A control's text closure: a text input's text, a label link's URL.

UIDateFunc

text
type UIDateFunc = ref func(const AYear: int32; const AMonth: int32; const ADay: int32)

A date picker's closure: the date chosen.

UITimeFunc

text
type UITimeFunc = ref func(const AHour: int32; const AMinute: int32; const ASecond: int32)

A time picker's closure: the time chosen.

UIColorFunc

text
type UIColorFunc = ref func(const AColor: UIColor)

A colour picker's closure: the colour chosen.

UITabCloseFunc

text
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

text
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: AName the name. Returns: this object, so calls chain
  • method WorkerThreads(const ACount: int32): self: The worker threads Raven runs (0: one a CPU core, the default). Parameters: ACount how many. Returns: this object, so calls chain
  • method NoRenderThread(const AOn: bool): self: true to render on the UI thread rather than a render thread of its own. Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • method NoVsync(const AOn: bool): self: true to draw frames without waiting for the display (vsync off). Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • method Validation(const AOn: bool): self: true to turn the GPU driver's validation on (slower: finds rendering mistakes). Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • method Headless(const AOn: bool): self: true for no OS window: windows draw off screen and take their input by injection (tools, tests). Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • method UIScale(const AScale: float32): self: The UI scale (0: the system's, the default; 2: everything twice as big). Parameters: AScale the scale. Returns: this object, so calls chain
  • method Backend(const ABackend: UIBackend): self: The renderer (UIBackend.Null renders nothing: headless runs and tests). Parameters: ABackend the backend. Returns: this object, so calls chain
  • const 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 to UIErrors) or an app is open already

Example: LApp := UIApp.Config().AppName("Notes").Backend(UIBackend.Vulkan).Open();

UIApp

text
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 named AName with Raven's defaults: the short form of UIApp.Config().AppName(AName).Open(). Parameters: AName the 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 with
  • static 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: true while this handle holds the open app. Returns: true while this handle holds the open app
  • static method Shutdown(): Ends Raven now, before its last handle goes (a host ending its UI before its own device or window): every <Name>Res destroyed, every closure let go; each copy of the app is then empty (IsValid() false). C: Rshutdown
  • static method Initialized(): bool: true while Raven is open (any app). C: Ris_initialized Returns: true while 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.g
  • const method Running(): bool: true until Quit is called or the last window is closed. C: Ris_running Returns: true until Quit is called or the last window is closed
  • const method Paused(): bool: true while the system has the app paused (a phone's app in the background). C: Ris_app_paused Returns: true while the system has the app paused (a phone's app in the background)
  • const method OnUIThread(): bool: true when called on the UI thread (the one that opened the app). C: Ris_ui_thread Returns: true when called on the UI thread (the one that opened the app)
  • const method ExitCode(): int32: The exit code Quit set (0 when none was). C: Rget_exit_code Returns: the exit code Quit set (0 when none was)
  • const method Delta(): float64: The seconds the last frame took. C: Rget_delta_time Returns: the seconds the last frame took
  • const method Time(): float64: The seconds since the app opened. C: Rget_time Returns: the seconds since the app opened
  • method Vsync(const AOn: bool): self: Waits for the display before each frame (true, the default) or not. C: Rset_vsync Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Vsync(): bool: true when frames wait for the display. C: Rget_vsync Returns: true when frames wait for the display
  • method UIScale(const AScale: float32): self: The UI scale (2: everything twice as big). C: Rset_ui_scale Parameters: AScale the scale. Returns: this object, so calls chain
  • const method UIScale(): float32: The UI scale. C: Rget_ui_scale Returns: the UI scale
  • method Direction(const ADirection: UIDirection): self: The layout direction of every window (right to left for Arabic or Hebrew). C: Rset_layout_direction Parameters: ADirection the direction. Returns: this object, so calls chain
  • const method Direction(): UIDirection: The layout direction. C: Rget_layout_direction Returns: the layout direction
  • method Animations(const AOn: bool): self: Animations on (true, the default) or off. C: Rset_animations_enabled Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Animations(): bool: true when animations are on. C: Rget_animations_enabled Returns: true when animations are on
  • method AnimationSpeed(const ASpeed: float32): self: How fast animations run (1: as designed, 0.5: half speed). C: Rset_animation_speed Parameters: ASpeed the speed. Returns: this object, so calls chain
  • const method AnimationSpeed(): float32: How fast animations run. C: Rget_animation_speed Returns: how fast animations run
  • method AnimationStep(const ASeconds: float64): self: Animations step ASeconds each 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: ASeconds the time, in seconds. Returns: this object, so calls chain
  • const method WorkerThreads(): int32: The worker threads Raven runs. C: Rget_worker_thread_count Returns: the worker threads Raven runs
  • method Run(): int32: Runs the app until Quit is called or the last window is closed, drawing a frame whenever something changed and sleeping between (a tool's loop). Returns: the exit code Quit set
  • method 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: false once Quit was called or the last window is closed
  • method WaitFrame(const ATimeout: float64): bool: Sleeps until something happens (an event, a task, a timer) or ATimeout seconds pass (a negative one: no limit), then draws a frame. C: Rwait_frame Parameters: ATimeout the timeout. Returns: false once Quit was called or the last window is closed
  • method WaitEvents(const ATimeout: float64): Sleeps until an event comes or ATimeout seconds pass, drawing nothing. C: Rwait_events Parameters: ATimeout the timeout.
  • method PollEvents(): Takes the pending OS events, drawing nothing. C: Rpoll_events
  • method Quit(): Ends the loop with exit code 0 (Run returns, Frame gives false). Any thread. C: Rquit
  • method Quit(const ACode: int32): Ends the loop with exit code ACode. Any thread. C: Rquit Parameters: ACode the exit code.
  • method WakeUp(): Wakes a WaitFrame / WaitEvents sleeping on the UI thread. Any thread. C: Rwake_up
  • method InjectAppEvent(const AEvent: UIAppEvent): Acts as if the system sent the life-cycle event AEvent (tests). C: Rinject_app_event Parameters: AEvent the event.
  • method OnFrame(const AFunc: UIFrameFunc): self: Runs AFunc at every frame with the seconds since the frame before (nil: none). C: Rset_frame_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • method OnAppEvent(const AFunc: UIAppEventFunc): self: Runs AFunc on each life-cycle event (nil: none). C: Rset_app_event_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • method OnDeviceReset(const AFunc: UITaskFunc): self: Runs AFunc after 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: AFunc the func it runs. Returns: this object, so calls chain
  • method Post(const AFunc: UITaskFunc): Runs AFunc once on the UI thread, at the next frame. Any thread: the way a worker hands its result to the UI. C: Rtask_post Parameters: AFunc the 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 use
  • const method MemoryCheck(): bool: Checks Raven's memory for damage (a debug aid). C: Rmemory_check Returns: true when it is sound
  • method MemoryTrim(): Gives the memory Raven keeps for reuse back to the heap. C: Rmemory_trim
  • static 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): Puts AText on the clipboard. C: Rclipboard_set_text Parameters: AText the text.
  • static method ClipboardHTML(const AText: string; const AHTML: string): Puts AText on the clipboard with AHTML as its formatted form (pasted into a program that takes HTML). C: Rclipboard_set_html Parameters: AText the text; AHTML the HTML.
  • static method Notify(const ATitle: string; const ABody: string): bool: Shows a system notification of normal urgency. C: Rnotification_show Parameters: ATitle the title; ABody the body. Returns: true when the system showed it (or NotifyFallback's routine took it)
  • static method Notify(const ATitle: string; const ABody: string; const AUrgency: UIUrgency): bool: Shows a system notification of urgency AUrgency. C: Rnotification_show Parameters: ATitle the title; ABody the body; AUrgency the urgency. Returns: true when the system showed it (or NotifyFallback's routine took it)
  • static method NotifySupported(): bool: true when the system shows notifications. C: Rnotification_is_supported Returns: true when the system shows notifications
  • method NotifyFallback(const AFunc: UINotifyFunc): self: Runs AFunc for a notification the system cannot show, to show it another way (a toast in the window; nil: none). C: Rnotification_set_fallback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • method OnNotifyClicked(const AFunc: UITaskFunc): self: Runs AFunc when the user clicks a notification the app showed (nil: none). C: Rnotification_set_clicked_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • static method TaskbarBadge(const AText: string): bool: Shows AText as the badge on the app's taskbar button ("" removes it). C: Rtaskbar_set_badge Parameters: AText the text. Returns: true when the system has taskbar badges
  • static 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: ATasks the tasks. Returns: true when the system has jump lists

Example: LApp := UIApp("Notes"); LApp.OnFrame(func(const ADelta: float64) begin Tick(ADelta); end); return LApp.Run();

UIErrors

text
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.None when none was). C: Rerror_get_last Returns: the error Raven reported last (UIErrorCode.None when none was)
  • static method Text(const ACode: UIErrorCode): string: The name of the error code ACode, e.g. "R_ERROR_INVALID_ID". C: Rerror_to_string Parameters: ACode the error code. Returns: the name of the error code ACode, e.g
  • static method Text(const ASeverity: UISeverity): string: The name of the severity ASeverity. C: Rseverity_to_string Parameters: ASeverity the severity. Returns: the name of the severity ASeverity
  • static method OnError(const AFunc: UIErrorFunc): Runs AFunc for every error Raven reports, with its code, severity and detail, in place of Report's console lines (nil: none). Set it before the app opens to see the errors of opening too. C: Rerror_set_callback Parameters: AFunc the func it runs.
  • static method Report(): Writes every error Raven reports on the console, one line each: [Raven] <code> (<severity>): <detail>, in place of an OnError routine. 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

text
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 running AFunc after AInterval seconds, then again every AInterval seconds when ARepeat is true (the app must be open). C: Rtimer_create Parameters: AInterval the interval; ARepeat true to run again every interval; AFunc the func it runs.
  • const method IsValid(): bool: true while the timer runs (a one-shot timer that fired runs no more). C: Rtimer_is_valid Returns: true while the timer runs (a one-shot timer that fired runs no more)
  • static method Of(const ATimer: Rid): UITimerRes: A handle to the timer ATimer this layer made (sharing its holder), as its routine is handed when it fires; an empty handle for any other Rid. Parameters: ATimer the timer. Returns: a handle to the timer ATimer this layer made (sharing its holder), as its routine is handed when it fires; an empty handle for any other Rid
  • const method Id(): Rid: The timer's Rid, for .C calls (R_INVALID_ID when the handle holds none). Returns: the timer's Rid, for .C calls (R_INVALID_ID when the handle holds none)

Example: LTick := UITimerRes(1.0, true, func(const ATimer: UITimerRes) begin Refresh(); end);

UIPixels

text
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 * 4 bytes.

Example: LIcon := UITextureRes.Decode(LPNG); LWindow.Icon(LIcon);

UITextureRes

text
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 at APath (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: APath the file's path.
  • static method View(const ATexture: Rid): UITextureRes: A borrowed handle of the texture ATexture (a Rid System.Raven.C gave): it never destroys it. Parameters: ATexture the texture. Returns: a borrowed handle of the texture ATexture (a Rid System.Raven.C gave): it never destroys it
  • static method Adopt(const ATexture: Rid): UITextureRes: The handle owning the texture ATexture a System.Raven.C call made (it destroys it with its last copy, the app's end too). Parameters: ATexture the texture. Returns: the handle owning the texture ATexture a 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 from AIO (from where it stands to its end), decoded now (empty when it cannot be read). C: Rtexture_create Parameters: AIO the IO. Returns: the texture of the image file read from AIO (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 bytes AData, decoded now (Raven copies them). C: Rtexture_create Parameters: AData the bytes. Returns: the texture of the image file bytes AData, decoded now (Raven copies them)
  • static method FromSVG(const ASVG: string; const AScale: float32): UITextureRes: The SVG text ASVG drawn into a texture at AScale pixels 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: ASVG the SVG; AScale the scale. Returns: the SVG text ASVG drawn into a texture at AScale pixels 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 pixels APixels (empty when they hold fewer bytes than their size needs). C: Rtexture_create_from_pixels Parameters: APixels the pixels. Returns: a texture of the pixels APixels (empty when they hold fewer bytes than their size needs)
  • static method Load(const APath: string): UITextureRes: The texture of the image file at APath, decoded on a worker thread: the handle is usable at once, what shows it draws nothing until it is Ready. C: Rtexture_create_from_file_async Parameters: APath the file's path. Returns: the texture of the image file at APath, decoded on a worker thread: the handle is usable at once, what shows it draws nothing until it is Ready
  • static method LoadMemory(const AData: array of uint8): UITextureRes: The texture of the image file bytes AData, decoded on a worker thread (Raven copies them), as Load. C: Rtexture_create_async Parameters: AData the bytes. Returns: the texture of the image file bytes AData, decoded on a worker thread (Raven copies them), as Load
  • static method Decode(const AData: array of uint8): UIPixels: The image file bytes AData decoded 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: AData the bytes. Returns: the image file bytes AData decoded to pixels, on the calling thread (any thread), with no texture made: empty pixels (Width 0) when Raven cannot read them
  • const method IsValid(): bool: true while it holds a texture Raven still has. C: Rtexture_is_valid Returns: true while it holds a texture Raven still has
  • const method Id(): Rid: The texture's Rid, for .C calls (R_INVALID_ID when the handle holds none or it is destroyed). Returns: the texture's Rid, for .C calls (R_INVALID_ID when the handle holds none or it is destroyed)
  • const method Ready(): bool: true once it is decoded (always for one decoded at once). C: Rtexture_is_ready Returns: true once 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 chain
  • const 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 otherwise
  • const method Update(const APixels: UIPixels): self: Its pixels replaced by APixels (their size may differ; nothing when they hold fewer bytes than their size needs). C: Rtexture_update Parameters: APixels the pixels. Returns: this object, so calls chain
  • const method Filter(const AFilter: UIFilter): self: How it is sampled when drawn at another size. C: Rtexture_set_filter Parameters: AFilter the filter. Returns: this object, so calls chain

Example: LLogo := UITextureRes("$P:../../../../res/assets/ui/logo.png"); UIImage.Create().Texture(LLogo).Stretch(UIStretch.Fit);

UIFontRes

text
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 at APath (through the program's IO hooks; empty when it cannot be read; the app must be open). C: Rfont_create_from_file Parameters: APath the file's path.
  • static method View(const AFont: Rid): UIFontRes: A borrowed handle of the font AFont (a Rid System.Raven.C gave): it never destroys it. Parameters: AFont the font. Returns: a borrowed handle of the font AFont (a Rid System.Raven.C gave): it never destroys it
  • static method FromIO(const AIO: IO): UIFontRes: The font file read from AIO (from where it stands to its end; empty when it cannot be read). C: Rfont_create Parameters: AIO the IO. Returns: the font file read from AIO (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 bytes AData (Raven copies them). C: Rfont_create Parameters: AData the bytes. Returns: the font file bytes AData (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), borrowed
  • static 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), borrowed
  • const method IsValid(): bool: true while it holds a font Raven still has. C: Rfont_is_valid Returns: true while it holds a font Raven still has
  • const method Id(): Rid: The font's Rid, for .C calls (R_INVALID_ID when the handle holds none or it is destroyed). Returns: the font's Rid, for .C calls (R_INVALID_ID when the handle holds none or it is destroyed)
  • const method Fallback(const AFallback: UIFontRes): self: AFallback draws the characters this font lacks (an empty handle: none); kept while this font lives. C: Rfont_set_fallback Parameters: AFallback the fallback. Returns: this object, so calls chain
  • const method Variant(const AStyle: UIFontStyle; const AVariant: UIFontRes): self: AVariant drawn for the style AStyle of 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: AStyle the style; AVariant the variant. Returns: this object, so calls chain
  • const method Variant(const AStyle: UIFontStyle): UIFontRes: The font drawn for the style AStyle of this one: the variant given, else the one Raven derives (it lives as long as this font), borrowed. C: Rfont_get_variant Parameters: AStyle the style. Returns: the font drawn for the style AStyle of this one: the variant given, else the one Raven derives (it lives as long as this font), borrowed
  • const method Measure(const ASize: float32; const AText: string): UISize: The size of AText (UTF-8, \n starting lines) at the font size ASize (0: the theme's), in logical units at scale 1; an empty handle measures with the theme's font. C: Rfont_measure_text Parameters: ASize the size; AText the text. Returns: the size of AText (UTF-8, \n starting lines) at the font size ASize (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

text
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 at APath (a .spv; through the program's IO hooks), drawn as AFlags say (empty when it cannot be read). C: Rshader_create_from_file Parameters: APath the file's path; AFlags the flags.
  • static method View(const AShader: Rid): UIShaderRes: A borrowed handle of the shader AShader (a Rid System.Raven.C gave): it never destroys it. Parameters: AShader the shader. Returns: a borrowed handle of the shader AShader (a Rid System.Raven.C gave): it never destroys it
  • static method FromSPIRV(const ASPIRV: array of uint8; const AFlags: UIShaderFlags): UIShaderRes: The SPIR-V code ASPIRV (copied), drawn as AFlags say: empty when the code is not SPIR-V (a backend that refuses it reports an error and draws a rectangle). C: Rshader_create Parameters: ASPIRV the SPIRV; AFlags the flags. Returns: the SPIR-V code ASPIRV (copied), drawn as AFlags say: 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 effect AEffect (made the first time it is asked for), borrowed. C: Reffect_get Parameters: AEffect the effect. Returns: the built-in effect AEffect (made the first time it is asked for), borrowed
  • static method Effect(const AName: string): UIShaderRes: The built-in effect named AName ("aurora", "shimmer", "neon", "ripple", "plasma", "grain", "spotlight", "mesh"), borrowed; empty for another name. C: Reffect_find Parameters: AName the name. Returns: the built-in effect named AName ("aurora", "shimmer", "neon", "ripple", "plasma", "grain", "spotlight", "mesh"), borrowed; empty for another name
  • static method EffectName(const AEffect: UIEffect): string: The name of the built-in effect AEffect ("aurora" ..). C: Reffect_get_name Parameters: AEffect the effect. Returns: the name of the built-in effect AEffect ("aurora" ..)
  • static method EffectDefaults(const AEffect: UIEffect): RShaderLook: The look the built-in effect AEffect is drawn with when none is given. C: Reffect_get_defaults Parameters: AEffect the effect. Returns: the look the built-in effect AEffect is drawn with when none is given
  • static method Look(): RShaderLook: A look with Raven's starting values (colours, parameters, radius, animation), to change and hand to UIBorder.Effect or UIPainter.Shader. C: Rshader_look_init Returns: a look with Raven's starting values (colours, parameters, radius, animation), to change and hand to UIBorder.Effect or UIPainter.Shader
  • const method IsValid(): bool: true while it holds a shader Raven still has. C: Rshader_is_valid Returns: true while it holds a shader Raven still has
  • const method Id(): Rid: The shader's Rid, for .C calls (R_INVALID_ID when the handle holds none or it is destroyed). Returns: the shader's Rid, for .C calls (R_INVALID_ID when 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, else UIShaderRes.Look()'s). C: Rshader_look_defaults Returns: the look it is drawn with when none is given (a built-in effect's own, else UIShaderRes.Look()'s)

Example: LWave := UIShaderRes("$P:wave.spv", []); LBorder.Effect(LWave, LWave.Defaults());

UITheme

text
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 with Metric stay; colours and styles set here are lost (put them in a loaded theme to keep them). C: Rlook_set Parameters: ALook the look.
  • static method Look(): UILook: The look in use. C: Rlook_get Returns: the look in use
  • static method Dark(const AOn: bool): Dark (true) or light colours for the look in use. C: Rtheme_set_dark Parameters: AOn true to turn it on, false to turn it off.
  • static method Dark(): bool: true while the colours are dark. C: Rtheme_is_dark Returns: true while the colours are dark
  • static method FollowSystem(const AOn: bool): Dark or light following the system's setting as it changes (true). C: Rtheme_follow_system Parameters: AOn true to turn it on, false to turn it off.
  • static method SystemDark(): bool: true when the system is set to dark. C: Rtheme_get_system_dark Returns: true when the system is set to dark
  • static method Accent(const AColor: UIColor): The accent colour (its alpha unused): selections, focus, the default buttons. C: Rtheme_set_accent Parameters: AColor the 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: ATexture the 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 of ARole for every widget with none of its own. C: Rtheme_set_color Parameters: ARole the role; AColor the colour.
  • static method Color(const ARole: UIColorRole): UIColor: The colour of ARole. C: Rtheme_get_color Parameters: ARole the role. Returns: the colour of ARole
  • static method Metric(const AMetric: UIMetric; const AValue: float32): The size AMetric (font size, corner radius, paddings ..) for every widget with none of its own; kept through a look switch. C: Rtheme_set_metric Parameters: AMetric the metric; AValue the value.
  • static method Metric(const AMetric: UIMetric): float32: The size AMetric. C: Rtheme_get_metric Parameters: AMetric the metric. Returns: the size AMetric
  • static method Material(const AMaterial: UIMaterial): What the panels are made of (solid or a glass). C: Rtheme_set_material Parameters: AMaterial the material.
  • static method Material(): UIMaterial: The material in use. C: Rtheme_get_material Returns: the material in use
  • static 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: AFont the font.
  • static method Font(): UIFontRes: The theme's font, borrowed. C: Rtheme_get_font Returns: the theme's font, borrowed
  • static method StyleColor(const AWidget: string; const AClass: string; const ARole: UIColorRole; const AColor: UIColor): The colour of ARole for the widgets of the kind AWidget (its XML name: "Button" ..; "": every kind) with the style class AClass ("": 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: AWidget the widget; AClass the class name; ARole the role; AColor the colour.
  • static method StyleMetric(const AWidget: string; const AClass: string; const AMetric: UIMetric; const AValue: float32): The size AMetric for the widgets of the kind AWidget ("": every kind) with the style class AClass ("": whatever their classes), as StyleColor. C: Rtheme_set_style_metric Parameters: AWidget the widget; AClass the class name; AMetric the metric; AValue the value.
  • static method StyleMaterial(const AWidget: string; const AClass: string; const AMaterial: UIMaterial): The material of the widgets of the kind AWidget ("": every kind) with the style class AClass ("": whatever their classes), as StyleColor. C: Rtheme_set_style_material Parameters: AWidget the widget; AClass the class name; AMaterial the material.
  • static method ClearStyles(): Every style set by kind and class removed. C: Rtheme_clear_styles
  • static method TokenColor(const AToken: UITokenKind; const AColor: UIColor): The text editors' colour of the token kind AToken. C: Rtheme_set_token_color Parameters: AToken the token; AColor the colour.
  • static method TokenColor(const AToken: UITokenKind): UIColor: The text editors' colour of the token kind AToken. C: Rtheme_get_token_color Parameters: AToken the token. Returns: the text editors' colour of the token kind AToken
  • static method ClearTokenColors(): The token colours back to the look's. C: Rtheme_clear_token_colors
  • static method Load(const APath: string): string: Loads the theme file (XML) at APath, ready to Use; loading a theme of a name that is loaded already updates every widget using it. Parameters: APath the file's path. Returns: The theme's name; "" (the error reported) when it cannot be loaded. C: Rtheme_load
  • static method LoadText(const AXML: string): string: Loads a theme from the XML text AXML, as Load. C: Rtheme_load_from_memory Parameters: AXML the XML text. Returns: the theme's name; "" (the error reported) when it cannot be loaded
  • static method Use(const AName: string): bool: The theme named AName (a built-in one, "Dark" .., or one loaded) for the app. Parameters: AName the name. Returns: false (the error reported) when no theme has that name. C: Rtheme_use
  • static 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 theme AIndex (0 .. Count() - 1; "" outside). C: Rtheme_get_name_at Parameters: AIndex the index, from 0. Returns: the name of the theme AIndex (0 .
  • static method Save(const APath: string; const AName: string): bool: Saves the theme named AName as an XML file at APath. Parameters: APath the file's path; AName the name. Returns: false when 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

text
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 part UILayout.Fill sets.
  • UILayoutPart.Auto: The part UILayout.Auto sets.
  • UILayoutPart.Margin: The part UILayout.Margin sets.
  • UILayoutPart.HAlign: The part UILayout.HAlign sets.
  • UILayoutPart.VAlign: The part UILayout.VAlign sets.
  • UILayoutPart.MaxSize: The part UILayout.MaxSize sets.
  • UILayoutPart.Cell: The part UILayout.Cell sets.
  • UILayoutPart.Span: The part UILayout.Span sets.
  • UILayoutPart.Anchors: The part UILayout.Anchors sets.
  • UILayoutPart.At: The part UILayout.At sets.
  • UILayoutPart.Size: The part UILayout.Size sets.
  • UILayoutPart.Pivot: The part UILayout.Pivot sets.
  • UILayoutPart.Title: The part UILayout.Title sets.

UILayoutParts

text
type UILayoutParts = set of UILayoutPart

A set of UILayoutPart.

UILayout

text
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 takes AShare of the room its parent has left (a box's children share it by their shares). C: Rslot_set_fill Parameters: AShare the share. Returns: the child takes AShare of 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 room AAll around every side of the child. C: Rslot_set_padding Parameters: AAll the room on every side. Returns: the same room AAll around every side of the child
  • const 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: ALeft the room on the left; ATop the room above; ARight the room on the right; ABottom the room below. Returns: the layout with that room set
  • const method HAlign(const AAlign: UIHAlign): UILayout: How the child lines up across its slot's width. C: Rslot_set_halign Parameters: AAlign the alignment. Returns: how the child lines up across its slot's width
  • const method VAlign(const AAlign: UIVAlign): UILayout: How the child lines up across its slot's height. C: Rslot_set_valign Parameters: AAlign the alignment. Returns: how the child lines up across its slot's height
  • const method Align(const AHorizontal: UIHAlign; const AVertical: UIVAlign): UILayout: Both alignments at once. C: Rslot_set_halign, Rslot_set_valign Parameters: AHorizontal the horizontal; AVertical the vertical. Returns: the layout with both alignments set
  • const method MaxSize(const ALargest: float32): UILayout: The largest size the child takes along its parent's direction. C: Rslot_set_max_size Parameters: ALargest the largest. Returns: the largest size the child takes along its parent's direction
  • const method Cell(const AColumn: int32; const ARow: int32): UILayout: The grid cell the child sits in. C: Rslot_set_grid Parameters: AColumn the column, from 0; ARow the row, from 0. Returns: the grid cell the child sits in
  • const 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: AColumns the columns; ARows the rows. Returns: the grid columns and rows the child spans from its cell
  • const 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: AMinX the min X; AMinY the min Y; AMaxX the max X; AMaxY the 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: AX the x coordinate; AY the y coordinate. Returns: the child's position on a canvas, from its anchors
  • const method Size(const AWidth: float32; const AHeight: float32): UILayout: The child's size on a canvas. C: Rslot_set_size Parameters: AWidth the width; AHeight the height. Returns: the child's size on a canvas
  • const 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: AX the x coordinate; AY the 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: AText the 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

text
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 kind AKind with Raven's defaults, in no parent yet (the widget types' own Create give their typed handle). C: Rwidget_create Parameters: AKind the kind. Returns: a new widget of the kind AKind with Raven's defaults, in no parent yet (the widget types' own Create give their typed handle)
  • static method FromXML(const APath: string): UIWidget: A widget tree made from the XML layout file APath (IsValid() false when it does not load: its error reported to UIErrors). C: Rwidget_create_from_xml_file Parameters: APath the file's path. Returns: a widget tree made from the XML layout file APath (IsValid() false when it does not load: its error reported to UIErrors)
  • static method FromXMLText(const AXML: string): UIWidget: A widget tree made from the XML layout text AXML. C: Rwidget_create_from_xml Parameters: AXML the XML text. Returns: a widget tree made from the XML layout text AXML
  • static method Wrap(const AId: Rid): UIWidget: The handle of the widget System.Raven.C gave as AId (R_INVALID_ID: an empty one). Parameters: AId the id. Returns: the handle of the widget System.Raven.C gave as AId (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 against T.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 against T.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 calls
  • const method IsValid(): bool: true while the handle names a widget (one Raven has not destroyed). C: Rwidget_is_valid Returns: true while 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 kind
  • const method Destroy(): Destroys the widget and everything inside it (each told by its OnDestroy); the handles naming them are no longer valid. C: Rwidget_destroy
  • const method Add(const AChild: UIWidget): self: Places AChild last inside this widget, with Raven's default layout. C: Rwidget_add_child Parameters: AChild the child widget. Returns: this object, so calls chain
  • const method Add(const AChild: UIWidget; const ALayout: UILayout): self: Places AChild last inside this widget, sitting as ALayout says. C: Rwidget_add_child, Rslot_* Parameters: AChild the child widget; ALayout the layout. Returns: this object, so calls chain
  • const method Insert(const AIndex: int32; const AChild: UIWidget): self: Places AChild at AIndex among this widget's children. C: Rwidget_insert_child Parameters: AIndex the index, from 0; AChild the child widget. Returns: this object, so calls chain
  • const method Insert(const AIndex: int32; const AChild: UIWidget; const ALayout: UILayout): self: Places AChild at AIndex among this widget's children, sitting as ALayout says. C: Rwidget_insert_child, Rslot_* Parameters: AIndex the index, from 0; AChild the child widget; ALayout the layout. Returns: this object, so calls chain
  • const method Remove(const AChild: UIWidget): self: Takes AChild out of this widget (it is not destroyed: place it again, or destroy it). C: Rwidget_remove_child Parameters: AChild the child widget. Returns: this object, so calls chain
  • const method Clear(): self: Destroys every child of this widget. C: Rwidget_clear_children Returns: this object, so calls chain
  • const method Layout(const ALayout: UILayout): self: How the widget sits in its parent, set to ALayout's parts. C: Rslot_* Parameters: ALayout the layout. Returns: this object, so calls chain
  • const 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; the Begin<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; the Begin<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 holds
  • const method Child(const AIndex: int32): UIWidget: The child at AIndex (0 .. ChildCount() - 1; an empty handle outside). C: Rwidget_get_child Parameters: AIndex the index, from 0. Returns: the child at AIndex (0 .
  • const method Name(const AName: string): self: The name Find looks for (an XML layout's Name). C: Rwidget_set_name Parameters: AName the name. Returns: this object, so calls chain
  • const 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 named AName inside this one (searched as Raven searches: the name an XML layout or Name gave it), as the widget type T. Raises ADAM_RAVEN_EXC_NOT_FOUND when no widget has the name and ADAM_RAVEN_EXC_KIND when it is of a kind T does not view (the message names the name and both kinds). C: Rwidget_find Parameters: AName the name. Returns: the widget named AName inside this one (searched as Raven searches: the name an XML layout or Name gave it), as the widget type T Example: LWindow.Content().Find<UISlider>("volume").OnChanged(func(const AValue: float32) begin .. end);
  • const method Has<T>(const AName: string): bool: true when a widget named AName is inside this one and T views its kind. Parameters: AName the name. Returns: true when a widget named AName is inside this one and T views its kind
  • const method TryFind<T>(const AName: string; var AWidget: T): bool: The widget named AName inside this one into AWidget as T: false (AWidget unchanged) when none has the name or T does not view its kind. Parameters: AName the name; AWidget the widget. Returns: true when it was found and viewed as T
  • const method As<T>(): T: This widget as the widget type T. Raises ADAM_RAVEN_EXC_NOT_FOUND for an empty or destroyed handle, ADAM_RAVEN_EXC_KIND when T does not view its kind. Returns: this widget as the widget type T
  • const method Is<T>(): bool: true when the handle names a widget whose kind T views. Returns: true when the handle names a widget whose kind T views
  • const method HitTest(const APoint: UIPoint): UIWidget: The innermost widget inside this one under APoint (window units) that takes the pointer (an empty handle for none). C: Rwidget_hit_test Parameters: APoint the point. Returns: the innermost widget inside this one under APoint (window units) that takes the pointer (an empty handle for none)
  • const method Pick(const APoint: UIPoint): UIWidget: The innermost widget inside this one under APoint, whether it takes the pointer or not. C: Rwidget_pick Parameters: APoint the point. Returns: the innermost widget inside this one under APoint, whether it takes the pointer or not
  • const method Visibility(const AVisibility: UIVisibility): self: Shown, hidden (its room kept) or collapsed (no room). C: Rwidget_set_visibility Parameters: AVisibility the visibility. Returns: this object, so calls chain
  • const method Visibility(): UIVisibility: What Visibility(..) sets, read back. C: Rwidget_get_visibility Returns: what Visibility(..) set last
  • const method Show(): self: Visibility(UIVisibility.Visible). Returns: this object, so calls chain
  • const method Hide(): self: Visibility(UIVisibility.Hidden): not drawn, its room kept. Returns: this object, so calls chain
  • const method Collapse(): self: Visibility(UIVisibility.Collapsed): not drawn, no room. Returns: this object, so calls chain
  • const method Enabled(const AOn: bool): self: false greys the widget out and it takes no input (nor do its children). C: Rwidget_set_enabled Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Enabled(): bool: What Enabled(..) sets, read back. C: Rwidget_is_enabled Returns: true when Enabled(..) turned it on
  • const method HitTestable(const AOn: bool): self: false lets the pointer pass through the widget to what is under it. C: Rwidget_set_hit_testable Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Opacity(const AOpacity: float32): self: How opaque the widget and its children are drawn (0..1). C: Rwidget_set_opacity Parameters: AOpacity the opacity. Returns: this object, so calls chain
  • const method Clipping(const AOn: bool): self: true cuts the children's drawing to the widget's rectangle. C: Rwidget_set_clipping Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Tooltip(const AText: string): self: The text shown when the pointer rests on the widget ("" for none). C: Rwidget_set_tooltip Parameters: AText the text. Returns: this object, so calls chain
  • const method Tooltip(): string: What Tooltip(..) 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: ACursor the cursor. Returns: this object, so calls chain
  • const method Direction(const ADirection: UIDirection): self: The widget's text and layout direction (UIDirection.Inherit: its parent's). C: Rwidget_set_direction Parameters: ADirection the direction. Returns: this object, so calls chain
  • const method Direction(): UIDirection: What Direction(..) 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: AWidth the width; AHeight the height. Returns: this object, so calls chain
  • const method MinSize(const AWidth: float32; const AHeight: float32): self: The smallest size the widget is given. C: Rwidget_set_min_size Parameters: AWidth the width; AHeight the height. Returns: this object, so calls chain
  • const method MaxSize(const AWidth: float32; const AHeight: float32): self: The largest size the widget is given. C: Rwidget_set_max_size Parameters: AWidth the width; AHeight the height. Returns: this object, so calls chain
  • const 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 units
  • const method DesiredSize(): UISize: The size the widget asks for. C: Rwidget_get_desired_size Returns: the size the widget asks for
  • const method Hovered(): bool: true while the pointer is over the widget. C: Rwidget_is_hovered Returns: true while the pointer is over the widget
  • const method Focusable(const AOn: bool): self: true lets the widget take the keyboard focus. C: Rwidget_set_focusable Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Focus(): self: Gives the widget the keyboard focus. C: Rwidget_focus Returns: this object, so calls chain
  • const method Focused(): bool: true while the widget has the keyboard focus. C: Rwidget_is_focused Returns: true while the widget has the keyboard focus
  • const 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 chain
  • const method Invalidate(): self: Has the widget drawn again at the next frame. C: Rwidget_invalidate Returns: this object, so calls chain
  • const method Transition(const ATransition: UITransition): self: The animation the widget plays each time it is shown. C: Rwidget_set_transition Parameters: ATransition the transition. Returns: this object, so calls chain
  • const method Transition(const ATransition: UITransition; const ADelay: float32): self: The animation the widget plays each time it is shown, ADelay seconds after. C: Rwidget_set_transition Parameters: ATransition the transition; ADelay the delay. Returns: this object, so calls chain
  • const method Play(const ATransition: UITransition): self: Plays the animation ATransition on the widget now. C: Rwidget_play_transition Parameters: ATransition the transition. Returns: this object, so calls chain
  • const method Play(const ATransition: UITransition; const ADelay: float32): self: Plays the animation ATransition on the widget ADelay seconds from now. C: Rwidget_play_transition Parameters: ATransition the transition; ADelay the delay. Returns: this object, so calls chain
  • const method WindowDrag(const AOn: bool): self: true makes dragging the widget move its window (a custom title bar). C: Rwidget_set_window_drag Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const 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: AAction the action. Returns: this object, so calls chain
  • const method Action(): string: What Action(..) 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: AHandle the handle. Returns: this object, so calls chain
  • const method UserHandle(): ptr: What UserHandle(..) 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 draw ARole with (over the theme's). C: Rwidget_set_color Parameters: ARole the role; AColor the colour. Returns: this object, so calls chain
  • const method Color(const ARole: UIColorRole): UIColor: The colour the widget draws ARole with. C: Rwidget_get_color Parameters: ARole the role. Returns: the colour the widget draws ARole with
  • const method ClearColor(const ARole: UIColorRole): self: ARole back to the theme's colour. C: Rwidget_clear_color Parameters: ARole the role. Returns: this object, so calls chain
  • const method Metric(const AMetric: UIMetric; const AValue: float32): self: The size AMetric the widget and its children use (over the theme's). C: Rwidget_set_metric Parameters: AMetric the metric; AValue the value. Returns: this object, so calls chain
  • const method Metric(const AMetric: UIMetric): float32: What Metric(..) sets, read back. C: Rwidget_get_metric Parameters: AMetric the metric. Returns: the size AMetric the widget and its children use (over the theme's)
  • const method ClearMetric(const AMetric: UIMetric): self: AMetric back to the theme's. C: Rwidget_clear_metric Parameters: AMetric the metric. Returns: this object, so calls chain
  • const method Material(const AMaterial: UIMaterial): self: What the widget's panels are drawn as (solid, glass ..). C: Rwidget_set_material Parameters: AMaterial the material. Returns: this object, so calls chain
  • const method Material(): UIMaterial: What Material(..) 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 theme UITheme loaded; "" follows the app's theme again). Parameters: AName the name. Returns: false (the error reported) when no theme has that name. C: Rwidget_set_theme
  • const 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: AKind the kind. Returns: this object, so calls chain
  • const 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 with
  • const 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: AClasses the classes. Returns: this object, so calls chain
  • const method Class(): string: What Class(..) 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 class AClass. C: Rwidget_add_class Parameters: AClass the class name. Returns: this object, so calls chain
  • const method RemoveClass(const AClass: string): self: Takes the style class AClass away. C: Rwidget_remove_class Parameters: AClass the class name. Returns: this object, so calls chain
  • const method HasClass(const AClass: string): bool: true when the widget has the style class AClass. C: Rwidget_has_class Parameters: AClass the class name. Returns: true when the widget has the style class AClass
  • const 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: AName the name; AValue the text. Returns: false for an attribute the tag lacks or a value it refuses. C: Rwidget_set_attribute
  • const method TextKey(const AAttribute: string; const AKey: string): self: The attribute AAttribute ("Text", "Tooltip" ..) shows the text the locale's strings give AKey, again whenever the language changes. C: Rwidget_set_text_key Parameters: AAttribute the attribute; AKey the key. Returns: this object, so calls chain
  • const method Text(const AText: string): bool: Sets the text the widget shows (its Text attribute: a label's, a button's, a check box's, a text input's, a text editor's ..). Parameters: AText the text. Returns: false for a widget with no text. C: Rwidget_set_attribute
  • const 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 handle
  • const method OnEvent(const AFunc: UIEventFunc): self: Runs AFunc for each input event the widget gets, before its own handling; AFunc returns true when it handled the event (the widget's own handling skipped). C: Rwidget_set_event_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnDestroy(const AFunc: UITaskFunc): self: Runs AFunc when 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: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnDrop(const AFunc: UIDropFunc): self: Runs AFunc at each stage of a drag and drop over the widget (files, text, a drag of the app's own); AFunc returns true when the widget takes the drop. C: Rwidget_set_drop_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnTouch(const AFunc: UITouchFunc): self: Runs AFunc for each touch on the widget; true when it handled it. C: Rwidget_set_touch_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnPen(const AFunc: UIPenFunc): self: Runs AFunc for each pen event on the widget; true when it handled it. C: Rwidget_set_pen_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnGesture(const AFunc: UIGestureFunc): self: Runs AFunc for each gesture on the widget (pinch, swipe ..); true when it handled it. C: Rwidget_set_gesture_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method TouchMode(const AMode: UITouchMode): self: How touches on the widget act (UITouchMode.Auto: by its kind). C: Rwidget_set_touch_mode Parameters: AMode the mode. Returns: this object, so calls chain
  • const method TouchMode(): UITouchMode: What TouchMode(..) 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: true has the widget get gestures (OnGesture). C: Rwidget_set_touch_gestures Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method TouchGestures(): bool: What TouchGestures(..) sets, read back. C: Rwidget_get_touch_gestures Returns: true when TouchGestures(..) turned it on
  • const method PenMouse(const AOn: bool): self: true has a pen act as the mouse on the widget too. C: Rwidget_set_pen_mouse Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method PenMouse(): bool: What PenMouse(..) sets, read back. C: Rwidget_get_pen_mouse Returns: true when PenMouse(..) turned it on
  • const method AccessibleName(const AName: string): self: The name a screen reader says for the widget. C: Rwidget_set_accessible_name Parameters: AName the name. Returns: this object, so calls chain
  • const method AccessibleName(): string: What AccessibleName(..) sets, read back. C: Rwidget_get_accessible_name Returns: the name a screen reader says for the widget
  • const method AccessibleDescription(const ADescription: string): self: The longer description a screen reader gives. C: Rwidget_set_accessible_description Parameters: ADescription the description. Returns: this object, so calls chain
  • const 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: ARole the role. Returns: this object, so calls chain
  • const method AccessibleRole(): UIRole: What AccessibleRole(..) 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: true hides the widget and its children from screen readers. C: Rwidget_set_accessible_hidden Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method AccessibleLabelledBy(const ALabel: UIWidget): self: The widget whose text names this one for a screen reader. C: Rwidget_set_accessible_labelled_by Parameters: ALabel the label. Returns: this object, so calls chain
  • const method AccessibleChecked(const AOn: bool): self: The checked state a screen reader says (a custom toggle's). C: Rwidget_set_accessible_checked Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method OnAccessiblePress(const AFunc: UITaskFunc): self: Runs AFunc when a screen reader presses the widget (a custom control's action). C: Rwidget_set_accessible_action Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const 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: AFont the font. Returns: this object, so calls chain
  • const method Font(): UIFontRes: The font Font gave the widget, borrowed (empty for none). C: Rwidget_get_font Returns: the font Font gave the widget, borrowed (empty for none)

Example: LName := LWindow.Content().Find<UIWidget>("name").Text();

UIWindow

text
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, then Open(). Returns: a window opened in a chain (UIWindowConfig): title, size, flags and the rest, then Open()
  • static method Create(const ATitle: string; const AWidth: int32; const AHeight: int32): UIWindow: Opens a window of the title ATitle and the size AWidth x AHeight (logical units), shown with Raven's defaults. C: Rwindow_create Parameters: ATitle the title; AWidth the width; AHeight the height. Returns: the new UIWindow
  • static method FromXML(const APath: string): UIWindow: A window made from the XML window file APath (IsValid() false when it does not load: its error reported to UIErrors). C: Rwindow_create_from_xml_file Parameters: APath the file's path. Returns: a window made from the XML window file APath (IsValid() false when it does not load: its error reported to UIErrors)
  • static method FromXMLText(const AXML: string): UIWindow: A window made from the XML window text AXML. C: Rwindow_create_from_xml Parameters: AXML the XML text. Returns: a window made from the XML window text AXML
  • static method Wrap(const AId: Rid): UIWindow: The handle of the window System.Raven.C gave as AId (R_INVALID_ID: an empty one). Parameters: AId the id. Returns: the handle of the window System.Raven.C gave as AId (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 calls
  • const method IsValid(): bool: true while the handle names a window (one Raven has not destroyed). C: Rwindow_is_valid Returns: true while 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: its OnClose may refuse. C: Rwindow_close
  • const method Destroy(): Closes the window at once (no OnClose asked) and destroys its content; its handles are no longer valid and its closures are released. C: Rwindow_destroy
  • const method Content(const AWidget: UIWidget): self: AWidget as the window's content (the root of what it shows). C: Rwindow_set_content Parameters: AWidget the widget. Returns: this object, so calls chain
  • const 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 named AName in the window's content, viewed as T (UIWidget.Find<T>). Parameters: AName the name. Returns: the widget named AName in the window's content, viewed as T (UIWidget.Find<T>) Raises: ADAM_RAVEN_EXC_NOT_FOUND when none has the name, ADAM_RAVEN_EXC_KIND when it is of a kind T does not view
  • const method Has<T>(const AName: string): bool: true when a widget of a kind T views is named AName in the window's content. Parameters: AName the name. Returns: true when a widget of a kind T views is named AName in the window's content
  • const method Title(const ATitle: string): self: The title its title bar and the taskbar show. C: Rwindow_set_title Parameters: ATitle the title. Returns: this object, so calls chain
  • const method Title(): string: What Title(..) sets, read back. C: Rwindow_get_title Returns: the title its title bar and the taskbar show
  • const method Size(const AWidth: int32; const AHeight: int32): self: The client area's size in logical units. C: Rwindow_set_size Parameters: AWidth the width; AHeight the height. Returns: this object, so calls chain
  • const method Size(): UISize: The client area's size in logical units. C: Rwindow_get_size Returns: the client area's size in logical units
  • const 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: AWidth the width; AHeight the height. Returns: this object, so calls chain
  • const method Position(const AX: int32; const AY: int32): self: Its top-left corner on the screen. C: Rwindow_set_position Parameters: AX the x coordinate; AY the y coordinate. Returns: this object, so calls chain
  • const method Position(): UIPoint: Its top-left corner on the screen. C: Rwindow_get_position Returns: its top-left corner on the screen
  • const method Center(): self: Centred on its screen. C: Rwindow_center Returns: this object, so calls chain
  • const 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 unit
  • const 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 chain
  • const method Hide(): self: Hides the window. C: Rwindow_hide Returns: this object, so calls chain
  • const method Focus(): self: Brings it forward as the window the user works in. C: Rwindow_focus Returns: this object, so calls chain
  • const method Maximize(): self: Maximizes the window. C: Rwindow_maximize Returns: this object, so calls chain
  • const method Minimize(): self: Minimizes the window. C: Rwindow_minimize Returns: this object, so calls chain
  • const method Restore(): self: Back from maximized or minimized. C: Rwindow_restore Returns: this object, so calls chain
  • const method Maximized(): bool: True while the window is maximized. C: Rwindow_is_maximized Returns: true when it is maximized
  • const method Minimized(): bool: True while the window is minimized. C: Rwindow_is_minimized Returns: true when it is minimized
  • const method Active(): bool: true while it is the window the user works in. C: Rwindow_is_active Returns: true while it is the window the user works in
  • const method BeginMove(): Starts the system's move of the window with the pointer (a custom header bar's drag). C: Rwindow_begin_move
  • const method BeginResize(const AEdge: UIEdge): Starts the system's resize of the window from its edge AEdge. C: Rwindow_begin_resize Parameters: AEdge the edge.
  • const method ClearColor(const AColor: UIColor): self: The colour the window is cleared to under its content. C: Rwindow_set_clear_color Parameters: AColor the colour. Returns: this object, so calls chain
  • const method Backdrop(const ABackdrop: UIBackdrop): bool: What shows through behind its content (a transparent window's blur, acrylic, mica). Parameters: ABackdrop the backdrop. Returns: false when the system cannot show it. C: Rwindow_set_backdrop
  • const method Backdrop(): UIBackdrop: What shows through behind its content, as Backdrop(..) set it. C: Rwindow_get_backdrop Returns: the backdrop
  • const method Theme(const AName: string): bool: A theme of its own, by name ("Dark", a theme UITheme loaded; "" follows the app's). Parameters: AName the name. Returns: false (the error reported) when no theme has that name. C: Rwindow_set_theme
  • const method Theme(const AKind: UIThemeKind): self: One of Raven's built-in themes as its own. C: Rwindow_set_theme Parameters: AKind the kind. Returns: this object, so calls chain
  • const method Theme(): string: The name of the theme it uses. C: Rwindow_get_theme Returns: the name of the theme it uses
  • const method HasOwnTheme(): bool: true when it has a theme of its own (not the app's). C: Rwindow_has_own_theme Returns: true when 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: AOpacity the opacity. Returns: false when the system cannot fade windows. C: Rwindow_set_opacity
  • const method Opacity(): float32: The whole window's opacity (0 clear .. 1 opaque). C: Rwindow_get_opacity Returns: the opacity
  • const method Topmost(const AOn: bool): bool: true keeps it above the other windows. Parameters: AOn true to turn it on, false to turn it off. Returns: false when the system cannot. C: Rwindow_set_topmost
  • const 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: AOwner the owner. Returns: false when the window system cannot keep it with its owner (it is still destroyed with it), or nothing changed: AOwner is not valid or is owned by it. C: Rwindow_set_owner
  • const method Owner(): UIWindow: The window it belongs to (an empty handle: none). C: Rwindow_get_owner Returns: the owner window
  • const method PictureInPicture(const AOn: bool): bool: true shows it as a small picture-in-picture window over the others. Parameters: AOn true to turn it on, false to turn it off. Returns: false when the system cannot. C: Rwindow_set_picture_in_picture
  • const method PictureInPicture(): bool: True while it shows as a picture-in-picture window. C: Rwindow_is_picture_in_picture Returns: true when it does
  • const 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: ACorner the corner; AWidth the width; AHeight the height. Returns: this object, so calls chain
  • const method Inspector(const AOn: bool): self: true shows Raven's widget inspector for it. C: Rwindow_set_inspector Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method InspectorShown(): bool: True while Raven's widget inspector is shown for it. C: Rwindow_is_inspector_shown Returns: true when it is shown
  • const 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: true for the splash screen Raven showed at the start (destroyed once the app's main window is ready). C: Rwindow_is_splash_screen Returns: true for 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_redraw
  • const method ContinuousRedraw(const AOn: bool): self: true draws it every frame (games, live views), not only when something changed. C: Rwindow_set_continuous_redraw Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method UserHandle(const AHandle: ptr): self: A pointer of the program's own kept with the window. C: Rwindow_set_user_handle Parameters: AHandle the handle. Returns: this object, so calls chain
  • const method UserHandle(): ptr: What UserHandle(..) sets, read back. C: Rwindow_get_user_handle Returns: a pointer of the program's own kept with the window
  • const method NativeHandle(var ANative: RNativeWindow): bool: The system's own window (HWND, X11 Window, wl_surface ..) into ANative. Parameters: ANative receives the native window. Returns: false when the window has none (headless). C: Rwindow_get_native_handle
  • const method Capture(var AWidth: int32; var AHeight: int32): array of uint8: What the window shows, as RGBA bytes (AWidth x AHeight pixels, rows from the top); empty when it cannot be captured. Waits for the frame to be drawn. C: Rwindow_capture, Rpixels_free Parameters: AWidth the width; AHeight the height. Returns: what the window shows, as RGBA bytes (AWidth x AHeight pixels, rows from the top); empty when it cannot be captured
  • const method FrameStats(): RFrameStats: The last frame's timings and counts. C: Rwindow_get_frame_stats Returns: the last frame's timings and counts
  • const 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 chain
  • const method MousePosition(): UIPoint: The pointer in the window's logical units. C: Rwindow_get_mouse_position Returns: the pointer in the window's logical units
  • const method KeyDown(const AKey: UIKey): bool: true while AKey is held down. C: Rwindow_is_key_down Parameters: AKey the key. Returns: true while AKey is held down
  • const method MouseDown(const AButton: UIPointerButton): bool: true while AButton is held down. C: Rwindow_is_mouse_button_down Parameters: AButton the button. Returns: true while AButton is held down
  • const method Mods(): UIModifiers: The modifier keys held down. C: Rwindow_get_modifiers Returns: the modifier keys held down
  • const method MouseInside(): bool: true while the pointer is over the window. C: Rwindow_is_mouse_inside Returns: true while the pointer is over the window
  • const method TabNavigation(const AOn: bool): self: true (the default) moves the focus with Tab / Shift+Tab. C: Rwindow_set_tab_navigation Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Shortcut(const AKey: UIKey; const AMods: UIModifiers; const AAction: string): self: AKey with the modifiers AMods runs the action AAction (an action UIActions registered). C: Rwindow_register_shortcut Parameters: AKey the key; AMods the modifier keys; AAction the action. Returns: this object, so calls chain
  • const method RemoveShortcut(const AKey: UIKey; const AMods: UIModifiers): self: The shortcut AKey with AMods removed. C: Rwindow_unregister_shortcut Parameters: AKey the key; AMods the modifier keys. Returns: this object, so calls chain
  • const method WantsTextInput(): bool: true while a text field has the focus (the on-screen keyboard is wanted). C: Rwindow_wants_text_input Returns: true while 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 into AInfo. Parameters: AInfo the info. Returns: false when no text field has the focus. C: Rwindow_get_text_input_info
  • const 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 into AStart .. AStop (byte offsets). Parameters: AStart the start; AStop the byte offset it ends at. Returns: false when no text field has the focus. C: Rwindow_get_text_input_selection
  • const method SelectTextInput(const AStart: int32; const AStop: int32): bool: The focused text field's selection set to AStart .. AStop (byte offsets). Parameters: AStart the start; AStop the byte offset it ends at. Returns: false when no text field has the focus. C: Rwindow_set_text_input_selection
  • const method ReplaceTextInput(const AStart: int32; const AStop: int32; const AText: string): bool: The focused text field's bytes AStart .. AStop replaced by AText (an IME's commit). Parameters: AStart the start; AStop the byte offset it ends at; AText the text. Returns: false when no text field has the focus. C: Rwindow_replace_text_input
  • const 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: Runs AFunc when the on-screen keyboard shows or hides (nil: none). C: Rwindow_set_keyboard_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnBack(const AFunc: UIAskFunc): self: Runs AFunc for the system's back (Android's back, a mouse's back button): true when it handled it (nil: none). C: Rwindow_set_back_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method BackEnabled(const AOn: bool): self: true tells the system the window takes the back (its OnBack runs). C: Rwindow_set_back_enabled Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method WantsBack(): bool: True while Back would be taken: a popup or dialog is open, or BackEnabled(true) said so. C: Rwindow_wants_back Returns: true when it would
  • const method OnClose(const AFunc: UIAskFunc): self: Runs AFunc when the user asks to close the window: true lets it close, false keeps it open (nil: it closes). C: Rwindow_set_close_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnResize(const AFunc: UIResizeFunc): self: Runs AFunc with the new size (logical units) when the window is resized (nil: none). C: Rwindow_set_resize_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnDrop(const AFunc: UIDropFunc): self: Runs AFunc at each stage of a drag and drop over the window that no widget took: true when it takes the drop (nil: none). C: Rwindow_set_drop_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnEvent(const AFunc: UIEventFunc): self: Runs AFunc for every input event before any widget gets it: true when it handled the event, so no widget gets it (nil: none). C: Rwindow_set_event_hook Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method HasPopup(): bool: true while a popup is open in the window. C: Rwindow_has_popup Returns: true while a popup is open in the window
  • const method PopupCount(): int32: How many popups are open, the innermost last. C: Rwindow_get_popup_count Returns: how many popups are open, the innermost last
  • const method Popup(const AIndex: int32): UIWidget: The content of the open popup at AIndex (0: the outermost). C: Rwindow_get_popup Parameters: AIndex the index, from 0. Returns: the content of the open popup at AIndex (0: the outermost)
  • const method ClosePopups(): self: Every open popup closed. C: Rwindow_close_popups Returns: this object, so calls chain
  • const method Popup(const AContent: UIWidget; const AAt: UIPoint; const AOnClosed: UIClosedFunc): Opens AContent as a popup at AAt (logical units); AOnClosed runs once with its result when it closes (nil: none). C: Rpopup_open Parameters: AContent the content widget; AAt the point; AOnClosed the on closed.
  • static method ClosePopup(const AContent: UIWidget; const AResult: int32): The popup whose content is AContent closed with the result AResult. C: Rpopup_close Parameters: AContent the content widget; AResult the result.
  • static method PopupOpen(const AContent: UIWidget): bool: true while AContent is open as a popup. C: Rpopup_is_open Parameters: AContent the content widget. Returns: true while AContent is open as a popup
  • const method Dialog(const AContent: UIWidget; const AOnClosed: UIClosedFunc): Opens AContent as a modal dialog over the window; AOnClosed runs once with its result when it closes (nil: none). C: Rdialog_open Parameters: AContent the content widget; AOnClosed the on closed.
  • static method CloseDialog(const AContent: UIWidget; const AResult: int32): The dialog whose content is AContent closed with the result AResult. C: Rdialog_close Parameters: AContent the content widget; AResult the result.
  • const method RunDialog(const AContent: UIWidget): int32: Opens AContent as a modal dialog and waits (the app's frames go on) until it closes. Parameters: AContent the content widget. Returns: its result. C: Rdialog_run
  • const method HasDialog(): bool: true while a dialog is open over the window. C: Rwindow_has_dialog Returns: true while a dialog is open over the window
  • const 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: ATitle the title; AText the text; AButtons the buttons. Returns: the button pressed. C: Rmessage_box Example: if LWindow.Message("Quit", "Save first?", UIMessageButtons.YesNo) = UIMessageResult.Yes then
  • const method TouchSettings(const ASettings: RTouchSettings): self: Its own touch and pen settings (over the app's, UITouch). C: Rwindow_set_touch_settings Parameters: ASettings the settings. Returns: this object, so calls chain
  • const method TouchSettings(): RTouchSettings: What TouchSettings(..) 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 now
  • const method PenInRange(): bool: true while a pen hovers over or touches the window. C: Rwindow_is_pen_in_range Returns: true while a pen hovers over or touches the window
  • const method TouchActive(): bool: true while a touch, its inertia or a gesture goes on. C: Rwindow_is_touch_active Returns: true while a touch, its inertia or a gesture goes on
  • const method AdvanceTouch(const ASeconds: float64): self: Moves the window's touch timing (long presses, inertia) on by ASeconds (tests). C: Rwindow_advance_touch Parameters: ASeconds the time, in seconds. Returns: this object, so calls chain
  • const method TaskbarProgress(const AState: UITaskbarProgress; const AValue: float32): bool: The progress its taskbar button shows (AValue 0..1). Parameters: AState the state; AValue the value. Returns: false when the system shows none. C: Rwindow_set_taskbar_progress
  • const method RequestAttention(const ACritical: bool): bool: Flashes its taskbar button (ACritical: until the user looks, else once). Parameters: ACritical the critical. Returns: false when the system cannot. C: Rwindow_request_attention
  • const method InjectMove(const AAt: UIPoint): self: The pointer moved to AAt. C: Rwindow_inject_mouse_move Parameters: AAt the point. Returns: this object, so calls chain
  • const method InjectButton(const AButton: UIPointerButton; const ADown: bool): self: AButton pressed (ADown) or let go. C: Rwindow_inject_mouse_button Parameters: AButton the button; ADown true for pressed, false for let go. Returns: this object, so calls chain
  • const method InjectWheel(const ADelta: UIPoint): self: The wheel turned by ADelta (x across, y up). C: Rwindow_inject_mouse_wheel Parameters: ADelta the delta. Returns: this object, so calls chain
  • const method InjectKey(const AKey: UIKey; const ADown: bool; const AMods: UIModifiers): self: AKey pressed (ADown) or let go with the modifiers AMods. C: Rwindow_inject_key Parameters: AKey the key; ADown true for pressed, false for let go; AMods the modifier keys. Returns: this object, so calls chain
  • const method InjectText(const AText: string): self: AText typed (as a keyboard's text input). C: Rwindow_inject_text Parameters: AText the text. Returns: this object, so calls chain
  • const method InjectDrag(const AAt: UIPoint; const AInside: bool): bool: A drag from outside moved to AAt (AInside false: it left the window). Parameters: AAt the point; AInside the inside. Returns: true when something there takes it. C: Rwindow_inject_drag
  • const method InjectDrop(const AAt: UIPoint; const APaths: StringArray; const AText: string): bool: Files APaths and the text AText dropped from outside at AAt. Parameters: AAt the point; APaths the paths; AText the text. Returns: true when something there took the drop. C: Rwindow_inject_drop
  • const method InjectBack(): bool: The system's back pressed. Returns: true when the window handled it. C: Rwindow_inject_back
  • const method InjectTouch(const ATouchId: int32; const APhase: UITouchPhase; const AAt: UIPoint): self: The touch ATouchId at the stage APhase at AAt. C: Rwindow_inject_touch Parameters: ATouchId the touch id; APhase the phase; AAt the point. Returns: this object, so calls chain
  • const 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 stage APhase at AAt: its pressure (0..1), tilt (degrees), buttons held and eraser end. C: Rwindow_inject_pen Parameters: APhase the phase; AAt the point; APressure the pressure; ATilt the tilt; AButtons the buttons; AEraser the eraser. Returns: this object, so calls chain
  • const 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 gesture AKind at the stage APhase at AAt: its scale and rotation changes, its pan and how many fingers. C: Rwindow_inject_trackpad_gesture Parameters: AKind the kind; APhase the phase; AAt the point; AScale the scale; ARotation the rotation; APan the pan movement; AFingers the fingers. Returns: this object, so calls chain
  • const method InjectScroll(const ADelta: UIPoint): self: A trackpad's two-finger scroll by ADelta. C: Rwindow_inject_trackpad_scroll Parameters: ADelta the delta. Returns: this object, so calls chain
  • const method InjectScrollEnd(): self: The trackpad's scroll ended (its fingers lifted). C: Rwindow_inject_trackpad_scroll_end Returns: this object, so calls chain
  • const method Icon(const APixels: UIPixels): self: The window's icon (title bar, task bar) from APixels; 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: APixels the pixels. Returns: this object, so calls chain
  • const 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: ATexture the texture. Returns: this object, so calls chain

Example: LWindow := UIWindow.Config().Title("Notes").Size(800, 600).Center().Open();

UIWindowConfig

text
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: ATitle the title. Returns: this object, so calls chain
  • method Size(const AWidth: int32; const AHeight: int32): self: The client area's size in logical units. Parameters: AWidth the width; AHeight the height. Returns: this object, so calls chain
  • method Flags(const AFlags: UIWindowFlags): self: How it opens (hidden, borderless, maximized, a custom header bar ..). Parameters: AFlags the flags. Returns: this object, so calls chain
  • method MinSize(const AWidth: int32; const AHeight: int32): self: The smallest size the user can make it. Parameters: AWidth the width; AHeight the height. Returns: this object, so calls chain
  • method Position(const AX: int32; const AY: int32): self: Its top-left corner on the screen (not centred). Parameters: AX the x coordinate; AY the y coordinate. Returns: this object, so calls chain
  • method Center(): self: Centred on its screen (no position). Returns: this object, so calls chain
  • method Theme(const AKind: UIThemeKind): self: One of Raven's built-in themes as its own. Parameters: AKind the kind. Returns: this object, so calls chain
  • method Backdrop(const ABackdrop: UIBackdrop): self: What shows through behind its content (a transparent window's). Parameters: ABackdrop the backdrop. Returns: this object, so calls chain
  • method Content(const AWidget: UIWidget): self: AWidget as its content. Parameters: AWidget the widget. Returns: this object, so calls chain
  • const method Open(): UIWindow: Opens the window with the settings set (IsValid() false when Raven could not: the error reported to UIErrors). 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

text
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 now
  • static method Settings(const ASettings: RTouchSettings): ASettings as the app's. C: Rtouch_set_settings Parameters: ASettings the settings.
  • static method Defaults(): RTouchSettings: Raven's default settings. C: Rtouch_get_default_settings Returns: raven's default settings

UIDrag

text
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 from ASource (the pointer held on it) carrying the data AData of the type AType (the program's own name for it), showing ALabel by the pointer. Parameters: ASource the source; AType the type; AData the data; ALabel the label. Returns: false when a drag cannot start (one is on already). C: Rdrag_begin
  • static method Active(const AWindow: UIWindow): bool: true while a drag of the app's own is on in AWindow. C: Rdrag_is_active Parameters: AWindow the window. Returns: true while a drag of the app's own is on in AWindow
  • static method DataType(const AWindow: UIWindow): string: The type of the drag on in AWindow ("" when none). C: Rdrag_get_type Parameters: AWindow the window. Returns: the type of the drag on in AWindow ("" when none)
  • static method Data(const AWindow: UIWindow): string: The data of the drag on in AWindow ("" when none). C: Rdrag_get_data Parameters: AWindow the window. Returns: the data of the drag on in AWindow ("" when none)
  • static method Cancel(const AWindow: UIWindow): The drag on in AWindow cancelled (nothing is dropped). C: Rdrag_cancel Parameters: AWindow the window.
  • static method Highlight(const ARect: UIRect): Where the drop would land, highlighted while the drag is over it (from an OnDrop at its Enter / Move stage). C: Rdrop_set_highlight_rect Parameters: ARect the rectangle.

UIPanel

text
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 HBox
  • const method Spacing(const ASpacing: float32): self: The gap between two children, in window units. C: Rpanel_set_spacing Parameters: ASpacing the spacing. Returns: this object, so calls chain
  • const method Spacing(): float32: What Spacing(..) sets, read back. C: Rpanel_get_spacing Returns: the gap between two children, in window units

UIVBox

text
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 box
  • static 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

text
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 box
  • static method Kinds(): UIWidgetKinds: The kind a horizontal box views. Returns: the kind a horizontal box views

UIGrid

text
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 grid
  • static method Kinds(): UIWidgetKinds: The kind a grid views. Returns: the kind a grid views
  • const method ColumnFill(const AColumn: int32; const AFill: float32): self: The share of the spare width column AColumn takes (0: as wide as its content). C: Rgrid_set_column_fill Parameters: AColumn the column, from 0; AFill the share of the room it takes. Returns: this object, so calls chain
  • const method RowFill(const ARow: int32; const AFill: float32): self: The share of the spare height row ARow takes (0: as tall as its content). C: Rgrid_set_row_fill Parameters: ARow the row, from 0; AFill the share of the room it takes. Returns: this object, so calls chain

UIUniformGrid

text
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 grid
  • static method Kinds(): UIWidgetKinds: The kind a uniform grid views. Returns: the kind a uniform grid views
  • const method Columns(const AColumns: int32): self: The cells to a row (0: as many as fit MinCellSize). C: Runiform_grid_set_columns Parameters: AColumns the columns. Returns: this object, so calls chain
  • const method MinCellSize(const AWidth: float32; const AHeight: float32): self: The smallest a cell is. C: Runiform_grid_set_min_cell_size Parameters: AWidth the width; AHeight the height. Returns: this object, so calls chain

UIOverlay

text
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 overlay
  • static method Kinds(): UIWidgetKinds: The kind an overlay views. Returns: the kind an overlay views

UIBorder

text
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 border
  • static method Kinds(): UIWidgetKinds: The kind a border views. Returns: the kind a border views
  • const 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: ALeft the room on the left; ATop the room above; ARight the room on the right; ABottom the room below. Returns: this object, so calls chain
  • const method Padding(const AAll: float32): self: The same room AAll on every side. C: Rborder_set_padding Parameters: AAll the room on every side. Returns: this object, so calls chain
  • const method Background(const AColor: UIColor): self: The colour the frame is filled with. C: Rborder_set_background Parameters: AColor the colour. Returns: this object, so calls chain
  • const method Outline(const AWidth: float32; const AColor: UIColor): self: An outline AWidth wide in AColor (0 wide: none). C: Rborder_set_outline Parameters: AWidth the width; AColor the colour. Returns: this object, so calls chain
  • const method CornerRadius(const ARadius: float32): self: Every corner rounded by ARadius. C: Rborder_set_corner_radius Parameters: ARadius the radius. Returns: this object, so calls chain
  • const 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: ATopLeft the top-left corner's radius; ATopRight the top-right corner's radius; ABottomRight the bottom-right corner's radius; ABottomLeft the bottom-left corner's radius. Returns: this object, so calls chain
  • const method Shadow(const ABlur: float32; const AOffset: UIPoint): self: A drop shadow blurred by ABlur, moved by AOffset (0 blur: none). C: Rborder_set_shadow Parameters: ABlur the blur radius; AOffset the offset. Returns: this object, so calls chain
  • const method Material(const AMaterial: UIMaterial): self: What the frame's own panel is drawn as (solid, glass ..). C: Rborder_set_material Parameters: AMaterial the material. Returns: this object, so calls chain
  • const method Effect(const AShader: UIShaderRes; const ALook: RShaderLook): self: AShader drawn as the border's background (under its child), with the look ALook (colours, parameters, radius, animation; an empty handle removes it); kept while it is set. C: Rborder_set_effect Parameters: AShader the shader; ALook the look. Returns: this object, so calls chain
  • const method Effect(const AShader: UIShaderRes): self: AShader drawn as the border's background with its own default look (AShader.Defaults()). C: Rborder_set_effect Parameters: AShader the shader. Returns: this object, so calls chain
  • const method Effect(): UIShaderRes: The effect drawn, borrowed (empty for none). C: Rborder_get_effect Returns: the effect drawn, borrowed (empty for none)

UISizeBox

text
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 box
  • static method Kinds(): UIWidgetKinds: The kind a size box views. Returns: the kind a size box views
  • const method AspectRatio(const ARatio: float32): self: The child's width over its height (0: no ratio kept). C: Rsize_box_set_aspect_ratio Parameters: ARatio the ratio. Returns: this object, so calls chain

UISpacer

text
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 spacer AWidth by AHeight. C: Rwidget_create, Rspacer_set_size Parameters: AWidth the width; AHeight the height. Returns: a new spacer AWidth by AHeight
  • static method Kinds(): UIWidgetKinds: The kind a spacer views. Returns: the kind a spacer views
  • const method Size(const AWidth: float32; const AHeight: float32): self: The room the spacer asks for. C: Rspacer_set_size Parameters: AWidth the width; AHeight the height. Returns: this object, so calls chain

UIScrollBox

text
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 box
  • static method Kinds(): UIWidgetKinds: The kind a scroll box views. Returns: the kind a scroll box views
  • const method Orientation(const AOrientation: UIOrientation): self: The direction it scrolls. C: Rscroll_box_set_orientation Parameters: AOrientation the orientation. Returns: this object, so calls chain
  • const method ScrollBoth(const AOn: bool): self: Scrolls in both directions when AOn. C: Rscroll_box_set_scroll_both Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Offset(const AOffset: UIPoint): self: Scrolls to AOffset (window units from the child's top left). C: Rscroll_box_set_offset Parameters: AOffset the offset. Returns: this object, so calls chain
  • const method Offset(): UIPoint: How far it is scrolled. C: Rscroll_box_get_offset Returns: how far it is scrolled
  • const 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

text
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 splitter
  • static method Kinds(): UIWidgetKinds: The kind a splitter views. Returns: the kind a splitter views
  • const method Orientation(const AOrientation: UIOrientation): self: Horizontal: panes side by side; vertical: one above the other. C: Rsplitter_set_orientation Parameters: AOrientation the orientation. Returns: this object, so calls chain
  • const method MinPaneSize(const ASize: float32): self: The smallest a pane is dragged to. C: Rsplitter_set_min_pane_size Parameters: ASize the size. Returns: this object, so calls chain

UIWrapBox

text
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 box
  • static method Kinds(): UIWidgetKinds: The kind a wrap box views. Returns: the kind a wrap box views

UICanvas

text
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 canvas
  • static method Kinds(): UIWidgetKinds: The kind a canvas views. Returns: the kind a canvas views

UISwitcher

text
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 switcher
  • static method Kinds(): UIWidgetKinds: The kind a switcher views. Returns: the kind a switcher views
  • const method Index(const AIndex: int32): self: Shows the child at AIndex. C: Rswitcher_set_index Parameters: AIndex the index, from 0. Returns: this object, so calls chain
  • const method Index(): int32: The index of the child shown. C: Rswitcher_get_index Returns: the index of the child shown

UITabView

text
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 pages
  • static method Kinds(): UIWidgetKinds: The kind a tab view views. Returns: the kind a tab view views
  • const method AddTab(const ATitle: string; const AContent: UIWidget): UITab: A new page AContent last, under a tab titled ATitle (an empty tab when Raven refuses it). C: Rtab_view_add_tab Parameters: ATitle the title; AContent the content widget. Returns: a new page AContent last, under a tab titled ATitle (an empty tab when Raven refuses it)
  • const method Active(const AIndex: int32): self: Shows the page at AIndex. C: Rtab_view_set_active Parameters: AIndex the index, from 0. Returns: this object, so calls chain
  • const 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 when AOn (an editor's: each with a close button, shrinking when they do not fit). C: Rtab_view_set_documents Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method TabCount(): int32: The pages the view holds. C: Rtab_view_get_tab_count Returns: the pages the view holds
  • const method Tab(const AIndex: int32): UITab: The tab at AIndex (an empty one outside 0 .. TabCount() - 1). C: Rtab_view_get_tab Parameters: AIndex the index, from 0. Returns: the tab at AIndex (an empty one outside 0 .
  • const method FindTab(const AContent: UIWidget): UITab: The tab of the page AContent (an empty one when it is no page here). C: Rtab_view_find_tab Parameters: AContent the content widget. Returns: the tab of the page AContent (an empty one when it is no page here)
  • const method OnChanged(const AFunc: UIIndexFunc): self: Runs AFunc with the index of the page shown when it changes. C: Rtab_view_set_changed_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnClose(const AFunc: UITabCloseFunc): self: Runs AFunc when a tab's close button is pressed: true deletes its page, false keeps it. C: Rtab_view_set_close_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain

Example: LTabs := UITabView.Create(); LTabs.AddTab("General", LGeneral).Closable(false);

UITab

text
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 page AContent in the tab view AView (both Rids). Parameters: AView the view; AContent the content widget. Returns: the tab of the page AContent in the tab view AView (both Rids)
  • const method IsValid(): bool: true while the tab's page is one of its tab view's. C: Rtab_view_find_tab Returns: true while the tab's page is one of its tab view's
  • const 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 in
  • const method Content(): UIWidget: The page the tab shows. Returns: the page the tab shows
  • const method Title(const ATitle: string): self: The tab's title. C: Rtab_view_set_tab_title Parameters: ATitle the title. Returns: this object, so calls chain
  • const method Closable(const AOn: bool): self: A close button on the tab when AOn. C: Rtab_view_set_tab_closable Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Show(): self: Shows the tab's page. C: Rtab_view_show_tab Returns: this object, so calls chain
  • const method Icon(const ATexture: UITextureRes): self: The whole of ATexture as 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: ATexture the texture. Returns: this object, so calls chain
  • const method Icon(const ATexture: UITextureRes; const AUVMin: UIPoint; const AUVMax: UIPoint; const ATint: bool): self: A part of ATexture as 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; ATint true: the texture is a mask drawn in the text colour. C: Rtab_view_set_tab_icon Parameters: ATexture the texture; AUVMin the lowest texture coordinates (0 .. 1); AUVMax the highest texture coordinates (0 .. 1); ATint the tint colour. Returns: this object, so calls chain

UIExpander

text
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 titled ATitle. C: Rwidget_create(R_WIDGET_EXPANDER), Rexpander_set_title Parameters: ATitle the title. Returns: a new, closed expander titled ATitle
  • static method Kinds(): UIWidgetKinds: The kind an expander views. Returns: the kind an expander views
  • const method Title(const ATitle: string): self: The header's title. C: Rexpander_set_title Parameters: ATitle the title. Returns: this object, so calls chain
  • const method Title(): string: What Title(..) sets, read back. C: Rexpander_get_title Returns: the header's title
  • const method Expanded(const AOn: bool): self: Opens (true) or closes the content. C: Rexpander_set_expanded Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Expanded(): bool: What Expanded(..) sets, read back. C: Rexpander_is_expanded Returns: true when Expanded(..) turned it on
  • const method OnChanged(const AFunc: UIToggleFunc): self: Runs AFunc with the new state when the expander opens or closes. C: Rexpander_set_changed_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain

UILabel

text
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 showing AText. C: Rlabel_create Parameters: AText the text. Returns: a new label showing AText
  • static method Kinds(): UIWidgetKinds: The kind a label views. Returns: the kind a label views
  • const method TextSize(const ASize: float32): self: The text's size in window units. C: Rlabel_set_text_size Parameters: ASize the size. Returns: this object, so calls chain
  • const method Align(const AAlign: UITextAlign): self: How each line sits across the label. C: Rlabel_set_text_align Parameters: AAlign the alignment. Returns: this object, so calls chain
  • const method Wrap(const AOn: bool): self: Wraps long lines at the label's width when AOn. C: Rlabel_set_wrap Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Color(const AColor: UIColor): self: The text's colour (the theme's text colour by default). C: Rlabel_set_color Parameters: AColor the colour. Returns: this object, so calls chain
  • const method Markdown(const AOn: bool): self: The text read as Markdown when AOn (headings, emphasis, lists, code, links). C: Rlabel_set_markdown Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Markdown(): bool: What Markdown(..) sets, read back. C: Rlabel_get_markdown Returns: true when Markdown(..) turned it on
  • const 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 out
  • const method Selectable(const AOn: bool): self: The text selectable (and copied) with the pointer when AOn. C: Rlabel_set_selectable Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Selectable(): bool: What Selectable(..) sets, read back. C: Rlabel_get_selectable Returns: true when Selectable(..) turned it on
  • const 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 chain
  • const method ClearSelection(): self: Selects nothing. C: Rlabel_clear_selection Returns: this object, so calls chain
  • const method OnLink(const AFunc: UITextFunc): self: Runs AFunc with a Markdown link's URL when it is clicked (OpenURL it, or route it). C: Rlabel_set_link_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const 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: AFont the font. Returns: this object, so calls chain

Example: UILabel.Create("Ready").TextSize(18.0f).Color(UIColor.FromRGBA(80, 200, 120));

UIButton

text
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 labelled AText. C: Rbutton_create Parameters: AText the text. Returns: a new button labelled AText
  • static method Kinds(): UIWidgetKinds: The kind a button views. Returns: the kind a button views
  • const method Style(const AStyle: UIButtonStyle): self: How the button is drawn (default, primary, flat). C: Rbutton_set_style Parameters: AStyle the style. Returns: this object, so calls chain
  • const method OnClick(const AFunc: UITaskFunc): self: Runs AFunc when the button is clicked. C: Rbutton_set_clicked_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain

Example: UIButton.Create("Save").Style(UIButtonStyle.Primary).OnClick(func() begin Save(); end);

UICheckBox

text
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 labelled AText. C: Rcheckbox_create Parameters: AText the text. Returns: a new, unchecked check box labelled AText
  • static method Kinds(): UIWidgetKinds: The kind a check box views. Returns: the kind a check box views
  • const method Checked(const AOn: bool): self: Checks (true) or clears it. C: Rcheckbox_set_checked Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Checked(): bool: What Checked(..) sets, read back. C: Rcheckbox_is_checked Returns: true when Checked(..) turned it on
  • const method Style(const AStyle: UICheckStyle): self: Drawn as a check box, a radio button or a switch. C: Rcheckbox_set_style Parameters: AStyle the style. Returns: this object, so calls chain
  • const method OnChanged(const AFunc: UIToggleFunc): self: Runs AFunc with the new state when it is checked or cleared. C: Rcheckbox_set_changed_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain

UISlider

text
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 views
  • const method Range(const AMin: float32; const AMax: float32): self: The values at its ends. C: Rslider_set_range Parameters: AMin the lowest value; AMax the highest value. Returns: this object, so calls chain
  • const method Range(): UIRange: Its ends and its step. C: Rslider_get_range Returns: its ends and its step
  • const method Value(const AValue: float32): self: Moves the thumb to AValue (kept in the range). C: Rslider_set_value Parameters: AValue the value. Returns: this object, so calls chain
  • const method Value(): float32: What Value(..) sets, read back. C: Rslider_get_value Returns: what Value(..) set last
  • const method Step(const AStep: float32): self: The thumb moves in steps of AStep (0: freely). C: Rslider_set_step Parameters: AStep the step. Returns: this object, so calls chain
  • const method Orientation(const AOrientation: UIOrientation): self: Lies across (horizontal) or stands up (vertical). C: Rslider_set_orientation Parameters: AOrientation the orientation. Returns: this object, so calls chain
  • const method OnChanged(const AFunc: UIValueFunc): self: Runs AFunc with the value as the thumb moves. C: Rslider_set_changed_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain

UIProgressBar

text
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 bar
  • static method Kinds(): UIWidgetKinds: The kind a progress bar views. Returns: the kind a progress bar views
  • const method Value(const AValue: float32): self: Fills it to AValue (0 .. 1). C: Rprogress_bar_set_value Parameters: AValue the value. Returns: this object, so calls chain
  • const method Value(): float32: What Value(..) sets, read back. C: Rprogress_bar_get_value Returns: what Value(..) set last

UIImage

text
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 yet
  • static method Kinds(): UIWidgetKinds: The kind an image views. Returns: the kind an image views
  • const method Tint(const AColor: UIColor): self: Multiplies the picture by AColor (an icon in a theme's colour). C: Rimage_set_tint_color Parameters: AColor the colour. Returns: this object, so calls chain
  • const method TintText(const AOn: bool): self: Tinted with the theme's text colour when AOn (follows light / dark). C: Rimage_set_tint_text Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Stretch(const AStretch: UIStretch): self: How the picture fits the widget (fill, fit, cover, none). C: Rimage_set_stretch Parameters: AStretch the stretch. Returns: this object, so calls chain
  • const 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: AUVMin the lowest texture coordinates (0 .. 1); AUVMax the highest texture coordinates (0 .. 1). Returns: this object, so calls chain
  • const method CornerRadius(const ARadius: float32): self: The picture's corners rounded by ARadius. C: Rimage_set_corner_radius Parameters: ARadius the radius. Returns: this object, so calls chain
  • const method Texture(const ATexture: UITextureRes): self: The texture it shows (an empty handle: nothing); kept while it is set. C: Rimage_set_texture Parameters: ATexture the texture. Returns: this object, so calls chain

UITextInput

text
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 field
  • static method Kinds(): UIWidgetKinds: The kind a text input views. Returns: the kind a text input views
  • const method Placeholder(const AText: string): self: The hint shown while the field is empty. C: Rtext_input_set_placeholder Parameters: AText the text. Returns: this object, so calls chain
  • const method Password(const AOn: bool): self: The text hidden behind dots when AOn. C: Rtext_input_set_password Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Password(): bool: What Password(..) sets, read back. C: Rtext_input_is_password Returns: true when Password(..) turned it on
  • const method ReadOnly(const AOn: bool): self: The text shown and selectable but not editable when AOn. C: Rtext_input_set_read_only Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method ReadOnly(): bool: What ReadOnly(..) sets, read back. C: Rtext_input_is_read_only Returns: true when ReadOnly(..) turned it on
  • const method MaxLength(const ALength: int32): self: The most characters it takes (0: no limit). C: Rtext_input_set_max_length Parameters: ALength the length. Returns: this object, so calls chain
  • const method SelectAll(): self: Selects the whole text. C: Rtext_input_select_all Returns: this object, so calls chain
  • const 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: AType the type. Returns: this object, so calls chain
  • const method InputType(): UIInputType: What InputType(..) sets, read back. C: Rtext_input_get_input_type Returns: what the text is (e-mail, number ..): the keyboard a touch device shows
  • const method ReturnKey(const AKey: UIReturnKey): self: The label of a touch keyboard's return key. C: Rtext_input_set_return_key Parameters: AKey the key. Returns: this object, so calls chain
  • const method ReturnKey(): UIReturnKey: What ReturnKey(..) sets, read back. C: Rtext_input_get_return_key Returns: the label of a touch keyboard's return key
  • const method OnChanged(const AFunc: UITextFunc): self: Runs AFunc with the text at each change. C: Rtext_input_set_changed_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnCommit(const AFunc: UITextFunc): self: Runs AFunc with the text when it is committed (Enter, the return key). C: Rtext_input_set_committed_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain

Example: UITextInput.Create().Placeholder("Search").OnCommit(func(const S: string) begin Find(S); end);

UISpinBox

text
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 box
  • static method Kinds(): UIWidgetKinds: The kind a spin box views. Returns: the kind a spin box views
  • const method Range(const AMin: float64; const AMax: float64): self: The lowest and highest values it takes. C: Rspin_box_set_range Parameters: AMin the lowest value; AMax the highest value. Returns: this object, so calls chain
  • const method Range(): UIRange: Its range and its step. C: Rspin_box_get_range Returns: its range and its step
  • const method Value(const AValue: float64): self: Sets the value (kept in the range). C: Rspin_box_set_value Parameters: AValue the value. Returns: this object, so calls chain
  • const method Value(): float64: What Value(..) sets, read back. C: Rspin_box_get_value Returns: what Value(..) set last
  • const method Step(const AStep: float64): self: One step's size. C: Rspin_box_set_step Parameters: AStep the step. Returns: this object, so calls chain
  • const method Decimals(const ADecimals: int32): self: The digits shown after the point. C: Rspin_box_set_decimals Parameters: ADecimals the decimals. Returns: this object, so calls chain
  • const method Buttons(const AOn: bool): self: Step buttons beside the number when AOn (else drag to scrub, arrows / wheel to step). C: Rspin_box_set_buttons Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Buttons(): bool: What Buttons(..) sets, read back. C: Rspin_box_get_buttons Returns: true when Buttons(..) turned it on
  • const method OnChanged(const AFunc: UIValue64Func): self: Runs AFunc with the value when it changes. C: Rspin_box_set_changed_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain

UIComboBox

text
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 items
  • static method Kinds(): UIWidgetKinds: The kind a combo box views. Returns: the kind a combo box views
  • const method AddItem(const AText: string): int32: AText as the last item: its index. C: Rcombo_box_add_item Parameters: AText the text. Returns: AText as the last item: its index
  • const method ClearItems(): self: Every item removed. C: Rcombo_box_clear_items Returns: this object, so calls chain
  • const method ItemCount(): int32: The items it holds. C: Rcombo_box_get_item_count Returns: the items it holds
  • const method Item(const AIndex: int32): string: The text of the item at AIndex ("" outside). C: Rcombo_box_get_item_text Parameters: AIndex the index, from 0. Returns: the text of the item at AIndex ("" outside)
  • const method Selected(const AIndex: int32): self: Chooses the item at AIndex (-1: none). C: Rcombo_box_set_selected Parameters: AIndex the index, from 0. Returns: this object, so calls chain
  • const 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: Runs AFunc with the index chosen when it changes. C: Rcombo_box_set_changed_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain

UISeparator

text
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 separator
  • static method Kinds(): UIWidgetKinds: The kind a separator views. Returns: the kind a separator views
  • const method Orientation(const AOrientation: UIOrientation): self: A line across (horizontal) or up (vertical). C: Rseparator_set_orientation Parameters: AOrientation the orientation. Returns: this object, so calls chain

UIRating

text
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 default
  • static method Kinds(): UIWidgetKinds: The kind a rating views. Returns: the kind a rating views
  • const method Value(const AValue: float32): self: The stars lit (0 .. Max, halves with AllowHalf). C: Rrating_set_value Parameters: AValue the value. Returns: this object, so calls chain
  • const method Value(): float32: What Value(..) 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: AMax the largest number. Returns: this object, so calls chain
  • const method Max(): int32: What Max(..) sets, read back. C: Rrating_get_max Returns: the stars shown
  • const method AllowHalf(const AOn: bool): self: Half stars allowed when AOn. C: Rrating_set_allow_half Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method ReadOnly(const AOn: bool): self: Shown but not changeable when AOn. C: Rrating_set_read_only Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method StarSize(const ASize: float32): self: A star's size in window units. C: Rrating_set_star_size Parameters: ASize the size. Returns: this object, so calls chain
  • const method OnChanged(const AFunc: UIValueFunc): self: Runs AFunc with the value when it is changed. C: Rrating_set_changed_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain

UIPagination

text
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 pagination
  • static method Kinds(): UIWidgetKinds: The kind a pagination views. Returns: the kind a pagination views
  • const method PageCount(const ACount: int32): self: The pages there are. C: Rpagination_set_page_count Parameters: ACount how many. Returns: this object, so calls chain
  • const method PageCount(): int32: What PageCount(..) sets, read back. C: Rpagination_get_page_count Returns: the pages there are
  • const method Page(const APage: int32): self: Goes to page APage. C: Rpagination_set_page Parameters: APage the page. Returns: this object, so calls chain
  • const method Page(): int32: The page shown. C: Rpagination_get_page Returns: the page shown
  • const method Siblings(const ACount: int32): self: The page buttons shown on each side of the current one. C: Rpagination_set_siblings Parameters: ACount how many. Returns: this object, so calls chain
  • const method OnChanged(const AFunc: UIIndexFunc): self: Runs AFunc with the page when it changes. C: Rpagination_set_changed_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain

UIBreadcrumb

text
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 breadcrumb
  • static method Kinds(): UIWidgetKinds: The kind a breadcrumb views. Returns: the kind a breadcrumb views
  • const method Items(const AItems: array of string): self: Replaces the items with AItems (Raven separates them by '|', so no item holds one). C: Rbreadcrumb_set_items Parameters: AItems the items. Returns: this object, so calls chain
  • const method AddItem(const AText: string): int32: AText as the last item: its index. C: Rbreadcrumb_add_item Parameters: AText the text. Returns: AText as the last item: its index
  • const method Truncate(const ACount: int32): self: Keeps the first ACount items (Truncate(AIndex + 1) goes back to the item clicked). C: Rbreadcrumb_truncate Parameters: ACount how many. Returns: this object, so calls chain
  • const method ItemCount(): int32: The items it holds. C: Rbreadcrumb_get_item_count Returns: the items it holds
  • const method Item(const AIndex: int32): string: The text of the item at AIndex ("" outside). C: Rbreadcrumb_get_item_text Parameters: AIndex the index, from 0. Returns: the text of the item at AIndex ("" outside)
  • const method OnClick(const AFunc: UIIndexFunc): self: Runs AFunc with the index of the item clicked. C: Rbreadcrumb_set_clicked_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain

UIDatePicker

text
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 picker
  • static method Kinds(): UIWidgetKinds: The kind a date picker views. Returns: the kind a date picker views
  • const method Date(const AYear: int32; const AMonth: int32; const ADay: int32): self: Sets the date (AMonth 1 .. 12). C: Rdate_picker_set_date Parameters: AYear the year; AMonth the month; ADay the day. Returns: this object, so calls chain
  • const method Date(): UIDate: The date chosen. C: Rdate_picker_get_date Returns: the date chosen
  • const 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: AMin the earliest date; AMax the latest date. Returns: this object, so calls chain
  • const 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: ADay the day. Returns: this object, so calls chain
  • const 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: AFormat the pixel format. Returns: this object, so calls chain
  • const method Open(const AOn: bool): self: Opens (true) or closes the calendar. C: Rdate_picker_set_open Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Open(): bool: What Open(..) sets, read back. C: Rdate_picker_is_open Returns: true when Open(..) turned it on
  • const method OnChanged(const AFunc: UIDateFunc): self: Runs AFunc with the date when it is changed. C: Rdate_picker_set_changed_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain

UITimePicker

text
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 picker
  • static method Kinds(): UIWidgetKinds: The kind a time picker views. Returns: the kind a time picker views
  • const method Time(const AHour: int32; const AMinute: int32; const ASecond: int32): self: Sets the time (AHour 0 .. 23). C: Rtime_picker_set_time Parameters: AHour the hour; AMinute the minute; ASecond the second, 0 .. 59. Returns: this object, so calls chain
  • const method Time(): UITime: The time chosen. C: Rtime_picker_get_time Returns: the time chosen
  • const method SecondsVisible(const AOn: bool): self: The seconds shown (and chosen) when AOn. C: Rtime_picker_set_seconds_visible Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method MinuteStep(const AStep: int32): self: The minutes move in steps of AStep. C: Rtime_picker_set_minute_step Parameters: AStep the step. Returns: this object, so calls chain
  • const method OnChanged(const AFunc: UITimeFunc): self: Runs AFunc with the time when it is changed. C: Rtime_picker_set_changed_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain

UIColorPicker

text
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 picker
  • static method Kinds(): UIWidgetKinds: The kind a colour picker views. Returns: the kind a colour picker views
  • const method Color(const AColor: UIColor): self: Sets the colour chosen. C: Rcolor_picker_set_color Parameters: AColor the colour. Returns: this object, so calls chain
  • const method Color(): UIColor: The colour chosen. C: Rcolor_picker_get_color Returns: the colour chosen
  • const 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: AH the hue, in degrees (0 to 360); AS the saturation, 0 to 1; AV the value (brightness), 0 to 1. Returns: this object, so calls chain
  • const 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: AHex the hex. Returns: false when the text is no colour (the colour unchanged). C: Rcolor_picker_set_hex
  • const 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 when AOn. C: Rcolor_picker_set_alpha_enabled Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method PreviousColor(const AColor: UIColor): self: The colour shown beside the new one (the one being replaced). C: Rcolor_picker_set_previous_color Parameters: AColor the colour. Returns: this object, so calls chain
  • const method AddSwatch(const AColor: UIColor): self: AColor as the last swatch. C: Rcolor_picker_add_swatch Parameters: AColor the colour. Returns: this object, so calls chain
  • const method ClearSwatches(): self: Every swatch removed. C: Rcolor_picker_clear_swatches Returns: this object, so calls chain
  • const method SwatchCount(): int32: The swatches it holds. C: Rcolor_picker_get_swatch_count Returns: the swatches it holds
  • const method Popup(const AOn: bool): self: A button opening the picker in a popup when AOn (else the picker itself). C: Rcolor_picker_set_popup Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Compact(const AOn: bool): self: The small form (no hex field, no swatches) when AOn. C: Rcolor_picker_set_compact Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method OnChanged(const AFunc: UIColorFunc): self: Runs AFunc with the colour as it is changed. C: Rcolor_picker_set_changed_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain

UIToast

text
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 nothing
  • static method Kinds(): UIWidgetKinds: The kind a toast views. Returns: the kind a toast views
  • const method Show(const AText: string; const ASeconds: float64): self: Shows AText for ASeconds, of the kind Kind set last. C: Rtoast_show Parameters: AText the text; ASeconds the time, in seconds. Returns: this object, so calls chain
  • const method Show(const AText: string; const AKind: UIToastKind; const ASeconds: float64): self: Shows AText of the kind AKind for ASeconds. C: Rtoast_show_kind Parameters: AText the text; AKind the kind; ASeconds the time, in seconds. Returns: this object, so calls chain
  • const method Hide(): self: Hides the message shown (the next queued one shows). C: Rtoast_hide Returns: this object, so calls chain
  • const method Clear(): self: Hides the message shown and drops the queued ones. C: Rtoast_clear Returns: this object, so calls chain
  • const method Shown(): bool: true while a message is shown. C: Rtoast_is_shown Returns: true while a message is shown
  • const method Count(): int32: The messages shown and queued. C: Rtoast_get_count Returns: the messages shown and queued
  • const method Queue(const AQueue: UIToastQueue): self: What a new message does to the ones shown (replace, queue after, stack). C: Rtoast_set_queue Parameters: AQueue the queue. Returns: this object, so calls chain
  • const method Queue(): UIToastQueue: What Queue(..) 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: ACount how many. Returns: this object, so calls chain
  • const method Kind(const AKind: UIToastKind): self: The kind of the next messages (and of the one shown, when replacing): beside the base's Kind(), the widget's kind. C: Rtoast_set_kind Parameters: AKind the kind. Returns: this object, so calls chain
  • const method ActionText(const AText: string): self: A button at the end of the next messages ("" removes it). C: Rtoast_set_action_text Parameters: AText the text. Returns: this object, so calls chain
  • const method OnAction(const AFunc: UITaskFunc): self: Runs AFunc when a message's action button is pressed (the message then hides). C: Rtoast_set_action_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain

Example: LToast.ActionText("Undo").OnAction(func() begin Undo(); end).Show("Deleted", 3.0);

UITreeItem

text
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 as AItem. Parameters: AItem the item. Returns: the handle of the tree item System.Raven.C gave as AItem
  • const method Id(): Rid: The item's Rid, for System.Raven.C's calls. Returns: the item's Rid, for System.Raven.C's calls
  • const method IsValid(): bool: true while the handle names an item of a tree. C: Rtree_item_is_valid Returns: true while the handle names an item of a tree
  • const method Destroy(): Deletes the item and its descendants, their icons let go. C: Rtree_item_destroy
  • const method Text(const AText: string): self: The item's text. C: Rtree_item_set_text Parameters: AText the text. Returns: this object, so calls chain
  • const method Text(): string: What Text(..) sets, read back. C: Rtree_item_get_text Returns: the item's text
  • const method Expanded(const AOn: bool): self: Shows (true) or hides its children. C: Rtree_item_set_expanded Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Expanded(): bool: What Expanded(..) sets, read back. C: Rtree_item_is_expanded Returns: true when Expanded(..) turned it on
  • const 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: AHandle the handle. Returns: this object, so calls chain
  • const method UserHandle(): ptr: What UserHandle(..) 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 children
  • const method Child(const AIndex: int32): UITreeItem: Its child at AIndex (names none outside). C: Rtree_item_get_child Parameters: AIndex the index, from 0. Returns: its child at AIndex (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: AColor the colour. Returns: this object, so calls chain
  • const method Selected(const AOn: bool): self: Adds it to (true) or takes it from its tree's selection. C: Rtree_item_set_selected Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Selected(): bool: What Selected(..) sets, read back. C: Rtree_item_is_selected Returns: true when Selected(..) turned it on
  • const method Icon(const ATexture: UITextureRes): self: The whole of ATexture as 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's ClearItems. C: Rtree_item_set_icon Parameters: ATexture the texture. Returns: this object, so calls chain
  • const method Icon(const ATexture: UITextureRes; const AUVMin: UIPoint; const AUVMax: UIPoint): self: A part of ATexture as 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: ATexture the texture; AUVMin the lowest texture coordinates (0 .. 1); AUVMax the highest texture coordinates (0 .. 1). Returns: this object, so calls chain

UITableColumn

text
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 column AColumn of the table ATable (a Rid). Parameters: ATable the table; AColumn the column, from 0. Returns: the column AColumn of the table ATable (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: true while the index is one of its table's columns. C: Rtable_get_column_count Returns: true while the index is one of its table's columns
  • const method Header(const AHeader: string): self: The column's header text. C: Rtable_set_column_header Parameters: AHeader the header. Returns: this object, so calls chain
  • const method Header(): string: What Header(..) sets, read back. C: Rtable_get_column_header Returns: the column's header text
  • const method Width(const AWidth: float32): self: Its width in logical units. C: Rtable_set_column_width Parameters: AWidth the width. Returns: this object, so calls chain
  • const 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: AFill the share of the room it takes. Returns: this object, so calls chain
  • const method Sortable(const AOn: bool): self: false: a click on its header does not sort (on by default). C: Rtable_set_column_sortable Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Align(const AAlign: UITextAlign): self: Where its texts sit in their cells. C: Rtable_set_column_align Parameters: AAlign the alignment. Returns: this object, so calls chain

UITableRow

text
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 row ARow of the table ATable (a Rid). Parameters: ATable the table; ARow the row, from 0. Returns: the row ARow of the table ATable (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: true while the index is one of its table's rows. C: Rtable_get_row_count Returns: true while the index is one of its table's rows
  • const method Selected(const AOn: bool): self: Adds it to (true) or takes it from the selection. C: Rtable_set_row_selected Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Selected(): bool: What Selected(..) sets, read back. C: Rtable_is_row_selected Returns: true when Selected(..) turned it on
  • const method Cell(const AColumn: int32; const AText: string): self: The text of its cell in the column AColumn (a '|' in it stays). C: Rtable_set_cell Parameters: AColumn the column, from 0; AText the text. Returns: this object, so calls chain
  • const method Cell(const AColumn: int32): string: What Cell(..) sets, read back. C: Rtable_get_cell Parameters: AColumn the column, from 0. Returns: the text of its cell in the column AColumn (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: AColor the colour. Returns: this object, so calls chain
  • const method Remove(): Removes the row from its table (the rows after it move up). C: Rtable_remove_row

UITileSection

text
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 section ASection of the tile view AView (a Rid). Parameters: AView the view; ASection the section. Returns: the section ASection of the tile view AView (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: true while the index is one of its tile view's sections. C: Rtile_view_get_section_count Returns: true while the index is one of its tile view's sections
  • const 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: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Folded(): bool: What Folded(..) sets, read back. C: Rtile_view_is_section_folded Returns: true when Folded(..) turned it on

UITile

text
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 of Icon shown, in texture coordinates (0 .. 1).
  • IconUVMax: UIPoint: The bottom-right corner of the part of Icon shown, 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

text
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

text
type UITreeFunc = ref func(const AItem: UITreeItem)

A tree view's item closure: the item selected or activated.

UITreeContextFunc

text
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

text
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

text
type UIItemTextFunc = ref func(const AIndex: int32): string

A virtual list's text closure: the text of the row AIndex.

UIItemColorFunc

text
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

text
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

text
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

text
type UISortFunc = ref func(const AColumn: int32; const ADescending: bool)

A table's sort closure: the column clicked and the order asked for.

UITileFunc

text
type UITileFunc = ref func(const AIndex: int32; var ATile: UITile)

A tile view's tile closure: fills ATile for the tile AIndex.

UITileHeaderFunc

text
type UITileHeaderFunc = ref func(const ASection: int32; var AHeader: UITileHeader)

A tile view's section closure: fills AHeader for the section ASection.

UITileSectionFunc

text
type UITileSectionFunc = ref func(const ASection: UITileSection)

A tile view's section closure: the section the user folded or unfolded.

UIDragDataFunc

text
type UIDragDataFunc = ref func(): string

A tile view's drag closure: the data of a drag of the selected tiles ("" keeps their indices).

UIListView

text
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 rows
  • static method Kinds(): UIWidgetKinds: The kind a list view views. Returns: the kind a list view views
  • const method AddItem(const AText: string): int32: AText as the last row: its index. C: Rlist_view_add_item Parameters: AText the text. Returns: AText as the last row: its index
  • const method Item(const AIndex: int32; const AText: string): self: The text of the row AIndex. C: Rlist_view_set_item_text Parameters: AIndex the index, from 0; AText the text. Returns: this object, so calls chain
  • const method Item(const AIndex: int32): string: What Item(..) sets, read back. C: Rlist_view_get_item_text Parameters: AIndex the index, from 0. Returns: the text of the row AIndex
  • const method RemoveItem(const AIndex: int32): self: The row AIndex removed (the rows after it move up). C: Rlist_view_remove_item Parameters: AIndex the index, from 0. Returns: this object, so calls chain
  • const method ClearItems(): self: Every row removed. C: Rlist_view_clear_items Returns: this object, so calls chain
  • const method ItemCount(): int32: The rows it has. C: Rlist_view_get_item_count Returns: the rows it has
  • const method Virtual(const ACount: int32; const AFunc: UIItemTextFunc): self: Virtual mode, for large or computed data: ACount rows, the list storing none and running AFunc for the text of each row it draws. C: Rlist_view_set_virtual_items Parameters: ACount how many; AFunc the func it runs. Returns: this object, so calls chain
  • const method ItemColor(const AFunc: UIItemColorFunc): self: Colours the rows' texts: Raven runs AFunc for each row it draws (stored or virtual); the colour stays on a selected or hovered row. C: Rlist_view_set_item_color_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method Selected(const AIndex: int32): self: Selects the row AIndex (-1: none). C: Rlist_view_set_selected Parameters: AIndex the index, from 0. Returns: this object, so calls chain
  • const 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 row AIndex shows. C: Rlist_view_scroll_to_item Parameters: AIndex the index, from 0. Returns: this object, so calls chain
  • const method OnSelect(const AFunc: UIIndexFunc): self: Runs AFunc with the row selected when the selection changes. C: Rlist_view_set_selection_changed_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnActivate(const AFunc: UIIndexFunc): self: Runs AFunc with the row activated (double click, Enter; the widget's action runs too). C: Rlist_view_set_activated_callback Parameters: AFunc the 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

text
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 items
  • static method Kinds(): UIWidgetKinds: The kind a tree view views. Returns: the kind a tree view views
  • const method AddItem(const AParent: UITreeItem; const AText: string): UITreeItem: A new item AText as the last child of AParent. C: Rtree_view_add_item Parameters: AParent the parent; AText the text. Returns: a new item AText as the last child of AParent
  • const method AddItem(const AText: string): UITreeItem: A new top-level item AText, the last one. C: Rtree_view_add_item Parameters: AText the text. Returns: a new top-level item AText, the last one
  • const method ClearItems(): self: Every item deleted. C: Rtree_view_clear_items Returns: this object, so calls chain
  • const method ItemCount(): int32: Its top-level items. C: Rtree_view_get_item_count Returns: its top-level items
  • const method Item(const AIndex: int32): UITreeItem: Its top-level item at AIndex (names none outside). C: Rtree_view_get_item Parameters: AIndex the index, from 0. Returns: its top-level item at AIndex (names none outside)
  • const method Selected(const AItem: UITreeItem): self: Selects AItem alone (an empty handle: none). C: Rtree_view_set_selected_item Parameters: AItem the item. Returns: this object, so calls chain
  • const 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: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method ClearSelection(): self: Nothing selected. C: Rtree_view_clear_selection Returns: this object, so calls chain
  • const method SelectionCount(): int32: The items selected. C: Rtree_view_get_selection_count Returns: the items selected
  • const method Selection(const AIndex: int32): UITreeItem: The selected item at AIndex, top to bottom. C: Rtree_view_get_selection Parameters: AIndex the index, from 0. Returns: the selected item at AIndex, top to bottom
  • const method ScrollTo(const AItem: UITreeItem): self: Scrolls (unfolding its ancestors) until AItem shows. C: Rtree_view_scroll_to_item Parameters: AItem the item. Returns: this object, so calls chain
  • const method DragType(const AType: string): self: Items can be dragged: the selection goes to the drag with the type AType and, as data, the items' Rids in decimal separated by spaces ("": no drag, the default). C: Rtree_view_set_drag_type Parameters: AType the type. Returns: this object, so calls chain
  • const method ItemAt(const AAt: UIPoint): UITreeItem: The item at AAt, a point in the tree (a drop's local point; names none in the empty space). C: Rtree_view_get_item_at Parameters: AAt the point. Returns: the item at AAt, 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 when AWholeTree (an empty handle and false: none). C: Rtree_view_set_drop_highlight Parameters: AItem the item; AWholeTree the whole tree. Returns: this object, so calls chain
  • const method OnSelect(const AFunc: UITreeFunc): self: Runs AFunc with the item selected (the one clicked last) when the selection changes. C: Rtree_view_set_selection_changed_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnActivate(const AFunc: UITreeFunc): self: Runs AFunc with the item activated (double click, Enter; the widget's action runs too). C: Rtree_view_set_activated_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnContext(const AFunc: UITreeContextFunc): self: Runs AFunc on a right click: the item under the pointer (selected first; names none in the empty space) and the point in the window, for UIMenu.Open. C: Rtree_view_set_context_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain

Example: LDocs := LTree.AddItem("Docs"); LTree.AddItem(LDocs, "README.md"); LDocs.Expanded(true);

UITable

text
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 columns
  • static method Kinds(): UIWidgetKinds: The kind a table views. Returns: the kind a table views
  • const method AddColumn(const AHeader: string; const AWidth: float32): UITableColumn: A new last column headed AHeader, AWidth wide (0 or less: Raven's 120); the stored rows get an empty cell in it. C: Rtable_add_column Parameters: AHeader the header; AWidth the width. Returns: a new last column headed AHeader, AWidth wide (0 or less: Raven's 120); the stored rows get an empty cell in it
  • const method ColumnCount(): int32: Its columns. C: Rtable_get_column_count Returns: its columns
  • const method Column(const AIndex: int32): UITableColumn: Its column at AIndex. Parameters: AIndex the index, from 0. Returns: its column at AIndex
  • const method ClearColumns(): self: Every column removed, with the stored rows. C: Rtable_clear_columns Returns: this object, so calls chain
  • const 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 cells ACells, in column order (a '|' in a text stays). C: Rtable_add_row + Rtable_set_cell Parameters: ACells the cells. Returns: a new last row with the cells ACells, in column order (a '|' in a text stays)
  • const method Row(const AIndex: int32): UITableRow: Its row at AIndex (in the order shown). Parameters: AIndex the index, from 0. Returns: its row at AIndex (in the order shown)
  • const method RemoveRow(const AIndex: int32): self: The row AIndex removed (the rows after it move up). C: Rtable_remove_row Parameters: AIndex the index, from 0. Returns: this object, so calls chain
  • const method ClearRows(): self: Every stored row removed. C: Rtable_clear_rows Returns: this object, so calls chain
  • const 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: ARow the row, from 0; AColumn the column, from 0; AText the text. Returns: this object, so calls chain
  • const method Cell(const ARow: int32; const AColumn: int32): string: What Cell(..) sets, read back. C: Rtable_get_cell Parameters: ARow the row, from 0; AColumn the 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: ARows rows, the table storing none and running AFunc for the text of each cell it draws. C: Rtable_set_virtual_rows Parameters: ARows the rows; AFunc the func it runs. Returns: this object, so calls chain
  • const method CellColor(const AFunc: UICellColorFunc): self: Colours the cells' texts: Raven runs AFunc for each cell it draws (it wins over CellTextColor). C: Rtable_set_cell_color_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const 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: ARow the row, from 0; AColumn the column, from 0; AColor the colour. Returns: this object, so calls chain
  • const method MultiSelect(const AOn: bool): self: Several rows selectable (Ctrl + click one more, Shift + click a range). C: Rtable_set_multi_select Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Selected(const ARow: int32): self: The row ARow selected alone (-1: none). C: Rtable_set_selected Parameters: ARow the row, from 0. Returns: this object, so calls chain
  • const 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 chain
  • const method SelectionCount(): int32: The rows selected. C: Rtable_get_selection_count Returns: the rows selected
  • const method Selection(const AIndex: int32): int32: The selected row at AIndex, top to bottom (-1 outside). C: Rtable_get_selection Parameters: AIndex the index, from 0. Returns: the selected row at AIndex, top to bottom (-1 outside)
  • const method ScrollTo(const ARow: int32): self: Scrolls until the row ARow shows. C: Rtable_scroll_to_row Parameters: ARow the row, from 0. Returns: this object, so calls chain
  • const method Sort(const AColumn: int32; const ADescending: bool): self: Sorts by the column AColumn (stored rows move; -1 shows no sorted column). C: Rtable_sort Parameters: AColumn the column, from 0; ADescending the descending. Returns: this object, so calls chain
  • const 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: true when sorted from the highest down. C: Rtable_is_sort_descending Returns: true when sorted from the highest down
  • const method HeaderVisible(const AOn: bool): self: Shows (true) or hides the header row. C: Rtable_set_header_visible Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method GridLines(const AOn: bool): self: Lines between the cells. C: Rtable_set_grid_lines Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Striped(const AOn: bool): self: Every other row a little darker. C: Rtable_set_striped Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method OnSelect(const AFunc: UIIndexFunc): self: Runs AFunc with the row selected when the selection changes. C: Rtable_set_selection_changed_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnActivate(const AFunc: UIIndexFunc): self: Runs AFunc with the row activated (double click, Enter). C: Rtable_set_activated_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnSort(const AFunc: UISortFunc): self: Runs AFunc when a header is clicked to sort: the column and the order (a virtual table orders its data there). C: Rtable_set_sort_callback Parameters: AFunc the 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

text
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 tiles
  • static method Kinds(): UIWidgetKinds: The kind a tile view views. Returns: the kind a tile view views
  • const method Items(const ACount: int32; const AFunc: UITileFunc): self: ACount tiles, each described by AFunc when it is drawn; the selection is cleared and the sections removed. C: Rtile_view_set_items Parameters: ACount how many; AFunc the func it runs. Returns: this object, so calls chain
  • const method Refresh(): self: Draws the tiles again (their description changed, not their number). C: Rtile_view_refresh Returns: this object, so calls chain
  • const method Count(): int32: Its tiles. C: Rtile_view_get_count Returns: its tiles
  • const 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: AWidth the width; AHeight the height; AIconSize the icon size. Returns: this object, so calls chain
  • const method EmptyText(const AText: string): self: The text shown when there is no tile. C: Rtile_view_set_empty_text Parameters: AText the text. Returns: this object, so calls chain
  • const 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: AWidth the width. Returns: this object, so calls chain
  • const method Sections(const ACount: int32; const AFunc: UITileHeaderFunc): self: ACount sections, each header described by AFunc (its First read now, its texts when drawn), all unfolded; give them after the tiles. C: Rtile_view_set_sections Parameters: ACount how many; AFunc the func it runs. Returns: this object, so calls chain
  • const method SectionCount(): int32: Its sections. C: Rtile_view_get_section_count Returns: its sections
  • const method Section(const AIndex: int32): UITileSection: The section AIndex. Parameters: AIndex the index, from 0. Returns: the section AIndex
  • const method SectionOf(const AIndex: int32): UITileSection: The section of the tile AIndex (names none before the first section). C: Rtile_view_get_section_of Parameters: AIndex the index, from 0. Returns: the section of the tile AIndex (names none before the first section)
  • const method SectionAt(const AAt: UIPoint): UITileSection: The section whose header is at AAt, a point in the widget (names none elsewhere). C: Rtile_view_get_section_at Parameters: AAt the point. Returns: the section whose header is at AAt, a point in the widget (names none elsewhere)
  • const method Selected(const AIndex: int32; const AOn: bool): self: Adds the tile AIndex to (true) or takes it from the selection. C: Rtile_view_set_selected Parameters: AIndex the index, from 0; AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Selected(const AIndex: int32): bool: What Selected(..) sets, read back. C: Rtile_view_is_selected Parameters: AIndex the index, from 0. Returns: true when Selected(..) turned it on
  • const method ClearSelection(): self: Nothing selected. C: Rtile_view_clear_selection Returns: this object, so calls chain
  • const method SelectOnly(const AIndex: int32): self: The tile AIndex selected alone. C: Rtile_view_select_only Parameters: AIndex the index, from 0. Returns: this object, so calls chain
  • const 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 selected
  • const method Selection(const ANth: int32): int32: The index of the ANth selected tile, in order. C: Rtile_view_get_selection Parameters: ANth the nth. Returns: the index of the ANth selected tile, in order
  • const method ScrollTo(const AIndex: int32): self: Scrolls until the tile AIndex shows. C: Rtile_view_scroll_to Parameters: AIndex the index, from 0. Returns: this object, so calls chain
  • const method ItemAt(const AAt: UIPoint): int32: The tile at AAt, a point in the widget (a drop's local point; -1 elsewhere). C: Rtile_view_get_item_at Parameters: AAt the point. Returns: the tile at AAt, 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: AIndex the index, from 0. Returns: this object, so calls chain
  • const method DragType(const AType: string): self: Tiles can be dragged: the selected ones go to the drag with the type AType and, as data, their indices separated by spaces or DragData's text ("": no drag). C: Rtile_view_set_drag_type Parameters: AType the type. Returns: this object, so calls chain
  • const method DragData(const AFunc: UIDragDataFunc): self: The data of a drag, given by AFunc (paths of files ..) in place of the indices (its "" keeps them). C: Rtile_view_set_drag_data_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnSelect(const AFunc: UIIndexFunc): self: Runs AFunc with the current tile (-1 for none) when the selection changes. C: Rtile_view_set_selection_changed_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnActivate(const AFunc: UIIndexFunc): self: Runs AFunc with the tile activated (double click, Enter). C: Rtile_view_set_activated_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnContext(const AFunc: UIIndexContextFunc): self: Runs AFunc on 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: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnSectionToggled(const AFunc: UITileSectionFunc): self: Runs AFunc with the section the user folded or unfolded. C: Rtile_view_set_section_toggled_callback Parameters: AFunc the 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

text
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 views
  • const method Text(const AText: string): self: The item's text. C: Rmenu_item_set_text Parameters: AText the text. Returns: this object, so calls chain
  • const method Text(): string: What Text(..) sets, read back. C: Rmenu_item_get_text Returns: the item's text
  • const method Shortcut(const AKey: UIKey; const AMods: UIModifiers): self: Shows the shortcut AKey with AMods beside the item, and runs the item when they are pressed in its menu bar's window. C: Rmenu_item_set_shortcut Parameters: AKey the key; AMods the modifier keys. Returns: this object, so calls chain
  • const 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: AText the text. Returns: this object, so calls chain
  • const method ResetShortcutText(): self: The formatted shortcut shown again in place of ShortcutText's. C: Rmenu_item_set_shortcut_text (NULL) Returns: this object, so calls chain
  • const method Checkable(const AOn: bool): self: The item shows a check mark that a click toggles. C: Rmenu_item_set_checkable Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Checked(const AOn: bool): self: Puts the check mark on (true) or off (a checkable item). C: Rmenu_item_set_checked Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Checked(): bool: True while the item is checked. C: Rmenu_item_is_checked Returns: true when it is checked
  • const method OnClick(const AFunc: UITaskFunc): self: Runs AFunc when the item is clicked (or its shortcut pressed). C: Rmenu_item_set_clicked_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method Icon(const ATexture: UITextureRes): self: The whole of ATexture as 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: ATexture the texture. Returns: this object, so calls chain
  • const method Icon(const ATexture: UITextureRes; const AUVMin: UIPoint; const AUVMax: UIPoint; const ATint: bool): self: A part of ATexture as 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; ATint true: the texture is a mask drawn in the text colour. C: Rmenu_item_set_icon Parameters: ATexture the texture; AUVMin the lowest texture coordinates (0 .. 1); AUVMax the highest texture coordinates (0 .. 1); ATint the tint colour. Returns: this object, so calls chain

UIMenu

text
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 items
  • static method Kinds(): UIWidgetKinds: The kind a menu views. Returns: the kind a menu views
  • const 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: ATitle the title. Returns: this object, so calls chain
  • const 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: AColor the colour. Returns: this object, so calls chain
  • const method AddItem(const AText: string): UIMenuItem: A new last item AText. C: Rmenu_add_item Parameters: AText the text. Returns: a new last item AText
  • const 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 widget
  • const method AddHeader(const AText: string): UIWidget: A caption row keyboard navigation skips: its widget. C: Rmenu_add_header Parameters: AText the text. Returns: a caption row keyboard navigation skips: its widget
  • const method AddMenu(const ATitle: string): UIMenu: A new last sub-menu titled ATitle. C: Rmenu_add_menu Parameters: ATitle the title. Returns: a new last sub-menu titled ATitle
  • const method Open(const AWindow: UIWindow; const AAt: UIPoint): self: Opens the menu as a popup at AAt in AWindow (logical units). C: Rmenu_open Parameters: AWindow the window; AAt the point. Returns: this object, so calls chain

Example: LMenu := UIMenu.Create(); LMenu.AddItem("Rename").OnClick(func() begin Rename(); end); LList.ContextMenu(LMenu);

UIMenuBar

text
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 menus
  • static method Kinds(): UIWidgetKinds: The kind a menu bar views. Returns: the kind a menu bar views
  • const method Native(const AOn: bool): self: false keeps the bar in the window everywhere (macOS included). C: Rmenu_bar_set_native Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Native(): bool: true while the system shows the bar in place of the window. C: Rmenu_bar_is_native Returns: true while the system shows the bar in place of the window
  • const method AddMenu(const ATitle: string): UIMenu: A new last menu titled ATitle. C: Rmenu_add_menu Parameters: ATitle the title. Returns: a new last menu titled ATitle
  • const 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

text
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

text
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

text
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

text
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's APainter (a paint callback's own, for System.Raven.C code). Parameters: APainter the painter. Returns: the painter of Raven's APainter (a paint callback's own, for System.Raven.C code)
  • const method IsValid(): bool: true when it names a painter (inside a paint closure). Returns: true when it names a painter (inside a paint closure)
  • const method Rect(const ARect: UIRect; const AColor: UIColor; const ARadius: float32): ARect filled with AColor, its corners rounded by ARadius (0: square). C: Rdraw_rect Parameters: ARect the rectangle; AColor the colour; ARadius the radius.
  • const method RectOutline(const ARect: UIRect; const AWidth: float32; const AColor: UIColor; const ARadius: float32): ARect's outline, AWidth wide, in AColor, its corners rounded by ARadius. C: Rdraw_rect_outline Parameters: ARect the rectangle; AWidth the width; AColor the colour; ARadius the radius.
  • const method Shadow(const ARect: UIRect; const ABlur: float32; const AColor: UIColor; const ARadius: float32): A soft shadow of ARect (corners rounded by ARadius), blurred over ABlur units, in AColor. C: Rdraw_shadow Parameters: ARect the rectangle; ABlur the blur radius; AColor the colour; ARadius the radius.
  • const method Circle(const ACenter: UIPoint; const ARadius: float32; const AColor: UIColor): A filled circle around ACenter. C: Rdraw_circle Parameters: ACenter the centre; ARadius the radius; AColor the colour.
  • const method Line(const AFrom: UIPoint; const ATo: UIPoint; const AWidth: float32; const AColor: UIColor): A straight line from AFrom to ATo, AWidth wide. C: Rdraw_line Parameters: AFrom the start point; ATo the end point; AWidth the width; AColor the 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 from AFrom to ATo pulled by AControl1 and AControl2, AWidth wide. C: Rdraw_curve Parameters: AFrom the start point; AControl1 the first control point; AControl2 the second control point; ATo the end point; AWidth the width; AColor the colour.
  • const method Triangle(const AFirst: UIPoint; const ASecond: UIPoint; const AThird: UIPoint; const AColor: UIColor): A filled triangle with the corners AFirst, ASecond and AThird. C: Rdraw_triangle Parameters: AFirst the first corner; ASecond the second corner; AThird the third corner; AColor the colour.
  • const method Glass(const ARect: UIRect; const ARadius: float32; const AColor: UIColor): ARect as frosted glass over what is behind it, tinted AColor, its corners rounded by ARadius. C: Rdraw_glass Parameters: ARect the rectangle; ARadius the radius; AColor the colour.
  • const method Spring(var ASpring: RSpring; const ATarget: float32; const AMotion: UIMotion): float32: ASpring moved one frame toward ATarget as AMotion eases (the widget is drawn again while it moves). C: Rdraw_spring Parameters: ASpring the spring; ATarget the target; AMotion the motion. Returns: the spring's value this frame
  • const method PushClip(const ARect: UIRect): What is drawn from now on clipped to ARect (inside the clip already in place), until PopClip. C: Rdraw_push_clip_rect Parameters: ARect the rectangle.
  • const method PopClip(): The clip before the last PushClip back. C: Rdraw_pop_clip_rect
  • const method Image(const ATexture: UITextureRes; const ARect: UIRect; const ATint: UIColor): ATexture stretched to ARect, multiplied by ATint (white: its own colours). C: Rdraw_image Parameters: ATexture the texture; ARect the rectangle; ATint the tint colour.
  • const method Text(const AFont: UIFontRes; const ASize: float32; const AAt: UIPoint; const AColor: UIColor; const AText: string): AText (UTF-8) in AFont (an empty handle: the theme's) at the size ASize (0: the theme's), the first line's top-left corner at AAt, in AColor. C: Rdraw_text Parameters: AFont the font; ASize the size; AAt the point; AColor the colour; AText the text.
  • const method Shader(const AShader: UIShaderRes; const ARect: UIRect; const ALook: RShaderLook): AShader drawn over ARect with the look ALook. C: Rdraw_shader Parameters: AShader the shader; ARect the rectangle; ALook the 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

text
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

text
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

text
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

text
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

text
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 holding AText ("" for an empty one). C: Rtext_editor_create Parameters: AText the text. Returns: a new editor holding AText ("" for an empty one)
  • static method Kinds(): UIWidgetKinds: The kind a text editor views. Returns: the kind a text editor views
  • const 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 line ALine (from 0), with no line break ("" past the last). C: Rtext_editor_get_line Parameters: ALine the line. Returns: the text of the line ALine (from 0), with no line break ("" past the last)
  • const method Insert(const AText: string): self: AText typed in at the cursor (replacing the selection), as one undo step. C: Rtext_editor_insert_text Parameters: AText the text. Returns: this object, so calls chain
  • const method Cursor(const APos: UITextPos): self: The cursor put at APos (kept inside the text), the selection gone. C: Rtext_editor_set_cursor Parameters: APos the position. Returns: this object, so calls chain
  • const method Cursor(): UITextPos: Where the cursor is. C: Rtext_editor_get_cursor Returns: where the cursor is
  • const method Select(const ASpan: UITextSpan): self: The text from ASpan.First up to ASpan.Last selected (the cursor at its last place). C: Rtext_editor_select Parameters: ASpan the span. Returns: this object, so calls chain
  • const method SelectAll(): self: The whole text selected. C: Rtext_editor_select_all Returns: this object, so calls chain
  • const 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: true when some text is selected. C: Rtext_editor_get_selection Returns: true when some text is selected
  • const 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 line ALine shows. C: Rtext_editor_scroll_to_line Parameters: ALine the line. Returns: this object, so calls chain
  • const method Undo(): self: The last edit taken back. C: Rtext_editor_undo Returns: this object, so calls chain
  • const method Redo(): self: The last edit taken back made again. C: Rtext_editor_redo Returns: this object, so calls chain
  • const method CanUndo(): bool: true when there is an edit to take back. C: Rtext_editor_can_undo Returns: true when there is an edit to take back
  • const method CanRedo(): bool: true when there is an undone edit to make again. C: Rtext_editor_can_redo Returns: true when there is an undone edit to make again
  • const 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: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const 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: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method LineNumbers(const AOn: bool): self: Line numbers shown in a gutter (AOn). C: Rtext_editor_set_line_numbers Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method TabSize(const ASpaces: int32): self: A tab is ASpaces columns wide. C: Rtext_editor_set_tab_size Parameters: ASpaces the spaces. Returns: this object, so calls chain
  • const 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: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Syntax(const ASyntax: UISyntax): self: Coloured by one of Raven's built-in syntaxes (Language names any registered one). C: Rtext_editor_set_syntax Parameters: ASyntax the syntax. Returns: this object, so calls chain
  • const method Language(const AName: string): self: Coloured as the registered language AName ("" or an unknown name: plain text). C: Rtext_editor_set_language Parameters: AName the name. Returns: this object, so calls chain
  • const 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: AText the text. Returns: this object, so calls chain
  • const method Zoom(const AZoom: float32): self: The text drawn at AZoom times its size (1: as the theme says). C: Rtext_editor_set_zoom Parameters: AZoom the zoom. Returns: this object, so calls chain
  • const method Zoom(): float32: What Zoom(..) sets, read back. C: Rtext_editor_get_zoom Returns: the text drawn at AZoom times 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: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Markdown(const AOn: bool): self: Markdown shown styled as it is typed (AOn): headings, strong, emphasis, links. C: Rtext_editor_set_markdown Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Markdown(): bool: What Markdown(..) sets, read back. C: Rtext_editor_get_markdown Returns: true when Markdown(..) turned it on
  • const method Token(const APos: UITextPos): UITokenKind: What the colouring found at APos (a keyword, a string, a comment ..). C: Rtext_editor_get_token Parameters: APos the position. Returns: what the colouring found at APos (a keyword, a string, a comment ..)
  • const method Completion(const AOn: bool): self: Completion offered as the user types (AOn): the words AddCompletion gave, those of the text (CompletionWords) and the language's keywords. C: Rtext_editor_set_completion Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method ShowCompletions(): self: The completion list opened at the cursor now. C: Rtext_editor_show_completions Returns: this object, so calls chain
  • const method Completing(): bool: true while the completion list is open. C: Rtext_editor_is_completing Returns: true while the completion list is open
  • const method AddCompletion(const AText: string; const ADetail: string): self: AText offered in the completion list, ADetail beside it ("" for none); best added from OnCompletion, which runs as the list opens. C: Rtext_editor_add_completion Parameters: AText the text; ADetail the detail. Returns: this object, so calls chain
  • const method AddCompletion(const AText: string; const ADetail: string; const AInsert: string): self: AText offered in the completion list, ADetail beside it, AInsert typed in when it is picked (a snippet). C: Rtext_editor_add_completion_insert Parameters: AText the text; ADetail the detail; AInsert the insert. Returns: this object, so calls chain
  • const 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: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method AutoPairs(const AOn: bool): self: A bracket or quote typed gets its closing one (AOn). C: Rtext_editor_set_auto_pairs Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method AddMarker(const ALine: int32; const AFirst: int32; const ALast: int32; const AKind: UIMarkKind; const AText: string): self: A marker of the kind AKind under the line ALine from the column AFirst up to ALast, AText its tooltip. C: Rtext_editor_add_marker Parameters: ALine the line; AFirst the first column; ALast the column it runs up to; AKind the kind; AText the text. Returns: this object, so calls chain
  • const method ClearMarkers(): self: Every marker removed. C: Rtext_editor_clear_markers Returns: this object, so calls chain
  • const method MarkerCount(): int32: The markers it has. C: Rtext_editor_get_marker_count Returns: the markers it has
  • const method OnZoom(const AFunc: UIValueFunc): self: Runs AFunc with the zoom when the user zooms. C: Rtext_editor_set_zoom_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnCompletion(const AFunc: UITextFunc): self: Runs AFunc with the word typed so far as the completion list opens: it adds the words to offer (AddCompletion). C: Rtext_editor_set_completion_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnHover(const AFunc: UIHoverFunc): self: Runs AFunc with 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: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnChanged(const AFunc: UITaskFunc): self: Runs AFunc whenever the text changes (typed, pasted, undone or set). C: Rtext_editor_set_changed_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method Font(const AFont: UIFontRes; const ASize: float32): self: The editor's own font at the size ASize (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: AFont the font; ASize the size. Returns: this object, so calls chain

Example: LCode := UITextEditor.Create("begin\nend.").Language("adam").LineNumbers(true);

UIFileBrowser

text
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 folder
  • static method Kinds(): UIWidgetKinds: The kind a file browser views. Returns: the kind a file browser views
  • const 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: AMode the mode. Returns: this object, so calls chain
  • const method Directory(const APath: string): bool: Shows the folder APath. Parameters: APath the file's path. Returns: false when it cannot be read (the browser stays where it was). C: Rfile_browser_set_directory
  • const method Directory(): string: The folder it shows. C: Rfile_browser_get_directory Returns: the folder it shows
  • const method Refresh(): self: The folder read again (files added or removed outside). C: Rfile_browser_refresh Returns: this object, so calls chain
  • const 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: AFilters the filters. Returns: this object, so calls chain
  • const method ShowHidden(const AOn: bool): self: Hidden files and folders listed (AOn). C: Rfile_browser_set_show_hidden Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Multiple(const AOn: bool): self: Several files may be picked at once (AOn; open mode). C: Rfile_browser_set_multiple Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const 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: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method PlacesVisible(const AOn: bool): self: Its places column (home, drives, recent folders) shown (AOn). C: Rfile_browser_set_places_visible Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const 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: AName the name. Returns: this object, so calls chain
  • const 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: AExtension the extension. Returns: this object, so calls chain
  • const method SelectionCount(): int32: The entries picked in its list. C: Rfile_browser_get_selection_count Returns: the entries picked in its list
  • const method Selection(const AIndex: int32): string: The full path of the picked entry AIndex ("" past the last). C: Rfile_browser_get_selection Parameters: AIndex the index, from 0. Returns: the full path of the picked entry AIndex ("" past the last)
  • const method Select(const AName: string): self: The entry named AName in the folder shown picked (the others no longer). C: Rfile_browser_select Parameters: AName the name. Returns: this object, so calls chain
  • const method OnAccept(const AFunc: UITextFunc): self: Runs AFunc with 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: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnCancel(const AFunc: UITaskFunc): self: Runs AFunc when the user cancels (Cancel, Escape). C: Rfile_browser_set_cancelled_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnSelect(const AFunc: UITextFunc): self: Runs AFunc with the full path of the entry the user moves the selection to. C: Rfile_browser_set_selection_changed_callback Parameters: AFunc the 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

text
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 yet
  • static method Kinds(): UIWidgetKinds: The kind a viewport views. Returns: the kind a viewport views
  • const method Stretch(const AStretch: UIStretch): self: How its texture fits its rectangle. C: Rviewport_set_stretch Parameters: AStretch the stretch. Returns: this object, so calls chain
  • const method FlipY(const AOn: bool): self: Its texture drawn upside down (AOn; a bottom-up render target). C: Rviewport_set_flip_y Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const 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: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const 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: AOn true to turn it on, false to turn it off. Returns: false when the system or the backend has none (headless). C: Rviewport_set_native
  • const method NativeHandle(var ANative: RNativeWindow): bool: The native child window (HWND, X11 Window, wl_surface ..) into ANative. Parameters: ANative receives the native window. Returns: false when it has none (Native off, headless). C: Rviewport_get_native_handle
  • const 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: Runs AFunc each 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: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnResize(const AFunc: UIResizeFunc): self: Runs AFunc with its new size in pixels when it changes (a render target to remake). C: Rviewport_set_resize_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const 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: ATexture the 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

text
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 yet
  • static method Kinds(): UIWidgetKinds: The kind a custom widget views. Returns: the kind a custom widget views
  • const method OnPaint(const AFunc: UIPaintFunc): self: Runs AFunc each time the widget is drawn, with its painter (valid in the call only) and its size. C: Rcustom_set_paint_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnMeasure(const AFunc: UIMeasureFunc): self: Runs AFunc when 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: AFunc the 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

text
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 pages
  • static method Kinds(): UIWidgetKinds: The kind a carousel views. Returns: the kind a carousel views
  • const method Page(const APage: int32; const AAnimated: bool): self: The page APage (from 0) shown, sliding there when AAnimated. C: Rcarousel_set_page Parameters: APage the page; AAnimated the animated. Returns: this object, so calls chain
  • const method Page(): int32: The page it shows. C: Rcarousel_get_page Returns: the page it shows
  • const method PageCount(): int32: The pages it has. C: Rcarousel_get_page_count Returns: the pages it has
  • const method Next(): self: The next page shown (after the last: the first when it loops). C: Rcarousel_next Returns: this object, so calls chain
  • const method Prev(): self: The page before shown (before the first: the last when it loops). C: Rcarousel_prev Returns: this object, so calls chain
  • const 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: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Loop(): bool: What Loop(..) sets, read back. C: Rcarousel_get_loop Returns: true when Loop(..) turned it on
  • const method Autoplay(const ASeconds: float64): self: The next page shown every ASeconds (0: never). C: Rcarousel_set_autoplay Parameters: ASeconds the time, in seconds. Returns: this object, so calls chain
  • const method Autoplay(): float64: What Autoplay(..) sets, read back. C: Rcarousel_get_autoplay Returns: the next page shown every ASeconds (0: never)
  • const method Indicators(const AOn: bool): self: A dot for each page shown (AOn). C: Rcarousel_set_indicators_visible Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Indicators(): bool: What Indicators(..) sets, read back. C: Rcarousel_get_indicators_visible Returns: true when Indicators(..) turned it on
  • const method Arrows(const AOn: bool): self: Previous / next arrows shown (AOn). C: Rcarousel_set_arrows_visible Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Arrows(): bool: What Arrows(..) sets, read back. C: Rcarousel_get_arrows_visible Returns: true when Arrows(..) turned it on
  • const method Orientation(const AOrientation: UIOrientation): self: The pages slide across (horizontal) or up and down (vertical). C: Rcarousel_set_orientation Parameters: AOrientation the orientation. Returns: this object, so calls chain
  • const method Orientation(): UIOrientation: What Orientation(..) 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: Runs AFunc with the page shown each time it changes. C: Rcarousel_set_page_changed_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain

Example: LShow := UICarousel.Create().Add(LPage1).Add(LPage2).Loop(true).Autoplay(4.0);

UIPlotPoint

text
type UIPlotPoint = record

A point in a plot's data units.

Members

  • X: float64: The x value.
  • Y: float64: The y value.

UILatLon

text
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

text
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 (its Id(); 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

text
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 series ASeries of the plot APlot (a Rid). Parameters: APlot the plot; ASeries the series. Returns: the series ASeries of the plot APlot (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: true while the index is one of its plot's series. C: Rplot_get_series_count Returns: true while the index is one of its plot's series
  • const method Name(const AName: string): self: The name the legend shows. C: Rplot_set_series_name Parameters: AName the name. Returns: this object, so calls chain
  • const method Name(): string: What Name(..) sets, read back. C: Rplot_get_series_name Returns: the name the legend shows
  • const method Data(const AX: array of float64; const AY: array of float64): self: Its points: the pairs of AX and AY (as many as the shorter has), replacing the ones it had (copied). C: Rplot_set_series_data Parameters: AX the x coordinate; AY the y coordinate. Returns: this object, so calls chain
  • const method Append(const AX: array of float64; const AY: array of float64): self: The pairs of AX and AY (as many as the shorter has) added after its points (copied). C: Rplot_append_series_data Parameters: AX the x coordinate; AY the y coordinate. Returns: this object, so calls chain
  • const method Add(const AX: float64; const AY: float64): self: The point (AX, AY) added after its points. C: Rplot_add_point Parameters: AX the x coordinate; AY the y coordinate. Returns: this object, so calls chain
  • const method ClearData(): self: Every point removed. C: Rplot_clear_series_data Returns: this object, so calls chain
  • const method PointCount(): int32: The points it has. C: Rplot_get_point_count Returns: the points it has
  • const method Point(const AIndex: int32): UIPlotPoint: Its point AIndex (from 0; 0, 0 for one it does not have). C: Rplot_get_point Parameters: AIndex the index, from 0. Returns: its point AIndex (from 0; 0, 0 for one it does not have)
  • const method MaxPoints(const AMax: int32): self: At most AMax points kept, the oldest leaving first (0: no limit): a live feed. C: Rplot_set_series_max_points Parameters: AMax the largest number. Returns: this object, so calls chain
  • const method Color(const AColor: UIColor): self: Its colour (the theme's own until set). C: Rplot_set_series_color Parameters: AColor the colour. Returns: this object, so calls chain
  • const method Line(const AStyle: UILineStyle; const AWidth: float32): self: Its line's style and width in logical units. C: Rplot_set_series_line Parameters: AStyle the style; AWidth the width. Returns: this object, so calls chain
  • const method Marker(const AShape: UIMarkerShape; const ASize: float32): self: The marker drawn at each point and its size. C: Rplot_set_series_marker Parameters: AShape the shape; ASize the size. Returns: this object, so calls chain
  • const method MarkerFilled(const AOn: bool): self: Its markers filled (AOn) or outlined. C: Rplot_set_series_marker_filled Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const 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: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Fill(const AOpacity: float32): self: The area under its line filled at AOpacity (0: none, 1: solid). C: Rplot_set_series_fill Parameters: AOpacity the opacity. Returns: this object, so calls chain
  • const 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: AX the x coordinate; AY the y coordinate. Returns: this object, so calls chain
  • const method Visible(const AOn: bool): self: Shown (AOn) or hidden (its legend entry stays). C: Rplot_set_series_visible Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Visible(): bool: What Visible(..) sets, read back. C: Rplot_is_series_visible Returns: true when Visible(..) turned it on
  • const method Remove(): The series removed from its plot (the ones after it move down by one). C: Rplot_remove_series

UIPlotAxis

text
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 axis AAxis of the plot APlot (a Rid). Parameters: APlot the plot; AAxis the axis. Returns: the axis AAxis of the plot APlot (a Rid)
  • const method Axis(): UIAxis: Which axis it is. Returns: which axis it is
  • const method Label(const ALabel: string): self: The text written along it. C: Rplot_set_axis_label Parameters: ALabel the label. Returns: this object, so calls chain
  • const method Label(): string: What Label(..) sets, read back. C: Rplot_get_axis_label Returns: the text written along it
  • const method Scale(const AScale: UIAxisScale): self: Its scale: linear, logarithmic, or symmetric logarithmic (linear near 0). C: Rplot_set_axis_scale Parameters: AScale the scale. Returns: this object, so calls chain
  • const method Scale(): UIAxisScale: What Scale(..) 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 -AThreshold to AThreshold. C: Rplot_set_axis_linear_threshold Parameters: AThreshold the threshold. Returns: this object, so calls chain
  • const method Range(const AMin: float64; const AMax: float64): self: The values it shows, from AMin to AMax (it stops fitting the data). C: Rplot_set_axis_range Parameters: AMin the lowest value; AMax the highest value. Returns: this object, so calls chain
  • const 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: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method AutoFit(): bool: What AutoFit(..) sets, read back. C: Rplot_is_axis_auto_fit Returns: true when AutoFit(..) turned it on
  • const 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: AFormat the pixel format. Returns: this object, so calls chain
  • const method Visible(const AOn: bool): self: Shown (AOn) or hidden. C: Rplot_set_axis_visible Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Grid(const AOn: bool): self: Grid lines drawn at its ticks (AOn). C: Rplot_set_axis_grid Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Inverted(const AOn: bool): self: Its values run the other way (AOn). C: Rplot_set_axis_inverted Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Locked(const AOn: bool): self: The user may not pan or zoom it (AOn). C: Rplot_set_axis_locked Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain

UIDragLine

text
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 line ALine of the plot APlot (a Rid). Parameters: APlot the plot; ALine the line. Returns: the drag line ALine of the plot APlot (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: true while the index is one of its plot's drag lines. C: Rplot_get_drag_line_count Returns: true while the index is one of its plot's drag lines
  • const method Value(const AValue: float64): self: The value it stands at. C: Rplot_set_drag_line_value Parameters: AValue the value. Returns: this object, so calls chain
  • const method Value(): float64: What Value(..) sets, read back. C: Rplot_get_drag_line_value Returns: the value it stands at
  • const method Color(const AColor: UIColor): self: Its colour. C: Rplot_set_drag_line_color Parameters: AColor the colour. Returns: this object, so calls chain
  • const method Remove(): The line removed from its plot (the ones after it move down by one). C: Rplot_remove_drag_line

UIChartSlice

text
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 slice ASlice of the chart AChart (a Rid). Parameters: AChart the chart; ASlice the slice. Returns: the slice ASlice of the chart AChart (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: true while the index is one of its chart's slices. C: Rchart_get_slice_count Returns: true while the index is one of its chart's slices
  • const method Value(const AValue: float64): self: Its value (its share is its value over the chart's total). C: Rchart_set_slice_value Parameters: AValue the value. Returns: this object, so calls chain
  • const method Value(): float64: What Value(..) 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: ALabel the label. Returns: this object, so calls chain
  • const method Label(): string: What Label(..) sets, read back. C: Rchart_get_slice_label Returns: its label
  • const method Color(const AColor: UIColor): self: Its colour (the theme's own until set). C: Rchart_set_slice_color Parameters: AColor the colour. Returns: this object, so calls chain
  • const method Remove(): The slice removed from its chart. C: Rchart_remove_slice

UIMapMarker

text
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 id AMarker on the map AMap (a Rid). Parameters: AMap the map; AMarker the marker. Returns: the marker with the id AMarker on the map AMap (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: true when it names a marker id (Raven gives -1 for a marker it could not add). Returns: true when 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: ALatitude the latitude; ALongitude the longitude. Returns: this object, so calls chain
  • const method Label(const ALabel: string): self: The text shown beside it ("": none). C: Rmap_view_set_marker_label Parameters: ALabel the label. Returns: this object, so calls chain
  • const method Color(const AColor: UIColor): self: Its colour (the theme's accent until set). C: Rmap_view_set_marker_color Parameters: AColor the colour. Returns: this object, so calls chain
  • const method Remove(): The marker removed from its map. C: Rmap_view_remove_marker

UISeriesToggleFunc

text
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

text
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

text
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

text
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

text
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

text
type UIMarkerFunc = ref func(const AMarker: UIMapMarker)

What UIMapView.OnMarkerClick runs when the user clicks a marker.

UIMapViewFunc

text
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

text
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 series
  • static method Kinds(): UIWidgetKinds: The kind a plot views. Returns: the kind a plot views
  • const method Title(const ATitle: string): self: The title written above it. C: Rplot_set_title Parameters: ATitle the title. Returns: this object, so calls chain
  • const method Title(): string: What Title(..) sets, read back. C: Rplot_get_title Returns: the title written above it
  • const method AddSeries(const AName: string): UIPlotSeries: A new series named AName (the legend's text), with no points. C: Rplot_add_series Parameters: AName the name. Returns: a new series named AName (the legend's text), with no points
  • const method RemoveSeries(const ASeries: UIPlotSeries): self: ASeries removed (the ones after it move down by one). C: Rplot_remove_series Parameters: ASeries the series. Returns: this object, so calls chain
  • const method Clear(): self: Every series and drag line removed. C: Rplot_clear Returns: this object, so calls chain
  • const method SeriesCount(): int32: The series it has. C: Rplot_get_series_count Returns: the series it has
  • const method Series(const AIndex: int32): UIPlotSeries: Its series AIndex (from 0). Parameters: AIndex the index, from 0. Returns: its series AIndex (from 0)
  • const method Axis(const AAxis: UIAxis): UIPlotAxis: Its axis AAxis. Parameters: AAxis the axis. Returns: its axis AAxis
  • const method Fit(): self: Every axis not locked fitted to the data, following it again. C: Rplot_fit Returns: this object, so calls chain
  • const method Legend(const APlace: UILegendPlace): self: Where the legend goes (UILegendPlace.Hidden: none). C: Rplot_set_legend Parameters: APlace the place. Returns: this object, so calls chain
  • const method Crosshair(const AOn: bool): self: Lines across it under the pointer (AOn). C: Rplot_set_crosshair Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method MouseText(const AOn: bool): self: The pointer's place in data units written in a corner (AOn). C: Rplot_set_mouse_text Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Tooltips(const AOn: bool): self: The point nearest the pointer shown in a tooltip (AOn). C: Rplot_set_tooltips Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method MousePosition(var APoint: UIPlotPoint): bool: The pointer's place in data units in APoint (X / Y axes). C: Rplot_get_mouse_position Parameters: APoint the point. Returns: true when the pointer is over the plot's area
  • const 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: AX the x coordinate; AY the 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 at APoint (the plot's own units). C: Rplot_point_to_data Parameters: APoint the point. Returns: the data point drawn at APoint (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 at AValue of AAxis, labelled ALabel ("": none). C: Rplot_add_drag_line Parameters: AAxis the axis; AValue the value; ALabel the label. Returns: a new drag line across the plot at AValue of AAxis, labelled ALabel ("": none)
  • const method DragLineCount(): int32: The drag lines it has. C: Rplot_get_drag_line_count Returns: the drag lines it has
  • const method DragLine(const AIndex: int32): UIDragLine: Its drag line AIndex (from 0). Parameters: AIndex the index, from 0. Returns: its drag line AIndex (from 0)
  • const method OnViewChanged(const AFunc: UITaskFunc): self: Runs AFunc each time the user pans or zooms it. C: Rplot_set_view_changed_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnDragLine(const AFunc: UIDragLineFunc): self: Runs AFunc with the line and its value while the user drags a drag line. C: Rplot_set_drag_line_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnSeriesToggled(const AFunc: UISeriesToggleFunc): self: Runs AFunc with the series and whether it is shown when the user toggles it in the legend. C: Rplot_set_series_toggled_callback Parameters: AFunc the 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

text
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 kind AKind, empty. C: Rchart_create Parameters: AKind the kind. Returns: a new chart of the kind AKind, empty
  • static method Kinds(): UIWidgetKinds: The kind a chart views. Returns: the kind a chart views
  • const 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: AKind the kind. Returns: this object, so calls chain
  • const 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: ATitle the title. Returns: this object, so calls chain
  • const method Title(): string: What Title(..) sets, read back. C: Rchart_get_title Returns: the title written above it
  • const method Format(const AFormat: string): self: The C format its values are written with ("%.0f%%"; "": Raven's own). C: Rchart_set_format Parameters: AFormat the pixel format. Returns: this object, so calls chain
  • const method Color(const AColor: UIColor): self: Its main colour (a gauge's arc, a sparkline's line). C: Rchart_set_color Parameters: AColor the colour. Returns: this object, so calls chain
  • const method Legend(const AOn: bool): self: A legend shown (AOn). C: Rchart_set_legend Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Clear(): self: Every slice, band, cell and value removed. C: Rchart_clear Returns: this object, so calls chain
  • const 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 labelled ALabel worth AValue (pie / donut). C: Rchart_add_slice Parameters: ALabel the label; AValue the value. Returns: a new slice labelled ALabel worth AValue (pie / donut)
  • const method SliceCount(): int32: The slices it has. C: Rchart_get_slice_count Returns: the slices it has
  • const method Slice(const AIndex: int32): UIChartSlice: Its slice AIndex (from 0). Parameters: AIndex the index, from 0. Returns: its slice AIndex (from 0)
  • const method Total(): float64: The sum of its slices' values. C: Rchart_get_total Returns: the sum of its slices' values
  • const method Selected(const AIndex: int32): self: The slice AIndex selected (pulled out; -1: none). C: Rchart_set_selected Parameters: AIndex the index, from 0. Returns: this object, so calls chain
  • const 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: ARatio the ratio. Returns: this object, so calls chain
  • const 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: AText the text; ACaption the caption. Returns: this object, so calls chain
  • const method OnSliceClick(const AFunc: UISliceFunc): self: Runs AFunc with the slice and whether it is selected when the user clicks one. C: Rchart_set_slice_clicked_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method Range(const AMin: float64; const AMax: float64): self: A gauge's range, from AMin to AMax. C: Rchart_set_range Parameters: AMin the lowest value; AMax the highest value. Returns: this object, so calls chain
  • const 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: AValue the value. Returns: this object, so calls chain
  • const method Value(): float64: What Value(..) sets, read back. C: Rchart_get_value Returns: a gauge's value
  • const method AddBand(const AFrom: float64; const ATo: float64; const AColor: UIColor): self: A band of a gauge's arc from AFrom to ATo coloured AColor. C: Rchart_add_band Parameters: AFrom the band's start; ATo the band's end; AColor the colour. Returns: this object, so calls chain
  • const method ClearBands(): self: Every band removed. C: Rchart_clear_bands Returns: this object, so calls chain
  • const method BandCount(): int32: The bands a gauge has. C: Rchart_get_band_count Returns: the bands a gauge has
  • const method Grid(const ARows: int32; const AColumns: int32): self: A heatmap of ARows x AColumns cells, every one 0. C: Rchart_set_grid Parameters: ARows the rows; AColumns the columns. Returns: this object, so calls chain
  • const method Grid(const ARows: int32; const AColumns: int32; const AValues: array of float32): self: A heatmap of ARows x AColumns cells, their values row by row from AValues (copied; one too short leaves every cell 0). C: Rchart_set_grid Parameters: ARows the rows; AColumns the columns; AValues the values. Returns: this object, so calls chain
  • const method RowCount(): int32: A heatmap's rows. C: Rchart_get_row_count Returns: a heatmap's rows
  • const method ColumnCount(): int32: A heatmap's columns. C: Rchart_get_column_count Returns: a heatmap's columns
  • const method Cell(const ARow: int32; const AColumn: int32; const AValue: float32): self: The value of a heatmap's cell at ARow, AColumn. C: Rchart_set_cell Parameters: ARow the row, from 0; AColumn the column, from 0; AValue the value. Returns: this object, so calls chain
  • const method Cell(const ARow: int32; const AColumn: int32): float32: What Cell(..) sets, read back. C: Rchart_get_cell Parameters: ARow the row, from 0; AColumn the column, from 0. Returns: the value of a heatmap's cell at ARow, AColumn
  • const 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: ALabels the labels. Returns: this object, so calls chain
  • const 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: ALabels the labels. Returns: this object, so calls chain
  • const method RowLabel(const AIndex: int32): string: The label of a heatmap's row AIndex ("": none). C: Rchart_get_row_label Parameters: AIndex the index, from 0. Returns: the label of a heatmap's row AIndex ("": none)
  • const method ColumnLabel(const AIndex: int32): string: The label of a heatmap's column AIndex ("": none). C: Rchart_get_column_label Parameters: AIndex the index, from 0. Returns: the label of a heatmap's column AIndex ("": none)
  • const method ColorScale(const ALow: UIColor; const AHigh: UIColor): self: A heatmap's colours: ALow for its smallest value, AHigh for its largest. C: Rchart_set_color_scale Parameters: ALow the colour for the smallest value; AHigh the colour for the largest value. Returns: this object, so calls chain
  • const method OnCellClick(const AFunc: UICellFunc): self: Runs AFunc with the cell's row, column and value when the user clicks a heatmap cell. C: Rchart_set_cell_clicked_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method Values(const AValues: array of float32): self: A sparkline's values, replacing the ones it had (copied). C: Rchart_set_values Parameters: AValues the values. Returns: this object, so calls chain
  • const method Push(const AValue: float32; const AMaxCount: int32): self: AValue added after a sparkline's values, the oldest leaving past AMaxCount (0: no limit). C: Rchart_push_value Parameters: AValue the value; AMaxCount the max count. Returns: this object, so calls chain
  • const method ValueCount(): int32: The values a sparkline has. C: Rchart_get_value_count Returns: the values a sparkline has
  • const method ValueAt(const AIndex: int32): float32: A sparkline's value AIndex (from 0, the oldest). C: Rchart_get_value_at Parameters: AIndex the index, from 0. Returns: a sparkline's value AIndex (from 0, the oldest)
  • const method Fill(const AOn: bool): self: The area under a sparkline filled (AOn). C: Rchart_set_fill Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Marker(const AOn: bool): self: A marker on a sparkline's last value (AOn). C: Rchart_set_marker Parameters: AOn true to turn it on, false to 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

text
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, empty
  • static method Kinds(): UIWidgetKinds: The kind a PDF view views. Returns: the kind a PDF view views
  • static method Available(): bool: true when PDFium was found: PDF views can show documents and PDFs can be printed on Windows. C: Rpdf_is_available Returns: true when PDFium was found: PDF views can show documents and PDFs can be printed on Windows
  • const method LoadFile(const APath: string): bool: The PDF file APath shown (read through Adam's streams). C: Rpdf_view_load_file Parameters: APath the file's path. Returns: false when it cannot be shown (see Status())
  • const method LoadFile(const APath: string; const APassword: string): bool: The PDF file APath, protected by APassword, shown. C: Rpdf_view_load_file Parameters: APath the file's path; APassword the password. Returns: false when it cannot be shown (see Status())
  • const method LoadMemory(const AData: array of uint8): bool: The PDF in AData shown (copied). C: Rpdf_view_load_memory Parameters: AData the bytes. Returns: false when it cannot be shown (see Status())
  • const method LoadMemory(const AData: array of uint8; const APassword: string): bool: The PDF in AData, protected by APassword, shown (copied). C: Rpdf_view_load_memory Parameters: AData the bytes; APassword the password. Returns: false when it cannot be shown (see Status())
  • const method Close(): self: The document closed: the view is empty. C: Rpdf_view_close Returns: this object, so calls chain
  • const 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 none
  • const method PageCount(): int32: The pages of the document shown. C: Rpdf_view_get_page_count Returns: the pages of the document shown
  • const method PageSize(const APage: int32): UISize: The size of its page APage (from 0) in points (1/72 inch). C: Rpdf_view_get_page_size Parameters: APage the page. Returns: the size of its page APage (from 0) in points (1/72 inch)
  • const method Page(const APage: int32): self: Scrolled to its page APage (from 0). C: Rpdf_view_set_page Parameters: APage the page. Returns: this object, so calls chain
  • const method Page(): int32: The page at the top of the view. C: Rpdf_view_get_page Returns: the page at the top of the view
  • const method Zoom(const AZoom: float32): self: Its zoom (1: the pages at their size; it stops fitting). C: Rpdf_view_set_zoom Parameters: AZoom the zoom. Returns: this object, so calls chain
  • const method Zoom(): float32: What Zoom(..) 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: AFit the fit. Returns: this object, so calls chain
  • const method Fit(): UIPDFFit: What Fit(..) sets, read back. C: Rpdf_view_get_fit Returns: how the pages fit the view: its width, a whole page, or the zoom set
  • const 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 page APage (from 0). C: Rpdf_view_get_page_text Parameters: APage the page. Returns: the text of its page APage (from 0)
  • const method Print(const ADesc: UIPrintDesc): bool: The document shown printed as ADesc says (the job named after its title). Waits until the job is sent. C: Rpdf_view_print Parameters: ADesc the print settings. Returns: false when cancelled or when it cannot print
  • const method OnPageChanged(const AFunc: UIIndexFunc): self: Runs AFunc with the page at the top each time the user scrolls to another. C: Rpdf_view_set_page_changed_callback Parameters: AFunc the 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

text
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 tiles
  • static method Kinds(): UIWidgetKinds: The kind a map views. Returns: the kind a map views
  • const method Center(const ALatitude: float64; const ALongitude: float64): self: The place at its center, at once. C: Rmap_view_set_center Parameters: ALatitude the latitude; ALongitude the longitude. Returns: this object, so calls chain
  • const method Center(): UILatLon: What Center(..) sets, read back. C: Rmap_view_get_center Returns: the place at its center, at once
  • const 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: AZoom the zoom. Returns: this object, so calls chain
  • const method Zoom(): float64: What Zoom(..) 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 range
  • const method ZoomRange(const AMin: float64; const AMax: float64): self: The zooms the user may reach, from AMin to AMax (within 0 .. 24). C: Rmap_view_set_zoom_range Parameters: AMin the lowest value; AMax the highest value. Returns: this object, so calls chain
  • const 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 at AZoom (at once while animations are off). C: Rmap_view_animate_to Parameters: ALatitude the latitude; ALongitude the longitude; AZoom the zoom. Returns: this object, so calls chain
  • const method ScreenToLatLon(const APoint: UIPoint): UILatLon: The place drawn at APoint (the map's own units from its top-left corner). C: Rmap_view_screen_to_latlon Parameters: APoint the point. Returns: the place drawn at APoint (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: ALatitude the latitude; ALongitude the longitude. Returns: where the place is drawn, in the map's own units from its top-left corner
  • const method OnTile(const AFunc: UIMapTileFunc): self: Runs AFunc with 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 with Tile, TileData or TileFailed. C: Rmap_view_set_tile_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnTileCancel(const AFunc: UIMapTileFunc): self: Runs AFunc with a tile asked for that the map no longer wants (moved away before it came). C: Rmap_view_set_tile_cancel_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method Tile(const AZoom: int32; const AX: int32; const AY: int32; const APixels: array of uint8; const AWidth: int32; const AHeight: int32): self: The tile AZoom / AX / AY as AWidth x AHeight RGBA pixels (rows from the top; copied; 1 .. 4096 on a side). C: Rmap_view_set_tile Parameters: AZoom the zoom; AX the x coordinate; AY the y coordinate; APixels the pixels; AWidth the width; AHeight the height. Returns: this object, so calls chain
  • const method TileData(const AZoom: int32; const AX: int32; const AY: int32; const AData: array of uint8): self: The tile AZoom / AX / AY from an image file's bytes (PNG, JPEG ..; decoded). C: Rmap_view_set_tile_data Parameters: AZoom the zoom; AX the x coordinate; AY the y coordinate; AData the bytes. Returns: this object, so calls chain
  • const method TileFailed(const AZoom: int32; const AX: int32; const AY: int32): self: The tile AZoom / AX / AY cannot be had (the map draws a coarser one there). C: Rmap_view_set_tile_failed Parameters: AZoom the zoom; AX the x coordinate; AY the y coordinate. Returns: this object, so calls chain
  • const 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: APath the file's path. Returns: this object, so calls chain
  • const method TilePath(): string: What TilePath(..) 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: ASize the size. Returns: this object, so calls chain
  • const method TileSize(): int32: What TileSize(..) 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: ABytes the bytes. Returns: this object, so calls chain
  • const method CacheUsage(): int64: The bytes its tiles take now. C: Rmap_view_get_cache_usage Returns: the bytes its tiles take now
  • const 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 chain
  • const method TileState(const AZoom: int32; const AX: int32; const AY: int32): UITileState: Where its tile AZoom / AX / AY stands. C: Rmap_view_get_tile_state Parameters: AZoom the zoom; AX the x coordinate; AY the y coordinate. Returns: where its tile AZoom / AX / AY stands
  • const method AddMarker(const ALatitude: float64; const ALongitude: float64; const ALabel: string): UIMapMarker: A new marker at the place, labelled ALabel ("": none). C: Rmap_view_add_marker Parameters: ALatitude the latitude; ALongitude the longitude; ALabel the label. Returns: a new marker at the place, labelled ALabel ("": none)
  • const method ClearMarkers(): self: Every marker removed. C: Rmap_view_clear_markers Returns: this object, so calls chain
  • const method MarkerCount(): int32: The markers it has. C: Rmap_view_get_marker_count Returns: the markers it has
  • const method OnMarkerClick(const AFunc: UIMarkerFunc): self: Runs AFunc with the marker the user clicks. C: Rmap_view_set_marker_clicked_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnViewChanged(const AFunc: UIMapViewFunc): self: Runs AFunc with the map's center and zoom each time the user moves it or a move ends. C: Rmap_view_set_view_changed_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method Attribution(const AText: string): self: The credit written in a corner (the tiles' source: "© OpenStreetMap"; "": none). C: Rmap_view_set_attribution Parameters: AText the text. Returns: this object, so calls chain
  • const method Attribution(): string: What Attribution(..) 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

text
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, titled ATitle ("": no title; the app must be open). C: Rpdf_document_create, Rpdf_document_set_title Parameters: ATitle the title.
  • const method IsValid(): bool: true while it holds a document. Returns: true while it holds a document
  • const method Id(): Rid: The document's Rid, for .C calls (R_INVALID_ID when the handle holds none or it is deleted). Returns: the document's Rid, for .C calls (R_INVALID_ID when 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: ATitle the title. Returns: this object, so calls chain
  • const method Author(const AAuthor: string): self: The author readers show. C: Rpdf_document_set_author Parameters: AAuthor the author. Returns: this object, so calls chain
  • const method Subject(const ASubject: string): self: The subject readers show. C: Rpdf_document_set_subject Parameters: ASubject the subject. Returns: this object, so calls chain
  • const method AddPage(const AWidth: float32; const AHeight: float32): self: A new page AWidth x AHeight points; drawing goes to it. C: Rpdf_document_add_page Parameters: AWidth the width; AHeight the height. Returns: this object, so calls chain
  • const method PageCount(): int32: The pages it has. C: Rpdf_document_get_page_count Returns: the pages it has
  • const method FillColor(const AColor: UIColor): self: The colour shapes are filled and text is written with. C: Rpdf_document_set_fill_color Parameters: AColor the colour. Returns: this object, so calls chain
  • const method StrokeColor(const AColor: UIColor): self: The colour of lines and outlines. C: Rpdf_document_set_stroke_color Parameters: AColor the colour. Returns: this object, so calls chain
  • const method LineWidth(const AWidth: float32): self: The width of lines and outlines, in points (1 at first). C: Rpdf_document_set_line_width Parameters: AWidth the width. Returns: this object, so calls chain
  • const method Rect(const ARect: UIRect; const ARadius: float32; const APaint: UIPDFPaints): self: ARect filled and / or outlined as APaint says, its corners rounded by ARadius. C: Rpdf_document_draw_rect Parameters: ARect the rectangle; ARadius the radius; APaint the paint. Returns: this object, so calls chain
  • const method Ellipse(const ARect: UIRect; const APaint: UIPDFPaints): self: The ellipse inside ARect, filled and / or outlined as APaint says. C: Rpdf_document_draw_ellipse Parameters: ARect the rectangle; APaint the paint. Returns: this object, so calls chain
  • const method Line(const AFrom: UIPoint; const ATo: UIPoint): self: A line from AFrom to ATo in the stroke colour. C: Rpdf_document_draw_line Parameters: AFrom the start point; ATo the end point. Returns: this object, so calls chain
  • const method AddFont(const AData: array of uint8): int32: A TrueType font from AData (copied, embedded in the file). C: Rpdf_document_add_font Parameters: AData the bytes. Returns: its number for Font, -1 when it is not a TrueType font
  • const method AddFontFile(const APath: string): int32: A TrueType font from the file APath (embedded in the document). C: Rpdf_document_add_font_from_file Parameters: APath the file's path. Returns: its number for Font, -1 when it is not a TrueType font
  • const method Font(const AFont: UIPDFFont; const ASize: float32; const AStyle: UIPDFTexts): self: The text written next set in one of Raven's fonts, ASize points, in AStyle. C: Rpdf_document_set_font Parameters: AFont the font; ASize the size; AStyle the style. Returns: this object, so calls chain
  • const method Font(const AFont: int32; const ASize: float32; const AStyle: UIPDFTexts): self: The text written next set in the font AFont added (AddFont), ASize points, in AStyle. C: Rpdf_document_set_font Parameters: AFont the font; ASize the size; AStyle the style. Returns: this object, so calls chain
  • const 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 font
  • const method Measure(const AText: string): float32: The width of AText in the current font, in points (its widest line). C: Rpdf_document_measure_text Parameters: AText the text. Returns: the width of AText in the current font, in points (its widest line)
  • const method Text(const AAt: UIPoint; const AText: string): float32: AText in the fill colour, the top of its first line at AAt ("\n" starts a line below). C: Rpdf_document_draw_text Parameters: AAt the point; AText the text. Returns: its width
  • const method Paragraph(const AAt: UIPoint; const AWidth: float32; const AText: string; const AAlign: UIHAlign): float32: AText wrapped at its spaces to fit AWidth from AAt, each line placed by AAlign. C: Rpdf_document_draw_paragraph Parameters: AAt the point; AWidth the width; AText the text; AAlign the alignment. Returns: the height it took
  • const method Image(const ARect: UIRect; const APixels: array of uint8; const AWidth: int32; const AHeight: int32): self: A picture of AWidth x AHeight RGBA pixels (rows from the top) stretched over ARect (a width or height of 0 keeps its proportions; both 0: 96 pixels per inch). C: Rpdf_document_draw_image Parameters: ARect the rectangle; APixels the pixels; AWidth the width; AHeight the height. Returns: this object, so calls chain
  • const method DrawWindow(const AWindow: UIWindow; const ARect: UIRect): bool: What the window AWindow shows, as a picture over ARect (a size of 0 x 0: its size on the screen). C: Rpdf_document_draw_window Parameters: AWindow the window; ARect the rectangle. Returns: false when the window cannot be captured
  • const method Save(const APath: string): bool: The document written to the file APath. C: Rpdf_document_save Parameters: APath the file's path. Returns: false when it cannot be written
  • const 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 as ADesc says. Waits until the job is sent. C: Rpdf_document_print Parameters: ADesc the print settings. Returns: false when cancelled or when it cannot print
  • static method PrintMemory(const APDF: array of uint8; const ADesc: UIPrintDesc): bool: The PDF in APDF printed as ADesc says (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: APDF the PDF; ADesc the print settings. Returns: false when cancelled or when it cannot print
  • static method PrintFile(const APath: string; const ADesc: UIPrintDesc): bool: The PDF file APath printed as ADesc says. Waits until the job is sent. C: Rpdf_print_file Parameters: APath the file's path; ADesc the print settings. Returns: false when 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

text
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

text
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

text
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

text
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 id ATrack on the timeline ATimeline (a Rid). Parameters: ATimeline the timeline; ATrack the track. Returns: the track with the id ATrack on the timeline ATimeline (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: true when it names a track (Raven gives 0 for none). Returns: true when 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: AName the name. Returns: this object, so calls chain
  • const method Name(): string: What Name(..) sets, read back. C: Rtimeline_get_track_name Returns: the name shown in its header
  • const method Color(const AColor: UIColor): self: The colour of its clips (AColor's alpha is not used). C: Rtimeline_set_track_color Parameters: AColor the colour. Returns: this object, so calls chain
  • const method Height(const AHeight: float32): self: Its height in logical units (the timeline's default until set). C: Rtimeline_set_track_height Parameters: AHeight the height. Returns: this object, so calls chain
  • const method Locked(const AOn: bool): self: true: the user cannot move, stretch or delete its items. C: Rtimeline_set_track_locked Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Muted(const AOn: bool): self: true: shown muted (its clips dimmed). C: Rtimeline_set_track_muted Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Muted(): bool: What Muted(..) sets, read back. C: Rtimeline_is_track_muted Returns: true when Muted(..) turned it on
  • const 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); false when the name or the value is not one. C: Rtimeline_set_track_style Parameters: AProperty the property; AValue the text. Returns: true when it was set
  • const method Remove(): The track removed with its items. C: Rtimeline_remove_track

UITimelineItem

text
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 id AItem on the timeline ATimeline (a Rid). Parameters: ATimeline the timeline; AItem the item. Returns: the item with the id AItem on the timeline ATimeline (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: true when it names an item (Raven gives 0 for none). Returns: true when 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 marker
  • const 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 seconds
  • const 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 track ATrack from AStart for ALength seconds (a key or a marker takes no length). C: Rtimeline_set_item Parameters: ATrack the track; AStart the start; ALength the length. Returns: this object, so calls chain
  • const method Label(const ALabel: string): self: The text shown on it. C: Rtimeline_set_item_label Parameters: ALabel the label. Returns: this object, so calls chain
  • const method Label(): string: What Label(..) sets, read back. C: Rtimeline_get_item_label Returns: the text shown on it
  • const method Color(const AColor: UIColor): self: Its own colour (AColor's alpha is not used). C: Rtimeline_set_item_color Parameters: AColor the colour. Returns: this object, so calls chain
  • const method Style(const AProperty: string; const AValue: string): bool: One style property of the item, as UITrack.Style. C: Rtimeline_set_item_style Parameters: AProperty the property; AValue the text. Returns: true when it was set
  • const method Select(const AAdd: bool): self: The item selected; AAdd keeps the others selected. C: Rtimeline_select Parameters: AAdd true to keep the others selected. Returns: this object, so calls chain
  • const method Selected(): bool: True while the item is selected. C: Rtimeline_is_selected Returns: true when it is selected
  • const method Remove(): The item removed. C: Rtimeline_remove_item

UIGraphNode

text
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 id ANode on the graph AGraph (a Rid). Parameters: AGraph the graph; ANode the node. Returns: the node with the id ANode on the graph AGraph (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: true when it names a node (Raven gives 0 for none). Returns: true when 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: ATitle the title. Returns: this object, so calls chain
  • const method Title(): string: What Title(..) sets, read back. C: Rnode_graph_get_node_title Returns: the text in its header
  • const method Position(const APosition: UIPoint): self: Where its top left stands, in canvas units. C: Rnode_graph_set_node_position Parameters: APosition the position. Returns: this object, so calls chain
  • const method Position(): UIPoint: What Position(..) sets, read back. C: Rnode_graph_get_node_position Returns: where its top left stands, in canvas units
  • const 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: AColor the colour. Returns: this object, so calls chain
  • const 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); false when the name or the value is not one. C: Rnode_graph_set_node_style Parameters: AProperty the property; AValue the text. Returns: true when it was set
  • const 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: AWidget the widget. Returns: this object, so calls chain
  • const method Content(): UIWidget: What Content(..) 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: AName the name. Returns: this object, so calls chain
  • const method Name(): string: What Name(..) 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: AData the user data. Returns: this object, so calls chain
  • const method UserData(): ptr: What UserData(..) 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; AAdd keeps the others selected. C: Rnode_graph_select_node Parameters: AAdd true to keep the others selected. Returns: this object, so calls chain
  • const method Selected(): bool: True while the node is selected. C: Rnode_graph_is_node_selected Returns: true when it is selected
  • const method Active(const AOn: bool): self: true: drawn as running (its outline lit). C: Rnode_graph_set_node_active Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const 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: AColor the colour. Returns: this object, so calls chain
  • const 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: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const 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 chain
  • const method Badge(const AText: string): self: A short text in a chip on its header ("": none). C: Rnode_graph_set_node_badge Parameters: AText the text. Returns: this object, so calls chain
  • const 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: AColor the colour. Returns: this object, so calls chain
  • const method Remove(): The node removed with its pins and links. C: Rnode_graph_remove_node
  • const method Icon(const ATexture: UITextureRes): self: ATexture as 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: ATexture the texture. Returns: this object, so calls chain

UIGraphPin

text
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 id APin on the graph AGraph (a Rid). Parameters: AGraph the graph; APin the pin. Returns: the pin with the id APin on the graph AGraph (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: true when it names a pin (Raven gives 0 for none). Returns: true when 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 to
  • const method IsOutput(): bool: true for an output pin. C: Rnode_graph_is_pin_output Returns: true for an output pin
  • const method Label(): string: The text beside it. C: Rnode_graph_get_pin_label Returns: the text beside it
  • const 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: AName the name. Returns: this object, so calls chain
  • const method Position(): UIPoint: Where it is drawn, in canvas units. C: Rnode_graph_get_pin_position Returns: where it is drawn, in canvas units
  • const method Style(const AProperty: string; const AValue: string): bool: One style property of the pin, as UIGraphNode.Style. C: Rnode_graph_set_pin_style Parameters: AProperty the property; AValue the text. Returns: true when it was set
  • const method Multiple(const AOn: bool): self: true: an input taking more than one link. C: Rnode_graph_set_pin_multiple Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Tag(const AText: string): self: A short text in a chip beside it ("": none; UINodeGraph.TagAt finds it). C: Rnode_graph_set_pin_tag Parameters: AText the text. Returns: this object, so calls chain
  • const method TagLit(const AOn: bool): self: true: its tag drawn lit. C: Rnode_graph_set_pin_tag_lit Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const 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: AEmphasis the emphasis. Returns: this object, so calls chain
  • const method Remove(): The pin removed with its links. C: Rnode_graph_remove_pin
text
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 id ALink on the graph AGraph (a Rid). Parameters: AGraph the graph; ALink the link. Returns: the link with the id ALink on the graph AGraph (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: true when it names a link (Raven gives 0 for none: pins that cannot be linked). Returns: true when 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 from
  • const method Input(): UIGraphPin: The input pin it arrives at. C: Rnode_graph_get_link_input Returns: the input pin it arrives at
  • const 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 chain
  • const 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: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Disconnect(): The link removed. C: Rnode_graph_disconnect

UIBlock

text
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 id ABlock in the editor AEditor (a Rid). Parameters: AEditor the editor; ABlock the block. Returns: the block with the id ABlock in the editor AEditor (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: true when it names a block (Raven gives 0 for none). Returns: true when 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 mouth AMouth (none when empty). C: Rblock_editor_get_body Parameters: AMouth the mouth. Returns: the first block in its mouth AMouth (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 has
  • const method Input(const ASlot: int32): UIBlock: The value block in its slot ASlot (none when the slot holds a typed value). C: Rblock_editor_get_input Parameters: ASlot the slot. Returns: the value block in its slot ASlot (none when the slot holds a typed value)
  • const method Value(const ASlot: int32; const AValue: string): self: The typed value of its slot ASlot. C: Rblock_editor_set_value Parameters: ASlot the slot; AValue the text. Returns: this object, so calls chain
  • const method Value(const ASlot: int32): string: What Value(..) sets, read back. C: Rblock_editor_get_value Parameters: ASlot the slot. Returns: the typed value of its slot ASlot
  • const method Parent(): UIBlock: The block it hangs from (none at a script's top); Spot says where. C: Rblock_editor_get_parent Returns: the block it hangs from (none at a script's top); Spot says where
  • const 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 units
  • const method Glow(const AOn: bool): self: true: drawn running (a halo breathes around it). C: Rblock_editor_set_block_glow Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Deletable(const AOn: bool): self: false: the user cannot delete it. C: Rblock_editor_set_block_deletable Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Select(const AAdd: bool): self: The block selected; AAdd keeps the others selected. C: Rblock_editor_select Parameters: AAdd true to keep the others selected. Returns: this object, so calls chain
  • const method Attach(const ATarget: UIBlock; const APart: UIBlockPart; const AIndex: int32): bool: The block (with what hangs under it) put at APart / AIndex of ATarget; false when it does not fit there. C: Rblock_editor_attach Parameters: ATarget the target; APart the part; AIndex the index, from 0. Returns: true when it was attached
  • const method Detach(const AAt: UIPoint): self: The block (with what hangs under it) taken out: a script of its own at AAt (canvas units). C: Rblock_editor_detach Parameters: AAt the point. Returns: this object, so calls chain
  • const method Remove(): The block removed with what hangs under it. C: Rblock_editor_remove_block

UIDockPanel

text
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 panel APanel (its widget's Rid) of the area AArea (a Rid). Parameters: AArea the area; APanel the panel. Returns: the panel APanel (its widget's Rid) of the area AArea (a Rid)
  • const method IsValid(): bool: true when it names a panel. Returns: true when it names a panel
  • const 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 side ASide of ARelative (an empty UIWidget(): of the whole area), ASize its share (0 .. 1). C: Rdock_area_move_panel Parameters: ASide the side; ARelative the widget it docks beside; ASize the size. Returns: this object, so calls chain
  • const method Title(const ATitle: string): self: The text of its tab. C: Rdock_area_set_panel_title Parameters: ATitle the title. Returns: this object, so calls chain
  • const method Closable(const AOn: bool): self: false: its tab has no close button. C: Rdock_area_set_panel_closable Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Close(): The panel closed as the user's close button does (deleted, or hidden with UIDockArea.CloseHides). C: Rdock_area_close_panel
  • const method Hide(): self: The panel taken out of the layout, kept for Open. C: Rdock_area_hide_panel Returns: this object, so calls chain
  • const method Open(): self: A hidden panel put back where it was. C: Rdock_area_open_panel Returns: this object, so calls chain
  • const method IsOpen(): bool: true while it is in the layout (not hidden). C: Rdock_area_is_panel_open Returns: true while 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 chain
  • const method Shown(): bool: true while its tab is the one in front. C: Rdock_area_is_panel_shown Returns: true while its tab is the one in front
  • const method Float(const AX: int32; const AY: int32): UIWindow: The panel floated at AX, AY (native mode: the screen; in-window mode: the window, logical units); the window it is in now. C: Rdock_area_float_panel Parameters: AX the x coordinate; AY the y coordinate. Returns: the panel floated at AX, AY (native mode: the screen; in-window mode: the window, logical units); the window it is in now
  • const method Dock(): self: A floating panel put back where it was in the area. C: Rdock_area_dock_panel Returns: this object, so calls chain
  • const 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 of ATexture as 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: ATexture the texture. Returns: this object, so calls chain
  • const method Icon(const ATexture: UITextureRes; const AUVMin: UIPoint; const AUVMax: UIPoint; const ATint: bool): self: A part of ATexture as 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; ATint true: the texture is a mask drawn in the text colour. C: Rdock_area_set_panel_icon Parameters: ATexture the texture; AUVMin the lowest texture coordinates (0 .. 1); AUVMax the highest texture coordinates (0 .. 1); ATint the tint colour. Returns: this object, so calls chain

UIPlayheadFunc

text
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

text
type UITimelineItemFunc = ref func(const AItem: UITimelineItem)

What a UITimeline's item events run: the item (OnSelect: the item just clicked, or none).

UIGraphConnectFunc

text
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

text
type UIGraphLinkFunc = ref func(const ALink: UIGraphLink)

What UINodeGraph.OnLinked / OnUnlinked run: the link (an unlinked one's pins can still be read).

UIGraphNodeFunc

text
type UIGraphNodeFunc = ref func(const ANode: UIGraphNode)

What a UINodeGraph's node events run: the node (OnSelect: the node just clicked, or none).

UIGraphContextFunc

text
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

text
type UIGraphPinFunc = ref func(const APin: UIGraphPin; const AAt: UIPoint)

What UINodeGraph.OnWireDropped / OnPinClick run: the pin and the point, in canvas units.

UICanvasPointFunc

text
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

text
type UIBlockFunc = ref func(const ABlock: UIBlock)

What a UIBlockEditor's block events run: the block.

UIBlockContextFunc

text
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

text
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

text
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

text
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 tracks
  • static method Kinds(): UIWidgetKinds: The kind a timeline views. Returns: the kind a timeline views
  • const method Duration(const ASeconds: float64): self: How long it runs, in seconds. C: Rtimeline_set_duration Parameters: ASeconds the time, in seconds. Returns: this object, so calls chain
  • const method Duration(): float64: What Duration(..) sets, read back. C: Rtimeline_get_duration Returns: how long it runs, in seconds
  • const method Time(const ASeconds: float64): self: Where the playhead stands, in seconds (no closure is told). C: Rtimeline_set_time Parameters: ASeconds the time, in seconds. Returns: this object, so calls chain
  • const method Time(): float64: What Time(..) 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: AFramesPerSecond the frames per second. Returns: this object, so calls chain
  • const method FrameRate(): float64: What FrameRate(..) sets, read back. C: Rtimeline_get_frame_rate Returns: the frames per second its ruler and snapping count in
  • const 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: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method View(const ASpan: UITimeSpan): self: The span shown, in seconds. C: Rtimeline_set_view Parameters: ASpan the span. Returns: this object, so calls chain
  • const method View(): UITimeSpan: What View(..) sets, read back. C: Rtimeline_get_view Returns: the span shown, in seconds
  • const method Playing(const AOn: bool): self: true: the playhead runs by itself. C: Rtimeline_set_playing Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Playing(): bool: What Playing(..) sets, read back. C: Rtimeline_is_playing Returns: true when Playing(..) turned it on
  • const method Loop(const AOn: bool): self: true: playing goes back to the start at the end. C: Rtimeline_set_loop Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method HeaderWidth(const AWidth: float32): self: The width of the track-name column, in logical units. C: Rtimeline_set_header_width Parameters: AWidth the width. Returns: this object, so calls chain
  • const 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: AHeight the height. Returns: this object, so calls chain
  • const method RulerHeight(): float32: What RulerHeight(..) sets, read back. C: Rtimeline_get_ruler_height Returns: the height of the time ruler, in logical units
  • const method DefaultTrackHeight(const AHeight: float32): self: The height a track has until its own is set. C: Rtimeline_set_default_track_height Parameters: AHeight the height. Returns: this object, so calls chain
  • const method DefaultTrackHeight(): float32: What DefaultTrackHeight(..) sets, read back. C: Rtimeline_get_default_track_height Returns: the height a track has until its own is set
  • const method Preset(const APreset: UIPreset): self: The look it is drawn with. C: Rtimeline_set_preset Parameters: APreset the preset. Returns: this object, so calls chain
  • const method Preset(): UIPreset: What Preset(..) sets, read back. C: Rtimeline_get_preset Returns: the look it is drawn with
  • const method AddTrack(const AName: string): UITrack: A new track named AName, under the others. C: Rtimeline_add_track Parameters: AName the name. Returns: a new track named AName, under the others
  • const method TrackCount(): int32: How many tracks it has. C: Rtimeline_get_track_count Returns: how many tracks it has
  • const method Track(const AIndex: int32): UITrack: Its track AIndex from the top (0 first). C: Rtimeline_get_track Parameters: AIndex the index, from 0. Returns: its track AIndex from the top (0 first)
  • const method AddMarker(const ATime: float64; const ALabel: string): UITimelineItem: A new marker at ATime seconds, labelled ALabel. C: Rtimeline_add_marker Parameters: ATime the time; ALabel the label. Returns: a new marker at ATime seconds, labelled ALabel
  • const method ItemCount(): int32: How many items (clips, keys, markers) it has. C: Rtimeline_get_item_count Returns: how many items (clips, keys, markers) it has
  • const method Item(const AIndex: int32): UITimelineItem: Its item AIndex, in the order they were added (0 first). C: Rtimeline_get_item Parameters: AIndex the index, from 0. Returns: its item AIndex, 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 chain
  • const method ClearSelection(): self: No item selected. C: Rtimeline_clear_selection Returns: this object, so calls chain
  • const method SelectionCount(): int32: How many items are selected. C: Rtimeline_get_selection_count Returns: how many items are selected
  • const method Selected(const AIndex: int32): UITimelineItem: Its selected item AIndex (0 first). C: Rtimeline_get_selected Parameters: AIndex the index, from 0. Returns: its selected item AIndex (0 first)
  • const method OnTime(const AFunc: UIPlayheadFunc): self: Runs AFunc with the playhead's time as the user scrubs it or it plays. C: Rtimeline_set_time_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnChanged(const AFunc: UITimelineItemFunc): self: Runs AFunc with each item the user moves, stretches or retimes, as it happens. C: Rtimeline_set_changed_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnSelect(const AFunc: UITimelineItemFunc): self: Runs AFunc when the selection changes, with the item just clicked (or none). C: Rtimeline_set_selection_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnActivate(const AFunc: UITimelineItemFunc): self: Runs AFunc with an item the user double-clicks. C: Rtimeline_set_activated_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnRemoved(const AFunc: UITimelineItemFunc): self: Runs AFunc with an item the user deletes (the Delete key), before it goes; without it the Delete key does nothing. C: Rtimeline_set_removed_callback Parameters: AFunc the 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

text
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 nodes
  • static method Kinds(): UIWidgetKinds: The kind a node graph views. Returns: the kind a node graph views
  • const method AddNode(const ATitle: string; const AAt: UIPoint): UIGraphNode: A new node titled ATitle with its top left at AAt (canvas units). C: Rnode_graph_add_node Parameters: ATitle the title; AAt the point. Returns: a new node titled ATitle with its top left at AAt (canvas units)
  • const method Clear(): self: Every node and link removed. C: Rnode_graph_clear Returns: this object, so calls chain
  • const method NodeCount(): int32: How many nodes it has. C: Rnode_graph_get_node_count Returns: how many nodes it has
  • const method Node(const AIndex: int32): UIGraphNode: Its node AIndex, in the order they were added (0 first). C: Rnode_graph_get_node Parameters: AIndex the index, from 0. Returns: its node AIndex, in the order they were added (0 first)
  • const method FindNode(const AName: string): UIGraphNode: Its node named AName (none when it has no such node). C: Rnode_graph_find_node Parameters: AName the name. Returns: its node named AName (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 type AType (AColor's alpha is not used). C: Rnode_graph_set_type_color Parameters: AType the type; AColor the colour. Returns: this object, so calls chain
  • const method TypeStyle(const AType: string; const AProperty: string; const AValue: string): bool: One style property of the pins and wires of the type AType, as UIGraphNode.Style. C: Rnode_graph_set_type_style Parameters: AType the type; AProperty the property; AValue the text. Returns: true when it was set
  • const method Connect(const AOutput: UIGraphPin; const AInput: UIGraphPin): UIGraphLink: A new link from the output AOutput to the input AInput (none when they cannot be linked: two inputs, types that differ; no closure is told). C: Rnode_graph_connect Parameters: AOutput the output; AInput the input. Returns: a new link from the output AOutput to the input AInput (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 has
  • const method Link(const AIndex: int32): UIGraphLink: Its link AIndex (0 first). C: Rnode_graph_get_link Parameters: AIndex the index, from 0. Returns: its link AIndex (0 first)
  • const method View(const AView: UICanvasView): self: The canvas point at its center and its zoom. C: Rnode_graph_set_view Parameters: AView the view. Returns: this object, so calls chain
  • const method View(): UICanvasView: What View(..) sets, read back. C: Rnode_graph_get_view Returns: the canvas point at its center and its zoom
  • const method ToCanvas(const APoint: UIPoint): UIPoint: The canvas point under APoint of the widget. C: Rnode_graph_to_canvas Parameters: APoint the point. Returns: the canvas point under APoint of the widget
  • const method FromCanvas(const APoint: UIPoint): UIPoint: The point of the widget the canvas point APoint is drawn at. C: Rnode_graph_from_canvas Parameters: APoint the point. Returns: the point of the widget the canvas point APoint is drawn at
  • const method FrameAll(): self: The view moved and zoomed to show every node. C: Rnode_graph_frame_all Returns: this object, so calls chain
  • const method GridVisible(const AOn: bool): self: false: no grid drawn behind the nodes. C: Rnode_graph_set_grid_visible Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method FlowVisible(const AOn: bool): self: true: dots run along the wires (data flowing). C: Rnode_graph_set_flow_visible Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const 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: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Preset(const APreset: UIPreset): self: The look it is drawn with. C: Rnode_graph_set_preset Parameters: APreset the preset. Returns: this object, so calls chain
  • const method Preset(): UIPreset: What Preset(..) sets, read back. C: Rnode_graph_get_preset Returns: the look it is drawn with
  • const 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: AWidth the width. Returns: this object, so calls chain
  • const method PinLabelWidth(): float32: What PinLabelWidth(..) 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 chain
  • const method SelectionCount(): int32: How many nodes are selected. C: Rnode_graph_get_selection_count Returns: how many nodes are selected
  • const method SelectedNode(const AIndex: int32): UIGraphNode: Its selected node AIndex (0 first). C: Rnode_graph_get_selected_node Parameters: AIndex the index, from 0. Returns: its selected node AIndex (0 first)
  • const method NodeAt(const APoint: UIPoint): UIGraphNode: The node under APoint of the widget (none). C: Rnode_graph_get_node_at Parameters: APoint the point. Returns: the node under APoint of the widget (none)
  • const method PinAt(const APoint: UIPoint): UIGraphPin: The pin near APoint of the widget, or whose tag is under it (none). C: Rnode_graph_get_pin_at Parameters: APoint the point. Returns: the pin near APoint of the widget, or whose tag is under it (none)
  • const method LinkAt(const APoint: UIPoint): UIGraphLink: The link under APoint of the widget (none; a hidden link never is). C: Rnode_graph_get_link_at Parameters: APoint the point. Returns: the link under APoint of the widget (none; a hidden link never is)
  • const method TagAt(const APoint: UIPoint): UIGraphPin: The pin whose tag chip is under APoint of the widget (none). C: Rnode_graph_get_tag_at Parameters: APoint the point. Returns: the pin whose tag chip is under APoint of the widget (none)
  • const method OnConnect(const AFunc: UIGraphConnectFunc): self: Runs AFunc when the user is about to link two pins that may be linked: false refuses. C: Rnode_graph_set_connect_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnLinked(const AFunc: UIGraphLinkFunc): self: Runs AFunc with a link the user made. C: Rnode_graph_set_linked_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnUnlinked(const AFunc: UIGraphLinkFunc): self: Runs AFunc with a link the user removes, before it goes. C: Rnode_graph_set_unlinked_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnMoved(const AFunc: UIGraphNodeFunc): self: Runs AFunc with each node the user moved, when the button is released. C: Rnode_graph_set_moved_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnSelect(const AFunc: UIGraphNodeFunc): self: Runs AFunc when the selection changes, with the node just clicked (or none). C: Rnode_graph_set_selection_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnRemoved(const AFunc: UIGraphNodeFunc): self: Runs AFunc with 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: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnActivate(const AFunc: UIGraphNodeFunc): self: Runs AFunc with a node the user double-clicks. C: Rnode_graph_set_activated_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnContext(const AFunc: UIGraphContextFunc): self: Runs AFunc on a right click; without it the right button does nothing. C: Rnode_graph_set_context_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnCanvasActivate(const AFunc: UICanvasPointFunc): self: Runs AFunc on a double click on the empty canvas; without it that frames every node. C: Rnode_graph_set_canvas_activated_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnWireDropped(const AFunc: UIGraphPinFunc): self: Runs AFunc when 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: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnPinClick(const AFunc: UIGraphPinFunc): self: Runs AFunc with 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: AFunc the 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

text
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 scripts
  • static method Kinds(): UIWidgetKinds: The kind a block editor views. Returns: the kind a block editor views
  • const method AddKind(const AName: string; const ALabel: string; const AShape: UIBlockShape; const ACategory: string): int32: A new kind of block named AName, with its block in the palette's category ACategory; ALabel is 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: AName the name; ALabel the label; AShape the shape; ACategory the category. Returns: a new kind of block named AName, with its block in the palette's category ACategory; ALabel is 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 category ACategory (AColor's alpha is not used). C: Rblock_editor_set_category_color Parameters: ACategory the category; AColor the colour. Returns: this object, so calls chain
  • const method PaletteVisible(const AOn: bool): self: false: no palette shown (the program adds every block). C: Rblock_editor_set_palette_visible Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method KindVisible(const AKind: string; const AOn: bool): self: false: the kind AKind's block left out of the palette. C: Rblock_editor_set_kind_visible Parameters: AKind the kind; AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method KindLabel(const AKind: string; const ALabel: string): bool: A new label for the kind AKind (its blocks keep the values of the slots still there); false when there is no such kind. C: Rblock_editor_set_kind_label Parameters: AKind the kind; ALabel the label. Returns: true when the label was set
  • const method SlotOptions(const AKind: string; const ASlot: int32; const AOptions: array of string): self: The choices of the %m slot ASlot of the kind AKind (empty: the slot is typed in). C: Rblock_editor_set_slot_options Parameters: AKind the kind; ASlot the slot; AOptions the options. Returns: this object, so calls chain
  • const method AddBlock(const AKind: string; const AAt: UIPoint): UIBlock: A new block of the kind AKind, the top of a script of its own at AAt (canvas units); none on an error. C: Rblock_editor_add_block Parameters: AKind the kind; AAt the point. Returns: a new block of the kind AKind, the top of a script of its own at AAt (canvas units); none on an error
  • const method Clear(): self: Every script removed. C: Rblock_editor_clear Returns: this object, so calls chain
  • const method ScriptCount(): int32: How many scripts it has. C: Rblock_editor_get_script_count Returns: how many scripts it has
  • const method Script(const AIndex: int32): UIBlock: The top block of its script AIndex (0 first). C: Rblock_editor_get_script Parameters: AIndex the index, from 0. Returns: the top block of its script AIndex (0 first)
  • const method SelectionCount(): int32: How many blocks are selected. C: Rblock_editor_get_selection_count Returns: how many blocks are selected
  • const method Selected(const AIndex: int32): UIBlock: Its selected block AIndex (0 first). C: Rblock_editor_get_selected Parameters: AIndex the index, from 0. Returns: its selected block AIndex (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: AView the view. Returns: this object, so calls chain
  • const method View(): UICanvasView: What View(..) sets, read back. C: Rblock_editor_get_view Returns: the canvas point its view stands at and its zoom
  • const method Save(): string: Every script as text (for Load). C: Rblock_editor_save Returns: every script as text (for Load)
  • const method Load(const AText: string): bool: The scripts replaced by those of AText (from Save); false when it is not such a text. C: Rblock_editor_load Parameters: AText the text. Returns: true when the scripts were loaded
  • const method OnChanged(const AFunc: UIBlockFunc): self: Runs AFunc each time the user changes a script, with the block changed. C: Rblock_editor_set_changed_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnClick(const AFunc: UIBlockFunc): self: Runs AFunc with a block the user clicks (to run its script). C: Rblock_editor_set_clicked_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnContext(const AFunc: UIBlockContextFunc): self: Runs AFunc on a right click. C: Rblock_editor_set_context_callback Parameters: AFunc the 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

text
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 area
  • static method Kinds(): UIWidgetKinds: The kind a dock area views. Returns: the kind a dock area views
  • const method AddPanel(const AWidget: UIWidget; const ATitle: string; const ASide: UIDockSide; const ARelative: UIWidget; const ASize: float32): UIDockPanel: AWidget docked as a panel titled ATitle at the side ASide of ARelative (an empty UIWidget(): of the whole area; with UIDockSide.Tab, a tab beside it), ASize its share (0 .. 1). C: Rdock_area_add_panel Parameters: AWidget the widget; ATitle the title; ASide the side; ARelative the widget it docks beside; ASize the size. Returns: AWidget docked as a panel titled ATitle at the side ASide of ARelative (an empty UIWidget(): of the whole area; with UIDockSide.Tab, a tab beside it), ASize its share (0 .
  • const method Panel(const AWidget: UIWidget): UIDockPanel: The panel AWidget (one docked here). Parameters: AWidget the widget. Returns: the panel AWidget (one docked here)
  • const method CloseHides(const AOn: bool): self: true: a tab's close button hides its panel (UIDockPanel.Open brings it back) instead of deleting it. C: Rdock_area_set_close_hides Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Movable(const AOn: bool): self: false: the user cannot drag its panels elsewhere. C: Rdock_area_set_movable Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Tearable(const AOn: bool): self: true: a panel dragged out of the area floats. C: Rdock_area_set_tearable Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Tearable(): bool: What Tearable(..) sets, read back. C: Rdock_area_is_tearable Returns: true when Tearable(..) turned it on
  • const 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: AMode the mode. Returns: this object, so calls chain
  • const 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 as ALayout (from SaveLayout); false when it is not such a text. C: Rdock_area_load_layout Parameters: ALayout the layout. Returns: true when the layout was applied
  • const method OnClose(const AFunc: UIDockCloseFunc): self: Runs AFunc when the user closes a panel, before it goes: false keeps it. C: Rdock_area_set_close_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain
  • const method OnChanged(const AFunc: UITaskFunc): self: Runs AFunc after the user moves, resizes, shows or closes a panel. C: Rdock_area_set_changed_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain

Example: LDock := UIDockArea.Create(); LDock.AddPanel(LFiles, "Files", UIDockSide.Left, UIWidget(), 0.25f);

UIIsland

text
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 island
  • static method Kinds(): UIWidgetKinds: The kind an island views. Returns: the kind an island views
  • const method Expanded(const AOn: bool): self: Unfolded (true) or folded (no closure is told). C: Risland_set_expanded Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Expanded(): bool: What Expanded(..) sets, read back. C: Risland_is_expanded Returns: true when Expanded(..) turned it on
  • const method ExpandFor(const ASeconds: float64): self: Unfolded for ASeconds, then folded again. C: Risland_expand_for Parameters: ASeconds the time, in seconds. Returns: this object, so calls chain
  • const method ExpandOnHover(const AOn: bool): self: true: it unfolds while the pointer is over it. C: Risland_set_expand_on_hover Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method ExpandOnClick(const AOn: bool): self: true: a click unfolds or folds it. C: Risland_set_expand_on_click Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Attached(const AOn: bool): self: true: drawn attached to the top edge of its window. C: Risland_set_attached Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Notch(const AOn: bool): self: true: it goes into the screen's camera housing when there is one. C: Risland_set_notch Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const method Notch(): bool: What Notch(..) sets, read back. C: Risland_get_notch Returns: true when Notch(..) turned it on
  • const method InNotch(): bool: true while it is in the screen's camera housing. C: Risland_is_in_notch Returns: true while it is in the screen's camera housing
  • const method OnChanged(const AFunc: UIToggleFunc): self: Runs AFunc when the user unfolds or folds it: whether it is unfolded now. C: Risland_set_changed_callback Parameters: AFunc the func it runs. Returns: this object, so calls chain

UIHeaderBar

text
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 titled ATitle, with every button. C: Rheader_bar_create Parameters: ATitle the title. Returns: a new header bar titled ATitle, with every button
  • static method Kinds(): UIWidgetKinds: The kind a header bar views. Returns: the kind a header bar views
  • const method Title(const ATitle: string): self: Its title. C: Rheader_bar_set_title Parameters: ATitle the title. Returns: this object, so calls chain
  • const method Buttons(const AButtons: UIHeaderButtons): self: The window buttons it shows. C: Rheader_bar_set_buttons Parameters: AButtons the buttons. Returns: this object, so calls chain
  • const 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: ASide the side. Returns: this object, so calls chain
  • const method TitleAlign(const AAlign: UIHAlign): self: Where its title stands. C: Rheader_bar_set_title_align Parameters: AAlign the alignment. Returns: this object, so calls chain
  • const method TitleNotch(const AOn: bool): self: true: its title kept clear of the screen's camera housing. C: Rheader_bar_set_title_notch Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • const 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: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain

UIBackgroundBlur

text
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 style
  • static method Kinds(): UIWidgetKinds: The kind a background blur views. Returns: the kind a background blur views
  • const method Style(const AStyle: UIBlurStyle): self: How it blurs. C: Rbackground_blur_set_style Parameters: AStyle the style. Returns: this object, so calls chain
  • const method Style(): UIBlurStyle: What Style(..) sets, read back. C: Rbackground_blur_get_style Returns: how it blurs
  • const method Radius(const ARadius: float32): self: The blur's radius, in logical units. C: Rbackground_blur_set_radius Parameters: ARadius the radius. Returns: this object, so calls chain
  • const method Radius(): float32: What Radius(..) sets, read back. C: Rbackground_blur_get_radius Returns: the blur's radius, in logical units
  • const method Tint(const AColor: UIColor): self: The colour laid over the blur. C: Rbackground_blur_set_tint Parameters: AColor the colour. Returns: this object, so calls chain
  • const method ClearTint(): self: The style's own tint back. C: Rbackground_blur_clear_tint Returns: this object, so calls chain
  • const method Saturation(const ASaturation: float32): self: How saturated what shows through is (1: as it is). C: Rbackground_blur_set_saturation Parameters: ASaturation the saturation. Returns: this object, so calls chain
  • const method Grain(const AGrain: float32): self: How much grain is laid over it (0: none). C: Rbackground_blur_set_grain Parameters: AGrain the grain. Returns: this object, so calls chain
  • const 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: ATopLeft the top-left corner's radius; ATopRight the top-right corner's radius; ABottomRight the bottom-right corner's radius; ABottomLeft the bottom-left corner's radius. Returns: this object, so calls chain
  • const 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: ALeft the room on the left; ATop the room above; ARight the room on the right; ABottom the room below. Returns: this object, so calls chain
  • const method Shadow(const ABlur: float32): self: The blur of the shadow under it (0: none). C: Rbackground_blur_set_shadow Parameters: ABlur the blur radius. Returns: this object, so calls chain

UIActionFunc

text
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

text
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

text
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

text
type UILocaleFunc = ref func(const ALanguage: string)

The language Raven's texts are in now (UILocale.OnChanged).

UIScriptLogFunc

text
type UIScriptLogFunc = ref func(const AText: string)

A line a script logged (UIScript.OnLog).

UIScriptDiagnosticFunc

text
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

text
type UITrayClickFunc = ref func(const AButton: UIPointerButton)

A tray icon clicked with AButton (UITrayRes.OnClick).

UIActionContext

text
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 as AContext (the layer's trampoline builds it). Parameters: AContext the context. Returns: the context Raven hands an action's callback as AContext (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 name
  • const method ArgCount(): int32: How many arguments it was given. C: Raction_get_argument_count Returns: how many arguments it was given
  • const method Number(const AIndex: int32): float64: Argument AIndex (from 0) as a number. C: Raction_get_number Parameters: AIndex the index, from 0. Returns: argument AIndex (from 0) as a number
  • const method Text(const AIndex: int32): string: Argument AIndex (from 0) as text. C: Raction_get_string Parameters: AIndex the index, from 0. Returns: argument AIndex (from 0) as text
  • const method Flag(const AIndex: int32): bool: Argument AIndex (from 0) as true / false. C: Raction_get_bool Parameters: AIndex the index, from 0. Returns: the argument as a bool
  • const method Reply(const AValue: float64): The number it gives back (a signature with : number). C: Raction_return_number Parameters: AValue the value.
  • const method Reply(const AText: string): The text it gives back (a signature with : string). C: Raction_return_string Parameters: AText the text.
  • const method Reply(const AValue: bool): The true / false it gives back (a signature with : bool). C: Raction_return_bool Parameters: AValue the value.
  • const method Fail(const AMessage: string): The call failed with AMessage (a script sees an error). C: Raction_fail Parameters: AMessage the message.

Example: UIActions.Bind("app.save", "(path: string): bool", func(const C: UIActionContext) begin C.Reply(Save(C.Text(0))); end);

UIActionCallFunc

text
type UIActionCallFunc = ref func(const AContext: UIActionContext)

The routine answering an action bound with parameters.

UIActions

text
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): AFunc answers the action AName; binding a name again (either way) replaces it. C: Raction_bind Parameters: AName the name; AFunc the func it runs.
  • static method Bind(const AName: string; const ASignature: string; const AFunc: UIActionCallFunc): bool: AFunc answers the action AName with typed parameters and a result, as its ASignature says ("(path: string): bool"); a widget firing it hands what its event gives (a slider's value, a check box's state ..). Parameters: AName the name; ASignature the signature; AFunc the func it runs. Returns: false (the error reported) when the signature is not valid. C: Raction_bind_with_parameters
  • static method BindPrefix(const APrefix: string; const AFunc: UIActionPrefixFunc): AFunc answers every action whose name starts with APrefix and 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 (nil removes it). C: Raction_set_default_handler Parameters: APrefix the prefix; AFunc the func it runs.
  • static method Fallback(const AFunc: UIActionFallbackFunc): AFunc answers every action no binding and no prefix took (nil: none does). C: Raction_set_default_handler Parameters: AFunc the func it runs.
  • static method Unbind(const AName: string): The action AName no longer answered by its binding. C: Raction_unbind Parameters: AName the name.
  • static method Fire(const AName: string; const ASender: UIWidget): Runs the action AName as if ASender fired it (an empty UIWidget(): no sender). C: Raction_fire Parameters: AName the name; ASender the sender.
  • static method Builtins(const AOn: bool): Raven's built-in actions (app.quit, window.close ..) on or off. C: Raction_set_builtins Parameters: AOn true to turn it on, false to turn it off.
  • static method IsBuiltin(const AName: string): bool: true when AName is one of Raven's built-in actions. C: Raction_is_builtin Parameters: AName the name. Returns: true when AName is 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

text
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 file APath. Parameters: APath the file's path. Returns: false (the error reported) when it does not load. C: Rlocale_load_csv
  • static method LoadCSVText(const ACSV: string): bool: Loads (adds) the tables of the CSV text ACSV, as LoadCSV. C: Rlocale_load_csv_from_memory Parameters: ACSV the CSV. Returns: false (the error reported) when it does not load
  • static method Clear(): Every table emptied. C: Rlocale_clear
  • static method Text(const ALanguage: string; const AKey: string; const AText: string): AText as the text of AKey in ALanguage. C: Rlocale_set_text Parameters: ALanguage the language; AKey the key; AText the text.
  • static method Tr(const AKey: string): string: The text of AKey in the language in use (the fallback language's, else the key). C: Rtr Parameters: AKey the key. Returns: the text of AKey in the language in use (the fallback language's, else the key)
  • static method Tr(const AKey: string; const AArgs: StringArray): string: The text of AKey with its {0} {1} .. replaced by AArgs. C: Rtr_format Parameters: AKey the key; AArgs the args. Returns: the text of AKey with its {0} {1} .
  • static method Has(const AKey: string): bool: true when AKey has a text. C: Rtr_exists Parameters: AKey the key. Returns: true when AKey has a text
  • static method Plural(const AKey: string; const ACount: int32): string: The plural form of AKey for ACount (the language's .one / .few / .other .. key), {n} replaced by the count. C: Rtr_plural Parameters: AKey the key; ACount how many. Returns: the plural form of AKey for ACount (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 have
  • static method LanguageAt(const AIndex: int32): string: The code of language AIndex (from 0). C: Rlocale_get_language_at Parameters: AIndex the index, from 0. Returns: the code of language AIndex (from 0)
  • static method Language(const ACode: string): bool: ACode as the language in use; every widget's @key text follows. Parameters: ACode the language code. Returns: false when the tables have no such language. C: Rlocale_set_language
  • static method Language(): string: The code of the language in use. C: Rlocale_get_language Returns: the code of the language in use
  • static method SystemLanguage(): string: The system's language code. C: Rlocale_get_system_language Returns: the system's language code
  • static method FallbackLanguage(const ACode: string): ACode as the language a missing text comes from. C: Rlocale_set_fallback_language Parameters: ACode the language code.
  • static method RTL(): bool: true when the language in use is written right to left. C: Rlocale_is_rtl Returns: true when the language in use is written right to left
  • static method FormatNumber(const AValue: float64; const ADecimals: int32): string: AValue with ADecimals decimals, written the language's way. C: Rlocale_format_number Parameters: AValue the value; ADecimals the decimals. Returns: AValue with ADecimals decimals, written the language's way
  • static method OnChanged(const AFunc: UILocaleFunc): AFunc runs when the language in use changes (nil: none). C: Rlocale_set_changed_callback Parameters: AFunc the func it runs.

Example: UILocale.LoadCSV("res/assets/ui/texts.csv"); UILocale.Language("fr"); LLabel.Text(UILocale.Tr("greeting"));

UIAccessibilitySettings

text
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

text
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 by AScale. C: Raccessibility_set_text_scale Parameters: AScale the scale.
  • static method TextScale(): float32: The scale every text is drawn at. C: Raccessibility_get_text_scale Returns: the scale
  • static method HighContrast(const AOn: bool): High contrast colours on or off. C: Raccessibility_set_high_contrast Parameters: AOn true to turn it on, false to turn it off.
  • static method HighContrast(): bool: True while high contrast colours are on. C: Raccessibility_get_high_contrast Returns: true when they are
  • static method FocusAlwaysVisible(const AOn: bool): The focus ring shown always (true), or only after a key. C: Raccessibility_set_focus_always_visible Parameters: AOn true to turn it on, false to 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: true when it is
  • static method ReduceMotion(const AOn: bool): Animations shortened or left out (true). C: Raccessibility_set_reduce_motion Parameters: AOn true to turn it on, false to turn it off.
  • static method ReduceMotion(): bool: True while animations are shortened or left out. C: Raccessibility_get_reduce_motion Returns: true when they are
  • static method ColorFilter(const AFilter: UIColorFilter): The colour filter every window is drawn through. C: Raccessibility_set_color_filter Parameters: AFilter the filter.
  • static method ColorFilter(): UIColorFilter: The colour filter every window is drawn through. C: Raccessibility_get_color_filter Returns: the filter
  • static method SystemSettings(): UIAccessibilitySettings: The system's own settings. C: Raccessibility_get_system_settings Returns: the system's own settings
  • static method FollowSystem(): The text scale, contrast and motion taken from the system's settings. C: Raccessibility_follow_system
  • static method Announce(const AText: string; const AAssertive: bool): AText said by the screen reader: at once (AAssertive), or after what it says now. C: Raccessibility_announce Parameters: AText the text; AAssertive the assertive.
  • static method ScreenReader(): bool: true while a screen reader runs. C: Raccessibility_is_screen_reader_active Returns: true while a screen reader runs

Example: UIAccessibility.FollowSystem(); UIAccessibility.Announce("Saved", false);

UIScript

text
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 script ASource, named AName in diagnostics ("" for none). Parameters: ASource the source; AName the name. Returns: false when it has an error (nothing of it installed). C: Rscript_load
  • static method LoadFile(const APath: string): bool: Installs the script file APath, as Load. C: Rscript_load_file Parameters: APath the file's path. Returns: false when it has an error (nothing of it installed)
  • static method Check(const ASource: string; const AName: string): int32: Checks the script ASource (or an XML document's scripts: text starting with <) without running or installing anything; its diagnostics are reported. Parameters: ASource the source; AName the name. Returns: the number of errors (0: none). C: Rscript_check
  • static method CheckFile(const APath: string): int32: Checks the script file APath (a .rvs or an .xml), as Check. Parameters: APath the file's path. Returns: the number of errors (0: none), -1 when it cannot be read. C: Rscript_check_file
  • static method Format(const ASource: string; const AIndent: string): string: ASource formatted, AIndent one level of indentation ("": four spaces). C: Rscript_format Parameters: ASource the source; AIndent the indent. Returns: ASource formatted, AIndent one level of indentation ("": four spaces)
  • static method Reset(): Every installed script removed. C: Rscript_reset
  • static method HasFunction(const AName: string): bool: true when an installed script has the function AName. C: Rscript_has_function Parameters: AName the name. Returns: true when an installed script has the function AName
  • static method Enabled(const AOn: bool): Scripts run (true) or are ignored. C: Rscript_set_enabled Parameters: AOn true to turn it on, false to turn it off.
  • static method Enabled(): bool: True while scripts run. C: Rscript_is_enabled Returns: true when they run
  • static 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: AMaxInstructions the max instructions; AMaxDepth the max depth; AMaxMemory the max memory.
  • static method OnLog(const AFunc: UIScriptLogFunc): AFunc gets what scripts log (nil: none). C: Rscript_set_log_callback Parameters: AFunc the func it runs.
  • static method OnDiagnostic(const AFunc: UIScriptDiagnosticFunc): AFunc gets every script diagnostic (nil: none). C: Rscript_set_diagnostic_callback Parameters: AFunc the func it runs.

Example: UIScript.OnDiagnostic(DoReport); if not UIScript.Load(LSource, "main.rs") then return; end;

UILanguageDef

text
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

text
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: Declares ADef (replacing the language of that name); its texts are copied. Parameters: ADef the language definition. Returns: false (the error reported) when it is not valid. C: Rlanguage_register
  • static method Find(const AName: string; var ADef: UILanguageDef): bool: The language AName read into ADef. Parameters: AName the name; ADef the language definition. Returns: false (ADef unchanged) when there is none. C: Rlanguage_get
  • static method Count(): int32: How many languages there are. C: Rlanguage_get_count Returns: how many languages there are
  • static method Name(const AIndex: int32): string: The name of language AIndex (from 0). C: Rlanguage_get_name Parameters: AIndex the index, from 0. Returns: the name of language AIndex (from 0)
  • static method ForFile(const APath: string): string: The language of the file APath by its extension ("" for none). C: Rlanguage_for_file Parameters: APath the file's path. Returns: the language of the file APath by its extension ("" for none)

Example: LDef.Name := "adam"; LDef.Extensions := "adam"; LDef.Keywords := "module func begin end"; UISyntaxLanguage.Register(LDef);

UIFileDialog

text
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 (see init). Returns: a dialog with the defaults (see init)
  • method Parent(const AWindow: UIWindow): self: The window it belongs to (shown over it). Parameters: AWindow the window. Returns: this object, so calls chain
  • method Title(const ATitle: string): self: Its title. Parameters: ATitle the title. Returns: this object, so calls chain
  • method Directory(const APath: string): self: The folder it opens in. Parameters: APath the file's path. Returns: this object, so calls chain
  • method FileName(const AName: string): self: The file name it offers. Parameters: AName the name. Returns: this object, so calls chain
  • method 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: AName the name; APatterns the patterns. Returns: this object, so calls chain
  • method DefaultExtension(const AExtension: string): self: The extension a saved name without one gets ("adam"). Parameters: AExtension the extension. Returns: this object, so calls chain
  • method Flags(const AFlags: UIFileDialogFlags): self: How it opens (several files, Raven's own, hidden files shown). Parameters: AFlags the flags. Returns: this object, so calls chain
  • const method Open(): StringArray: The files to open the user chose (several with UIFileDialogFlag.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 with UIFileDialogFlag.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

text
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 showing AIcon with the tooltip ATooltip (empty when the system has no tray: Supported). C: Rtray_create Parameters: AIcon the icon; ATooltip the tooltip.
  • static method Supported(): bool: true when the system has a tray. C: Rtray_is_supported Returns: true when the system has a tray
  • const method IsValid(): bool: true while the handle holds a tray icon. C: Rtray_is_valid Returns: true while the handle holds a tray icon
  • const method Id(): Rid: The icon's Rid, for .C calls (R_INVALID_ID when the handle holds none). Returns: the icon's Rid, for .C calls (R_INVALID_ID when the handle holds none)
  • const method Icon(const AIcon: UIPixels): self: The picture it shows (pixels as UIWindow.Icon's). C: Rtray_set_icon Parameters: AIcon the icon. Returns: this object, so calls chain
  • const method Tooltip(const AText: string): self: The text shown while the pointer rests on it. C: Rtray_set_tooltip Parameters: AText the text. Returns: this object, so calls chain
  • const method Title(const AText: string): self: The text beside it (where the system shows one). C: Rtray_set_title Parameters: AText the text. Returns: this object, so calls chain
  • const method Menu(const AMenu: UIMenu): self: The menu its click opens (an empty UIMenu(): none). C: Rtray_set_menu Parameters: AMenu the menu. Returns: this object, so calls chain
  • const 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: AFunc runs when it is clicked (nil: none). C: Rtray_set_clicked_callback Parameters: AFunc the 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

text
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 bytes AData (copied) as the file APath, replacing one registered there. Parameters: APath the file's path; AData the bytes. Returns: false (the error reported) when Raven refuses it. C: Rfile_register_memory
  • static method Unregister(const APath: string): The file APath no longer in memory. C: Rfile_unregister_memory Parameters: APath the file's path.
  • static method IsMemory(const APath: string): bool: true when APath is a registered memory file. C: Rfile_is_memory Parameters: APath the file's path. Returns: true when APath is a registered memory file

Example: UIFiles.Register("ui/main.xml", LBytes); UITheme.Load("ui/main.xml");

UIXMLReloadFunc

text
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

text
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

text
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

text
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: APath the file's path.
  • static method ResolvePath(const APath: string): string: Where APath, 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: APath the file's path. Returns: where APath, 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: AOn true to turn it on, false to turn it off.
  • static method AutoLoad(): bool: True while auto-loading is on. C: Rxml_get_auto_load Returns: true when it is on
  • static 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: AOn true to turn it on, false to turn it off.
  • static method LiveReload(): bool: True while live reload is on. C: Rxml_get_live_reload Returns: true when it is on
  • static 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_files
  • static method OnReload(const AFunc: UIXMLReloadFunc): AFunc runs 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: AFunc the func it runs.
  • static method RegisterWidgets(const AXML: string): int32: Reads the <Widget Name=".."> declarations of the XML text AXML (its root, or the children of a <Widgets> root), so the documents loaded afterwards can use their tags. Parameters: AXML the XML text. Returns: the tags declared. C: Rxml_register_widgets
  • static method RegisterWidgetsFile(const APath: string): int32: Reads the declarations of the file APath, as RegisterWidgets. Parameters: APath the file's path. Returns: the tags declared. C: Rxml_register_widgets_from_file
  • static method UnregisterWidget(const AName: string): The declared tag AName forgotten. C: Rxml_unregister_widget Parameters: AName the name.
  • static method WidgetRegistered(const AName: string): bool: true when AName is a declared tag. C: Rxml_is_widget_registered Parameters: AName the name. Returns: true when AName is a declared tag
  • static method RegisteredCount(): int32: The declared tags. C: Rxml_get_registered_widget_count Returns: the declared tags
  • static method RegisteredName(const AIndex: int32): string: The declared tag at AIndex (0 .. RegisteredCount() - 1). C: Rxml_get_registered_widget_name Parameters: AIndex the index, from 0. Returns: the declared tag at AIndex (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/>, ACreate making its widget and AAttribute (nil: none) given each attribute first. A tag registered again is replaced. Parameters: ATag the tag; ACreate the create; AAttribute the attribute. Returns: false when ATag is one of Raven's widgets or 64 tags are registered. C: Rxml_register_tag
  • static method UnregisterTag(const ATag: string): The tag made by code ATag forgotten, its closures let go. C: Rxml_unregister_tag Parameters: ATag the tag.
  • static method TagRegistered(const ATag: string): bool: true when ATag is a tag made by code. C: Rxml_is_tag_registered Parameters: ATag the tag. Returns: true when ATag is a tag made by code
  • static 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 at AIndex (0 .. TagCount() - 1). C: Rxml_get_tag_name Parameters: AIndex the index, from 0. Returns: raven's tag at AIndex (0 .
  • static method TagDescription(const ATag: string): string: One line about the tag ATag ("" when there is nothing to say). C: Rxml_get_tag_description Parameters: ATag the tag. Returns: the line ("" when there is nothing to say)
  • static method TagChildren(const ATag: string): int32: The child widgets ATag takes: 0 none, 1 a single one, 2 any number (a declared or unknown tag: 2). C: Rxml_get_tag_children Parameters: ATag the tag. Returns: the child widgets ATag takes: 0 none, 1 a single one, 2 any number (a declared or unknown tag: 2)
  • static method AttributeCount(const ATag: string): int32: The attributes ATag takes: its own, then every widget's, then its place's in its parent. C: Rxml_get_attribute_count Parameters: ATag the tag. Returns: the attributes ATag takes: its own, then every widget's, then its place's in its parent
  • static method AttributeInfo(const ATag: string; const AIndex: int32; var AInfo: RXmlAttributeInfo): bool: The attribute of ATag at AIndex (0 .. AttributeCount(ATag) - 1) into AInfo (its typed reads: RXmlAttributeInfo's extend). Parameters: ATag the tag; AIndex the index, from 0; AInfo the info. Returns: false for 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

text
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 file APath (the paths it names relative to its folder). C: Rxml_document_load Parameters: APath the file's path.
  • static method Create(const ARootTag: string): UIXMLDocRes: A new document of one element, the tag ARootTag. C: Rxml_document_create Parameters: ARootTag the root tag. Returns: a new document of one element, the tag ARootTag
  • static method Parse(const AXML: string): UIXMLDocRes: The document of the XML text AXML (IsValid() false when it does not read: its error reported to UIErrors). C: Rxml_document_parse Parameters: AXML the XML text. Returns: the document of the XML text AXML (IsValid() false when it does not read: its error reported to UIErrors)
  • static method Parse(const AXML: string; var AError: RXmlError): UIXMLDocRes: The document of the XML text AXML; a mistake in it is described in AError (Message(), line, column) and not reported (IsValid() false). C: Rxml_document_parse Parameters: AXML the XML text; AError the error. Returns: the document of the XML text AXML; a mistake in it is described in AError (Message(), line, column) and not reported (IsValid() false)
  • static method View(const ADoc: Rid): UIXMLDocRes: The document ADoc of System.Raven.C, borrowed (never destroyed by this handle). Parameters: ADoc the doc. Returns: the document ADoc of System.Raven.C, borrowed (never destroyed by this handle)
  • const method IsValid(): bool: true while it holds a document. C: Rxml_document_is_valid Returns: true while it holds a document
  • const method Id(): Rid: The document's Rid, for .C calls (R_INVALID_ID when the handle holds none). Returns: the document's Rid, for .C calls (R_INVALID_ID when the handle holds none)
  • const method Root(): UIXMLNode: Its root element. C: Rxml_document_get_root Returns: its root element
  • const method ToString(): string: The document as text, one element a line, tab-indented (each node's Line() then says where it was written). C: Rxml_document_to_string Returns: the document as text, one element a line, tab-indented (each node's Line() then says where it was written)
  • const method Save(const APath: string): bool: Writes the document to the file APath. Parameters: APath the file's path. Returns: false when it could not be written. C: Rxml_document_save
  • const 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

text
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 as ANode. Parameters: ANode the node. Returns: the handle of the node System.Raven.C gave as ANode
  • const method Id(): Rid: The node's Rid, for System.Raven.C's calls. Returns: the node's Rid, for System.Raven.C's calls
  • const method IsValid(): bool: true while the handle names a node. C: Rxml_node_is_valid Returns: true while the handle names a node
  • const method IsComment(): bool: true for a comment. C: Rxml_node_is_comment Returns: true for a comment
  • const 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: ATag the tag. Returns: this object, so calls chain
  • const 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: AText the text. Returns: this object, so calls chain
  • const method Text(): string: What Text(..) sets, read back. C: Rxml_node_get_text Returns: the text inside the element (<Label>this</Label>), or the comment's
  • const 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 children
  • const method Child(const AIndex: int32): UIXMLNode: Its child at AIndex (0 .. ChildCount() - 1). C: Rxml_node_get_child Parameters: AIndex the index, from 0. Returns: its child at AIndex (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 element ATag, its last child. C: Rxml_node_add_child Parameters: ATag the tag. Returns: a new element ATag, its last child
  • const method AddChild(const ATag: string; const AIndex: int32): UIXMLNode: A new element ATag, its child at AIndex (-1: the end; an empty handle when it would be nested deeper than 256 levels). C: Rxml_node_add_child Parameters: ATag the tag; AIndex the index, from 0. Returns: a new element ATag, its child at AIndex (-1: the end; an empty handle when it would be nested deeper than 256 levels)
  • const method AddComment(const AText: string): UIXMLNode: A new comment AText, its last child. C: Rxml_node_add_comment Parameters: AText the text. Returns: a new comment AText, its last child
  • const method AddComment(const AText: string; const AIndex: int32): UIXMLNode: A new comment AText, its child at AIndex (-1: the end). C: Rxml_node_add_comment Parameters: AText the text; AIndex the index, from 0. Returns: a new comment AText, its child at AIndex (-1: the end)
  • const method AddXML(const AXML: string): UIXMLNode: The element of the XML text AXML (one element and what it holds: a paste, a template), read and added as its last child. C: Rxml_node_add_xml Parameters: AXML the XML text. Returns: the element of the XML text AXML (one element and what it holds: a paste, a template), read and added as its last child
  • const method AddXML(const AXML: string; const AIndex: int32): UIXMLNode: The element of AXML added as its child at AIndex (-1: the end). C: Rxml_node_add_xml Parameters: AXML the XML text; AIndex the index, from 0. Returns: the element of AXML added as its child at AIndex (-1: the end)
  • const method Remove(): Removes the node and what it holds (the root stays). C: Rxml_node_remove
  • const method Move(const AParent: UIXMLNode; const AIndex: int32): bool: Moves the node, with what it holds, under AParent at AIndex (counted once it left its place; -1: the end). Parameters: AParent the parent; AIndex the index, from 0. Returns: false when it cannot be (the root, a parent inside it, too deep). C: Rxml_node_move
  • const 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 it
  • const method ToString(): string: The node as XML text. C: Rxml_node_to_string Returns: the node as XML text
  • const method AttributeCount(): int32: Its attributes. C: Rxml_node_get_attribute_count Returns: its attributes
  • const method AttributeName(const AIndex: int32): string: The name of its attribute at AIndex. C: Rxml_node_get_attribute_name Parameters: AIndex the index, from 0. Returns: the name of its attribute at AIndex
  • const method AttributeValue(const AIndex: int32): string: The value of its attribute at AIndex. C: Rxml_node_get_attribute_value Parameters: AIndex the index, from 0. Returns: the value of its attribute at AIndex
  • const method Attribute(const AName: string; const AValue: string): self: The attribute AName set to AValue (added after the others when new). C: Rxml_node_set_attribute Parameters: AName the name; AValue the text. Returns: this object, so calls chain
  • const method Attribute(const AName: string): string: The value of the attribute AName (names compared without case; "" when it has none: HasAttribute). C: Rxml_node_get_attribute Parameters: AName the name. Returns: the value of the attribute AName (names compared without case; "" when it has none: HasAttribute)
  • const method HasAttribute(const AName: string): bool: true when it has the attribute AName. C: Rxml_node_get_attribute Parameters: AName the name. Returns: true when it has the attribute AName
  • const method RemoveAttribute(const AName: string): self: The attribute AName removed. C: Rxml_node_set_attribute Parameters: AName the name. Returns: this object, so calls chain
  • const 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

text
type UIHostCursorFunc = ref func(const AWindow: UIWindow; const ACursor: UICursor)

The routine giving Raven's window AWindow the cursor ACursor (UICursor.None: hidden).

UIHostClipboardSetFunc

text
type UIHostClipboardSetFunc = ref func(const AText: string)

The routine putting AText on the program's clipboard.

UIHostClipboardGetFunc

text
type UIHostClipboardGetFunc = ref func(): string

The routine giving the program's clipboard text ("" when it holds none).

UIHostWakeFunc

text
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

text
type UIVulkanLockFunc = ref func()

The routine taking (or giving back) the program's lock on the Vulkan queue Raven shares.

UIHostPlatform

text
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: AFunc the func it runs. Returns: this object, so calls chain
  • const 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: AFunc the func it runs. Returns: this object, so calls chain
  • const 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: AFunc the func it runs. Returns: this object, so calls chain
  • const 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: AFunc the func it runs. Returns: this object, so calls chain
  • const 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

text
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 with APlatform's closures. C: Rhost_platform_register Parameters: APlatform the 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_register
  • static method Active(): bool: true while the open app runs on the host platform. C: Rhost_platform_is_active Returns: true while the open app runs on the host platform
  • static method WindowSize(const AWindow: UIWindow; const AWidth: int32; const AHeight: int32; const AScale: float32): AWindow's size, AWidth x AHeight pixels, and its scale (pixels a UI unit). C: Rhost_window_set_size Parameters: AWindow the window; AWidth the width; AHeight the height; AScale the scale.
  • static method Insets(const AWindow: UIWindow; const ASafeArea: RInsets; const AKeyboardHeight: int32): The edges of AWindow system bars and notches cover, and the height the on-screen keyboard covers (0: none). C: Rhost_window_set_insets Parameters: AWindow the window; ASafeArea the safe area; AKeyboardHeight the keyboard height.
  • static method SystemDark(const AOn: bool): true when the system's look is dark (themes following the system follow it). C: Rhost_set_system_dark Parameters: AOn true to turn it on, false to 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 in AWindow. C: Rhost_inject_mouse_move Parameters: AWindow the window; AX the x coordinate; AY the y coordinate; AMods the 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 button AButton went down (APressed) or up at (AX, AY). C: Rhost_inject_mouse_button Parameters: AWindow the window; AX the x coordinate; AY the y coordinate; AButton the button; APressed true for down, false for up; AMods the modifier keys.
  • static method InjectWheel(const AWindow: UIWindow; const AX: float32; const AY: float32; const AMods: UIModifiers): The wheel turned by AX, AY notches. C: Rhost_inject_mouse_wheel Parameters: AWindow the window; AX the x coordinate; AY the y coordinate; AMods the modifier keys.
  • static method InjectLeave(const AWindow: UIWindow): The mouse left AWindow (hover ends). C: Rhost_inject_mouse_leave Parameters: AWindow the window.
  • static method InjectKey(const AWindow: UIWindow; const AKey: UIKey; const APressed: bool; const AMods: UIModifiers; const ARepeat: bool): The key AKey went down (APressed; ARepeat for the system's auto-repeat) or up. C: Rhost_inject_key Parameters: AWindow the window; AKey the key; APressed true for down, false for up; AMods the modifier keys; ARepeat true for the system's auto-repeat.
  • static method InjectText(const AWindow: UIWindow; const ACodepoint: uint32): The character ACodepoint (a Unicode code point) was typed. C: Rhost_inject_text Parameters: AWindow the window; ACodepoint the codepoint.
  • static method InjectFocus(const AWindow: UIWindow; const AOn: bool): AWindow took (true) or lost the keyboard focus. C: Rhost_inject_focus Parameters: AWindow the window; AOn true to turn it on, false to turn it off.
  • static method InjectClose(const AWindow: UIWindow): The user asked to close AWindow (its OnClose decides). C: Rhost_inject_close Parameters: AWindow the window.
  • static method RegisterBackend(const AVTable: RBackendVTable): The program's render backend, for UIBackend.Custom (before the app opens; Raven copies the table). C: Rbackend_register Parameters: AVTable the V table.
  • static method DeviceLost(): The program's backend lost its device (any thread): Raven makes its textures again. C: Rbackend_device_lost
  • static method CapturePixels(const ASize: uint64): ptr to uint8: A pixel buffer of ASize bytes Raven frees, for a backend's frame capture (RCapture.pixels); any thread. C: Rpixels_alloc Parameters: ASize the size. Returns: a pixel buffer of ASize bytes 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

text
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 enabled
  • static method RequiredDeviceExtensions(): StringArray: The device extensions Raven needs enabled. C: Rvulkan_get_required_device_extensions Returns: the device extensions Raven needs enabled
  • static method ExternalDevice(const AInstance: ptr; const APhysicalDevice: ptr; const ADevice: ptr; const AQueue: ptr; const AQueueFamily: uint32): Raven runs on the engine's device: its VkInstance, VkPhysicalDevice, VkDevice, graphics VkQueue and that queue's family (before the app opens). C: Rvulkan_set_external_device Parameters: AInstance the instance; APhysicalDevice the physical device; ADevice the device; AQueue the queue; AQueueFamily the queue family.
  • static method QueueLock(const ALock: UIVulkanLockFunc; const AUnlock: UIVulkanLockFunc): ALock and AUnlock run 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: ALock the lock; AUnlock the unlock.
  • static method Instance(): ptr: Raven's VkInstance. C: Rvulkan_get_instance Returns: raven's VkInstance
  • static method PhysicalDevice(): ptr: Raven's VkPhysicalDevice. C: Rvulkan_get_physical_device Returns: raven's VkPhysicalDevice
  • static method Device(): ptr: Raven's VkDevice. C: Rvulkan_get_device Returns: raven's VkDevice
  • static method GraphicsQueue(): ptr: Raven's graphics VkQueue. C: Rvulkan_get_graphics_queue Returns: raven's graphics VkQueue
  • static method GraphicsQueueFamily(): uint32: The graphics queue's family. C: Rvulkan_get_graphics_queue_family Returns: the graphics queue's family
  • static method SimulateDeviceLost(): Acts as if the device was lost (the recovery path, for tests). C: Rvulkan_simulate_device_lost
  • static method TextureFromImageView(const AImageView: uint64; const ASampler: uint64; const AWidth: int32; const AHeight: int32): UITextureRes: A texture showing the engine's VkImageView AImageView through its VkSampler ASampler, AWidth x AHeight (the engine keeps the image). C: Rvulkan_texture_create_from_image_view Parameters: AImageView the image view; ASampler the sampler; AWidth the width; AHeight the height. Returns: a texture showing the engine's VkImageView AImageView through its VkSampler ASampler, AWidth x AHeight (the engine keeps the image)
  • static method TextureImageView(const ATexture: UITextureRes; const AImageView: uint64; const ASampler: uint64; const AWidth: int32; const AHeight: int32): ATexture shows another image view of the engine's (after it made the image again). C: Rvulkan_texture_set_image_view Parameters: ATexture the texture; AImageView the image view; ASampler the sampler; AWidth the width; AHeight the height.
  • static method SharedTexture(const AWidth: int32; const AHeight: int32): UITextureRes: A texture AWidth x AHeight whose memory another process can open (SharedInfo). C: Rvulkan_texture_create_shared Parameters: AWidth the width; AHeight the height. Returns: a texture AWidth x AHeight whose 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 into AInfo. Parameters: ATexture the texture; AInfo the info. Returns: false when ATexture is no shared texture. C: Rvulkan_texture_get_shared_info

Example: LExtensions := UIVulkan.RequiredInstanceExtensions(); UIVulkan.ExternalDevice(LInstance, LGpu, LDevice, LQueue, LFamily);

Extends

extend UIColor

text
extend UIColor

Members

  • static method White(): UIColor: Opaque white (1, 1, 1, 1). Returns: the new UIColor
  • static method Black(): UIColor: Opaque black (0, 0, 0, 1). Returns: the new UIColor
  • static method Transparent(): UIColor: Fully transparent black (0, 0, 0, 0). Returns: the new UIColor
  • static method FromRGBA(const AR: uint8; const AG: uint8; const AB: uint8): UIColor: The opaque colour of the bytes AR, AG, AB (0..255 each). Parameters: AR the red byte; AG the green byte; AB the blue byte. Returns: the opaque colour of the bytes AR, 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 bytes AR, AG, AB, AA (0..255 each). Parameters: AR the red byte; AG the green byte; AB the blue byte; AA the alpha byte. Returns: the colour of the bytes AR, AG, AB, AA (0..255 each)
  • static method FromHex(const AText: string; const ADefault: UIColor): UIColor: The colour the hex text AText names (#RGB, #RGBA, #RRGGBB, #RRGGBBAA, the # optional: TryHexToRGBA), or ADefault for any other text. Parameters: AText the text; ADefault the default. Returns: the colour the hex text AText names (#RGB, #RGBA, #RRGGBB, #RRGGBBAA, the # optional: TryHexToRGBA), or ADefault for 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 hue AH (0..360), saturation AS and value AV (0..1). C: Rcolor_hsv_to_rgb Parameters: AH the hue, in degrees (0 to 360); AS the saturation, 0 to 1; AV the value (brightness), 0 to 1. Returns: the opaque colour of hue AH (0..360), saturation AS and value AV (0..1)
  • static method FromHSV(const AH: float32; const AS: float32; const AV: float32; const AA: float32): UIColor: The colour of hue AH (0..360), saturation AS, value AV and alpha AA (0..1). C: Rcolor_hsv_to_rgb Parameters: AH the hue, in degrees (0 to 360); AS the saturation, 0 to 1; AV the value (brightness), 0 to 1; AA the alpha (0..1). Returns: the colour of hue AH (0..360), saturation AS, value AV and alpha AA (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: AH the hue, in degrees (0 to 360); AS the saturation, 0 to 1; AV the value (brightness), 0 to 1.
  • const method Hex(): string: The colour as hex text, uppercase: #RRGGBB when it is opaque, else #RRGGBBAA (each channel rounded to its nearest byte; FromHex reads it back). Returns: the colour as hex text, uppercase: #RRGGBB when it is opaque, else #RRGGBBAA (each channel rounded to its nearest byte; FromHex reads it back)
  • const method WithAlpha(const AA: float32): UIColor: The colour with its alpha set to AA (0..1). Parameters: AA the new alpha (0..1). Returns: the colour with its alpha set to AA (0..1)
  • const method Lerp(const AB: UIColor; const AT: float32): UIColor: The colour AT of the way from this one to AB (0: this one, 1: AB), each channel mixed in a straight line. Parameters: AB the colour it mixes towards; AT how far along, 0 to 1. Returns: the colour AT of the way from this one to AB (0: this one, 1: AB), each channel mixed in a straight line
  • operator =(const A: UIColor; const B: UIColor): bool: The same colour: every channel equal. Parameters: A the left operand; B the right operand. Returns: true when every channel is equal

extend UIPoint

text
extend UIPoint

Members

  • operator +(const A: UIPoint; const B: UIPoint): UIPoint: The sum of two points (a point moved by an offset). Parameters: A the left operand; B the right operand. Returns: the sum of two points (a point moved by an offset)
  • operator -(const A: UIPoint; const B: UIPoint): UIPoint: The offset from B to A. Parameters: A the left operand; B the right operand. Returns: the offset from B to A
  • operator *(const A: UIPoint; const S: float32): UIPoint: The point scaled by S. Parameters: A the left operand; S the right operand. Returns: the point scaled by S
  • operator =(const A: UIPoint; const B: UIPoint): bool: The same point. Parameters: A the left operand; B the right operand. Returns: true when both coordinates are equal

extend UIRect

text
extend UIRect

Members

  • const method Contains(const AP: UIPoint): bool: true when AP lies inside the rectangle (its left and top edges in, its right and bottom edges out). Parameters: AP the point tested. Returns: true when AP lies 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

text
extend REvent

Members

  • const method Kind(): UIEventKind: The event's kind. Returns: the event's kind
  • const method Position(): UIPoint: Where it happened, in the window's logical units. Returns: where it happened, in the window's logical units
  • const method Local(): UIPoint: Where it happened, in the widget's own logical units. Returns: where it happened, in the widget's own logical units
  • const method Delta(): UIPoint: How far the pointer moved since the event before. Returns: how far the pointer moved since the event before
  • const 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 event
  • const method Key(): UIKey: The key of a key event. Returns: the key of a key event
  • const method Mods(): UIModifiers: The modifier keys held. Returns: the modifier keys held
  • const method Repeat(): bool: true for a key event the key's auto-repeat made. Returns: true for a key event the key's auto-repeat made
  • const 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: true when the wheel's amounts are precise (a trackpad's), not whole notches. Returns: true when the wheel's amounts are precise (a trackpad's), not whole notches
  • const method Target(): UIWidget: The widget the event happened on. Returns: the widget the event happened on
  • const method Window(): UIWindow: The window the event happened in. Returns: the window the event happened in

extend RDropEvent

text
extend RDropEvent

Members

  • const method Phase(): UIDropPhase: The drop's stage. Returns: the drop's stage
  • const method Position(): UIPoint: Where the pointer is, in the window's logical units. Returns: where the pointer is, in the window's logical units
  • const 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 units
  • const 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

text
extend RTouchEvent

Members

  • const method Phase(): UITouchPhase: The touch's stage. Returns: the touch's stage
  • const method Position(): UIPoint: Where the finger is, in the window's logical units. Returns: where the finger is, in the window's logical units
  • const 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 units
  • const method Mods(): UIModifiers: The modifier keys held. Returns: the modifier keys held
  • const method Target(): UIWidget: The widget the touch is on. Returns: the widget the touch is on
  • const method Window(): UIWindow: The window the touch is in. Returns: the window the touch is in

extend RPenEvent

text
extend RPenEvent

Members

  • const method Phase(): UIPenPhase: The input's stage. Returns: the input's stage
  • const method Position(): UIPoint: Where the pen is, in the window's logical units. Returns: where the pen is, in the window's logical units
  • const 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 units
  • const 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: true when the pen's eraser end is used. Returns: true when the pen's eraser end is used
  • const method Buttons(): UIPenButtons: The barrel buttons held. Returns: the barrel buttons held
  • const method Mods(): UIModifiers: The modifier keys held. Returns: the modifier keys held
  • const method Target(): UIWidget: The widget the pen is on. Returns: the widget the pen is on
  • const method Window(): UIWindow: The window the pen is in. Returns: the window the pen is in

extend RGestureEvent

text
extend RGestureEvent

Members

  • const method Phase(): UIGesturePhase: The gesture's stage. Returns: the gesture's stage
  • const method Kind(): UIGestureKind: The gesture's kind. Returns: the gesture's kind
  • const method Device(): UIGestureDevice: The device it comes from. Returns: the device it comes from
  • const method Position(): UIPoint: Where it is, in the window's logical units. Returns: where it is, in the window's logical units
  • const method Local(): UIPoint: Where it is, in the widget's own logical units. Returns: where it is, in the widget's own logical units
  • const method Pan(): UIPoint: How far it panned since the event before. Returns: how far it panned since the event before
  • const method Total(): UIPoint: How far it panned since it began. Returns: how far it panned since it began
  • const method Cancelled(): bool: true when the system cancelled it. Returns: true when the system cancelled it
  • const method Target(): UIWidget: The widget the gesture is on. Returns: the widget the gesture is on
  • const method Window(): UIWindow: The window the gesture is in. Returns: the window the gesture is in

extend RTextInputInfo

text
extend RTextInputInfo

Members

  • const method Kind(): UIInputType: The kind of text it takes. Returns: the kind of text it takes
  • const method ReturnKey(): UIReturnKey: The label of the on-screen keyboard's return key. Returns: the label of the on-screen keyboard's return key
  • const method Password(): bool: true for a password input (its text hidden). Returns: true for a password input (its text hidden)
  • const method ReadOnly(): bool: true when its text cannot be edited. Returns: true when its text cannot be edited

extend RAccessibilitySettings

text
extend RAccessibilitySettings

Members

  • const method HighContrast(): bool: true when high contrast is on. Returns: true when high contrast is on
  • const method ReduceMotion(): bool: true when the user asks for less motion. Returns: true when the user asks for less motion
  • const method ScreenReader(): bool: true when a screen reader runs. Returns: true when a screen reader runs

extend RTouchSettings

text
extend RTouchSettings

Members

  • const method MouseEmulation(): bool: true when a touch also acts as the mouse. Returns: true when a touch also acts as the mouse
  • const method Inertia(): bool: true when a fling keeps scrolling. Returns: true when a fling keeps scrolling
  • const method Gestures(): bool: true when pinch and swipe gestures are recognized. Returns: true when pinch and swipe gestures are recognized
  • const method PenMouseEmulation(): bool: true when a pen also acts as the mouse. Returns: true when a pen also acts as the mouse
  • const method PalmRejection(): bool: true when a palm resting on the screen is ignored while a pen is used. Returns: true when a palm resting on the screen is ignored while a pen is used
  • const method TrackpadGestures(): bool: true when a trackpad's gestures are recognized. Returns: true when a trackpad's gestures are recognized
  • const method SwipeNavigation(): bool: true when a swipe from the edge goes back. Returns: true when a swipe from the edge goes back

extend RXmlError

text
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

text
extend RXmlAttributeInfo

Members

  • const method Name(): string: The attribute's name. Returns: the attribute's name
  • const method Kind(): UIXMLAttrKind: The kind of value it takes. Returns: the kind of value it takes
  • const 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

text
extend RTileSection

Members

  • const method Text(): string: The section's title. Returns: the section's title
  • const method Detail(): string: The section's second line ("" for none). Returns: the section's second line ("" for none)

extend RTileItem

text
extend RTileItem

Members

  • const method Text(): string: The tile's title. Returns: the tile's title
  • const 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 with
  • const method TextColor(): UIColor: The colour of the tile's title. Returns: the colour of the tile's title
  • const method DetailColor(): UIColor: The colour of the tile's second line. Returns: the colour of the tile's second line

extend RShaderLook

text
extend RShaderLook

Members

  • const method Color(): UIColor: The look's first colour. Returns: the look's first colour
  • const method Color2(): UIColor: The look's second colour. Returns: the look's second colour
  • const method Animate(): bool: true when the shader animates (it is drawn every frame). Returns: true when the shader animates (it is drawn every frame)
  • const method Pointer(): bool: true when the shader follows the pointer. Returns: true when the shader follows the pointer

extend RSpring

text
extend RSpring

Members

  • method Kick(const AVelocity: float32): Gives the spring a push of AVelocity (units a second). C: Rspring_kick Parameters: AVelocity the velocity.
  • method Set(const AValue: float32): Puts the spring at AValue at once, at rest. C: Rspring_set Parameters: AValue the value.

extend UIWidget

text
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: AMenu the menu. Returns: this object, so calls chain
  • const method Begin<T>(): T: A new T (a widget type with a Create(): UIVBox, UIGrid, UIBorder ..) placed last inside this widget, to fill in the chain; its End() comes back to this widget. Returns: a new T (a widget type with a Create(): UIVBox, UIGrid, UIBorder ..) placed last inside this widget, to fill in the chain; its End() 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 new T placed last inside this widget, sitting as ALayout says. Parameters: ALayout the layout. Returns: a new T placed last inside this widget, sitting as ALayout says
  • const 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

text
extend UITableColumn

Members

  • const method Table(): UITable: The table the column is in. Returns: the table the column is in

extend UITableRow

text
extend UITableRow

Members

  • const method Table(): UITable: The table the row is in. Returns: the table the row is in

extend UITileSection

text
extend UITileSection

Members

  • const method View(): UITileView: The tile view the section is in. Returns: the tile view the section is in

extend UIApp

text
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: AMenu the menu. Returns: true when the system has taskbar menus (false too for a menu in a bar or in another menu)

extend UITrack

text
extend UITrack

Members

  • const method AddClip(const AStart: float64; const ALength: float64; const ALabel: string): UITimelineItem: A new clip on the track from AStart for ALength seconds, labelled ALabel. C: Rtimeline_add_clip Parameters: AStart the start; ALength the length; ALabel the label. Returns: a new clip on the track from AStart for ALength seconds, labelled ALabel
  • const method AddKey(const ATime: float64): UITimelineItem: A new key on the track at ATime seconds. C: Rtimeline_add_key Parameters: ATime the time. Returns: a new key on the track at ATime seconds

extend UIGraphNode

text
extend UIGraphNode

Members

  • const method AddInput(const ALabel: string; const AType: string): UIGraphPin: A new input pin labelled ALabel of the type AType ("": links to any type). C: Rnode_graph_add_input Parameters: ALabel the label; AType the type. Returns: a new input pin labelled ALabel of the type AType ("": links to any type)
  • const method AddOutput(const ALabel: string; const AType: string): UIGraphPin: A new output pin labelled ALabel of the type AType ("": links to any type). C: Rnode_graph_add_output Parameters: ALabel the label; AType the type. Returns: a new output pin labelled ALabel of the type AType ("": links to any type)
  • const method Input(const AIndex: int32): UIGraphPin: Its input AIndex (from the top, 0 first). C: Rnode_graph_get_input Parameters: AIndex the index, from 0. Returns: its input AIndex (from the top, 0 first)
  • const method Output(const AIndex: int32): UIGraphPin: Its output AIndex (from the top, 0 first). C: Rnode_graph_get_output Parameters: AIndex the index, from 0. Returns: its output AIndex (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: AName the name. Returns: its pin named (or labelled) AName (none when it has no such pin)

extend UIGraphPin

text
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

text
extend UIDockArea

Members

  • const method FloatWindow(const AFlags: UIWindowFlags; const AFunc: UIDockFloatFunc): self: How the windows of torn-off panels are made: the window flags AFlags (NoResize, Borderless, CustomHeader and Transparent count) and AFunc making each one's content (nil: the floating area is the whole window). C: Rdock_area_set_float_window Parameters: AFlags the flags; AFunc the func it runs. Returns: this object, so calls chain

extend UIDockPanel

text
extend UIDockPanel

Members

  • const method Area(): UIDockArea: The area it belongs to (its home). Returns: the area it belongs to (its home)

extend UIWindow

text
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 empty UIIsland(): none). C: Rwindow_set_island Parameters: AIsland the island. Returns: this object, so calls chain
  • const method Island(): UIIsland: What Island(..) sets, read back. C: Rwindow_get_island Returns: the window's island, in its title area or the screen's camera housing (an empty UIIsland(): none)

Constants

NameDeclarationDescription
ADAM_RAVEN_EXC_NOT_FOUNDconst ADAM_RAVEN_EXC_NOT_FOUND: int32 = 1The 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_KINDconst ADAM_RAVEN_EXC_KIND: int32 = 13The 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

text
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 window AWindow (open: Ready()), AAppName the application's name; then make its UI window (UIWindow.Create or UIWindow.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 to UIErrors). Parameters: AWindow the open raylib window Raven runs in; AAppName the application's name.
  • const method IsValid(): bool: true while Raven runs in the raylib window. Returns: true while Raven runs in the raylib window
  • const 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 for AWindow, 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: AWindow the Raven window the frame is run for. Returns: false once UIApp.Quit was called, the last Raven window is closed, or Raven is not running
  • const method Draw(const AWindow: UIWindow): Draws AWindow's last Raven frame over what the program drew: in raylib's window units, or with the frame window open between its BeginFrame and EndFrame (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 first Update. Parameters: AWindow the Raven window drawn.
  • const method Texture(const ATexture: TextureRes): UITextureRes: A Raven texture showing the raylib texture ATexture as it is in every frame (no copy) in an Image or a Viewport; it keeps ATexture alive while it shows it. Empty when Raven is not running or ATexture holds no texture. Parameters: ATexture the raylib texture shown. Returns: the Raven texture (empty when Raven is not running or ATexture holds none)
  • const method Texture(const ATarget: RenderTextureRes): UITextureRes: A Raven texture showing the render texture ATarget (what the program draws into it shows at once: a 3D view in a Viewport, FlipY(true): a render texture is bottom-up); it keeps ATarget alive while it shows it. Parameters: ATarget the render texture shown. Returns: the Raven texture (empty when Raven is not running or ATarget holds none)
  • const method Retarget(const ARaven: UITextureRes; const ATexture: TextureRes): bool: Points ARaven, a texture Texture made, at the raylib texture ATexture (a texture made again at a new size: the widget showing it keeps its Raven texture). Parameters: ARaven the Raven texture Texture made; ATexture the raylib texture it shows from now on. Returns: false when Raven is not running, ATexture holds no texture, or ARaven is not one Texture made
  • const method Retarget(const ARaven: UITextureRes; const ATarget: RenderTextureRes): bool: Points ARaven at the render texture ATarget, as Retarget for a texture. Parameters: ARaven the Raven texture Texture made; ATarget the render texture it shows from now on. Returns: false when Raven is not running, ATarget holds no texture, or ARaven is not one Texture made
  • method 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

text
extend Color

Members

  • const method ToRaven(): UIColor: The colour as System.Raven.Ext's UIColor (0..1 a channel). Returns: the UIColor

extend UIColor

text
extend UIColor

Members

  • const method ToRaylib(): Color: The colour as raylib's Color (a byte a channel, rounded; out of 0..1 clamped). Returns: the Color

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

text
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

text
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

text
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 load
  • height: 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

text
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_NULL
  • Key.Space: The space key. C: KEY_SPACE
  • Key.Apostrophe: The apostrophe key. C: KEY_APOSTROPHE
  • Key.Comma: The comma key. C: KEY_COMMA
  • Key.Minus: The minus key. C: KEY_MINUS
  • Key.Period: The period key. C: KEY_PERIOD
  • Key.Slash: The slash key. C: KEY_SLASH
  • Key.Zero: The 0 key. C: KEY_ZERO
  • Key.One: The 1 key. C: KEY_ONE
  • Key.Two: The 2 key. C: KEY_TWO
  • Key.Three: The 3 key. C: KEY_THREE
  • Key.Four: The 4 key. C: KEY_FOUR
  • Key.Five: The 5 key. C: KEY_FIVE
  • Key.Six: The 6 key. C: KEY_SIX
  • Key.Seven: The 7 key. C: KEY_SEVEN
  • Key.Eight: The 8 key. C: KEY_EIGHT
  • Key.Nine: The 9 key. C: KEY_NINE
  • Key.Semicolon: The semicolon key. C: KEY_SEMICOLON
  • Key.Equal: The equal key. C: KEY_EQUAL
  • Key.A: The A key. C: KEY_A
  • Key.B: The B key. C: KEY_B
  • Key.C: The C key. C: KEY_C
  • Key.D: The D key. C: KEY_D
  • Key.E: The E key. C: KEY_E
  • Key.F: The F key. C: KEY_F
  • Key.G: The G key. C: KEY_G
  • Key.H: The H key. C: KEY_H
  • Key.I: The I key. C: KEY_I
  • Key.J: The J key. C: KEY_J
  • Key.K: The K key. C: KEY_K
  • Key.L: The L key. C: KEY_L
  • Key.M: The M key. C: KEY_M
  • Key.N: The N key. C: KEY_N
  • Key.O: The O key. C: KEY_O
  • Key.P: The P key. C: KEY_P
  • Key.Q: The Q key. C: KEY_Q
  • Key.R: The R key. C: KEY_R
  • Key.S: The S key. C: KEY_S
  • Key.T: The T key. C: KEY_T
  • Key.U: The U key. C: KEY_U
  • Key.V: The V key. C: KEY_V
  • Key.W: The W key. C: KEY_W
  • Key.X: The X key. C: KEY_X
  • Key.Y: The Y key. C: KEY_Y
  • Key.Z: The Z key. C: KEY_Z
  • Key.LeftBracket: The left bracket key. C: KEY_LEFT_BRACKET
  • Key.Backslash: The backslash key. C: KEY_BACKSLASH
  • Key.RightBracket: The right bracket key. C: KEY_RIGHT_BRACKET
  • Key.Grave: The grave key. C: KEY_GRAVE
  • Key.Escape: The escape key. C: KEY_ESCAPE
  • Key.Enter: The enter key. C: KEY_ENTER
  • Key.Tab: The tab key. C: KEY_TAB
  • Key.Backspace: The backspace key. C: KEY_BACKSPACE
  • Key.Insert: The insert key. C: KEY_INSERT
  • Key.Delete: The delete key. C: KEY_DELETE
  • Key.Right: The right key. C: KEY_RIGHT
  • Key.Left: The left key. C: KEY_LEFT
  • Key.Down: The down key. C: KEY_DOWN
  • Key.Up: The up key. C: KEY_UP
  • Key.PageUp: The page up key. C: KEY_PAGE_UP
  • Key.PageDown: The page down key. C: KEY_PAGE_DOWN
  • Key.Home: The home key. C: KEY_HOME
  • Key.End: The end key. C: KEY_END
  • Key.CapsLock: The caps lock key. C: KEY_CAPS_LOCK
  • Key.ScrollLock: The scroll lock key. C: KEY_SCROLL_LOCK
  • Key.NumLock: The num lock key. C: KEY_NUM_LOCK
  • Key.PrintScreen: The print screen key. C: KEY_PRINT_SCREEN
  • Key.Pause: The pause key. C: KEY_PAUSE
  • Key.F1: The F1 key. C: KEY_F1
  • Key.F2: The F2 key. C: KEY_F2
  • Key.F3: The F3 key. C: KEY_F3
  • Key.F4: The F4 key. C: KEY_F4
  • Key.F5: The F5 key. C: KEY_F5
  • Key.F6: The F6 key. C: KEY_F6
  • Key.F7: The F7 key. C: KEY_F7
  • Key.F8: The F8 key. C: KEY_F8
  • Key.F9: The F9 key. C: KEY_F9
  • Key.F10: The F10 key. C: KEY_F10
  • Key.F11: The F11 key. C: KEY_F11
  • Key.F12: The F12 key. C: KEY_F12
  • Key.Kp0: The keypad 0 key. C: KEY_KP_0
  • Key.Kp1: The keypad 1 key. C: KEY_KP_1
  • Key.Kp2: The keypad 2 key. C: KEY_KP_2
  • Key.Kp3: The keypad 3 key. C: KEY_KP_3
  • Key.Kp4: The keypad 4 key. C: KEY_KP_4
  • Key.Kp5: The keypad 5 key. C: KEY_KP_5
  • Key.Kp6: The keypad 6 key. C: KEY_KP_6
  • Key.Kp7: The keypad 7 key. C: KEY_KP_7
  • Key.Kp8: The keypad 8 key. C: KEY_KP_8
  • Key.Kp9: The keypad 9 key. C: KEY_KP_9
  • Key.KpDecimal: The keypad decimal key. C: KEY_KP_DECIMAL
  • Key.KpDivide: The keypad divide key. C: KEY_KP_DIVIDE
  • Key.KpMultiply: The keypad multiply key. C: KEY_KP_MULTIPLY
  • Key.KpSubtract: The keypad subtract key. C: KEY_KP_SUBTRACT
  • Key.KpAdd: The keypad add key. C: KEY_KP_ADD
  • Key.KpEnter: The keypad enter key. C: KEY_KP_ENTER
  • Key.KpEqual: The keypad equal key. C: KEY_KP_EQUAL
  • Key.LeftShift: The left shift key. C: KEY_LEFT_SHIFT
  • Key.LeftControl: The left control key. C: KEY_LEFT_CONTROL
  • Key.LeftAlt: The left alt key. C: KEY_LEFT_ALT
  • Key.LeftSuper: The left super key. C: KEY_LEFT_SUPER
  • Key.RightShift: The right shift key. C: KEY_RIGHT_SHIFT
  • Key.RightControl: The right control key. C: KEY_RIGHT_CONTROL
  • Key.RightAlt: The right alt key. C: KEY_RIGHT_ALT
  • Key.RightSuper: The right super key. C: KEY_RIGHT_SUPER
  • Key.KbMenu: The keyboard menu key. C: KEY_KB_MENU
  • Key.Back: The back key. C: KEY_BACK
  • Key.Menu: The menu key. C: KEY_MENU
  • Key.VolumeUp: The volume up key. C: KEY_VOLUME_UP
  • Key.VolumeDown: The volume down key. C: KEY_VOLUME_DOWN

Example: if IsKeyPressed(int32(Key.Space)) then Jump(); end;

Button

text
type Button = choices(

A mouse button, raylib's MouseButton values.

Members

  • Button.Left: The left mouse button. C: MOUSE_BUTTON_LEFT
  • Button.Right: The right mouse button. C: MOUSE_BUTTON_RIGHT
  • Button.Middle: The middle mouse button. C: MOUSE_BUTTON_MIDDLE
  • Button.Side: The side mouse button. C: MOUSE_BUTTON_SIDE
  • Button.Extra: The extra mouse button. C: MOUSE_BUTTON_EXTRA
  • Button.Forward: The forward mouse button. C: MOUSE_BUTTON_FORWARD
  • Button.Back: The back mouse button. C: MOUSE_BUTTON_BACK

Cursor

text
type Cursor = choices(

A mouse cursor shape, raylib's MouseCursor values.

Members

  • Cursor.Default: Default pointer shape. C: MOUSE_CURSOR_DEFAULT
  • Cursor.Arrow: Arrow shape. C: MOUSE_CURSOR_ARROW
  • Cursor.IBeam: Text writing cursor shape. C: MOUSE_CURSOR_IBEAM
  • Cursor.Crosshair: Cross shape. C: MOUSE_CURSOR_CROSSHAIR
  • Cursor.PointingHand: Pointing hand cursor. C: MOUSE_CURSOR_POINTING_HAND
  • Cursor.ResizeEW: Horizontal resize/move arrow shape. C: MOUSE_CURSOR_RESIZE_EW
  • Cursor.ResizeNS: Vertical resize/move arrow shape. C: MOUSE_CURSOR_RESIZE_NS
  • Cursor.ResizeNWSE: Top-left to bottom-right diagonal resize/move arrow shape. C: MOUSE_CURSOR_RESIZE_NWSE
  • Cursor.ResizeNESW: The top-right to bottom-left diagonal resize/move arrow shape. C: MOUSE_CURSOR_RESIZE_NESW
  • Cursor.ResizeAll: The omnidirectional resize/move cursor shape. C: MOUSE_CURSOR_RESIZE_ALL
  • Cursor.NotAllowed: The operation-not-allowed shape. C: MOUSE_CURSOR_NOT_ALLOWED

PadButton

text
type PadButton = choices(

A gamepad button, raylib's GamepadButton values.

Members

  • PadButton.Unknown: Unknown button, for error checking. C: GAMEPAD_BUTTON_UNKNOWN
  • PadButton.LeftFaceUp: Gamepad left DPAD up button. C: GAMEPAD_BUTTON_LEFT_FACE_UP
  • PadButton.LeftFaceRight: Gamepad left DPAD right button. C: GAMEPAD_BUTTON_LEFT_FACE_RIGHT
  • PadButton.LeftFaceDown: Gamepad left DPAD down button. C: GAMEPAD_BUTTON_LEFT_FACE_DOWN
  • PadButton.LeftFaceLeft: Gamepad left DPAD left button. C: GAMEPAD_BUTTON_LEFT_FACE_LEFT
  • PadButton.RightFaceUp: Gamepad right button up (i.e. PS3: Triangle, Xbox: Y). C: GAMEPAD_BUTTON_RIGHT_FACE_UP
  • PadButton.RightFaceRight: Gamepad right button right (i.e. PS3: Circle, Xbox: B). C: GAMEPAD_BUTTON_RIGHT_FACE_RIGHT
  • PadButton.RightFaceDown: Gamepad right button down (i.e. PS3: Cross, Xbox: A). C: GAMEPAD_BUTTON_RIGHT_FACE_DOWN
  • PadButton.RightFaceLeft: Gamepad right button left (i.e. PS3: Square, Xbox: X). C: GAMEPAD_BUTTON_RIGHT_FACE_LEFT
  • PadButton.LeftTrigger1: Gamepad top/back trigger left (first), it could be a trailing button. C: GAMEPAD_BUTTON_LEFT_TRIGGER_1
  • PadButton.LeftTrigger2: Gamepad top/back trigger left (second), it could be a trailing button. C: GAMEPAD_BUTTON_LEFT_TRIGGER_2
  • PadButton.RightTrigger1: Gamepad top/back trigger right (first), it could be a trailing button. C: GAMEPAD_BUTTON_RIGHT_TRIGGER_1
  • PadButton.RightTrigger2: Gamepad top/back trigger right (second), it could be a trailing button. C: GAMEPAD_BUTTON_RIGHT_TRIGGER_2
  • PadButton.MiddleLeft: Gamepad center buttons, left one (i.e. PS3: Select). C: GAMEPAD_BUTTON_MIDDLE_LEFT
  • PadButton.Middle: Gamepad center buttons, middle one (i.e. PS3: PS, Xbox: XBOX). C: GAMEPAD_BUTTON_MIDDLE
  • PadButton.MiddleRight: Gamepad center buttons, right one (i.e. PS3: Start). C: GAMEPAD_BUTTON_MIDDLE_RIGHT
  • PadButton.LeftThumb: Gamepad joystick pressed button left. C: GAMEPAD_BUTTON_LEFT_THUMB
  • PadButton.RightThumb: Gamepad joystick pressed button right. C: GAMEPAD_BUTTON_RIGHT_THUMB

PadAxis

text
type PadAxis = choices(

A gamepad axis, raylib's GamepadAxis values.

Members

  • PadAxis.LeftX: Gamepad left stick X axis. C: GAMEPAD_AXIS_LEFT_X
  • PadAxis.LeftY: Gamepad left stick Y axis. C: GAMEPAD_AXIS_LEFT_Y
  • PadAxis.RightX: Gamepad right stick X axis. C: GAMEPAD_AXIS_RIGHT_X
  • PadAxis.RightY: Gamepad right stick Y axis. C: GAMEPAD_AXIS_RIGHT_Y
  • PadAxis.LeftTrigger: Gamepad back trigger left, pressure level: [1..-1]. C: GAMEPAD_AXIS_LEFT_TRIGGER
  • PadAxis.RightTrigger: Gamepad back trigger right, pressure level: [1..-1]. C: GAMEPAD_AXIS_RIGHT_TRIGGER

WindowFlag

text
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_MODE
  • WindowFlag.Resizable: Set to allow resizable window. C: FLAG_WINDOW_RESIZABLE
  • WindowFlag.Undecorated: Set to disable window decoration (frame and buttons). C: FLAG_WINDOW_UNDECORATED
  • WindowFlag.Transparent: Set to allow transparent framebuffer. C: FLAG_WINDOW_TRANSPARENT
  • WindowFlag.Msaa4xHint: Set to try enabling MSAA 4X. C: FLAG_MSAA_4X_HINT
  • WindowFlag.VSyncHint: Set to try enabling V-Sync on GPU. C: FLAG_VSYNC_HINT
  • WindowFlag.Hidden: Set to hide window. C: FLAG_WINDOW_HIDDEN
  • WindowFlag.AlwaysRun: Set to allow windows running while minimized. C: FLAG_WINDOW_ALWAYS_RUN
  • WindowFlag.Minimized: Set to minimize window (iconify). C: FLAG_WINDOW_MINIMIZED
  • WindowFlag.Maximized: Set to maximize window (expanded to monitor). C: FLAG_WINDOW_MAXIMIZED
  • WindowFlag.Unfocused: Set to window non focused. C: FLAG_WINDOW_UNFOCUSED
  • WindowFlag.Topmost: Set to window always on top. C: FLAG_WINDOW_TOPMOST
  • WindowFlag.HighDPI: Set to support HighDPI. C: FLAG_WINDOW_HIGHDPI
  • WindowFlag.MousePassthrough: Set to support mouse passthrough, only supported when FLAG_WINDOW_UNDECORATED. C: FLAG_WINDOW_MOUSE_PASSTHROUGH
  • WindowFlag.BorderlessWindowed: Set to run program in borderless windowed mode. C: FLAG_BORDERLESS_WINDOWED_MODE
  • WindowFlag.InterlacedHint: Set to try enabling interlaced video format (for V3D). C: FLAG_INTERLACED_HINT

WindowFlags

text
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

text
type LogLevel = choices(

A trace log level, raylib's TraceLogLevel values.

Members

  • LogLevel.All: Display all logs. C: LOG_ALL
  • LogLevel.Trace: Trace logging, intended for internal use only. C: LOG_TRACE
  • LogLevel.Debug: Debug logging, used for internal debugging, it should be disabled on release builds. C: LOG_DEBUG
  • LogLevel.Info: Info logging, used for program execution info. C: LOG_INFO
  • LogLevel.Warning: Warning logging, used on recoverable failures. C: LOG_WARNING
  • LogLevel.Error: Error logging, used on unrecoverable failures. C: LOG_ERROR
  • LogLevel.Fatal: Fatal logging, used to abort program: exit(EXIT_FAILURE). C: LOG_FATAL
  • LogLevel.None: Disable logging. C: LOG_NONE

Pixel

text
type Pixel = choices(

A pixel format, raylib's PixelFormat values.

Members

  • Pixel.Gray: 8 bit per pixel (no alpha). C: PIXELFORMAT_UNCOMPRESSED_GRAYSCALE
  • Pixel.GrayAlpha: 8*2 bpp (2 channels). C: PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA
  • Pixel.R5G6B5: 16 bpp. C: PIXELFORMAT_UNCOMPRESSED_R5G6B5
  • Pixel.R8G8B8: 24 bpp. C: PIXELFORMAT_UNCOMPRESSED_R8G8B8
  • Pixel.R5G5B5A1: 16 bpp (1 bit alpha). C: PIXELFORMAT_UNCOMPRESSED_R5G5B5A1
  • Pixel.R4G4B4A4: 16 bpp (4 bit alpha). C: PIXELFORMAT_UNCOMPRESSED_R4G4B4A4
  • Pixel.R8G8B8A8: 32 bpp. C: PIXELFORMAT_UNCOMPRESSED_R8G8B8A8
  • Pixel.R32: 32 bpp (1 channel - float). C: PIXELFORMAT_UNCOMPRESSED_R32
  • Pixel.R32G32B32: 32*3 bpp (3 channels - float). C: PIXELFORMAT_UNCOMPRESSED_R32G32B32
  • Pixel.R32G32B32A32: 32*4 bpp (4 channels - float). C: PIXELFORMAT_UNCOMPRESSED_R32G32B32A32
  • Pixel.R16: 16 bpp (1 channel - half float). C: PIXELFORMAT_UNCOMPRESSED_R16
  • Pixel.R16G16B16: 16*3 bpp (3 channels - half float). C: PIXELFORMAT_UNCOMPRESSED_R16G16B16
  • Pixel.R16G16B16A16: 16*4 bpp (4 channels - half float). C: PIXELFORMAT_UNCOMPRESSED_R16G16B16A16
  • Pixel.Dxt1RGB: 4 bpp (no alpha). C: PIXELFORMAT_COMPRESSED_DXT1_RGB
  • Pixel.Dxt1RGBA: 4 bpp (1 bit alpha). C: PIXELFORMAT_COMPRESSED_DXT1_RGBA
  • Pixel.Dxt3RGBA: 8 bpp. C: PIXELFORMAT_COMPRESSED_DXT3_RGBA
  • Pixel.Dxt5RGBA: 8 bpp. C: PIXELFORMAT_COMPRESSED_DXT5_RGBA
  • Pixel.Etc1RGB: 4 bpp. C: PIXELFORMAT_COMPRESSED_ETC1_RGB
  • Pixel.Etc2RGB: 4 bpp. C: PIXELFORMAT_COMPRESSED_ETC2_RGB
  • Pixel.Etc2EacRGBA: 8 bpp. C: PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA
  • Pixel.PvrtRGB: 4 bpp. C: PIXELFORMAT_COMPRESSED_PVRT_RGB
  • Pixel.PvrtRGBA: 4 bpp. C: PIXELFORMAT_COMPRESSED_PVRT_RGBA
  • Pixel.Astc4x4RGBA: Astc4x4RGBA pixels. C: PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA
  • Pixel.Astc8x8RGBA: Astc8x8RGBA pixels. C: PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA

Filter

text
type Filter = choices(

A texture filter, raylib's TextureFilter values.

Members

  • Filter.Point: No filter, pixel approximation. C: TEXTURE_FILTER_POINT
  • Filter.Bilinear: Linear filtering. C: TEXTURE_FILTER_BILINEAR
  • Filter.Trilinear: Trilinear filtering (linear with mipmaps). C: TEXTURE_FILTER_TRILINEAR
  • Filter.Anisotropic4x: Anisotropic filtering 4x. C: TEXTURE_FILTER_ANISOTROPIC_4X
  • Filter.Anisotropic8x: Anisotropic filtering 8x. C: TEXTURE_FILTER_ANISOTROPIC_8X
  • Filter.Anisotropic16x: Anisotropic filtering 16x. C: TEXTURE_FILTER_ANISOTROPIC_16X

WrapMode

text
type WrapMode = choices(

A texture wrap mode, raylib's TextureWrap values.

Members

  • WrapMode.Repeat: Repeats texture in tiled mode. C: TEXTURE_WRAP_REPEAT
  • WrapMode.Clamp: Clamps texture to edge pixel in tiled mode. C: TEXTURE_WRAP_CLAMP
  • WrapMode.MirrorRepeat: Mirrors and repeats the texture in tiled mode. C: TEXTURE_WRAP_MIRROR_REPEAT
  • WrapMode.MirrorClamp: Mirrors and clamps to border the texture in tiled mode. C: TEXTURE_WRAP_MIRROR_CLAMP

CubeLayout

text
type CubeLayout = choices(

A cubemap layout, raylib's CubemapLayout values.

Members

  • CubeLayout.AutoDetect: Automatically detect layout type. C: CUBEMAP_LAYOUT_AUTO_DETECT
  • CubeLayout.LineVertical: Layout is defined by a vertical line with faces. C: CUBEMAP_LAYOUT_LINE_VERTICAL
  • CubeLayout.LineHorizontal: Layout is defined by a horizontal line with faces. C: CUBEMAP_LAYOUT_LINE_HORIZONTAL
  • CubeLayout.CrossThreeByFour: Layout is defined by a 3x4 cross with cubemap faces. C: CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR
  • CubeLayout.CrossFourByThree: Layout is defined by a 4x3 cross with cubemap faces. C: CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE

FontKind

text
type FontKind = choices(

A font kind, raylib's FontType values.

Members

  • FontKind.Default: Default font generation, anti-aliased. C: FONT_DEFAULT
  • FontKind.Bitmap: Bitmap font generation, no anti-aliasing. C: FONT_BITMAP
  • FontKind.Sdf: SDF font generation, requires external shader. C: FONT_SDF

Blend

text
type Blend = choices(

A blend mode, raylib's BlendMode values.

Members

  • Blend.Alpha: Blend textures considering alpha (default). C: BLEND_ALPHA
  • Blend.Additive: Blend textures adding colors. C: BLEND_ADDITIVE
  • Blend.Multiplied: Blend textures multiplying colors. C: BLEND_MULTIPLIED
  • Blend.AddColors: Blend textures adding colors (alternative). C: BLEND_ADD_COLORS
  • Blend.SubtractColors: Blend textures subtracting colors (alternative). C: BLEND_SUBTRACT_COLORS
  • Blend.AlphaPremultiply: Blend premultiplied textures considering alpha. C: BLEND_ALPHA_PREMULTIPLY
  • Blend.Custom: Blend textures using custom src/dst factors (use rlSetBlendFactors()). C: BLEND_CUSTOM
  • Blend.CustomSeparate: Blend textures using custom rgb/alpha separate src/dst factors (use rlSetBlendFactorsSeparate()). C: BLEND_CUSTOM_SEPARATE

TouchGesture

text
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_TAP
  • TouchGesture.DoubleTap: Double tap gesture. C: GESTURE_DOUBLETAP
  • TouchGesture.Hold: Hold gesture. C: GESTURE_HOLD
  • TouchGesture.Drag: Drag gesture. C: GESTURE_DRAG
  • TouchGesture.SwipeRight: Swipe right gesture. C: GESTURE_SWIPE_RIGHT
  • TouchGesture.SwipeLeft: Swipe left gesture. C: GESTURE_SWIPE_LEFT
  • TouchGesture.SwipeUp: Swipe up gesture. C: GESTURE_SWIPE_UP
  • TouchGesture.SwipeDown: Swipe down gesture. C: GESTURE_SWIPE_DOWN
  • TouchGesture.PinchIn: Pinch in gesture. C: GESTURE_PINCH_IN
  • TouchGesture.PinchOut: Pinch out gesture. C: GESTURE_PINCH_OUT

TouchGestures

text
type TouchGestures = set of TouchGesture

A set of touch gestures: uint32(LGestures) is raylib's mask, TouchGestures(N) the set a mask holds.

CameraStyle

text
type CameraStyle = choices(

A camera update style, raylib's CameraMode values.

Members

  • CameraStyle.Custom: Camera custom, controlled by user (UpdateCamera() does nothing). C: CAMERA_CUSTOM
  • CameraStyle.Free: Camera free mode. C: CAMERA_FREE
  • CameraStyle.Orbital: Camera orbital, around target, zoom supported. C: CAMERA_ORBITAL
  • CameraStyle.FirstPerson: Camera first person. C: CAMERA_FIRST_PERSON
  • CameraStyle.ThirdPerson: Camera third person. C: CAMERA_THIRD_PERSON

Projection

text
type Projection = choices(

A camera projection, raylib's CameraProjection values.

Members

  • Projection.Perspective: Perspective projection. C: CAMERA_PERSPECTIVE
  • Projection.Orthographic: Orthographic projection. C: CAMERA_ORTHOGRAPHIC

NPatch

text
type NPatch = choices(

An n-patch layout, raylib's NPatchLayout values.

Members

  • NPatch.NinePatch: Npatch layout: 3x3 tiles. C: NPATCH_NINE_PATCH
  • NPatch.ThreePatchVertical: Npatch layout: 1x3 tiles. C: NPATCH_THREE_PATCH_VERTICAL
  • NPatch.ThreePatchHorizontal: Npatch layout: 3x1 tiles. C: NPATCH_THREE_PATCH_HORIZONTAL

MapIndex

text
type MapIndex = choices(

A material map index, raylib's MaterialMapIndex values.

Members

  • MapIndex.Albedo: Albedo material (same as: MATERIAL_MAP_DIFFUSE). C: MATERIAL_MAP_ALBEDO
  • MapIndex.Metalness: Metalness material (same as: MATERIAL_MAP_SPECULAR). C: MATERIAL_MAP_METALNESS
  • MapIndex.Normal: Normal material. C: MATERIAL_MAP_NORMAL
  • MapIndex.Roughness: Roughness material. C: MATERIAL_MAP_ROUGHNESS
  • MapIndex.Occlusion: Ambient occlusion material. C: MATERIAL_MAP_OCCLUSION
  • MapIndex.Emission: Emission material. C: MATERIAL_MAP_EMISSION
  • MapIndex.Height: Heightmap material. C: MATERIAL_MAP_HEIGHT
  • MapIndex.Cubemap: Cubemap material (NOTE: Uses GL_TEXTURE_CUBE_MAP). C: MATERIAL_MAP_CUBEMAP
  • MapIndex.Irradiance: Irradiance material (NOTE: Uses GL_TEXTURE_CUBE_MAP). C: MATERIAL_MAP_IRRADIANCE
  • MapIndex.Prefilter: Prefilter material (NOTE: Uses GL_TEXTURE_CUBE_MAP). C: MATERIAL_MAP_PREFILTER
  • MapIndex.Brdf: Brdf material. C: MATERIAL_MAP_BRDF

ShaderLoc

text
type ShaderLoc = choices(

A shader location index, raylib's ShaderLocationIndex values.

Members

  • ShaderLoc.VertexPosition: Shader location: vertex attribute: position. C: SHADER_LOC_VERTEX_POSITION
  • ShaderLoc.VertexTexcoord01: Shader location: vertex attribute: texcoord01. C: SHADER_LOC_VERTEX_TEXCOORD01
  • ShaderLoc.VertexTexcoord02: Shader location: vertex attribute: texcoord02. C: SHADER_LOC_VERTEX_TEXCOORD02
  • ShaderLoc.VertexNormal: Shader location: vertex attribute: normal. C: SHADER_LOC_VERTEX_NORMAL
  • ShaderLoc.VertexTangent: Shader location: vertex attribute: tangent. C: SHADER_LOC_VERTEX_TANGENT
  • ShaderLoc.VertexColor: Shader location: vertex attribute: color. C: SHADER_LOC_VERTEX_COLOR
  • ShaderLoc.MatrixMvp: Shader location: matrix uniform: model-view-projection. C: SHADER_LOC_MATRIX_MVP
  • ShaderLoc.MatrixView: Shader location: matrix uniform: view (camera transform). C: SHADER_LOC_MATRIX_VIEW
  • ShaderLoc.MatrixProjection: Shader location: matrix uniform: projection. C: SHADER_LOC_MATRIX_PROJECTION
  • ShaderLoc.MatrixModel: Shader location: matrix uniform: model (transform). C: SHADER_LOC_MATRIX_MODEL
  • ShaderLoc.MatrixNormal: Shader location: matrix uniform: normal. C: SHADER_LOC_MATRIX_NORMAL
  • ShaderLoc.VectorView: Shader location: vector uniform: view. C: SHADER_LOC_VECTOR_VIEW
  • ShaderLoc.ColorDiffuse: Shader location: vector uniform: diffuse color. C: SHADER_LOC_COLOR_DIFFUSE
  • ShaderLoc.ColorSpecular: Shader location: vector uniform: specular color. C: SHADER_LOC_COLOR_SPECULAR
  • ShaderLoc.ColorAmbient: Shader location: vector uniform: ambient color. C: SHADER_LOC_COLOR_AMBIENT
  • ShaderLoc.MapAlbedo: Shader location: sampler2d texture: albedo (same as: SHADER_LOC_MAP_DIFFUSE). C: SHADER_LOC_MAP_ALBEDO
  • ShaderLoc.MapMetalness: Shader location: sampler2d texture: metalness (same as: SHADER_LOC_MAP_SPECULAR). C: SHADER_LOC_MAP_METALNESS
  • ShaderLoc.MapNormal: Shader location: sampler2d texture: normal. C: SHADER_LOC_MAP_NORMAL
  • ShaderLoc.MapRoughness: Shader location: sampler2d texture: roughness. C: SHADER_LOC_MAP_ROUGHNESS
  • ShaderLoc.MapOcclusion: Shader location: sampler2d texture: occlusion. C: SHADER_LOC_MAP_OCCLUSION
  • ShaderLoc.MapEmission: Shader location: sampler2d texture: emission. C: SHADER_LOC_MAP_EMISSION
  • ShaderLoc.MapHeight: Shader location: sampler2d texture: heightmap. C: SHADER_LOC_MAP_HEIGHT
  • ShaderLoc.MapCubemap: Shader location: samplerCube texture: cubemap. C: SHADER_LOC_MAP_CUBEMAP
  • ShaderLoc.MapIrradiance: Shader location: samplerCube texture: irradiance. C: SHADER_LOC_MAP_IRRADIANCE
  • ShaderLoc.MapPrefilter: Shader location: samplerCube texture: prefilter. C: SHADER_LOC_MAP_PREFILTER
  • ShaderLoc.MapBrdf: Shader location: sampler2d texture: brdf. C: SHADER_LOC_MAP_BRDF
  • ShaderLoc.VertexBoneIds: Shader location: vertex attribute: bone indices. C: SHADER_LOC_VERTEX_BONEIDS
  • ShaderLoc.VertexBoneWeights: Shader location: vertex attribute: bone weights. C: SHADER_LOC_VERTEX_BONEWEIGHTS
  • ShaderLoc.BoneMatrices: Shader location: matrix attribute: bone transforms (animation). C: SHADER_LOC_MATRIX_BONETRANSFORMS
  • ShaderLoc.VertexInstanceTx: Shader location: vertex attribute: instance transforms. C: SHADER_LOC_VERTEX_INSTANCETRANSFORM

UniformType

text
type UniformType = choices(

A shader uniform data type, raylib's ShaderUniformDataType values.

Members

  • UniformType.Float: Shader uniform type: float. C: SHADER_UNIFORM_FLOAT
  • UniformType.Vec2: Shader uniform type: vec2 (2 float). C: SHADER_UNIFORM_VEC2
  • UniformType.Vec3: Shader uniform type: vec3 (3 float). C: SHADER_UNIFORM_VEC3
  • UniformType.Vec4: Shader uniform type: vec4 (4 float). C: SHADER_UNIFORM_VEC4
  • UniformType.Int: Shader uniform type: int. C: SHADER_UNIFORM_INT
  • UniformType.IVec2: Shader uniform type: ivec2 (2 int). C: SHADER_UNIFORM_IVEC2
  • UniformType.IVec3: Shader uniform type: ivec3 (3 int). C: SHADER_UNIFORM_IVEC3
  • UniformType.IVec4: Shader uniform type: ivec4 (4 int). C: SHADER_UNIFORM_IVEC4
  • UniformType.UInt: Shader uniform type: unsigned int. C: SHADER_UNIFORM_UINT
  • UniformType.UIVec2: Shader uniform type: uivec2 (2 unsigned int). C: SHADER_UNIFORM_UIVEC2
  • UniformType.UIVec3: Shader uniform type: uivec3 (3 unsigned int). C: SHADER_UNIFORM_UIVEC3
  • UniformType.UIVec4: Shader uniform type: uivec4 (4 unsigned int). C: SHADER_UNIFORM_UIVEC4
  • UniformType.Sampler2D: Shader uniform type: sampler2d. C: SHADER_UNIFORM_SAMPLER2D

AttribType

text
type AttribType = choices(

A shader attribute data type, raylib's ShaderAttributeDataType values.

Members

  • AttribType.Float: Shader attribute type: float. C: SHADER_ATTRIB_FLOAT
  • AttribType.Vec2: Shader attribute type: vec2 (2 float). C: SHADER_ATTRIB_VEC2
  • AttribType.Vec3: Shader attribute type: vec3 (3 float). C: SHADER_ATTRIB_VEC3
  • AttribType.Vec4: Shader attribute type: vec4 (4 float). C: SHADER_ATTRIB_VEC4

AutomationKind

text
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

text
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 at AArchive (its password APassword, "" for none), closed again at Unmount or the program's end. A source mounted before goes first. Parameters: AArchive the archive; APassword the password. Returns: false when the archive cannot be opened or used (nothing mounted then)
  • static method Mount(const ASource: IOSource): bool: Mounts ASource (the program keeps it: Unmount never closes it). A source mounted before goes first. Parameters: ASource the source. Returns: false when it cannot be used (nil, no room): nothing mounted then
  • static 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: true while a source is mounted

Example: if not Assets.Mount("$P:../../../../assets.zip", "Adam") then return 1; end;

GlyphsRes

text
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 file AData at ASize pixels: those of ACodepoints, or raylib's default 95 for none. C: LoadFontData Parameters: AData the bytes; ASize the size; ACodepoints the codepoints; AKind the kind.
  • const method IsValid(): bool: True when the glyphs loaded. Returns: true when the glyphs loaded
  • const 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: Glyph AIndex (0 to Count() - 1; an empty one outside): its image is borrowed, alive while this handle is. Parameters: AIndex the index, from 0. Returns: glyph AIndex (0 to Count() - 1; an empty one outside): its image is borrowed, alive while this handle is
  • const 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

text
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 at APath (from the mounted source). C: LoadImage Parameters: APath the file's path.
  • static method Adopt(const AImage: Image): ImageRes: Takes the .C image AImage over: unloaded with the last copy. Parameters: AImage the image. Returns: the new ImageRes
  • static method FromIO(const AIO: IO; const AType: string): ImageRes: Loads an image of type AType (".png" ...) from AIO. Parameters: AIO the IO; AType the type. Returns: the new ImageRes
  • static method FromMemory(const AType: string; const AData: array of uint8): ImageRes: Loads an image of type AType (".png" ...) from the file bytes AData. C: LoadImageFromMemory Parameters: AType the type; AData the bytes. Returns: the new ImageRes
  • static method Raw(const APath: string; const AWidth: int32; const AHeight: int32; const AFormat: Pixel; const AHeaderSize: int32): ImageRes: Loads raw pixels of AFormat (AWidth x AHeight, after AHeaderSize bytes) from APath. C: LoadImageRaw Parameters: APath the file's path; AWidth the width; AHeight the height; AFormat the pixel format; AHeaderSize the header size. Returns: the new ImageRes
  • static method Anim(const APath: string; var AFrames: int32): ImageRes: Loads every frame of the animated image at APath (a GIF), stacked top to bottom. C: LoadImageAnim Parameters: AFrames set to the number of frames; APath the file's path. Returns: the new ImageRes
  • static method Anim(const AType: string; const AData: array of uint8; var AFrames: int32): ImageRes: Loads every frame of an animated image of type AType from the file bytes AData. C: LoadImageAnimFromMemory Parameters: AType the type; AData the bytes; AFrames the frames. Returns: the new ImageRes
  • static method Color(const AWidth: int32; const AHeight: int32; const AColor: Color): ImageRes: A AWidth x AHeight image filled with AColor. C: GenImageColor Parameters: AWidth the width; AHeight the height; AColor the colour. Returns: a AWidth x AHeight image filled with AColor
  • static method GradientLinear(const AWidth: int32; const AHeight: int32; const ADirection: int32; const AStart: Color; const AEnd: Color): ImageRes: A linear gradient from AStart to AEnd. C: GenImageGradientLinear Parameters: ADirection degrees: 0 left to right, 90 top to bottom; AWidth the width; AHeight the height; AStart the start; AEnd the end. Returns: a linear gradient from AStart to AEnd
  • static method GradientRadial(const AWidth: int32; const AHeight: int32; const ADensity: float32; const AInner: Color; const AOuter: Color): ImageRes: A radial gradient, AInner at the center. C: GenImageGradientRadial Parameters: ADensity 0 to 1: where the outer color starts; AWidth the width; AHeight the height; AInner the colour at the centre; AOuter the colour at the edge. Returns: a radial gradient, AInner at the center
  • static method GradientSquare(const AWidth: int32; const AHeight: int32; const ADensity: float32; const AInner: Color; const AOuter: Color): ImageRes: A square gradient, AInner at the center. C: GenImageGradientSquare Parameters: AWidth the width; AHeight the height; ADensity the density; AInner the colour at the centre; AOuter the colour at the edge. Returns: a square gradient, AInner at the center
  • static method Checked(const AWidth: int32; const AHeight: int32; const AChecksX: int32; const AChecksY: int32; const AColor1: Color; const AColor2: Color): ImageRes: A checkerboard of AChecksX x AChecksY squares in two colors. C: GenImageChecked Parameters: AWidth the width; AHeight the height; AChecksX the checks X; AChecksY the checks Y; AColor1 the color1; AColor2 the color2. Returns: a checkerboard of AChecksX x AChecksY squares in two colors
  • static 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: AWidth the width; AHeight the height; AFactor the factor. Returns: the new ImageRes
  • static 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) at AScale. C: GenImagePerlinNoise Parameters: AWidth the width; AHeight the height; AOffsetX the offset X; AOffsetY the offset Y; AScale the scale. Returns: the new ImageRes
  • static method Cellular(const AWidth: int32; const AHeight: int32; const ATileSize: int32): ImageRes: Cellular (Worley) noise, one cell per ATileSize pixels. C: GenImageCellular Parameters: AWidth the width; AHeight the height; ATileSize the tile size. Returns: the new ImageRes
  • static method FontAtlas(const AGlyphs: GlyphsRes; var ARecs: array of Rectangle; const ASize: int32; const APadding: int32; const APacking: int32): ImageRes: A font atlas of AGlyphs at ASize pixels, APadding around each glyph. C: GenImageFontAtlas Parameters: ARecs set to each glyph's rectangle in the atlas; APacking 0: raylib's default packing, 1: skyline; AGlyphs the glyphs; ASize the size; APadding the padding. Returns: a font atlas of AGlyphs at ASize pixels, APadding around each glyph
  • const 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 part ARect of this one. C: ImageFromImage Parameters: ARect the rectangle. Returns: a new image of the part ARect of this one
  • const method Channel(const AIndex: int32): ImageRes: A new grayscale image of channel AIndex (0 red .. 3 alpha). C: ImageFromChannel Parameters: AIndex the index, from 0. Returns: a new grayscale image of channel AIndex (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: true when the image holds pixels
  • const method Width(): int32: The width in pixels. Returns: the width in pixels
  • const method Height(): int32: The height in pixels. Returns: the height in pixels
  • const 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 format
  • method ToFormat(const AFormat: Pixel): self: Converts the pixels to AFormat. C: ImageFormat Parameters: AFormat the pixel format. Returns: this object, so calls chain
  • method ToPot(const AFill: Color): self: Grows the image to power-of-two sides, the new pixels AFill. C: ImageToPOT Parameters: AFill the colour of the new pixels. Returns: this object, so calls chain
  • method Crop(const ARect: Rectangle): self: Cuts the image to ARect. C: ImageCrop Parameters: ARect the rectangle. Returns: this object, so calls chain
  • method AlphaCrop(const AThreshold: float32): self: Cuts the image to its pixels above AThreshold alpha (0 to 1). C: ImageAlphaCrop Parameters: AThreshold the threshold. Returns: this object, so calls chain
  • method AlphaClear(const AColor: Color; const AThreshold: float32): self: The pixels at or below AThreshold alpha become AColor. C: ImageAlphaClear Parameters: AColor the colour; AThreshold the threshold. Returns: this object, so calls chain
  • method AlphaMask(const AMask: ImageRes): self: The alpha channel becomes AMask's gray. C: ImageAlphaMask Parameters: AMask the mask. Returns: this object, so calls chain
  • method AlphaPremultiply(): self: Multiplies the colors by their alpha. C: ImageAlphaPremultiply Returns: this object, so calls chain
  • method BlurGaussian(const ASize: int32): self: A box blur approximating a Gaussian of ASize pixels. C: ImageBlurGaussian Parameters: ASize the size. Returns: this object, so calls chain
  • method Convolve(const AKernel: array of float32): self: Convolves the image with the square kernel AKernel (3 x 3: nine values, ...; an empty one does nothing). C: ImageKernelConvolution Parameters: AKernel the kernel. Returns: this object, so calls chain
  • method Resize(const AWidth: int32; const AHeight: int32): self: Scales the image to AWidth x AHeight (bicubic). C: ImageResize Parameters: AWidth the width; AHeight the height. Returns: this object, so calls chain
  • method ResizeNN(const AWidth: int32; const AHeight: int32): self: Scales the image to AWidth x AHeight (nearest neighbor: pixel art). C: ImageResizeNN Parameters: AWidth the width; AHeight the height. Returns: this object, so calls chain
  • method ResizeCanvas(const AWidth: int32; const AHeight: int32; const AOffsetX: int32; const AOffsetY: int32; const AFill: Color): self: Sets the canvas to AWidth x AHeight, the image at (AOffsetX, AOffsetY), the new pixels AFill. C: ImageResizeCanvas Parameters: AWidth the width; AHeight the height; AOffsetX the offset X; AOffsetY the offset Y; AFill the colour of the new pixels. Returns: this object, so calls chain
  • method GenMipmaps(): self: Adds every mipmap level. C: ImageMipmaps Returns: this object, so calls chain
  • method 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: ARed the red; AGreen the green; ABlue the blue; AAlpha the alpha. Returns: this object, so calls chain
  • method FlipVertical(): self: Flips the image upside down. C: ImageFlipVertical Returns: this object, so calls chain
  • method FlipHorizontal(): self: Mirrors the image left to right. C: ImageFlipHorizontal Returns: this object, so calls chain
  • method Rotate(const ADegrees: int32): self: Rotates by ADegrees (any angle, the canvas grown to hold it). C: ImageRotate Parameters: ADegrees the degrees. Returns: this object, so calls chain
  • method RotateCW(): self: Rotates 90 degrees clockwise. C: ImageRotateCW Returns: this object, so calls chain
  • method RotateCCW(): self: Rotates 90 degrees counter-clockwise. C: ImageRotateCCW Returns: this object, so calls chain
  • method Tint(const AColor: Color): self: Multiplies every pixel by AColor. C: ImageColorTint Parameters: AColor the colour. Returns: this object, so calls chain
  • method Invert(): self: Inverts every pixel's colour. C: ImageColorInvert Returns: this object, so calls chain
  • method Grayscale(): self: Turns the image to grayscale. C: ImageColorGrayscale Returns: this object, so calls chain
  • method Contrast(const AContrast: int32): self: Changes the contrast by AContrast (-100 to 100). C: ImageColorContrast Parameters: AContrast the contrast. Returns: this object, so calls chain
  • method Brightness(const ABrightness: int32): self: Changes the brightness by ABrightness (-255 to 255). C: ImageColorBrightness Parameters: ABrightness the brightness. Returns: this object, so calls chain
  • method Replace(const AFrom: Color; const ATo: Color): self: Every pixel of AFrom becomes ATo. C: ImageColorReplace Parameters: AFrom the colour replaced; ATo the colour put in its place. Returns: this object, so calls chain
  • const 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, AMaxSize at most. C: LoadImagePalette / UnloadImagePalette Parameters: AMaxSize the max size. Returns: the distinct colors of the image, AMaxSize at most
  • const method AlphaBorder(const AThreshold: float32): Rectangle: The smallest rectangle holding every pixel above AThreshold alpha (0 to 1). C: GetImageAlphaBorder Parameters: AThreshold the threshold. Returns: the smallest rectangle holding every pixel above AThreshold alpha (0 to 1)
  • const method Pixel(const AX: int32; const AY: int32): Color: The color of the pixel (AX, AY). C: GetImageColor Parameters: AX the x coordinate; AY the y coordinate. Returns: the color of the pixel (AX, AY)
  • method Clear(const AColor: Color): self: Fills the image with AColor. C: ImageClearBackground Parameters: AColor the colour. Returns: this object, so calls chain
  • method Pixel(const APos: Vector2; const AColor: Color): self: One pixel. C: ImageDrawPixel / ImageDrawPixelV Parameters: APos the position; AColor the colour. Returns: this object, so calls chain
  • method Line(const AStart: Vector2; const AEnd: Vector2; const AColor: Color): self: A one-pixel line. C: ImageDrawLine / ImageDrawLineV Parameters: AStart the start; AEnd the end; AColor the colour. Returns: this object, so calls chain
  • method Line(const AStart: Vector2; const AEnd: Vector2; const AThick: int32; const AColor: Color): self: A line AThick pixels wide. C: ImageDrawLineEx Parameters: AStart the start; AEnd the end; AThick the line thickness; AColor the colour. Returns: this object, so calls chain
  • method LineStrip(const APoints: array of Vector2; const AColor: Color): self: Lines joining APoints in turn. C: ImageDrawLineStrip Parameters: APoints the points; AColor the colour. Returns: this object, so calls chain
  • method Triangle(const AA: Vector2; const AB: Vector2; const AC: Vector2; const AColor: Color): self: A filled triangle (corners counter-clockwise). C: ImageDrawTriangle Parameters: AA the first corner; AB the second corner; AC the third corner; AColor the colour. Returns: this object, so calls chain
  • method 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: AA the first corner; AB the second corner; AC the third corner; AColorA the color A; AColorB the color B; AColorC the color C. Returns: this object, so calls chain
  • method TriangleLines(const AA: Vector2; const AB: Vector2; const AC: Vector2; const AColor: Color): self: A triangle's edges. C: ImageDrawTriangleLines Parameters: AA the first corner; AB the second corner; AC the third corner; AColor the colour. Returns: this object, so calls chain
  • method TriangleFan(const APoints: array of Vector2; const AColor: Color): self: A triangle fan (the first point its center). C: ImageDrawTriangleFan Parameters: APoints the points; AColor the colour. Returns: this object, so calls chain
  • method TriangleStrip(const APoints: array of Vector2; const AColor: Color): self: A triangle strip. C: ImageDrawTriangleStrip Parameters: APoints the points; AColor the colour. Returns: this object, so calls chain
  • method Rect(const ARect: Rectangle; const AColor: Color): self: A filled rectangle. C: ImageDrawRectangle / ImageDrawRectangleV / ImageDrawRectangleRec Parameters: ARect the rectangle; AColor the colour. Returns: this object, so calls chain
  • method Rect(const ARect: Rectangle; const AOrigin: Vector2; const ARotation: float32; const AColor: Color): self: A filled rectangle turned ARotation degrees about AOrigin (from its corner). C: ImageDrawRectanglePro Parameters: ARect the rectangle; AOrigin the origin; ARotation the rotation; AColor the colour. Returns: this object, so calls chain
  • method RectLines(const ARect: Rectangle; const AColor: Color): self: A rectangle's one-pixel edges. C: ImageDrawRectangleLines Parameters: ARect the rectangle; AColor the colour. Returns: this object, so calls chain
  • method RectLines(const ARect: Rectangle; const AThick: int32; const AColor: Color): self: A rectangle's edges AThick pixels wide. C: ImageDrawRectangleLinesEx Parameters: ARect the rectangle; AThick the line thickness; AColor the colour. Returns: this object, so calls chain
  • method 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: ATopLeft the top-left corner's color, then bottom-left, bottom-right, top-right; ARect the rectangle; ABottomLeft the bottom-left corner's colour; ABottomRight the bottom-right corner's colour; ATopRight the top-right corner's colour. Returns: this object, so calls chain
  • method Circle(const ACenter: Vector2; const ARadius: int32; const AColor: Color): self: A filled circle. C: ImageDrawCircle / ImageDrawCircleV Parameters: ACenter the centre; ARadius the radius; AColor the colour. Returns: this object, so calls chain
  • method CircleLines(const ACenter: Vector2; const ARadius: int32; const AColor: Color): self: A circle's outline. C: ImageDrawCircleLines / ImageDrawCircleLinesV Parameters: ACenter the centre; ARadius the radius; AColor the colour. Returns: this object, so calls chain
  • method CircleGradient(const ACenter: Vector2; const ARadius: float32; const AInner: Color; const AOuter: Color): self: A circle shaded from AInner at its center to AOuter. C: ImageDrawCircleGradient Parameters: ACenter the centre; ARadius the radius; AInner the colour at the centre; AOuter the colour at the edge. Returns: this object, so calls chain
  • method Image(const ASource: ImageRes; const APos: Vector2; const ATint: Color): self: ASource drawn at APos, multiplied by ATint. C: ImageDrawImage Parameters: ASource the source; APos the position; ATint the tint colour. Returns: this object, so calls chain
  • method Image(const ASource: ImageRes; const APos: Vector2; const ARotation: float32; const AScale: float32; const ATint: Color): self: ASource turned ARotation degrees and scaled by AScale at APos. C: ImageDrawImageEx Parameters: ASource the source; APos the position; ARotation the rotation; AScale the scale; ATint the tint colour. Returns: this object, so calls chain
  • method Image(const ASource: ImageRes; const ASourceRect: Rectangle; const APos: Vector2; const ATint: Color): self: The part ASourceRect of ASource at APos. C: ImageDrawImageRec Parameters: ASource the source; ASourceRect the source rect; APos the position; ATint the tint colour. Returns: this object, so calls chain
  • method Image(const ASource: ImageRes; const ASourceRect: Rectangle; const ADestRect: Rectangle; const ATint: Color): self: The part ASourceRect of ASource scaled into ADestRect. C: ImageDrawImagePro Parameters: ASource the source; ASourceRect the source rect; ADestRect the dest rect; ATint the tint colour. Returns: this object, so calls chain
  • method Image(const ASource: ImageRes; const ASourceRect: Rectangle; const ADestRect: Rectangle; const AOrigin: Vector2; const ARotation: float32; const ATint: Color): self: The part ASourceRect of ASource scaled into ADestRect, turned ARotation degrees about AOrigin (from the destination's corner). C: ImageDrawImagePro Parameters: ASource the source; ASourceRect the source rect; ADestRect the dest rect; AOrigin the origin; ARotation the rotation; ATint the tint colour. Returns: this object, so calls chain
  • const method Export(const APath: string): bool: Saves the image at APath (its extension the format: .png, .bmp, .qoi ...). C: ExportImage Parameters: APath the file's path. Returns: true when the file was written
  • const method ExportToMemory(const AType: string): array of uint8: The image as the bytes of a file of type AType (".png" ...; none when it cannot be written). C: ExportImageToMemory Parameters: AType the type. Returns: the image as the bytes of a file of type AType (".png" ...; none when it cannot be written)
  • const method ExportAsCode(const APath: string): bool: Saves the pixels as a C header at APath. C: ExportImageAsCode Parameters: APath the file's path. Returns: true when the file was written

Example: LImg: ImageRes("images/adam.png"); LImg.Resize(64, 64).FlipVertical(); LTex := LImg.ToTexture();

TextureRes

text
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 at APath (from the mounted source) as a texture. C: LoadTexture Parameters: APath the file's path.
  • static method Adopt(const ATexture: Texture2D): TextureRes: Takes the .C texture ATexture over: unloaded with the last copy (or the window). Parameters: ATexture the texture. Returns: the new TextureRes
  • static method View(const ATexture: Texture2D): TextureRes: A view of ATexture, 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: ATexture the texture. Returns: a view of ATexture, 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 type AType (".png" ...) from AIO as a texture. Parameters: AIO the IO; AType the type. Returns: the new TextureRes
  • static method FromImage(const AImage: ImageRes): TextureRes: AImage's pixels as a texture. C: LoadTextureFromImage Parameters: AImage the image. Returns: AImage's pixels as a texture
  • static method Cubemap(const AImage: ImageRes; const ALayout: CubeLayout): TextureRes: A cubemap from AImage's six faces laid out as ALayout. C: LoadTextureCubemap Parameters: AImage the image; ALayout the layout. Returns: a cubemap from AImage's six faces laid out as ALayout
  • const 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: true when the texture is on the GPU
  • const method Width(): int32: The width in pixels. Returns: the width in pixels
  • const method Height(): int32: The height in pixels. Returns: the height in pixels
  • const method Size(): Vector2: The size in pixels. Returns: the size in pixels
  • const 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 format
  • method Update(const APixels: ptr to const): Replaces every pixel with APixels (the texture's size and format). C: UpdateTexture Parameters: APixels the pixels.
  • method Update(const ARect: Rectangle; const APixels: ptr to const): Replaces the pixels of ARect with APixels. C: UpdateTextureRec Parameters: ARect the rectangle; APixels the pixels.
  • method GenMipmaps(): self: Adds every mipmap level. C: GenTextureMipmaps Returns: this object, so calls chain
  • method SetFilter(const AFilter: Filter): self: How the texture is sampled when scaled. C: SetTextureFilter Parameters: AFilter the filter. Returns: this object, so calls chain
  • method SetWrap(const AWrap: WrapMode): self: How the texture repeats past its edges. C: SetTextureWrap Parameters: AWrap the wrap mode. Returns: this object, so calls chain
  • const 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

text
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): A AWidth x AHeight render texture (RGBA, with a depth buffer). C: LoadRenderTexture Parameters: AWidth the width; AHeight the height.
  • init(const AWidth: int32; const AHeight: int32; const AFormat: Pixel): A AWidth x AHeight render texture of pixel format AFormat. C: LoadRenderTextureEx Parameters: AWidth the width; AHeight the height; AFormat the pixel format.
  • static method Adopt(const ATarget: RenderTexture2D): RenderTextureRes: Takes the .C render texture ATarget over: unloaded with the last copy (or the window). Parameters: ATarget the target. Returns: the new RenderTextureRes
  • const 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: true when the render texture is on the GPU
  • const 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.Texture of 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 pixels
  • const method Height(): int32: The height in pixels. Returns: the height in pixels
  • const method Begin(): Drawing lands in this texture, in its pixels, until End (inside a frame too: the frame comes back at End). C: BeginTextureMode
  • static 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

text
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 at APath (from the mounted source) at its default size. C: LoadFont Parameters: APath the file's path.
  • init(const APath: string; const ASize: int32): Loads the font file at APath at ASize pixels, raylib's default 95 glyphs. C: LoadFontEx Parameters: APath the file's path; ASize the size.
  • init(const APath: string; const ASize: int32; const ACodepoints: array of int32): Loads the font file at APath at ASize pixels, the glyphs of ACodepoints (none: raylib's default 95). C: LoadFontEx Parameters: APath the file's path; ASize the size; ACodepoints the codepoints.
  • static method Adopt(const AFont: Font): FontRes: Takes the .C font AFont over: unloaded with the last copy (or the window; raylib's default font never is). Parameters: AFont the font. Returns: the new FontRes
  • static 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 type AType (".ttf" ...) from AIO at ASize pixels, raylib's default 95 glyphs. Parameters: AIO the IO; AType the type; ASize the size. Returns: the new FontRes
  • static method FromMemory(const AType: string; const AData: array of uint8; const ASize: int32; const ACodepoints: array of int32): FontRes: Loads a font of type AType (".ttf" ...) from the file bytes AData at ASize pixels, the glyphs of ACodepoints (none: raylib's default 95). C: LoadFontFromMemory Parameters: AType the type; AData the bytes; ASize the size; ACodepoints the codepoints. Returns: the new FontRes
  • static method FromImage(const AImage: ImageRes; const AKey: Color; const AFirstChar: int32): FontRes: A bitmap font from AImage: glyphs in a row from AFirstChar, parted by the key color AKey. C: LoadFontFromImage Parameters: AImage the image; AKey the key; AFirstChar the first char. Returns: a bitmap font from AImage: glyphs in a row from AFirstChar, parted by the key color AKey
  • static method Glyphs(const AData: array of uint8; const ASize: int32; const ACodepoints: array of int32; const AKind: FontKind): GlyphsRes: The glyphs of the font file AData (for ImageRes.FontAtlas): GlyphsRes's own init. C: LoadFontData Parameters: AData the bytes; ASize the size; ACodepoints the codepoints; AKind the kind. Returns: the glyphs of the font file AData (for ImageRes.FontAtlas): GlyphsRes's own init
  • const 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: true when the font holds glyphs and an atlas
  • const method BaseSize(): int32: The size the glyphs were made at. Returns: the size the glyphs were made at
  • const method GlyphCount(): int32: How many glyphs the font holds. Returns: how many glyphs the font holds
  • const method GlyphPadding(): int32: The padding around each glyph in the atlas. Returns: the padding around each glyph in the atlas
  • const method Measure(const AText: string; const ASize: float32; const ASpacing: float32): Vector2: The size AText takes at ASize, ASpacing between glyphs. C: MeasureTextEx Parameters: AText the text; ASize the size; ASpacing the spacing. Returns: the size AText takes at ASize, ASpacing between glyphs
  • const method Measure(const AText: string; const ASize: int32): int32: The width AText takes at ASize by raylib's DrawText rules (10 the least, one unit of spacing per whole 10): Draw.Text's default-font form, measured. C: MeasureText Parameters: AText the text; ASize the size. Returns: the width AText takes at ASize by 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 codepoints ACodepoints take. C: MeasureTextCodepoints Parameters: ACodepoints the codepoints; ASize the size; ASpacing the spacing. Returns: the size the codepoints ACodepoints take
  • const method GlyphIndex(const ACodepoint: int32): int32: The index of codepoint ACodepoint's glyph ('?''s when the font lacks it). C: GetGlyphIndex Parameters: ACodepoint the codepoint. Returns: the index of codepoint ACodepoint's glyph ('?''s when the font lacks it)
  • const method Glyph(const ACodepoint: int32): GlyphInfo: Codepoint ACodepoint's glyph. C: GetGlyphInfo Parameters: ACodepoint the codepoint. Returns: codepoint ACodepoint's glyph
  • const method GlyphRect(const ACodepoint: int32): Rectangle: Codepoint ACodepoint's rectangle in the atlas. C: GetGlyphAtlasRec Parameters: ACodepoint the codepoint. Returns: codepoint ACodepoint's rectangle in the atlas
  • const 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 at APath. C: ExportFontAsCode Parameters: APath the file's path. Returns: true when the file was written
  • static method LineSpacing(const ASpacing: int32): The gap between lines of a text with line breaks, for every font. C: SetTextLineSpacing Parameters: ASpacing the spacing.

Example: LMono: FontRes("fonts/JetBrainsMonoRegular.ttf", 32); Draw.Text(LMono, "Score", Vector2(x: 8, y: 8), 32.0f, 1.0f, WHITE);

ShaderRes

text
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 at AVertexPath / AFragmentPath (from the mounted source); "" takes raylib's default for that stage. C: LoadShader Parameters: AVertexPath the vertex path; AFragmentPath the fragment path.
  • static method Adopt(const AShader: Shader): ShaderRes: Takes the .C shader AShader over: unloaded with the last copy (or the window). Parameters: AShader the shader. Returns: the new ShaderRes
  • static method FromCode(const AVertex: string; const AFragment: string): ShaderRes: Compiles and links the GLSL sources AVertex / AFragment; "" takes raylib's default for that stage. C: LoadShaderFromMemory Parameters: AVertex the vertex; AFragment the fragment. Returns: the new ShaderRes
  • static method FromIO(const AVertex: IO; const AFragment: IO): ShaderRes: Loads the stages from AVertex / AFragment (nil takes raylib's default for that stage). Parameters: AVertex the vertex; AFragment the fragment. Returns: the new ShaderRes
  • const 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: true when the program is linked on the GPU
  • const method Location(const AName: string): int32: The location of the uniform AName (-1 when the program has none). C: GetShaderLocation Parameters: AName the name. Returns: the location of the uniform AName (-1 when the program has none)
  • const method Attrib(const AName: string): int32: The location of the vertex attribute AName (-1 when the program has none). C: GetShaderLocationAttrib Parameters: AName the name. Returns: the location of the vertex attribute AName (-1 when the program has none)
  • method SetLoc(const ALoc: ShaderLoc; const ALocation: int32): self: Makes raylib's drawing feed ALoc through ALocation (a uniform or an attribute of this program, from Location / Attrib). C: shader.locs[] Parameters: ALoc the loc; ALocation the location. Returns: this object, so calls chain
  • method Set(const ALocation: int32; const AValue: float32): self: Sets the float uniform at ALocation. C: SetShaderValue Parameters: ALocation the location; AValue the value. Returns: this object, so calls chain
  • method Set(const ALocation: int32; const AValue: int32): self: Sets the int uniform (or sampler unit) at ALocation. C: SetShaderValue Parameters: ALocation the location; AValue the value. Returns: this object, so calls chain
  • method Set(const ALocation: int32; const AValue: Vector2): self: Sets the vec2 uniform at ALocation. C: SetShaderValue Parameters: ALocation the location; AValue the value. Returns: this object, so calls chain
  • method Set(const ALocation: int32; const AValue: Vector3): self: Sets the vec3 uniform at ALocation. C: SetShaderValue Parameters: ALocation the location; AValue the value. Returns: this object, so calls chain
  • method Set(const ALocation: int32; const AValue: Vector4): self: Sets the vec4 uniform at ALocation. C: SetShaderValue Parameters: ALocation the location; AValue the value. Returns: this object, so calls chain
  • method Set(const ALocation: int32; const AColor: Color): self: Sets the vec4 uniform at ALocation to AColor normalized (each channel 0..1). C: SetShaderValue, ColorNormalize Parameters: ALocation the location; AColor the colour. Returns: this object, so calls chain
  • method Set(const ALocation: int32; const AValues: array of float32; const AType: UniformType): self: Sets the uniform array at ALocation from AValues as elements of AType (a vec3 takes three values each; an int / uint type takes each value as a whole number). C: SetShaderValueV Parameters: ALocation the location; AValues the values; AType the type. Returns: this object, so calls chain
  • method Set(const ALocation: int32; const AMatrix: Matrix): self: Sets the mat4 uniform at ALocation. C: SetShaderValueMatrix Parameters: ALocation the location; AMatrix the matrix. Returns: this object, so calls chain
  • method Set(const ALocation: int32; const ATexture: TextureRes): self: Binds ATexture to the sampler uniform at ALocation. C: SetShaderValueTexture Parameters: ALocation the location; ATexture the texture. Returns: this object, so calls chain
  • const method Begin(): Drawing goes through this shader until End (the shader kept alive until then). C: BeginShaderMode
  • static 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

text
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 material AMaterial over: its maps, and the textures and shader that are not raylib's defaults, unloaded with the last copy (or the window). Parameters: AMaterial the material. Returns: the new MaterialRes
  • static 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 at APath (an .mtl, from the mounted source; its textures load beside it). C: LoadMaterials Parameters: APath the file's path. Returns: the materials of the file at APath (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: true when the material has its maps and a shader
  • method SetTexture(const AMap: MapIndex; const ATexture: TextureRes): self: Map AMap takes ATexture (kept alive by the material; a texture the material loaded for that map is unloaded). C: SetMaterialTexture Parameters: AMap the map; ATexture the texture. Returns: this object, so calls chain
  • method SetColor(const AMap: MapIndex; const AColor: Color): self: Map AMap's colour (the albedo map's tints the texture). Parameters: AMap the map; AColor the colour. Returns: this object, so calls chain
  • method SetValue(const AMap: MapIndex; const AValue: float32): self: Map AMap's value (a strength the shader reads: metalness, roughness ...). Parameters: AMap the map; AValue the value. Returns: this object, so calls chain
  • method SetShader(const AShader: ShaderRes): self: The material draws through AShader (kept alive by it; a shader the material loaded is unloaded). Parameters: AShader the shader. Returns: this object, so calls chain

Example: LSkin := MaterialRes.Default().SetTexture(MapIndex.Albedo, LTex).SetColor(MapIndex.Albedo, GOLD);

MeshRes

text
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 mesh AMesh over: its data and buffers unloaded with the last copy (or the window). Parameters: AMesh the mesh. Returns: the new MeshRes
  • static method Poly(const ASides: int32; const ARadius: float32): MeshRes: A flat polygon of ASides sides. C: GenMeshPoly Parameters: ASides how many sides; ARadius the radius. Returns: a flat polygon of ASides sides
  • static method Plane(const AWidth: float32; const ALength: float32; const AResX: int32; const AResZ: int32): MeshRes: A flat plane AWidth x ALength, AResX x AResZ quads. C: GenMeshPlane Parameters: AWidth the width; ALength the length; AResX the res X; AResZ the res Z. Returns: a flat plane AWidth x ALength, AResX x AResZ quads
  • static method Cube(const AWidth: float32; const AHeight: float32; const ALength: float32): MeshRes: A box. C: GenMeshCube Parameters: AWidth the width; AHeight the height; ALength the length. Returns: a box
  • static method Sphere(const ARadius: float32; const ARings: int32; const ASlices: int32): MeshRes: A sphere of ARings rings and ASlices slices. C: GenMeshSphere Parameters: ARadius the radius; ARings how many rings; ASlices how many slices. Returns: a sphere of ARings rings and ASlices slices
  • static method HemiSphere(const ARadius: float32; const ARings: int32; const ASlices: int32): MeshRes: A half sphere (no base). C: GenMeshHemiSphere Parameters: ARadius the radius; ARings how many rings; ASlices how 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: ARadius the radius; AHeight the height; ASlices how many slices. Returns: a cylinder
  • static method Cone(const ARadius: float32; const AHeight: float32; const ASlices: int32): MeshRes: A cone (its base ARadius). C: GenMeshCone Parameters: ARadius the radius; AHeight the height; ASlices how many slices. Returns: a cone (its base ARadius)
  • static method Torus(const ARadius: float32; const ASize: float32; const ARadSeg: int32; const ASides: int32): MeshRes: A torus (ASize its tube's radius). C: GenMeshTorus Parameters: ARadius the radius; ASize the size; ARadSeg the rad seg; ASides how many sides. Returns: a torus (ASize its 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: ARadius the radius; ASize the size; ARadSeg the rad seg; ASides how many sides. Returns: a trefoil knot
  • static method Heightmap(const AImage: ImageRes; const ASize: Vector3): MeshRes: A terrain from AImage's brightness, ASize its extent. C: GenMeshHeightmap Parameters: AImage the image; ASize the size. Returns: a terrain from AImage's brightness, ASize its extent
  • static method Cubicmap(const AImage: ImageRes; const ACubeSize: Vector3): MeshRes: Walls from AImage (a white pixel a cube of ACubeSize). C: GenMeshCubicmap Parameters: AImage the image; ACubeSize the cube size. Returns: the new MeshRes
  • const 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: true when the mesh's buffers are on the GPU (it can be drawn)
  • const method VertexCount(): int32: The vertices. Returns: the vertices
  • const method TriangleCount(): int32: The triangles. Returns: the triangles
  • method 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: ADynamic true for a buffer meant to be updated. Returns: this object, so calls chain
  • method UpdateBuffer(const AIndex: int32; const AData: ptr to const; const ASize: int32; const AOffset: int32): self: Replaces ASize bytes at AOffset of vertex buffer AIndex with AData. C: UpdateMeshBuffer Parameters: AIndex the index, from 0; AData the data; ASize the size; AOffset the offset. Returns: this object, so calls chain
  • method GenTangents(): self: Computes the tangents (for normal maps). C: GenMeshTangents Returns: this object, so calls chain
  • const method Bounds(): BoundingBox: The box around the vertices. C: GetMeshBoundingBox Returns: the box around the vertices
  • const method Draw(const AMaterial: MaterialRes; const ATransform: Matrix): Draws the mesh with AMaterial, placed by ATransform (inside Begin3D). C: DrawMesh Parameters: AMaterial the material; ATransform the transform.
  • const method DrawInstanced(const AMaterial: MaterialRes; const ATransforms: array of Matrix): Draws the mesh once per transform of ATransforms (a shader that reads the instance transform attribute). C: DrawMeshInstanced Parameters: AMaterial the material; ATransforms the transforms.
  • const method Export(const APath: string): bool: Writes the mesh as an .obj file. C: ExportMesh Parameters: APath the file's path. Returns: true when the file was written
  • const method ExportAsCode(const APath: string): bool: Writes the mesh as a C header of arrays. C: ExportMeshAsCode Parameters: APath the file's path. Returns: true when the file was written

Example: LBall := MeshRes.Sphere(1.0f, 16, 16); LBall.Draw(MaterialRes.Default(), MatrixIdentity());

ModelAnimationRes

text
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 set AAnimations of ACount clips over (LoadModelAnimations's result): unloaded with the last copy of its clips. C: UnloadModelAnimations Parameters: AAnimations the animations; ACount how many. Returns: a handle for each clip
  • static method Load(const APath: string): array of ModelAnimationRes: The animation clips of the model file at APath (from the mounted source). C: LoadModelAnimations Parameters: APath the file's path. Returns: the animation clips of the model file at APath (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: true when the handle holds a clip with frames
  • const 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 poses
  • const method FrameCount(): int32: The frames. Returns: the frames

Example: LClips := ModelAnimationRes.Load("res/assets/models/robot.glb"); LRobot.Animate(LClips[0], LFrame);

ModelRes

text
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 at APath (glTF / glb, OBJ, IQM, VOX, M3D; its materials and textures from beside it in the mounted source). C: LoadModel Parameters: APath the file's path.
  • static method Adopt(const AModel: Model): ModelRes: Takes the .C model AModel over (its meshes, materials, the textures and shaders its materials hold that are not raylib's defaults, its skeleton). Parameters: AModel the model. Returns: the new ModelRes
  • static method FromMesh(const AMesh: MeshRes): ModelRes: A model of AMesh alone (shared: the mesh stays AMesh's too) with raylib's default material. C: LoadModelFromMesh Parameters: AMesh the mesh. Returns: a model of AMesh alone (shared: the mesh stays AMesh's too) with raylib's default material
  • const 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: true when every mesh is on the GPU with a material
  • const 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 transform
  • const method MeshCount(): int32: The meshes. Returns: the meshes
  • const method MaterialCount(): int32: The materials. Returns: the materials
  • const method Mesh(const AIndex: int32): MeshRes: Mesh AIndex (shared with the model; an empty handle out of range). Parameters: AIndex the index, from 0. Returns: mesh AIndex (shared with the model; an empty handle out of range)
  • const method Material(const AIndex: int32): MaterialRes: Material AIndex (shared with the model: a change shows in the model; an empty handle out of range). Parameters: AIndex the index, from 0. Returns: material AIndex (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: Mesh AMesh is drawn with material AMaterial (both in range, else no change). C: SetModelMeshMaterial Parameters: AMesh the mesh; AMaterial the material's index. Returns: this object, so calls chain
  • method SetMaterial(const AIndex: int32; const AMaterial: MaterialRes): self: Material slot AIndex takes AMaterial (shared; the slot's material before goes with its last user). In range, else no change. Parameters: AIndex the index, from 0; AMaterial the material. Returns: this object, so calls chain
  • property 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 at APosition, scaled, tinted (inside Begin3D). C: DrawModel Parameters: APosition the position; AScale the scale; ATint the tint colour.
  • const method Draw(const APosition: Vector3; const AAxis: Vector3; const AAngle: float32; const AScale: Vector3; const ATint: Color): Draws the model at APosition, turned AAngle degrees about AAxis, scaled per axis. C: DrawModelEx Parameters: APosition the position; AAxis the axis; AAngle the angle; AScale the scale; ATint the tint colour.
  • const method DrawWires(const APosition: Vector3; const AScale: float32; const ATint: Color): Draws the model's triangle edges. C: DrawModelWires Parameters: APosition the position; AScale the scale; ATint the 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: APosition the position; AAxis the axis; AAngle the angle; AScale the scale; ATint the tint colour.
  • method Animate(const AClip: ModelAnimationRes; const AFrame: float32): Poses the model at frame AFrame of AClip (fractions blend neighbouring frames). C: UpdateModelAnimation Parameters: AClip the clip; AFrame the frame.
  • method Animate(const AClipA: ModelAnimationRes; const AFrameA: float32; const AClipB: ModelAnimationRes; const AFrameB: float32; const ABlend: float32): Poses the model between frame AFrameA of AClipA and frame AFrameB of AClipB (ABlend 0: A alone, 1: B alone). C: UpdateModelAnimationEx Parameters: AClipA the clip A; AFrameA the frame A; AClipB the clip B; AFrameB the frame B; ABlend the blend.
  • const method Fits(const AClip: ModelAnimationRes): bool: True when AClip poses this model's skeleton (the same bones). C: IsModelAnimationValid Parameters: AClip the clip. Returns: true when AClip poses this model's skeleton (the same bones)

Example: LRobot: ModelRes("res/assets/models/robot.glb"); LRobot.Draw(Vector3Zero(), 1.0f, WHITE);

AudioFunc

text
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

text
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 running AFunc on each block of frames. Parameters: AFunc the closure the audio thread runs.
  • const method IsValid(): bool: True when it runs a closure. Returns: whether it can be attached
  • const 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

text
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: InitAudioDevice
  • copy(const ASource: AudioDevice): One more hold on the same device: it stays open while any copy is held. Parameters: ASource the 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 play
  • property 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 / SetMasterVolume
  • static method BufferSize(const AFrames: int32): The buffer size, in sample frames, of the streams loaded after it (0: raylib's). C: SetAudioStreamBufferSizeDefault Parameters: AFrames the frames of each buffer.
  • static method AttachMixed(const AProcessor: AudioProcessor): bool: Runs AProcessor over everything mixed, kept alive until DetachMixed or the device's close. C: AttachAudioMixedProcessor Parameters: AProcessor the processor. Returns: false when the device is not open or the processor is empty (nothing attached); attaching one already attached does nothing more
  • static method DetachMixed(const AProcessor: AudioProcessor): Stops running AProcessor (the value AttachMixed was given, or a copy of it) over the mix. C: DetachAudioMixedProcessor Parameters: AProcessor the processor.

Example: LAudio: AudioDevice; LAudio.Volume := 0.8f; LCoin := SoundRes("res/assets/audio/sfx/coin_pickup.ogg");

WaveRes

text
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 at APath (from the mounted source: .wav, .ogg, .mp3, .qoa, .flac). C: LoadWave Parameters: APath the file's path.
  • static method Adopt(const AWave: Wave): WaveRes: Takes the .C wave AWave over: unloaded with the last copy. Parameters: AWave the wave. Returns: the new WaveRes
  • static method FromIO(const AIO: IO; const AType: string): WaveRes: Loads a wave of type AType (".wav" ...) from AIO (the IO stays the caller's). Parameters: AIO the IO; AType the type. Returns: the new WaveRes
  • static method FromMemory(const AType: string; const AData: array of uint8): WaveRes: Loads a wave of type AType (".wav" ...) from the file bytes AData. C: LoadWaveFromMemory Parameters: AType the type; AData the bytes. Returns: the new WaveRes
  • const 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: true when it holds sample data
  • const method Copy(): WaveRes: A wave of its own with the same samples. C: WaveCopy Returns: a wave of its own with the same samples
  • method Crop(const AFirst: int32; const ALast: int32): self: Keeps the frames AFirst up to (not including) ALast only. C: WaveCrop Parameters: AFirst the first frame kept; ALast the frame the kept ones end before. Returns: this object, so calls chain
  • method ToFormat(const ASampleRate: int32; const ASampleSize: int32; const AChannels: int32): self: Converts the samples to ASampleRate Hz, ASampleSize bits (8, 16 or 32: float) and AChannels channels. C: WaveFormat Parameters: ASampleRate the sample rate; ASampleSize the sample size; AChannels the channels. Returns: this object, so calls chain
  • const 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 frames
  • const method SampleRate(): int32: Its sample rate in Hz. Returns: its sample rate in Hz
  • const 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 file APath (.wav or .qoa). C: ExportWave Parameters: APath the file's path. Returns: false when it could not be written
  • const method ExportAsCode(const APath: string): bool: Writes the samples as a C header to APath. C: ExportWaveAsCode Parameters: APath the 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

text
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 at APath (from the mounted source). C: LoadSound Parameters: APath the file's path.
  • static method Adopt(const ASound: Sound): SoundRes: Takes the .C sound ASound over: unloaded with the last copy (or the device). Parameters: ASound the sound. Returns: the new SoundRes
  • static method FromIO(const AIO: IO; const AType: string): SoundRes: Loads a sound of type AType (".wav" ...) from AIO (the IO stays the caller's). Parameters: AIO the IO; AType the type. Returns: the new SoundRes
  • static method FromWave(const AWave: WaveRes): SoundRes: A sound of AWave's samples (copied: the wave may go). C: LoadSoundFromWave Parameters: AWave the wave. Returns: a sound of AWave'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: true when it holds a sound the device can play
  • const 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 alias
  • method Play(): self: Plays it from its start. C: PlaySound Returns: this object, so calls chain
  • method Stop(): self: Stops it. C: StopSound Returns: this object, so calls chain
  • method Pause(): self: Pauses it where it is. C: PauseSound Returns: this object, so calls chain
  • method Resume(): self: Plays on from where it paused. C: ResumeSound Returns: this object, so calls chain
  • const method Playing(): bool: True while it plays. C: IsSoundPlaying Returns: true while it plays
  • method 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: AVolume the volume, 0 (silent) to 1 (full). Returns: this object, so calls chain
  • method Pitch(const APitch: float32): self: Its pitch (1: as recorded). C: SetSoundPitch Parameters: APitch the pitch. Returns: this object, so calls chain
  • method Pan(const APan: float32): self: Its pan, 0 (left) to 1 (right), 0.5 the middle. C: SetSoundPan Parameters: APan the pan. Returns: this object, so calls chain
  • method Update(const AData: ptr to const; const AFrames: int32): self: Replaces its samples with AFrames frames at AData (its own format). C: UpdateSound Parameters: AData the data; AFrames the frames. Returns: this object, so calls chain

Example: LCoin := SoundRes("res/assets/audio/sfx/coin_pickup.ogg").Volume(0.6f); LCoin.Play();

MusicRes

text
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 at APath (from the mounted source). C: LoadMusicStream Parameters: APath the file's path.
  • static method FromIO(const AIO: IO; const AType: string): MusicRes: Opens music of type AType (".ogg" ...) read from AIO while it plays (the IO stays the caller's: open until the last copy goes). Parameters: AIO the IO; AType the type. Returns: the new MusicRes
  • static method FromMemory(const AType: string; const AData: array of uint8): MusicRes: Opens music of type AType (".ogg" ...) from the file bytes AData (kept with it while it plays). C: LoadMusicStreamFromMemory Parameters: AType the type; AData the bytes. Returns: the new MusicRes
  • const 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: true when it holds music the device can play
  • method Play(): self: Plays it (from its start, or from where it paused). C: PlayMusicStream Returns: this object, so calls chain
  • method Stop(): self: Stops it (back to its start). C: StopMusicStream Returns: this object, so calls chain
  • method Pause(): self: Pauses it where it is. C: PauseMusicStream Returns: this object, so calls chain
  • method Resume(): self: Plays on from where it paused. C: ResumeMusicStream Returns: this object, so calls chain
  • method Update(): Decodes the next part into its buffers: once a frame while it plays. C: UpdateMusicStream
  • const method Playing(): bool: True while it plays. C: IsMusicStreamPlaying Returns: true while it plays
  • method Seek(const ASeconds: float32): self: Moves it to ASeconds from its start. C: SeekMusicStream Parameters: ASeconds the time, in seconds. Returns: this object, so calls chain
  • method 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: AVolume the volume, 0 (silent) to 1 (full). Returns: this object, so calls chain
  • method Pitch(const APitch: float32): self: Its pitch (1: as recorded). C: SetMusicPitch Parameters: APitch the pitch. Returns: this object, so calls chain
  • method Pan(const APan: float32): self: Its pan, 0 (left) to 1 (right), 0.5 the middle. C: SetMusicPan Parameters: APan the pan. Returns: this object, so calls chain
  • method Looping(const ALoop: bool): self: Plays again from its start at its end (true) or stops there. C: music.looping Parameters: ALoop true to loop. Returns: this object, so calls chain
  • const method Looping(): bool: True when it plays again from its start at its end. C: music.looping Returns: true when it plays again from its start at its end
  • const method Length(): float32: Its length in seconds. C: GetMusicTimeLength Returns: its length in seconds
  • const 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

text
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 of ASampleRate Hz, ASampleSize bits (8, 16 or 32: float) and AChannels channels. C: LoadAudioStream Parameters: ASampleRate the sample rate; ASampleSize the sample size; AChannels the 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: true when it holds a stream the device plays
  • method Update(const AData: ptr to const; const AFrames: int32): self: Queues AFrames frames at AData (the stream's format) when a buffer is free (Processed). C: UpdateAudioStream Parameters: AData the data; AFrames the frames. Returns: this object, so calls chain
  • const method Processed(): bool: True when a buffer is free for Update. C: IsAudioStreamProcessed Returns: true when a buffer is free for Update
  • method Play(): self: Plays it. C: PlayAudioStream Returns: this object, so calls chain
  • method Pause(): self: Pauses it. C: PauseAudioStream Returns: this object, so calls chain
  • method Resume(): self: Plays on from where it paused. C: ResumeAudioStream Returns: this object, so calls chain
  • method Stop(): self: Stops it. C: StopAudioStream Returns: this object, so calls chain
  • const method Playing(): bool: True while it plays. C: IsAudioStreamPlaying Returns: true while it plays
  • method 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: AVolume the volume, 0 (silent) to 1 (full). Returns: this object, so calls chain
  • method Pitch(const APitch: float32): self: Its pitch (1: as fed). C: SetAudioStreamPitch Parameters: APitch the pitch. Returns: this object, so calls chain
  • method Pan(const APan: float32): self: Its pan, 0 (left) to 1 (right), 0.5 the middle. C: SetAudioStreamPan Parameters: APan the pan. Returns: this object, so calls chain
  • method Callback(const AFunc: AudioFunc): self: Has raylib's audio thread call AFunc for 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: AFunc the func it runs. Returns: this object, so calls chain
  • method Attach(const AProcessor: AudioProcessor): self: Runs AProcessor over 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: AProcessor the processor. Returns: this object, so calls chain
  • method Detach(const AProcessor: AudioProcessor): self: Stops running AProcessor (the value Attach was given, or a copy of it). C: DetachAudioStreamProcessor Parameters: AProcessor the 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

text
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

text
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 at APath (an entry of the mounted source, else a file). Parameters: APath the file's path.
  • static method FromIO(const AIO: IO; const AName: string): VideoRes: Opens a video read from AIO (the IO stays the caller's: open while the video is); AName names it. Parameters: AIO the IO; AName the name. Returns: the new VideoRes
  • const 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: true when it holds a video
  • method Play(): self: Plays it (from where it paused, or from its start). Returns: this object, so calls chain
  • method Pause(): self: Pauses it, its frame still drawn. Returns: this object, so calls chain
  • method Stop(): self: Stops it (back to its start, no frame drawn until it plays). Returns: this object, so calls chain
  • method Update(): Plays on by the time since the last update: once a frame.
  • method Update(const ASeconds: float64): Plays on by ASeconds (a fixed step). Parameters: ASeconds the time, in seconds.
  • method Seek(const ASeconds: float64): bool: Moves it to ASeconds from its start. Parameters: ASeconds the time, in seconds. Returns: false when it holds no video or cannot seek there
  • const 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: true while it plays
  • method Looping(const ALoop: bool): self: Plays again from its start at its end (true) or stops there. Parameters: ALoop true to loop. Returns: this object, so calls chain
  • const method Looping(): bool: True when it plays again from its start at its end. Returns: true when it plays again from its start at its end
  • method 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: AVolume the volume, 0 (silent) to 1 (full). Returns: this object, so calls chain
  • const 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: Calls AHandler with its new status on every change (nil: none). The handler is kept while the video is. Parameters: AHandler the handler. Returns: this object, so calls chain
  • const method HasAudio(): bool: True when it has a sound track. Returns: true when it has a sound track
  • const method ShaderUsed(): bool: True when its frames are converted on the GPU (decided at its first frame with a window). Returns: true when 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 second
  • const method Duration(): float64: Its length in seconds. Returns: its length in seconds
  • const method Time(): float64: The seconds played since its start. Returns: the seconds played since its start
  • const 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 pixels
  • const 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

text
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 for ACapacity events, 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: ACapacity how many events it can record.
  • init(const APath: string): Loads the .rae events at APath (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: APath the file's path.
  • static method Adopt(const AList: AutomationEventList): AutomationRes: Takes the .C list AList over: unloaded with the last copy. Parameters: AList the list. Returns: the new AutomationRes
  • static method FromIO(const AIO: IO): AutomationRes: Loads .rae events from AIO (the IO stays the caller's; nil gives raylib's empty list). Parameters: AIO the IO. Returns: the new AutomationRes
  • const method IsValid(): bool: True when it holds a list (its room for events). Returns: true when 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: SetAutomationEventList
  • static method BaseFrame(const AFrame: int32): The frame recording counts from (frame numbers are relative to it). C: SetAutomationEventBaseFrame Parameters: AFrame the 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: StartAutomationEventRecording
  • static method StopRecording(): Stops recording. C: StopAutomationEventRecording
  • const 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: Event AIndex (0 to Count() - 1; an empty one outside). Parameters: AIndex the index, from 0. Returns: event AIndex (0 to Count() - 1; an empty one outside)
  • static method Play(const AEvent: AutomationEvent): Plays AEvent back: raylib takes it as that frame's input. C: PlayAutomationEvent Parameters: AEvent the 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 to APath as .rae text; false when it holds none or the write fails. C: ExportAutomationEventList Parameters: APath the file's path. Returns: true when the file was written

Example: LRun: AutomationRes(4096); LRun.Use(); AutomationRes.StartRecording();

VRStereoRes

text
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 headset ADevice. C: LoadVrStereoConfig Parameters: ADevice the device.
  • const method IsValid(): bool: True when it holds a config. Returns: true when it holds a config
  • const 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: BeginVrStereoMode
  • static 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

text
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: true when 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

text
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

text
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 it
  • method Size(const ABaseWidth: int32; const ABaseHeight: int32): self: The base (virtual) size everything is drawn in. Parameters: ABaseWidth the base width, more than 0; ABaseHeight the base height, more than 0. Returns: this object, so calls chain
  • method Title(const AText: string): self: The window's title. Parameters: AText the text. Returns: this object, so calls chain
  • method Flags(const AFlags: WindowFlags): self: raylib's window flags, set before the window opens. C: SetConfigFlags Parameters: AFlags the 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: AZoom the zoom. Returns: this object, so calls chain
  • method IntegerScale(const AOn: bool): self: The letterbox kept a whole multiple of the base size (pixel art). C: SetFrameIntegerScale Parameters: AOn true to turn it on, false to turn it off. Returns: this object, so calls chain
  • method Color(const AColor: Color): self: The colour the frame is cleared to each BeginFrame. Parameters: AColor the colour. Returns: this object, so calls chain
  • method BarColor(const AColor: Color): self: The colour of the bars outside the frame. Parameters: AColor the colour. Returns: this object, so calls chain
  • method TargetFPS(const AFPS: int32): self: The frame rate EndFrame waits for (0: no wait). C: SetTargetFPS Parameters: AFPS the FPS. Returns: this object, so calls chain
  • method ExitKey(const AKey: Key): self: The key that closes the window (Key.Null: none). C: SetExitKey Parameters: AKey the key. Returns: this object, so calls chain
  • method MinSize(const AWidth: int32; const AHeight: int32): self: The smallest size the window may be resized to, in window units. C: SetWindowMinSize Parameters: AWidth the width; AHeight the height. Returns: this object, so calls chain
  • method MaxSize(const AWidth: int32; const AHeight: int32): self: The largest size the window may be resized to, in window units. C: SetWindowMaxSize Parameters: AWidth the width; AHeight the height. Returns: this object, so calls chain
  • method Icon(const AImage: ImageRes): self: The window's icon, set as it opens (R8G8B8A8; the @exeicon icon otherwise). C: SetWindowIcon Parameters: AImage the image. Returns: this object, so calls chain
  • method 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: AImages the images. Returns: this object, so calls chain
  • const 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

text
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 of Window.Config()...Open(). Parameters: ABaseWidth the base width, more than 0; ABaseHeight the base height, more than 0; ATitle the window's title.
  • copy(const ASource: Window): One more hold on the same window: it stays open while any copy is held. Parameters: ASource the 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: true while the window is open and not asked to close (its close button, the exit key): the loop's condition
  • method BeginFrame(): Begins a frame: BeginDrawing, then the frame in base units (the bars cleared, the frame filled with its colour). C: BeginDrawing
  • method EndFrame(): Ends the frame and shows it (events polled, the target frame rate waited for). C: EndDrawing
  • method 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: AColor the 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: true while this value's window is open
  • const method Fullscreen(): bool: True while the window is fullscreen. C: IsWindowFullscreen Returns: true while the window is fullscreen
  • const method Hidden(): bool: True while the window is hidden. C: IsWindowHidden Returns: true while the window is hidden
  • const method Minimized(): bool: True while the window is minimized. C: IsWindowMinimized Returns: true while the window is minimized
  • const method Maximized(): bool: True while the window is maximized. C: IsWindowMaximized Returns: true while the window is maximized
  • const method Focused(): bool: True while the window has the keyboard focus. C: IsWindowFocused Returns: true while the window has the keyboard focus
  • const method Resized(): bool: True when the window was resized in the last frame. C: IsWindowResized Returns: true when the window was resized in the last frame
  • const 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: AFlags the flags. Returns: true when 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: AFlags the flags.
  • method ClearFlags(const AFlags: WindowFlags): Clears AFlags on the open window. C: ClearWindowState Parameters: AFlags the 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: ToggleFullscreen
  • method 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: ToggleBorderlessWindowed
  • const method Borderless(): bool: True while the window is borderless (ToggleBorderless). Returns: true while the window is borderless (ToggleBorderless)
  • method Maximize(): Maximizes the window (a resizable one). C: MaximizeWindow
  • method Minimize(): Minimizes the window (a resizable one). C: MinimizeWindow
  • method Restore(): The window back from maximized or minimized. C: RestoreWindow
  • method Focus(): Gives the window the input focus. C: SetWindowFocused
  • method SetOpacity(const AOpacity: float32): The window's opacity, 0 (clear) to 1 (opaque). C: SetWindowOpacity Parameters: AOpacity the opacity.
  • method SetTitle(const AText: string): Sets the window's title. C: SetWindowTitle Parameters: AText the new title.
  • method SetPosition(const AX: int32; const AY: int32): The window's place on the screen, in window units. C: SetWindowPosition Parameters: AX the x coordinate; AY the y coordinate.
  • method SetMonitor(const AMonitor: int32): Moves the window to monitor AMonitor (Monitor.Count's range). C: SetWindowMonitor Parameters: AMonitor the 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: AWidth the width; AHeight the height.
  • method SetMinSize(const AWidth: int32; const AHeight: int32): The smallest size the user can make the window. C: SetWindowMinSize Parameters: AWidth the width; AHeight the height.
  • method SetMaxSize(const AWidth: int32; const AHeight: int32): The largest size the user can make the window. C: SetWindowMaxSize Parameters: AWidth the width; AHeight the 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: AKey the key.
  • const method Position(): Vector2: The window's place on the screen. C: GetWindowPosition Returns: the window's place on the screen
  • const 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.dpi
  • const method ScreenWidth(): int32: The window's width in screen coordinates. C: GetScreenWidth Returns: the width
  • const method ScreenHeight(): int32: The window's height in screen coordinates. C: GetScreenHeight Returns: the height
  • const 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 width
  • const 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 height
  • const 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 calls
  • const 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, is Camera().zoom). Returns: the monitor's scale the window is sized for: DPI() / 96 (the letterbox's own scale, window units per base unit, is Camera().zoom)
  • const method Zoom(): float32: The zoom the window's normal size takes. Returns: the zoom the window's normal size takes
  • method SetZoom(const AZoom: float32): A new zoom: the window takes base x AZoom x the monitor's scale. Parameters: AZoom the 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 units
  • const 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: AOn true to turn it on, false to turn it off.
  • method SwapBuffers(): Shows what was drawn (a custom loop with raylib's SUPPORT_CUSTOM_FRAME_CONTROL). C: SwapScreenBuffer
  • method PollEvents(): Takes the input events since the last call (a custom loop with SwapBuffers: EndFrame polls them itself). C: PollInputEvents
  • method Screenshot(const APath: string): Saves the window's picture as a PNG at APath. C: TakeScreenshot Parameters: APath the 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: AImage the 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: AImages the 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: AWindowWidth the window width; AWindowHeight the window height; ABaseWidth the frame's base width; ABaseHeight the frame's base height. Returns: the letterbox a base size takes in a window size: the largest rectangle of the base's aspect, centred
  • static 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: AWindowWidth the window width; AWindowHeight the window height; ABaseWidth the frame's base width; ABaseHeight the 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: ABaseWidth the frame's base width; ABaseHeight the frame's base height; ADPI the 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: APoint the point; ALetterbox the letterbox; ABaseWidth the frame's base width; ABaseHeight the 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

text
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 monitors
  • static method Current(): int32: The monitor the window is on. C: GetCurrentMonitor Returns: the monitor the window is on
  • static method Name(const AMonitor: int32): string: The monitor's name ("" when there is none of that number). C: GetMonitorName Parameters: AMonitor the monitor's index. Returns: the monitor's name ("" when there is none of that number)
  • static method Position(const AMonitor: int32): Vector2: Monitor AMonitor's top-left corner on the desktop, in screen coordinates. C: GetMonitorPosition Parameters: AMonitor the monitor's index. Returns: the corner
  • static method Width(const AMonitor: int32): int32: The monitor's current video mode's width. C: GetMonitorWidth Parameters: AMonitor the monitor's index. Returns: the monitor's current video mode's width
  • static method Height(const AMonitor: int32): int32: The monitor's current video mode's height. C: GetMonitorHeight Parameters: AMonitor the monitor's index. Returns: the monitor's current video mode's height
  • static method PhysicalWidth(const AMonitor: int32): int32: In millimetres. C: GetMonitorPhysicalWidth Parameters: AMonitor the monitor's index. Returns: the width in millimetres
  • static method PhysicalHeight(const AMonitor: int32): int32: In millimetres. C: GetMonitorPhysicalHeight Parameters: AMonitor the monitor's index. Returns: the height in millimetres
  • static method RefreshRate(const AMonitor: int32): int32: Monitor AMonitor's refresh rate, in hertz. C: GetMonitorRefreshRate Parameters: AMonitor the monitor's index. Returns: the rate

Time

text
type Time = object

The frame clock.

Members

  • static method FPS(): int32: The frames per second now. C: GetFPS Returns: the frames per second now
  • static method Delta(): float32: The last frame's time in seconds. C: GetFrameTime Returns: the last frame's time in seconds
  • static method Now(): float64: Seconds since the window opened. C: GetTime Returns: the seconds since the window opened
  • static method SetTargetFPS(const AFPS: int32): The frame rate EndFrame waits for (0: no wait). C: SetTargetFPS Parameters: AFPS the FPS.
  • static method Wait(const ASeconds: float64): Waits ASeconds (raylib's precise wait). C: WaitTime Parameters: ASeconds the time, in seconds.

Example: LPos := LPos + LVel * Time.Delta();

Clipboard

text
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): Puts AText on the clipboard. C: SetClipboardText Parameters: AText the 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

text
type Log = object

raylib's trace log.

Members

  • static method Level(const ALevel: LogLevel): The lowest level written (LogLevel.None: nothing). C: SetTraceLogLevel Parameters: ALevel the level.
  • static method Write(const ALevel: LogLevel; const AText: string): Writes AText to the log at ALevel (as is: no format). C: TraceLog Parameters: ALevel the level; AText the 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: AHandler the handler.

Example: Log.Level(LogLevel.Warning);

Random

text
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: ASeed the seed.
  • static method Value(const ALow: int32; const AHigh: int32): int32: A number from ALow to AHigh, both included. C: GetRandomValue Parameters: ALow the lowest number; AHigh the highest number. Returns: a number from ALow to AHigh, both included
  • static 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: ACount how many; ALow the lowest number; AHigh the highest number. Returns: the numbers

Keyboard

text
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: AKey the key. Returns: true in the frame AKey went down
  • static method PressedRepeat(const AKey: Key): bool: True in a frame the system repeats a held AKey. C: IsKeyPressedRepeat Parameters: AKey the key. Returns: true in a frame the system repeats a held AKey
  • static method Down(const AKey: Key): bool: True while AKey is held. C: IsKeyDown Parameters: AKey the key. Returns: true while AKey is held
  • static method Released(const AKey: Key): bool: True in the frame AKey came up. C: IsKeyReleased Parameters: AKey the key. Returns: true in the frame AKey came up
  • static method Up(const AKey: Key): bool: True while AKey is not held. C: IsKeyUp Parameters: AKey the key. Returns: true while AKey is not held
  • static 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: AKey the 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

text
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: AButton the button. Returns: true in the frame AButton went down
  • static method Down(const AButton: Button): bool: True while AButton is held. C: IsMouseButtonDown Parameters: AButton the button. Returns: true while AButton is held
  • static method Released(const AButton: Button): bool: True in the frame AButton came up. C: IsMouseButtonReleased Parameters: AButton the button. Returns: true in the frame AButton came up
  • static method Up(const AButton: Button): bool: True while AButton is not held. C: IsMouseButtonUp Parameters: AButton the button. Returns: true while AButton is not held
  • static method X(): int32: The mouse's x in window pixels. C: GetMouseX Returns: the mouse's x in window pixels
  • static method Y(): int32: The mouse's y in window pixels. C: GetMouseY Returns: the mouse's y in window pixels
  • static 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 pixels
  • static 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 axes
  • static method SetPosition(const AX: int32; const AY: int32): Moves the system cursor to AX, AY in window pixels. C: SetMousePosition Parameters: AX the x coordinate; AY the y coordinate.
  • static method SetOffset(const AX: int32; const AY: int32): What Position adds to the cursor's place (before SetScale). C: SetMouseOffset Parameters: AX the x coordinate; AY the y coordinate.
  • static method SetScale(const AX: float32; const AY: float32): What Position scales the offset cursor's place by. C: SetMouseScale Parameters: AX the x coordinate; AY the y coordinate.
  • static method SetCursor(const ACursor: Cursor): The cursor's shape over the window. C: SetMouseCursor Parameters: ACursor the cursor.
  • static method Show(): Shows the mouse cursor. C: ShowCursor
  • static method Hide(): Hides the mouse cursor. C: HideCursor
  • static method Hidden(): bool: True while the cursor is hidden. C: IsCursorHidden Returns: true while the cursor is hidden
  • static method Enable(): The cursor shown and free again (after Disable). C: EnableCursor
  • static method Disable(): The cursor hidden and held in the window (a first-person camera reads Delta). C: DisableCursor
  • static method OnScreen(): bool: True while the cursor is over the window. C: IsCursorOnScreen Returns: true while the cursor is over the window

Example: if Mouse.Pressed(Button.Left) then Fire(Mouse.FramePosition()); end;

Gamepad

text
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: AIndex the index, from 0.
  • const method Index(): int32: The pad's index. Returns: the pad's index
  • const method Available(): bool: True while the pad is connected. C: IsGamepadAvailable Returns: true while the pad is connected
  • const 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: AButton the button. Returns: true in the frame AButton went down
  • const method Down(const AButton: PadButton): bool: True while AButton is held. C: IsGamepadButtonDown Parameters: AButton the button. Returns: true while AButton is held
  • const method Released(const AButton: PadButton): bool: True in the frame AButton came up. C: IsGamepadButtonReleased Parameters: AButton the button. Returns: true in the frame AButton came up
  • const method Up(const AButton: PadButton): bool: True while AButton is not held (a pad that is not there: true). C: IsGamepadButtonUp Parameters: AButton the button. Returns: true while 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: AAxis the axis. Returns: the axis's place
  • method Vibrate(const ALeft: float32; const ARight: float32; const ASeconds: float32): Shakes the pad: the motors' strengths 0 to 1 for ASeconds. C: SetGamepadVibration Parameters: ALeft the left motor's strength, 0 to 1; ARight the right motor's strength, 0 to 1; ASeconds the 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: AMappings the mappings. Returns: raylib's result (1 when the lines were taken)

Example: LPad: Gamepad(0); if LPad.Down(PadButton.RightFaceDown) then Jump(); end;

Touch

text
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 pixels
  • static method Y(): int32: Touch point 0's y in window pixels. C: GetTouchY Returns: touch point 0's y, in window pixels
  • static method Position(const AIndex: int32): Vector2: Touch point AIndex's place in window pixels. C: GetTouchPosition Parameters: AIndex the index, from 0. Returns: the point's place, in window pixels
  • static method PointId(const AIndex: int32): int32: Touch point AIndex's id (-1 for none). C: GetTouchPointId Parameters: AIndex the 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 now
  • static method Enable(const AGestures: TouchGestures): The gestures raylib looks for (all by default). C: SetGesturesEnabled Parameters: AGestures the gestures.
  • static method Detected(const AGesture: TouchGesture): bool: True when AGesture was made this frame. C: IsGestureDetected Parameters: AGesture the gesture. Returns: true when AGesture was made this frame
  • static 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 none
  • static method HoldDuration(): float32: How long the hold gesture lasts, in seconds. C: GetGestureHoldDuration Returns: how long the hold gesture lasts, in seconds
  • static method DragVector(): Vector2: The drag gesture's move. C: GetGestureDragVector Returns: the drag gesture's move
  • static method DragAngle(): float32: The drag gesture's angle in degrees. C: GetGestureDragAngle Returns: the drag gesture's angle in degrees
  • static method PinchVector(): Vector2: The pinch gesture's move. C: GetGesturePinchVector Returns: the pinch gesture's move
  • static 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

text
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 through ACamera inside the frame (letterboxed). C: BeginMode2D Parameters: ACamera the 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: EndMode2D
  • static method Begin3D(const ACamera: Camera3D): Starts drawing a 3D scene through ACamera inside the frame (its projection at the base size's aspect, its viewport the letterbox). C: BeginMode3D Parameters: ACamera the 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: EndMode3D
  • static method BeginBlend(const ABlend: Blend): Starts blending what is drawn by ABlend. C: BeginBlendMode Parameters: ABlend the blend mode. Example: Draw.BeginBlend(Blend.Additive); Draw.Circle(LSpark, 4.0f, ORANGE); Draw.EndBlend();
  • static method EndBlend(): Ends BeginBlend: alpha blending again. C: EndBlendMode
  • static method BeginTexture(const ATarget: RenderTextureRes): Drawing lands in ATarget, in its pixels, until EndTexture (inside a frame too: the frame comes back at EndTexture). C: BeginTextureMode Parameters: ATarget the 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: EndTextureMode
  • static method BeginShader(const AShader: ShaderRes): Drawing goes through AShader until EndShader (the shader kept alive until then). C: BeginShaderMode Parameters: AShader the shader. Example: Draw.BeginShader(LGlow); Draw.Texture(LScene, Vector2Zero(), WHITE); Draw.EndShader();
  • static method EndShader(): Ends BeginShader: raylib's default shader again. C: EndShaderMode
  • static method BeginVR(const AConfig: VRStereoRes): Drawing renders the stereo pair through AConfig until EndVR. C: BeginVrStereoMode Parameters: AConfig the 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: EndVrStereoMode
  • static method ShapesTexture(const ATexture: TextureRes; const ARect: Rectangle): The texture and its part ARect raylib's shapes are drawn with (kept alive while set). C: SetShapesTexture Parameters: ATexture the texture; ARect the 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 use
  • static method BeginScissor(const ARect: Rectangle): Holds drawing to ARect, in base units: inside the frame it is mapped through the frame's camera and kept within the letterbox. C: BeginScissorMode Parameters: ARect the 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: EndScissorMode
  • static method Pixel(const APos: Vector2; const AColor: Color): One pixel at APos. C: DrawPixel / DrawPixelV Parameters: APos the position; AColor the colour.
  • static method Line(const AStart: Vector2; const AEnd: Vector2; const AColor: Color): A line from AStart to AEnd. C: DrawLine / DrawLineV Parameters: AStart the start; AEnd the end; AColor the colour. Example: Draw.Line(LFrom, LTo, WHITE);
  • static method Line(const AStart: Vector2; const AEnd: Vector2; const AThick: float32; const AColor: Color): A line AThick wide. C: DrawLineEx Parameters: AStart the start; AEnd the end; AThick the line thickness; AColor the colour.
  • static method LineStrip(const APoints: array of Vector2; const AColor: Color): Lines joining APoints in order (nothing for fewer than two). C: DrawLineStrip Parameters: APoints the points; AColor the colour.
  • static method LineBezier(const AStart: Vector2; const AEnd: Vector2; const AThick: float32; const AColor: Color): A cubic-eased curve from AStart to AEnd, AThick wide. C: DrawLineBezier Parameters: AStart the start; AEnd the end; AThick the line thickness; AColor the colour.
  • static method LineDashed(const AStart: Vector2; const AEnd: Vector2; const ADash: int32; const ASpace: int32; const AColor: Color): A dashed line: ADash drawn, ASpace left, in turn. C: DrawLineDashed Parameters: AStart the start; AEnd the end; ADash the dash; ASpace the space; AColor the 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: AA the first corner; AB the second corner; AC the third corner; AColor the 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: AA the first corner; AB the second corner; AC the third corner; AColorA the color A; AColorB the color B; AColorC the color C.
  • static method TriangleLines(const AA: Vector2; const AB: Vector2; const AC: Vector2; const AColor: Color): A triangle's outline. C: DrawTriangleLines Parameters: AA the first corner; AB the second corner; AC the third corner; AColor the colour.
  • static method TriangleLines(const AA: Vector2; const AB: Vector2; const AC: Vector2; const AThick: float32; const AColor: Color): A triangle's outline AThick wide. C: DrawTriangleLinesEx Parameters: AA the first corner; AB the second corner; AC the third corner; AThick the line thickness; AColor the 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: APoints the points; AColor the colour.
  • static method TriangleStrip(const APoints: array of Vector2; const AColor: Color): A triangle strip (nothing for fewer than three points). C: DrawTriangleStrip Parameters: APoints the points; AColor the colour.
  • static method Rect(const ARect: Rectangle; const AColor: Color): A filled rectangle. C: DrawRectangle / DrawRectangleV / DrawRectangleRec Parameters: ARect the rectangle; AColor the 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 turned ARotation degrees about AOrigin (relative to its corner, which lands at the rectangle's x, y). C: DrawRectanglePro Parameters: ARect the rectangle; AOrigin the origin; ARotation the rotation; AColor the colour.
  • static method RectGradientV(const ARect: Rectangle; const ATop: Color; const ABottom: Color): A rectangle shaded from ATop down to ABottom. C: DrawRectangleGradientV Parameters: ARect the rectangle; ATop the top colour; ABottom the bottom colour.
  • static method RectGradientH(const ARect: Rectangle; const ALeft: Color; const ARight: Color): A rectangle shaded from ALeft across to ARight. C: DrawRectangleGradientH Parameters: ARect the rectangle; ALeft the left colour; ARight the 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: ATopLeft the top-left corner's color, then bottom-left, bottom-right, top-right; ARect the rectangle; ABottomLeft the bottom-left corner's colour; ABottomRight the bottom-right corner's colour; ATopRight the top-right corner's colour.
  • static method RectLines(const ARect: Rectangle; const AColor: Color): A rectangle's outline, one unit wide. C: DrawRectangleLines Parameters: ARect the rectangle; AColor the colour.
  • static method RectLines(const ARect: Rectangle; const AThick: float32; const AColor: Color): A rectangle's outline AThick wide, inside the rectangle. C: DrawRectangleLinesEx Parameters: ARect the rectangle; AThick the line thickness; AColor the 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: ARoundness 0 (square) to 1 (the short side a half circle); ASegments the segments per corner (0: raylib picks); ARect the rectangle; AColor the colour.
  • static method RectRoundedLines(const ARect: Rectangle; const ARoundness: float32; const ASegments: int32; const AColor: Color): A rounded rectangle's outline. C: DrawRectangleRoundedLines Parameters: ARect the rectangle; ARoundness the roundness; ASegments how many segments; AColor the colour.
  • static method RectRoundedLines(const ARect: Rectangle; const ARoundness: float32; const ASegments: int32; const AThick: float32; const AColor: Color): A rounded rectangle's outline AThick wide. C: DrawRectangleRoundedLinesEx Parameters: ARect the rectangle; ARoundness the roundness; ASegments how many segments; AThick the line thickness; AColor the 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: ARotation degrees; ACenter the centre; ASides how many sides; ARadius the radius; AColor the 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: ACenter the centre; ASides how many sides; ARadius the radius; ARotation the rotation; AColor the 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 outline AThick wide. C: DrawPolyLinesEx Parameters: ACenter the centre; ASides how many sides; ARadius the radius; ARotation the rotation; AThick the line thickness; AColor the colour.
  • static method Circle(const ACenter: Vector2; const ARadius: float32; const AColor: Color): A filled circle. C: DrawCircle / DrawCircleV Parameters: ACenter the centre; ARadius the radius; AColor the colour.
  • static method CircleGradient(const ACenter: Vector2; const ARadius: float32; const AInner: Color; const AOuter: Color): A circle shaded from AInner at its center to AOuter at its edge. C: DrawCircleGradient Parameters: ACenter the centre; ARadius the radius; AInner the colour at the centre; AOuter the 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: ASegments the slice's segments (0: raylib picks); ACenter the centre; ARadius the radius; AStartAngle the start angle, in degrees; AEndAngle the end angle, in degrees; AColor the 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: ACenter the centre; ARadius the radius; AStartAngle the start angle, in degrees; AEndAngle the end angle, in degrees; ASegments how many segments; AColor the 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 outline AThick wide. C: DrawCircleSectorLinesEx Parameters: ACenter the centre; ARadius the radius; AStartAngle the start angle, in degrees; AEndAngle the end angle, in degrees; ASegments how many segments; AThick the line thickness; AColor the colour.
  • static method CircleLines(const ACenter: Vector2; const ARadius: float32; const AColor: Color): A circle's outline. C: DrawCircleLines / DrawCircleLinesV Parameters: ACenter the centre; ARadius the radius; AColor the colour.
  • static method CircleLines(const ACenter: Vector2; const ARadius: float32; const AThick: float32; const AColor: Color): A circle's outline AThick wide. C: DrawCircleLinesEx Parameters: ACenter the centre; ARadius the radius; AThick the line thickness; AColor the colour.
  • static method Ellipse(const ACenter: Vector2; const ARadiusH: float32; const ARadiusV: float32; const AColor: Color): A filled ellipse. C: DrawEllipse / DrawEllipseV Parameters: ACenter the centre; ARadiusH the horizontal radius; ARadiusV the vertical radius; AColor the colour.
  • static method EllipseLines(const ACenter: Vector2; const ARadiusH: float32; const ARadiusV: float32; const AColor: Color): An ellipse's outline. C: DrawEllipseLines / DrawEllipseLinesV Parameters: ACenter the centre; ARadiusH the horizontal radius; ARadiusV the vertical radius; AColor the colour.
  • static method EllipseLines(const ACenter: Vector2; const ARadiusH: float32; const ARadiusV: float32; const AThick: float32; const AColor: Color): An ellipse's outline AThick wide. C: DrawEllipseLinesEx Parameters: ACenter the centre; ARadiusH the horizontal radius; ARadiusV the vertical radius; AThick the line thickness; AColor the 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: ACenter the centre; AInner the inner radius; AOuter the outer radius; AStartAngle the start angle, in degrees; AEndAngle the end angle, in degrees; ASegments how many segments; AColor the 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: ACenter the centre; AInner the inner radius; AOuter the outer radius; AStartAngle the start angle, in degrees; AEndAngle the end angle, in degrees; ASegments how many segments; AColor the 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 outline AThick wide. C: DrawRingLinesEx Parameters: ACenter the centre; AInner the inner radius; AOuter the outer radius; AStartAngle the start angle, in degrees; AEndAngle the end angle, in degrees; ASegments how many segments; AThick the line thickness; AColor the colour.
  • static method SplineLinear(const APoints: array of Vector2; const AThick: float32; const AColor: Color): Straight lines through APoints, AThick wide (nothing for fewer than two). C: DrawSplineLinear Parameters: APoints the points; AThick the line thickness; AColor the colour.
  • static method SplineBasis(const APoints: array of Vector2; const AThick: float32; const AColor: Color): A B-spline over APoints (at least four). C: DrawSplineBasis Parameters: APoints the points; AThick the line thickness; AColor the colour.
  • static method SplineCatmullRom(const APoints: array of Vector2; const AThick: float32; const AColor: Color): A Catmull-Rom spline through APoints (at least four). C: DrawSplineCatmullRom Parameters: APoints the points; AThick the line thickness; AColor the 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: APoints the points; AThick the line thickness; AColor the 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: APoints the points; AThick the line thickness; AColor the colour.
  • static method SegmentLinear(const AStart: Vector2; const AEnd: Vector2; const AThick: float32; const AColor: Color): One straight piece. C: DrawSplineSegmentLinear Parameters: AStart the start; AEnd the end; AThick the line thickness; AColor the 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: AP1 the first point; AP2 the second point; AP3 the third point; AP4 the fourth point; AThick the line thickness; AColor the 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: AP1 the first point; AP2 the second point; AP3 the third point; AP4 the fourth point; AThick the line thickness; AColor the 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: AStart the start; AControl the control; AEnd the end; AThick the line thickness; AColor the 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: AStart the start; AControl1 the first control point; AControl2 the second control point; AEnd the end; AThick the line thickness; AColor the colour.
  • static method Text(const AText: string; const APos: Vector2; const ASize: float32; const AColor: Color): AText in raylib's default font, ASize units high (10 at least, as raylib's DrawText). C: DrawText Parameters: AText the text; APos the position; ASize the size; AColor the 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: APos the position.
  • static method Texture(const ATexture: TextureRes; const APos: Vector2; const ATint: Color): ATexture at APos, multiplied by ATint. C: DrawTexture / DrawTextureV Parameters: ATexture the texture; APos the position; ATint the 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): ATexture turned ARotation degrees about its corner and scaled by AScale. C: DrawTextureEx Parameters: ATexture the texture; APos the position; ARotation the rotation; AScale the scale; ATint the tint colour.
  • static method Texture(const ATexture: TextureRes; const ASource: Rectangle; const APos: Vector2; const ATint: Color): The part ASource of ATexture at APos (a negative width or height flips it). C: DrawTextureRec Parameters: ATexture the texture; ASource the source; APos the position; ATint the tint colour.
  • static method Texture(const ATexture: TextureRes; const ASource: Rectangle; const ADest: Rectangle; const AOrigin: Vector2; const ARotation: float32; const ATint: Color): The part ASource of ATexture scaled into ADest, turned ARotation degrees about AOrigin (from the destination's corner). C: DrawTexturePro Parameters: ATexture the texture; ASource the source; ADest the rectangle drawn into; AOrigin the origin; ARotation the rotation; ATint the tint colour.
  • static method Texture(const ATarget: RenderTextureRes; const APos: Vector2; const ATint: Color): ATarget's picture at APos, the right way up. C: DrawTextureRec (rows flipped) Parameters: ATarget the target; APos the position; ATint the 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, turned ARotation degrees about its corner and scaled by AScale. C: DrawTexturePro (rows flipped) Parameters: ATarget the target; APos the position; ARotation the rotation; AScale the scale; ATint the tint colour.
  • static method Texture(const ATarget: RenderTextureRes; const ASource: Rectangle; const APos: Vector2; const ATint: Color): The part ASource of ATarget's picture (in its pixels, top-down) at APos, the right way up. C: DrawTextureRec (rows flipped) Parameters: ATarget the target; ASource the source; APos the position; ATint the tint colour.
  • static method Texture(const ATarget: RenderTextureRes; const ASource: Rectangle; const ADest: Rectangle; const AOrigin: Vector2; const ARotation: float32; const ATint: Color): The part ASource of ATarget's picture scaled into ADest, the right way up, turned ARotation degrees about AOrigin. C: DrawTexturePro (rows flipped) Parameters: ATarget the target; ASource the source; ADest the rectangle drawn into; AOrigin the origin; ARotation the rotation; ATint the 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 at APos (nothing before its first frame). Parameters: AVideo the video; APos the position; ATint the 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 turned ARotation degrees about its corner and scaled by AScale. Parameters: AVideo the video; APos the position; ARotation the rotation; AScale the scale; ATint the tint colour.
  • static method Video(const AVideo: VideoRes; const ASource: Rectangle; const APos: Vector2; const ATint: Color): The part ASource (in its pixels) of AVideo's frame at APos. Parameters: AVideo the video; ASource the source; APos the position; ATint the tint colour.
  • static method Video(const AVideo: VideoRes; const ASource: Rectangle; const ADest: Rectangle; const AOrigin: Vector2; const ARotation: float32; const ATint: Color): The part ASource of AVideo's frame scaled into ADest, turned ARotation degrees about AOrigin (from the destination's corner). Parameters: AVideo the video; ASource the source; ADest the rectangle drawn into; AOrigin the origin; ARotation the rotation; ATint the 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): ATexture stretched into ADest by AInfo (a 9-patch or 3-patch: the corners kept, the edges and middle stretched), turned ARotation degrees about AOrigin. C: DrawTextureNPatch Parameters: ATexture the texture; AInfo the info; ADest the rectangle drawn into; AOrigin the origin; ARotation the rotation; ATint the tint colour.
  • static method Text(const AFont: FontRes; const AText: string; const APos: Vector2; const ASize: float32; const ASpacing: float32; const ATint: Color): AText in AFont at ASize, ASpacing between glyphs. C: DrawTextEx Parameters: AFont the font; AText the text; APos the position; ASize the size; ASpacing the spacing; ATint the 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): AText in AFont turned ARotation degrees about AOrigin. C: DrawTextPro Parameters: AFont the font; AText the text; APos the position; AOrigin the origin; ARotation the rotation; ASize the size; ASpacing the spacing; ATint the tint colour.
  • static method Codepoint(const AFont: FontRes; const ACodepoint: int32; const APos: Vector2; const ASize: float32; const ATint: Color): One codepoint's glyph in AFont. C: DrawTextCodepoint Parameters: AFont the font; ACodepoint the codepoint; APos the position; ASize the size; ATint the 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 of ACodepoints in AFont (nothing for none). C: DrawTextCodepoints Parameters: AFont the font; ACodepoints the codepoints; APos the position; ASize the size; ASpacing the spacing; ATint the tint colour.
  • static method Line3D(const AStart: Vector3; const AEnd: Vector3; const AColor: Color): A 3D line. C: DrawLine3D Parameters: AStart the start; AEnd the end; AColor the colour.
  • static method Point3D(const APos: Vector3; const AColor: Color): A 3D point. C: DrawPoint3D Parameters: APos the position; AColor the colour.
  • static method Circle3D(const ACenter: Vector3; const ARadius: float32; const AAxis: Vector3; const AAngle: float32; const AColor: Color): A circle turned AAngle degrees about AAxis. C: DrawCircle3D Parameters: ACenter the centre; ARadius the radius; AAxis the axis; AAngle the angle; AColor the 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: AA the first corner; AB the second corner; AC the third corner; AColor the 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: APoints the points; AColor the colour.
  • static method Cube(const APos: Vector3; const ASize: Vector3; const AColor: Color): A filled box centered at APos. C: DrawCube / DrawCubeV Parameters: ASize its width, height and length; APos the position; AColor the colour.
  • static method CubeWires(const APos: Vector3; const ASize: Vector3; const AColor: Color): A box's edges. C: DrawCubeWires / DrawCubeWiresV Parameters: APos the position; ASize the size; AColor the colour.
  • static method Sphere(const ACenter: Vector3; const ARadius: float32; const AColor: Color): A filled sphere. C: DrawSphere Parameters: ACenter the centre; ARadius the radius; AColor the colour.
  • static method Sphere(const ACenter: Vector3; const ARadius: float32; const ARings: int32; const ASlices: int32; const AColor: Color): A filled sphere of ARings rings and ASlices slices. C: DrawSphereEx Parameters: ACenter the centre; ARadius the radius; ARings how many rings; ASlices how many slices; AColor the 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: ACenter the centre; ARadius the radius; ARings how many rings; ASlices how many slices; AColor the 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 on APos. C: DrawCylinder Parameters: APos the position; ARadiusTop the radius top; ARadiusBottom the radius bottom; AHeight the height; ASides how many sides; AColor the 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 from AStart to AEnd. C: DrawCylinderEx Parameters: AStart the start; AEnd the end; AStartRadius the start radius; AEndRadius the end radius; ASides how many sides; AColor the 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 on APos. C: DrawCylinderWires Parameters: APos the position; ARadiusTop the radius top; ARadiusBottom the radius bottom; AHeight the height; ASides how many sides; AColor the 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 from AStart to AEnd. C: DrawCylinderWiresEx Parameters: AStart the start; AEnd the end; AStartRadius the start radius; AEndRadius the end radius; ASides how many sides; AColor the 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 from AStart to AEnd. C: DrawCapsule Parameters: AStart the start; AEnd the end; ARadius the radius; ASlices how many slices; ARings how many rings; AColor the 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: AStart the start; AEnd the end; ARadius the radius; ASlices how many slices; ARings how many rings; AColor the colour.
  • static method Plane(const ACenter: Vector3; const ASize: Vector2; const AColor: Color): A flat plane on the XZ axes. C: DrawPlane Parameters: ACenter the centre; ASize the size; AColor the colour.
  • static method Ray(const ARay: Ray; const AColor: Color): A ray as a line from its position along its direction. C: DrawRay Parameters: ARay the ray; AColor the colour.
  • static method Grid(const ASlices: int32; const ASpacing: float32): A grid on the XZ plane centered on the origin. C: DrawGrid Parameters: ASlices the lines each way; ASpacing the spacing.
  • static method Box(const ABox: BoundingBox; const AColor: Color): A bounding box's edges. C: DrawBoundingBox Parameters: ABox the box; AColor the colour.
  • static method Billboard(const ACamera: Camera3D; const ATexture: TextureRes; const APos: Vector3; const AScale: float32; const ATint: Color): ATexture facing ACamera at APos, AScale units high. C: DrawBillboard Parameters: ACamera the camera; ATexture the texture; APos the position; AScale the scale; ATint the tint colour.
  • static method Billboard(const ACamera: Camera3D; const ATexture: TextureRes; const ASource: Rectangle; const APos: Vector3; const ASize: Vector2; const ATint: Color): The part ASource of ATexture facing ACamera, ASize units. C: DrawBillboardRec Parameters: ACamera the camera; ATexture the texture; ASource the source; APos the position; ASize the size; ATint the 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 part ASource of ATexture facing ACamera with AUp as its up, turned ARotation degrees about AOrigin. C: DrawBillboardPro Parameters: ACamera the camera; ATexture the texture; ASource the source; APos the position; AUp the up direction; ASize the size; AOrigin the origin; ARotation the rotation; ATint the tint colour.

Example: Draw.Circle(Vector2(x: 160, y: 90), 20.0f, RED);

Spline

text
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: AStart the start; AEnd the end; AT how far along, 0 to 1. Returns: the point AT of the way along the piece
  • static 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: AP1 the first point; AP2 the second point; AP3 the third point; AP4 the fourth point; AT how far along, 0 to 1. Returns: the point AT of the way along the piece
  • static 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: AP1 the first point; AP2 the second point; AP3 the third point; AP4 the fourth point; AT how far along, 0 to 1. Returns: the point AT of the way along the piece
  • static method BezierQuadratic(const AStart: Vector2; const AControl: Vector2; const AEnd: Vector2; const AT: float32): Vector2: On a quadratic Bezier piece. C: GetSplinePointBezierQuadratic Parameters: AStart the start; AControl the control; AEnd the end; AT how far along, 0 to 1. Returns: the point AT of the way along the piece
  • static 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: AStart the start; AControl1 the first control point; AControl2 the second control point; AEnd the end; AT how far along, 0 to 1. Returns: the point AT of the way along the piece

Example: LShip := Spline.CatmullRom(LP1, LP2, LP3, LP4, LTime);

GLVersion

text
type GLVersion = choices(

The GL raylib runs on, rlgl's rlGlVersion values.

Members

  • GLVersion.Software: Software rendering. C: RL_OPENGL_SOFTWARE
  • GLVersion.OpenGL11: OpenGL 1.1. C: RL_OPENGL_11
  • GLVersion.OpenGL21: OpenGL 2.1 (GLSL 120). C: RL_OPENGL_21
  • GLVersion.OpenGL33: OpenGL 3.3 (GLSL 330). C: RL_OPENGL_33
  • GLVersion.OpenGL43: OpenGL 4.3 (using GLSL 330). C: RL_OPENGL_43
  • GLVersion.OpenGLES20: OpenGL ES 2.0 (GLSL 100). C: RL_OPENGL_ES_20
  • GLVersion.OpenGLES30: OpenGL ES 3.0 (GLSL 300 es). C: RL_OPENGL_ES_30

GLCull

text
type GLCull = choices(

The faces culled, rlgl's rlCullMode values.

Members

  • GLCull.Front: The front faces. C: RL_CULL_FACE_FRONT
  • GLCull.Back: The back faces. C: RL_CULL_FACE_BACK

GLAttachType

text
type GLAttachType = choices(

A framebuffer attachment point, rlgl's rlFramebufferAttachType values.

Members

  • GLAttachType.Color0: Framebuffer attachment type: color 0. C: RL_ATTACHMENT_COLOR_CHANNEL0
  • GLAttachType.Color1: Framebuffer attachment type: color 1. C: RL_ATTACHMENT_COLOR_CHANNEL1
  • GLAttachType.Color2: Framebuffer attachment type: color 2. C: RL_ATTACHMENT_COLOR_CHANNEL2
  • GLAttachType.Color3: Framebuffer attachment type: color 3. C: RL_ATTACHMENT_COLOR_CHANNEL3
  • GLAttachType.Color4: Framebuffer attachment type: color 4. C: RL_ATTACHMENT_COLOR_CHANNEL4
  • GLAttachType.Color5: Framebuffer attachment type: color 5. C: RL_ATTACHMENT_COLOR_CHANNEL5
  • GLAttachType.Color6: Framebuffer attachment type: color 6. C: RL_ATTACHMENT_COLOR_CHANNEL6
  • GLAttachType.Color7: Framebuffer attachment type: color 7. C: RL_ATTACHMENT_COLOR_CHANNEL7
  • GLAttachType.Depth: Framebuffer attachment type: depth. C: RL_ATTACHMENT_DEPTH
  • GLAttachType.Stencil: Framebuffer attachment type: stencil. C: RL_ATTACHMENT_STENCIL

GLAttachTextureType

text
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_X
  • GLAttachTextureType.CubemapNegativeX: Framebuffer texture attachment type: cubemap, -X side. C: RL_ATTACHMENT_CUBEMAP_NEGATIVE_X
  • GLAttachTextureType.CubemapPositiveY: Framebuffer texture attachment type: cubemap, +Y side. C: RL_ATTACHMENT_CUBEMAP_POSITIVE_Y
  • GLAttachTextureType.CubemapNegativeY: Framebuffer texture attachment type: cubemap, -Y side. C: RL_ATTACHMENT_CUBEMAP_NEGATIVE_Y
  • GLAttachTextureType.CubemapPositiveZ: Framebuffer texture attachment type: cubemap, +Z side. C: RL_ATTACHMENT_CUBEMAP_POSITIVE_Z
  • GLAttachTextureType.CubemapNegativeZ: Framebuffer texture attachment type: cubemap, -Z side. C: RL_ATTACHMENT_CUBEMAP_NEGATIVE_Z
  • GLAttachTextureType.Texture2D: Framebuffer texture attachment type: texture2d. C: RL_ATTACHMENT_TEXTURE2D
  • GLAttachTextureType.RenderBuffer: Framebuffer texture attachment type: renderbuffer. C: RL_ATTACHMENT_RENDERBUFFER

GLMatrix

text
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_MODELVIEW
  • GLMatrix.Projection: The projection matrix (GL_PROJECTION). C: RL_PROJECTION
  • GLMatrix.Texture: The texture matrix (GL_TEXTURE). C: RL_TEXTURE

GLMode

text
type GLMode = choices(

The primitives GL.Begin draws (RL_LINES, RL_TRIANGLES, RL_QUADS).

Members

  • GLMode.Lines: Lines (GL_LINES). C: RL_LINES
  • GLMode.Triangles: Triangles (GL_TRIANGLES). C: RL_TRIANGLES
  • GLMode.Quads: Quads (GL_QUADS). C: RL_QUADS

GLShaderType

text
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_SHADER
  • GLShaderType.Vertex: The vertex stage (GL_VERTEX_SHADER). C: RL_VERTEX_SHADER
  • GLShaderType.Compute: The compute stage (GL_COMPUTE_SHADER). C: RL_COMPUTE_SHADER

GLUsage

text
type GLUsage = choices(

A GPU buffer's usage hint (RL_STREAM_DRAW ..).

Members

  • GLUsage.StreamDraw: Stream draw use (GL_STREAM_DRAW). C: RL_STREAM_DRAW
  • GLUsage.StreamRead: Stream read use (GL_STREAM_READ). C: RL_STREAM_READ
  • GLUsage.StreamCopy: Stream copy use (GL_STREAM_COPY). C: RL_STREAM_COPY
  • GLUsage.StaticDraw: Static draw use (GL_STATIC_DRAW). C: RL_STATIC_DRAW
  • GLUsage.StaticRead: Static read use (GL_STATIC_READ). C: RL_STATIC_READ
  • GLUsage.StaticCopy: Static copy use (GL_STATIC_COPY). C: RL_STATIC_COPY
  • GLUsage.DynamicDraw: Dynamic draw use (GL_DYNAMIC_DRAW). C: RL_DYNAMIC_DRAW
  • GLUsage.DynamicRead: Dynamic read use (GL_DYNAMIC_READ). C: RL_DYNAMIC_READ
  • GLUsage.DynamicCopy: Dynamic copy use (GL_DYNAMIC_COPY). C: RL_DYNAMIC_COPY

GLDataType

text
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_BYTE
  • GLDataType.Float: Float components (GL_FLOAT). C: RL_FLOAT

GLTexParam

text
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_FILTER
  • GLTexParam.MinFilter: The min filter parameter (GL_TEXTURE_MIN_FILTER). C: RL_TEXTURE_MIN_FILTER
  • GLTexParam.WrapS: The wrap S parameter (GL_TEXTURE_WRAP_S). C: RL_TEXTURE_WRAP_S
  • GLTexParam.WrapT: The wrap T parameter (GL_TEXTURE_WRAP_T). C: RL_TEXTURE_WRAP_T
  • GLTexParam.Anisotropic: Anisotropic filter (custom identifier). C: RL_TEXTURE_FILTER_ANISOTROPIC
  • GLTexParam.MipmapBiasRatio: Texture mipmap bias, percentage ratio (custom identifier). C: RL_TEXTURE_MIPMAP_BIAS_RATIO

GLTexFilter

text
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_NEAREST
  • GLTexFilter.Linear: Linear filtering (GL_LINEAR). C: RL_TEXTURE_FILTER_LINEAR
  • GLTexFilter.MipNearest: Mip nearest filtering (GL_NEAREST_MIPMAP_NEAREST). C: RL_TEXTURE_FILTER_MIP_NEAREST
  • GLTexFilter.LinearMipNearest: Linear mip nearest filtering (GL_LINEAR_MIPMAP_NEAREST). C: RL_TEXTURE_FILTER_LINEAR_MIP_NEAREST
  • GLTexFilter.NearestMipLinear: Nearest mip linear filtering (GL_NEAREST_MIPMAP_LINEAR). C: RL_TEXTURE_FILTER_NEAREST_MIP_LINEAR
  • GLTexFilter.MipLinear: Mip linear filtering (GL_LINEAR_MIPMAP_LINEAR). C: RL_TEXTURE_FILTER_MIP_LINEAR

GLTexWrap

text
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_REPEAT
  • GLTexWrap.Clamp: Clamp wrapping (GL_CLAMP_TO_EDGE). C: RL_TEXTURE_WRAP_CLAMP
  • GLTexWrap.MirrorRepeat: Mirror repeat wrapping (GL_MIRRORED_REPEAT). C: RL_TEXTURE_WRAP_MIRROR_REPEAT
  • GLTexWrap.MirrorClamp: Mirror clamp wrapping (GL_MIRROR_CLAMP_EXT). C: RL_TEXTURE_WRAP_MIRROR_CLAMP

GLBlendFactor

text
type GLBlendFactor = choices(

A blend factor (RL_ZERO, RL_ONE, RL_SRC_COLOR ..).

Members

  • GLBlendFactor.Zero: The zero factor (GL_ZERO). C: RL_ZERO
  • GLBlendFactor.One: The one factor (GL_ONE). C: RL_ONE
  • GLBlendFactor.SrcColor: The src color factor (GL_SRC_COLOR). C: RL_SRC_COLOR
  • GLBlendFactor.OneMinusSrcColor: The one minus src color factor (GL_ONE_MINUS_SRC_COLOR). C: RL_ONE_MINUS_SRC_COLOR
  • GLBlendFactor.SrcAlpha: The src alpha factor (GL_SRC_ALPHA). C: RL_SRC_ALPHA
  • GLBlendFactor.OneMinusSrcAlpha: The one minus src alpha factor (GL_ONE_MINUS_SRC_ALPHA). C: RL_ONE_MINUS_SRC_ALPHA
  • GLBlendFactor.DstAlpha: The dst alpha factor (GL_DST_ALPHA). C: RL_DST_ALPHA
  • GLBlendFactor.OneMinusDstAlpha: The one minus dst alpha factor (GL_ONE_MINUS_DST_ALPHA). C: RL_ONE_MINUS_DST_ALPHA
  • GLBlendFactor.DstColor: The dst color factor (GL_DST_COLOR). C: RL_DST_COLOR
  • GLBlendFactor.OneMinusDstColor: The one minus dst color factor (GL_ONE_MINUS_DST_COLOR). C: RL_ONE_MINUS_DST_COLOR
  • GLBlendFactor.SrcAlphaSaturate: The src alpha saturate factor (GL_SRC_ALPHA_SATURATE). C: RL_SRC_ALPHA_SATURATE
  • GLBlendFactor.ConstantColor: The constant color factor (GL_CONSTANT_COLOR). C: RL_CONSTANT_COLOR
  • GLBlendFactor.OneMinusConstantColor: The one minus constant color factor (GL_ONE_MINUS_CONSTANT_COLOR). C: RL_ONE_MINUS_CONSTANT_COLOR
  • GLBlendFactor.ConstantAlpha: The constant alpha factor (GL_CONSTANT_ALPHA). C: RL_CONSTANT_ALPHA
  • GLBlendFactor.OneMinusConstantAlpha: The one minus constant alpha factor (GL_ONE_MINUS_CONSTANT_ALPHA). C: RL_ONE_MINUS_CONSTANT_ALPHA

GLBlendEquation

text
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_ADD
  • GLBlendEquation.Min: The min equation (GL_MIN). C: RL_MIN
  • GLBlendEquation.Max: The max equation (GL_MAX). C: RL_MAX
  • GLBlendEquation.Subtract: The subtract equation (GL_FUNC_SUBTRACT). C: RL_FUNC_SUBTRACT
  • GLBlendEquation.ReverseSubtract: The reverse subtract equation (GL_FUNC_REVERSE_SUBTRACT). C: RL_FUNC_REVERSE_SUBTRACT

GLFramebufferTarget

text
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_FRAMEBUFFER
  • GLFramebufferTarget.Draw: The draw target (GL_DRAW_FRAMEBUFFER). C: RL_DRAW_FRAMEBUFFER

GL

text
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: AMode the mode.
  • static method PushMatrix(): Saves the current matrix on the stack. C: rlPushMatrix
  • static method PopMatrix(): Restores the matrix saved last. C: rlPopMatrix
  • static method LoadIdentity(): The current matrix becomes the identity. C: rlLoadIdentity
  • static method Translate(const AX: float32; const AY: float32; const AZ: float32): Moves by (AX, AY, AZ). C: rlTranslatef Parameters: AX the x coordinate; AY the y coordinate; AZ the z coordinate.
  • static method Rotate(const AAngle: float32; const AX: float32; const AY: float32; const AZ: float32): Turns AAngle degrees about the axis (AX, AY, AZ). C: rlRotatef Parameters: AAngle the angle; AX the x coordinate; AY the y coordinate; AZ the z coordinate.
  • static method Scale(const AX: float32; const AY: float32; const AZ: float32): Scales by (AX, AY, AZ). C: rlScalef Parameters: AX the x coordinate; AY the y coordinate; AZ the z coordinate.
  • static method MultMatrix(const AMatrix: Matrix): Multiplies the current matrix by AMatrix. C: rlMultMatrixf Parameters: AMatrix the 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: ALeft the left of the view volume; ARight the right of the view volume; ABottom the bottom of the view volume; ATop the top of the view volume; ANear the near clip distance; AFar the 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: ALeft the left of the view volume; ARight the right of the view volume; ABottom the bottom of the view volume; ATop the top of the view volume; ANear the near clip distance; AFar the 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: AX the x coordinate; AY the y coordinate; AWidth the width; AHeight the height.
  • static method SetClipPlanes(const ANear: float64; const AFar: float64): The near / far clip planes raylib's 3D modes project with. C: rlSetClipPlanes Parameters: ANear the near clip distance; AFar the far clip distance.
  • static method GetCullDistanceNear(): float64: The near clip plane. C: rlGetCullDistanceNear Returns: the near clip plane
  • static method GetCullDistanceFar(): float64: The far clip plane. C: rlGetCullDistanceFar Returns: the far clip plane
  • static method Begin(const AMode: GLMode): Starts a primitive run: the vertices up to End make AMode's shapes. C: rlBegin Parameters: AMode the mode.
  • static method End(): Ends Begin's run. C: rlEnd
  • static method Vertex(const AX: int32; const AY: int32): A vertex at whole (AX, AY). C: rlVertex2i Parameters: AX the x coordinate; AY the y coordinate.
  • static method Vertex(const AX: float32; const AY: float32): A vertex at (AX, AY). C: rlVertex2f Parameters: AX the x coordinate; AY the y coordinate.
  • static method Vertex(const AX: float32; const AY: float32; const AZ: float32): A vertex at (AX, AY, AZ). C: rlVertex3f Parameters: AX the x coordinate; AY the y coordinate; AZ the z coordinate.
  • static method Vertex(const APoint: Vector2): A vertex at APoint. C: rlVertex2f Parameters: APoint the point.
  • static method Vertex(const APoint: Vector3): A vertex at APoint. C: rlVertex3f Parameters: APoint the point.
  • static method TexCoord(const AX: float32; const AY: float32): The next vertices' texture coordinate. C: rlTexCoord2f Parameters: AX the x coordinate; AY the y coordinate.
  • static method TexCoord(const ACoord: Vector2): The next vertices' texture coordinate. C: rlTexCoord2f Parameters: ACoord the coord.
  • static method Normal(const AX: float32; const AY: float32; const AZ: float32): The next vertices' normal. C: rlNormal3f Parameters: AX the x coordinate; AY the y coordinate; AZ the z coordinate.
  • static method Normal(const ANormal: Vector3): The next vertices' normal. C: rlNormal3f Parameters: ANormal the normal.
  • static method Color(const AColor: Color): The next vertices' color. C: rlColor4ub Parameters: AColor the 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: AR the red part, 0 to 1; AG the green part, 0 to 1; AB the 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: AR the red part, 0 to 1; AG the green part, 0 to 1; AB the blue part, 0 to 1; AA the alpha part, 0 to 1.
  • static method EnableVertexArray(const AVaoId: uint32): bool: Binds the vertex array AVaoId; false when vertex arrays are not supported. C: rlEnableVertexArray Parameters: AVaoId the vao id. Returns: true when it was bound
  • static method DisableVertexArray(): Unbinds the vertex array. C: rlDisableVertexArray
  • static method EnableVertexBuffer(const AId: uint32): Binds the vertex buffer AId. C: rlEnableVertexBuffer Parameters: AId the id.
  • static method DisableVertexBuffer(): Unbinds the vertex buffer. C: rlDisableVertexBuffer
  • static method EnableVertexBufferElement(const AId: uint32): Binds the element (index) buffer AId. C: rlEnableVertexBufferElement Parameters: AId the id.
  • static method DisableVertexBufferElement(): Unbinds the element (index) buffer. C: rlDisableVertexBufferElement
  • static method EnableVertexAttribute(const AIndex: uint32): Turns the vertex attribute AIndex on. C: rlEnableVertexAttribute Parameters: AIndex the index, from 0.
  • static method DisableVertexAttribute(const AIndex: uint32): Turns the vertex attribute AIndex off. C: rlDisableVertexAttribute Parameters: AIndex the index, from 0.
  • static method EnableStatePointer(const AAttribType: int32; const ABuffer: ptr): GL 1.1's client state array AAttribType (GL_VERTEX_ARRAY ..) reading ABuffer. C: rlEnableStatePointer Parameters: AAttribType the attrib type; ABuffer the buffer.
  • static method DisableStatePointer(const AAttribType: int32): Turns a client state array off (OpenGL 1.1). C: rlDisableStatePointer Parameters: AAttribType the 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 holding ASize bytes from ABuffer (nil: room only). C: rlLoadVertexBuffer Parameters: ABuffer the buffer; ASize the size; ADynamic true for a buffer meant to be updated. Returns: a new vertex buffer holding ASize bytes from ABuffer (nil: room only)
  • static method LoadVertexBufferElement(const ABuffer: ptr to const; const ASize: int32; const ADynamic: bool): uint32: A new element (index) buffer holding ASize bytes from ABuffer. C: rlLoadVertexBufferElement Parameters: ABuffer the buffer; ASize the size; ADynamic true for a buffer meant to be updated. Returns: a new element (index) buffer holding ASize bytes from ABuffer
  • static method UpdateVertexBuffer(const AId: uint32; const AData: ptr to const; const ADataSize: int32; const AOffset: int32): Writes ADataSize bytes from AData into the vertex buffer AId at byte AOffset. C: rlUpdateVertexBuffer Parameters: AId the id; AData the data; ADataSize the data size; AOffset the offset.
  • static method UpdateVertexBufferElements(const AId: uint32; const AData: ptr to const; const ADataSize: int32; const AOffset: int32): Writes ADataSize bytes from AData into the element buffer AId at byte AOffset. C: rlUpdateVertexBufferElements Parameters: AId the id; AData the data; ADataSize the data size; AOffset the offset.
  • static method UnloadVertexArray(const AVaoId: uint32): Deletes the vertex array AVaoId. C: rlUnloadVertexArray Parameters: AVaoId the vertex array's id.
  • static method UnloadVertexBuffer(const AVboId: uint32): Deletes the vertex buffer AVboId. C: rlUnloadVertexBuffer Parameters: AVboId the buffer's id.
  • static method SetVertexAttribute(const AIndex: uint32; const ACompSize: int32; const AType: GLDataType; const ANormalized: bool; const AStride: int32; const AOffset: int32): Attribute AIndex reads ACompSize components of AType per vertex, AStride bytes apart, from byte AOffset of the bound buffer. C: rlSetVertexAttribute Parameters: AIndex the index, from 0; ACompSize the comp size; AType the type; ANormalized the normalized; AStride the stride; AOffset the offset.
  • static method SetVertexAttributeDivisor(const AIndex: uint32; const ADivisor: int32): Attribute AIndex advances once per ADivisor instances (0: per vertex). C: rlSetVertexAttributeDivisor Parameters: AIndex the index, from 0; ADivisor the divisor.
  • static method SetVertexAttributeDefault(const ALocIndex: int32; const AValue: ptr to const; const AType: AttribType; const ACount: int32): The value attribute location ALocIndex takes when no buffer feeds it. C: rlSetVertexAttributeDefault Parameters: ALocIndex the shader location; AValue the value; AType the type; ACount how many.
  • static method DrawVertexArray(const AOffset: int32; const ACount: int32): Draws ACount vertices of the bound array from AOffset. C: rlDrawVertexArray Parameters: AOffset the offset; ACount how many.
  • static method DrawVertexArrayElements(const AOffset: int32; const ACount: int32; const ABuffer: ptr to const): Draws ACount indexed vertices from AOffset (ABuffer: the indices, nil for the bound element buffer). C: rlDrawVertexArrayElements Parameters: AOffset the offset; ACount how many; ABuffer the buffer.
  • static method DrawVertexArrayInstanced(const AOffset: int32; const ACount: int32; const AInstances: int32): Draws AInstances copies of ACount vertices from AOffset. C: rlDrawVertexArrayInstanced Parameters: AOffset the offset; ACount how many; AInstances the instances.
  • static method DrawVertexArrayElementsInstanced(const AOffset: int32; const ACount: int32; const ABuffer: ptr to const; const AInstances: int32): Draws AInstances copies of ACount indexed vertices from AOffset. C: rlDrawVertexArrayElementsInstanced Parameters: AOffset the offset; ACount how many; ABuffer the buffer; AInstances the instances.
  • static method ActiveTextureSlot(const ASlot: int32): The texture unit the next texture binds go to. C: rlActiveTextureSlot Parameters: ASlot the slot.
  • static method EnableTexture(const AId: uint32): Binds the texture AId. C: rlEnableTexture Parameters: AId the id.
  • static method DisableTexture(): Unbinds the 2D texture. C: rlDisableTexture
  • static method EnableTextureCubemap(const AId: uint32): Binds the cubemap AId. C: rlEnableTextureCubemap Parameters: AId the id.
  • static method DisableTextureCubemap(): Unbinds the cubemap texture. C: rlDisableTextureCubemap
  • static method TextureParameters(const AId: uint32; const AParam: GLTexParam; const AValue: int32): Sets the texture AId's AParam to AValue (Anisotropic: the level; MipmapBiasRatio: the bias x 100). C: rlTextureParameters Parameters: AId the id; AParam the parameter; AValue the value.
  • static method TextureParameters(const AId: uint32; const AParam: GLTexParam; const AFilter: GLTexFilter): Sets the texture AId's MagFilter or MinFilter to AFilter. C: rlTextureParameters Parameters: AId the id; AParam the parameter; AFilter the filter.
  • static method TextureParameters(const AId: uint32; const AParam: GLTexParam; const AWrap: GLTexWrap): Sets the texture AId's WrapS or WrapT to AWrap. C: rlTextureParameters Parameters: AId the id; AParam the parameter; AWrap the wrap mode.
  • static method CubemapParameters(const AId: uint32; const AParam: GLTexParam; const AValue: int32): Sets the cubemap AId's AParam to AValue. C: rlCubemapParameters Parameters: AId the id; AParam the parameter; AValue the value.
  • static method CubemapParameters(const AId: uint32; const AParam: GLTexParam; const AFilter: GLTexFilter): Sets the cubemap AId's MagFilter or MinFilter to AFilter. C: rlCubemapParameters Parameters: AId the id; AParam the parameter; AFilter the filter.
  • static method CubemapParameters(const AId: uint32; const AParam: GLTexParam; const AWrap: GLTexWrap): Sets the cubemap AId's WrapS or WrapT to AWrap. C: rlCubemapParameters Parameters: AId the id; AParam the parameter; AWrap the 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 from AData (nil: room only), its id (0 on a failure). C: rlLoadTexture Parameters: AData the data; AWidth the width; AHeight the height; AFormat the pixel format; AMipmaps how many mipmap levels. Returns: a new texture from AData (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: AWidth the width; AHeight the height; AUseRenderBuffer the 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 from AData (six faces of ASize x ASize). C: rlLoadTextureCubemap Parameters: AData the data; ASize the size; AFormat the pixel format; AMipmaps how many mipmap levels. Returns: a new cubemap from AData (six faces of ASize x ASize)
  • 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 pixels AData into the texture AId at (AX, AY). C: rlUpdateTexture Parameters: AId the id; AX the x coordinate; AY the y coordinate; AWidth the width; AHeight the height; AFormat the pixel format; AData the data.
  • static method GetGLTextureFormats(const AFormat: Pixel; var AGLInternalFormat: uint32; var AGLFormat: uint32; var AGLType: uint32): The GL internal format, format and type of AFormat. C: rlGetGlTextureFormats Parameters: AFormat the pixel format; AGLInternalFormat the GL internal format; AGLFormat the GL format; AGLType the GL type.
  • static method GetPixelFormatName(const AFormat: Pixel): string: AFormat's name ("R8G8B8A8" ..). C: rlGetPixelFormatName Parameters: AFormat the pixel format. Returns: AFormat's name ("R8G8B8A8" ..)
  • static method UnloadTexture(const AId: uint32): Deletes the texture AId from the GPU. C: rlUnloadTexture Parameters: AId the texture's id.
  • static method GenTextureMipmaps(const AId: uint32; const AWidth: int32; const AHeight: int32; const AFormat: Pixel; var AMipmaps: int32): Makes the texture AId's mipmaps; AMipmaps gets how many it has. C: rlGenTextureMipmaps Parameters: AId the id; AWidth the width; AHeight the height; AFormat the pixel format; AMipmaps how many mipmap levels.
  • static method ReadTexturePixels(const AId: uint32; const AWidth: int32; const AHeight: int32; const AFormat: Pixel): ptr: The texture AId's pixels in AFormat, in memory the program frees with MemFree (nil on a failure). C: rlReadTexturePixels Parameters: AId the id; AWidth the width; AHeight the height; AFormat the pixel format. Returns: the texture AId's pixels in AFormat, 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: AWidth the width; AHeight the height. Returns: the screen's pixels (R8G8B8A8, top row first), in memory the program frees with MemFree
  • static method SetTexture(const AId: uint32): Binds the texture AId for the next immediate-mode vertices (0: raylib's default white texture). C: rlSetTexture Parameters: AId the id.
  • static method EnableFramebuffer(const AId: uint32): Binds the framebuffer AId (drawing lands in it). C: rlEnableFramebuffer Parameters: AId the id.
  • static method DisableFramebuffer(): Drawing lands on the screen again. C: rlDisableFramebuffer
  • static 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: ACount how 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; ABufferMask is GL's buffer bits (GL_COLOR_BUFFER_BIT ..). C: rlBlitFramebuffer Parameters: ASrcX the src X; ASrcY the src Y; ASrcWidth the src width; ASrcHeight the src height; ADstX the dst X; ADstY the dst Y; ADstWidth the dst width; ADstHeight the dst height; ABufferMask the buffer mask.
  • static method BindFramebuffer(const ATarget: GLFramebufferTarget; const AFramebuffer: uint32): Binds the framebuffer AFramebuffer as ATarget's. C: rlBindFramebuffer Parameters: ATarget the target; AFramebuffer the 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 buffer ATexId to the framebuffer AId. C: rlFramebufferAttach Parameters: AId the id; ATexId the tex id; AAttach the attach; ATexType the tex type; AMipLevel the mip level.
  • static method FramebufferComplete(const AId: uint32): bool: True when the framebuffer AId can be drawn into. C: rlFramebufferComplete Parameters: AId the id. Returns: true when the framebuffer AId can be drawn into
  • static method UnloadFramebuffer(const AId: uint32): Unloads the framebuffer AId and its attachments. C: rlUnloadFramebuffer Parameters: AId the 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 into APixels in AFormat. C: rlCopyFramebuffer Parameters: AX the x coordinate; AY the y coordinate; AWidth the width; AHeight the height; AFormat the pixel format; APixels the pixels.
  • static method ResizeFramebuffer(const AWidth: int32; const AHeight: int32): Resizes the active framebuffer. C: rlResizeFramebuffer Parameters: AWidth the width; AHeight the height.
  • static method EnableColorBlend(): Turns colour blending on. C: rlEnableColorBlend
  • static method DisableColorBlend(): Turns colour blending off. C: rlDisableColorBlend
  • static method EnableDepthTest(): Turns the depth test on. C: rlEnableDepthTest
  • static method DisableDepthTest(): Turns the depth test off. C: rlDisableDepthTest
  • static method EnableDepthMask(): Depth writes on. C: rlEnableDepthMask
  • static method DisableDepthMask(): Depth writes off. C: rlDisableDepthMask
  • static method EnableBackfaceCulling(): Turns back-face culling on. C: rlEnableBackfaceCulling
  • static method DisableBackfaceCulling(): Turns back-face culling off. C: rlDisableBackfaceCulling
  • static method ColorMask(const AR: bool; const AG: bool; const AB: bool; const AA: bool): Which color channels drawing writes. C: rlColorMask Parameters: AR true to write red; AG true to write green; AB true to write blue; AA true to write alpha.
  • static method SetCullFace(const AFace: GLCull): The faces culled while culling is on. C: rlSetCullFace Parameters: AFace the face.
  • static method EnableScissorTest(): Turns the scissor test on. C: rlEnableScissorTest
  • static method DisableScissorTest(): Turns the scissor test off. C: rlDisableScissorTest
  • static 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: AX the x coordinate; AY the y coordinate; AWidth the width; AHeight the height.
  • static method EnablePointMode(): Polygons drawn as their corner points. C: rlEnablePointMode
  • static method DisablePointMode(): Turns point mode off. C: rlDisablePointMode
  • static method SetPointSize(const ASize: float32): The size points are drawn at. C: rlSetPointSize Parameters: ASize the size, in pixels.
  • static method GetPointSize(): float32: The size points are drawn at. C: rlGetPointSize Returns: the size, in pixels
  • static method EnableWireMode(): Polygons drawn as their edges. C: rlEnableWireMode
  • static method DisableWireMode(): Turns wire mode off. C: rlDisableWireMode
  • static method SetLineWidth(const AWidth: float32): The width lines are drawn at. C: rlSetLineWidth Parameters: AWidth the width, in pixels.
  • static method GetLineWidth(): float32: The width lines are drawn at. C: rlGetLineWidth Returns: the width, in pixels
  • static method EnableSmoothLines(): Turns line smoothing on. C: rlEnableSmoothLines
  • static method DisableSmoothLines(): Turns line smoothing off. C: rlDisableSmoothLines
  • static method EnableStereoRender(): Drawing renders a stereo pair (VRStereoRes.Begin's). C: rlEnableStereoRender
  • static method DisableStereoRender(): Turns stereo rendering off. C: rlDisableStereoRender
  • static method IsStereoRenderEnabled(): bool: True while stereo rendering is on. C: rlIsStereoRenderEnabled Returns: true while stereo rendering is on
  • static method ClearColor(const AColor: Color): The color the screen buffers clear to. C: rlClearColor Parameters: AColor the colour.
  • static method ClearScreenBuffers(): Clears the color and depth buffers. C: rlClearScreenBuffers
  • static method CheckErrors(): Logs every GL error pending. C: rlCheckErrors
  • static method SetBlendMode(const ABlend: Blend): The blend mode drawing uses. C: rlSetBlendMode Parameters: ABlend the 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: ASrc the src; ADst the dst; AEquation the 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: ASrcRGB the src RGB; ADstRGB the dst RGB; ASrcAlpha the src alpha; ADstAlpha the dst alpha; AEqRGB the eq RGB; AEqAlpha the eq alpha.
  • static method Init(const AWidth: int32; const AHeight: int32): Starts rlgl over a GL context of AWidth x AHeight (raylib's window does this itself). C: rlglInit Parameters: AWidth the width; AHeight the height.
  • static method Close(): Ends rlgl (raylib's window does this itself). C: rlglClose
  • static method LoadExtensions(const ALoader: ptr): Loads the GL extensions through ALoader (a GL loader's proc address routine). C: rlLoadExtensions Parameters: ALoader the loader.
  • static method GetProcAddress(const AName: string): ptr: The GL routine AName's address (nil when the GL has none). C: rlGetProcAddress Parameters: AName the name. Returns: the GL routine AName's address (nil when the GL has none)
  • static method GetVersion(): GLVersion: The GL raylib runs on. C: rlGetVersion Returns: the GL raylib runs on
  • static method SetFramebufferWidth(const AWidth: int32): The framebuffer width rlgl draws for. C: rlSetFramebufferWidth Parameters: AWidth the width.
  • static method GetFramebufferWidth(): int32: The default framebuffer's width. C: rlGetFramebufferWidth Returns: the default framebuffer's width
  • static method SetFramebufferHeight(const AHeight: int32): The framebuffer height rlgl draws for. C: rlSetFramebufferHeight Parameters: AHeight the height.
  • static method GetFramebufferHeight(): int32: The default framebuffer's height. C: rlGetFramebufferHeight Returns: the default framebuffer's height
  • static method GetTextureIdDefault(): uint32: raylib's default white texture's id. C: rlGetTextureIdDefault Returns: raylib's default white texture's id
  • static method GetShaderIdDefault(): uint32: raylib's default shader's id. C: rlGetShaderIdDefault Returns: raylib's default shader's id
  • static 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: ABuffers buffers of AElements quads each (unload it with UnloadRenderBatch). C: rlLoadRenderBatch Parameters: ABuffers the buffers; AElements the elements. Returns: a new render batch: ABuffers buffers of AElements quads each (unload it with UnloadRenderBatch)
  • static method UnloadRenderBatch(const ABatch: rlRenderBatch): Frees the render batch ABatch. C: rlUnloadRenderBatch Parameters: ABatch the batch.
  • static method DrawRenderBatch(var ABatch: rlRenderBatch): Draws what ABatch holds and empties it. C: rlDrawRenderBatch Parameters: ABatch the batch.
  • static method SetRenderBatchActive(const ABatch: ptr to rlRenderBatch): The batch the vertices go into (nil: raylib's default batch). C: rlSetRenderBatchActive Parameters: ABatch the batch.
  • static method DrawRenderBatchActive(): Draws what the active batch holds and empties it. C: rlDrawRenderBatchActive
  • static method CheckRenderBatchLimit(const ACount: int32): bool: Draws the active batch first when ACount more vertices would not fit; true when it did. C: rlCheckRenderBatchLimit Parameters: ACount how many. Returns: true when the batch was drawn
  • static method LoadShader(const ACode: string; const AType: GLShaderType): uint32: Compiles ACode as an AType stage, its id (0 on a failure). C: rlLoadShader Parameters: ACode the stage's source code; AType the type. Returns: compiles ACode as an AType stage, 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: AVertexCode the vertex code; AFragmentCode the 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: AVertexId the vertex id; AFragmentId the 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: AComputeId the compute id. Returns: the program's id (0 on a failure)
  • static method UnloadShader(const AId: uint32): Unloads a compiled stage. C: rlUnloadShader Parameters: AId the id.
  • static method UnloadShaderProgram(const AId: uint32): Deletes the shader program AId. C: rlUnloadShaderProgram Parameters: AId the program's id.
  • static method GetLocationUniform(const AId: uint32; const AName: string): int32: The location of the uniform AName in the program AId (-1: none). C: rlGetLocationUniform Parameters: AId the id; AName the name. Returns: the location of the uniform AName in the program AId (-1: none)
  • static method GetLocationAttrib(const AId: uint32; const AName: string): int32: The location of the attribute AName in the program AId (-1: none). C: rlGetLocationAttrib Parameters: AId the id; AName the name. Returns: the location of the attribute AName in the program AId (-1: none)
  • static method SetUniform(const ALocIndex: int32; const AValue: ptr to const; const AType: UniformType; const ACount: int32): Sets ACount elements of AType from AValue at location ALocIndex of the enabled program. C: rlSetUniform Parameters: ALocIndex the shader location; AValue the value; AType the type; ACount how many.
  • static method SetUniformMatrix(const ALocIndex: int32; const AMatrix: Matrix): Sets the matrix uniform at ALocIndex of the enabled program. C: rlSetUniformMatrix Parameters: ALocIndex the shader location; AMatrix the matrix.
  • static method SetUniformMatrices(const ALocIndex: int32; const AMatrices: array of Matrix): Sets the matrix array at location ALocIndex. C: rlSetUniformMatrices Parameters: ALocIndex the shader location; AMatrices the matrices.
  • static method SetUniformSampler(const ALocIndex: int32; const ATextureId: uint32): Binds the texture ATextureId to the sampler at location ALocIndex. C: rlSetUniformSampler Parameters: ALocIndex the shader location; ATextureId the 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: AId the id; ALocs the locs.
  • static method EnableShader(const AId: uint32): Binds the program AId. C: rlEnableShader Parameters: AId the id.
  • static method DisableShader(): Unbinds the shader program. C: rlDisableShader
  • static method ComputeShaderDispatch(const AGroupX: uint32; const AGroupY: uint32; const AGroupZ: uint32): Runs the bound compute program over AGroupX x AGroupY x AGroupZ work groups. C: rlComputeShaderDispatch Parameters: AGroupX the group X; AGroupY the group Y; AGroupZ the group Z.
  • static method LoadShaderBuffer(const ASize: uint32; const AData: ptr to const; const AUsage: GLUsage): uint32: A new shader storage buffer of ASize bytes from AData (nil: zeroed). C: rlLoadShaderBuffer Parameters: ASize the size; AData the data; AUsage the usage. Returns: a new shader storage buffer of ASize bytes from AData (nil: zeroed)
  • static method UnloadShaderBuffer(const AId: uint32): Deletes the shader buffer AId. C: rlUnloadShaderBuffer Parameters: AId the buffer's id.
  • static method UpdateShaderBuffer(const AId: uint32; const AData: ptr to const; const ASize: uint32; const AOffset: uint32): Writes ASize bytes from AData into the buffer AId at byte AOffset. C: rlUpdateShaderBuffer Parameters: AId the id; AData the data; ASize the size; AOffset the offset.
  • static method BindShaderBuffer(const AId: uint32; const AIndex: uint32): Binds the buffer AId to binding point AIndex. C: rlBindShaderBuffer Parameters: AId the id; AIndex the index, from 0.
  • static method ReadShaderBuffer(const AId: uint32; const ADest: ptr; const ACount: uint32; const AOffset: uint32): Reads ACount bytes of the buffer AId from byte AOffset into ADest. C: rlReadShaderBuffer Parameters: AId the id; ADest where the bytes go; ACount how many; AOffset the offset.
  • static method CopyShaderBuffer(const ADestId: uint32; const ASrcId: uint32; const ADestOffset: uint32; const ASrcOffset: uint32; const ACount: uint32): Copies ACount bytes between two buffers. C: rlCopyShaderBuffer Parameters: ADestId the dest id; ASrcId the src id; ADestOffset the dest offset; ASrcOffset the src offset; ACount how many.
  • static method GetShaderBufferSize(const AId: uint32): uint32: The buffer AId's size in bytes. C: rlGetShaderBufferSize Parameters: AId the id. Returns: the buffer AId's size in bytes
  • static method BindImageTexture(const AId: uint32; const AIndex: uint32; const AFormat: Pixel; const AReadOnly: bool): Binds the texture AId as image unit AIndex for compute programs. C: rlBindImageTexture Parameters: AId the id; AIndex the index, from 0; AFormat the pixel format; AReadOnly the read only.
  • static method GetMatrixModelview(): Matrix: The modelview matrix. C: rlGetMatrixModelview Returns: the modelview matrix
  • static method GetMatrixProjection(): Matrix: The projection matrix. C: rlGetMatrixProjection Returns: the projection matrix
  • static 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: Eye AEye's projection in stereo rendering (0 left, 1 right). C: rlGetMatrixProjectionStereo Parameters: AEye the eye, 0 (left) or 1 (right). Returns: eye AEye's projection in stereo rendering (0 left, 1 right)
  • static method GetMatrixViewOffsetStereo(const AEye: int32): Matrix: Eye AEye's view offset in stereo rendering (0 left, 1 right). C: rlGetMatrixViewOffsetStereo Parameters: AEye the eye, 0 (left) or 1 (right). Returns: eye AEye's view offset in stereo rendering (0 left, 1 right)
  • static method SetMatrixProjection(const AProjection: Matrix): Sets the projection matrix. C: rlSetMatrixProjection Parameters: AProjection the projection matrix.
  • static method SetMatrixModelview(const AView: Matrix): Sets the modelview matrix. C: rlSetMatrixModelview Parameters: AView the view matrix.
  • static method SetMatrixProjectionStereo(const ARight: Matrix; const ALeft: Matrix): The stereo pair's projections. C: rlSetMatrixProjectionStereo Parameters: ARight the right eye's matrix; ALeft the left eye's matrix.
  • static method SetMatrixViewOffsetStereo(const ARight: Matrix; const ALeft: Matrix): The stereo pair's view offsets. C: rlSetMatrixViewOffsetStereo Parameters: ARight the right eye's matrix; ALeft the left eye's matrix.
  • static method LoadDrawCube(): Draws a unit cube (raylib's skybox and cubemap work). C: rlLoadDrawCube
  • static 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

text
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: A the left operand; B the right operand. Returns: the component-wise sum
  • operator +(const A: Vector2; const S: float32): Vector2: S added to each component. C: Vector2AddValue Parameters: A the left operand; S the right operand. Returns: S added to each component
  • operator -(const A: Vector2; const B: Vector2): Vector2: Component-wise difference. C: Vector2Subtract Parameters: A the left operand; B the right operand. Returns: the component-wise difference
  • operator -(const A: Vector2; const S: float32): Vector2: S taken from each component. C: Vector2SubtractValue Parameters: A the left operand; S the right operand. Returns: S taken from each component
  • operator *(const A: Vector2; const B: Vector2): Vector2: Component-wise product. C: Vector2Multiply Parameters: A the left operand; B the right operand. Returns: the component-wise product
  • operator *(const A: Vector2; const S: float32): Vector2: The vector scaled by S. C: Vector2Scale Parameters: A the left operand; S the right operand. Returns: the vector scaled by S
  • operator /(const A: Vector2; const B: Vector2): Vector2: Component-wise quotient. C: Vector2Divide Parameters: A the left operand; B the right operand. Returns: the component-wise quotient
  • operator /(const A: Vector2; const S: float32): Vector2: The vector divided by S. C: Vector2Scale by 1 / S Parameters: A the left operand; S the right operand. Returns: the vector divided by S
  • operator =(const A: Vector2; const B: Vector2): bool: True when the vectors are equal within raymath's epsilon. C: Vector2Equals Parameters: A the left operand; B the right operand. Returns: true when the vectors are equal within raymath's epsilon
  • operator <>(const A: Vector2; const B: Vector2): bool: True when the vectors differ beyond raymath's epsilon. C: Vector2Equals Parameters: A the left operand; B the right operand. Returns: true when the vectors differ beyond raymath's epsilon
  • const method Negate(): Vector2: The vector negated. C: Vector2Negate Returns: the vector negated
  • const 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 length
  • const 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 with B. C: Vector2DotProduct Parameters: B the other vector. Returns: the dot product with B
  • const method Cross(const B: Vector2): float32: The 2D cross product (the z of the 3D one) with B. C: Vector2CrossProduct Parameters: B the other vector. Returns: the 2D cross product (the z of the 3D one) with B
  • const method Distance(const B: Vector2): float32: The distance to B. C: Vector2Distance Parameters: B the other point. Returns: the distance to B
  • const method DistanceSqr(const B: Vector2): float32: The squared distance to B. C: Vector2DistanceSqr Parameters: B the other point. Returns: the squared distance to B
  • const method Angle(const B: Vector2): float32: The signed angle in radians from this vector to B. C: Vector2Angle Parameters: B the other vector. Returns: the signed angle in radians from this vector to B
  • const method LineAngle(const B: Vector2): float32: The angle in radians of the line from this point to B. C: Vector2LineAngle Parameters: B the line's end. Returns: the angle in radians of the line from this point to B
  • const 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 by M. C: Vector2Transform Parameters: M the transform. Returns: the point transformed by M
  • const method Lerp(const B: Vector2; const T: float32): Vector2: The point T of the way to B (0 here, 1 at B). C: Vector2Lerp Parameters: B the end; T the amount. Returns: the point T of the way to B (0 here, 1 at B)
  • const method Reflect(const ANormal: Vector2): Vector2: The vector reflected off a surface of normal ANormal. C: Vector2Reflect Parameters: ANormal the surface's normal. Returns: the vector reflected off a surface of normal ANormal
  • const method Refract(const ANormal: Vector2; const R: float32): Vector2: The (normalized) vector refracted through a surface of normal ANormal. C: Vector2Refract Parameters: ANormal the surface's normal (normalized); R the ratio of the refractive indices. Returns: the (normalized) vector refracted through a surface of normal ANormal
  • const method Min(const B: Vector2): Vector2: Component-wise minimum with B. C: Vector2Min Parameters: B the other Vector2. Returns: the component-wise minimum with B
  • const method Max(const B: Vector2): Vector2: Component-wise maximum with B. C: Vector2Max Parameters: B the other Vector2. Returns: the component-wise maximum with B
  • const method Rotate(const AAngle: float32): Vector2: The vector rotated by AAngle radians. C: Vector2Rotate Parameters: AAngle the angle in radians. Returns: the vector rotated by AAngle radians
  • const method MoveTowards(const ATarget: Vector2; const AMaxDistance: float32): Vector2: The point moved toward ATarget by at most AMaxDistance. C: Vector2MoveTowards Parameters: ATarget where it moves to; AMaxDistance the longest step. Returns: the point moved toward ATarget by at most AMaxDistance
  • const method Clamp(const ALo: Vector2; const AHi: Vector2): Vector2: Each component clamped between ALo's and AHi's. C: Vector2Clamp Parameters: ALo the low corner; AHi the high corner. Returns: each component clamped between ALo's and AHi's
  • const method Clamp(const ALo: float32; const AHi: float32): Vector2: The vector with its length clamped between ALo and AHi. C: Vector2ClampValue Parameters: ALo the shortest length; AHi the longest length. Returns: the vector with its length clamped between ALo and AHi
  • const method In(const R: Rectangle): bool: True when the point is inside R. C: CheckCollisionPointRec Parameters: R the rectangle. Returns: true when the point is inside R
  • const method InCircle(const ACenter: Vector2; const ARadius: float32): bool: True when the point is inside the circle. C: CheckCollisionPointCircle Parameters: ACenter the circle's centre; ARadius its radius. Returns: true when the point is inside the circle
  • const method InTriangle(const AP1: Vector2; const AP2: Vector2; const AP3: Vector2): bool: True when the point is inside the triangle. C: CheckCollisionPointTriangle Parameters: AP1 the first point; AP2 the second point; AP3 the third point. Returns: true when the point is inside the triangle
  • const method OnLine(const AP1: Vector2; const AP2: Vector2; const AThreshold: int32): bool: True when the point is on the line from AP1 to AP2, within AThreshold pixels. C: CheckCollisionPointLine Parameters: AP1 the first point; AP2 the second point; AThreshold the threshold. Returns: true when the point is on the line from AP1 to AP2, within AThreshold pixels
  • const method InPoly(const APoints: array of Vector2): bool: True when the point is inside the polygon APoints (false for an empty one). C: CheckCollisionPointPoly Parameters: APoints the polygon's corners in order. Returns: true when the point is inside the polygon APoints (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; AAt is then where. C: CheckCollisionLines Parameters: AAt the crossing point, set when they cross; AS1 the first line's start; AE1 the first line's end; AS2 the second line's start; AE2 the second line's end. Returns: true when the segments cross; AAt is then where
  • static 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: AC1 the first circle's centre; AR1 its radius; AC2 the second circle's centre; AR2 its radius. Returns: true when 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 from AP1 to AP2. C: CheckCollisionCircleLine Parameters: ACenter the circle's centre; ARadius its radius; AP1 the segment's start; AP2 the segment's end. Returns: true when the circle touches the segment from AP1 to AP2 Example: 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 of ACam. C: GetScreenToWorld2D Parameters: ACam the camera. Returns: the screen point as a world point of ACam
  • const method WorldToScreen(const ACam: Camera2D): Vector2: The world point of ACam as a screen point. C: GetWorldToScreen2D Parameters: ACam the camera. Returns: the world point of ACam as a screen point
  • const method ScreenToRay(const ACam: Camera3D): Ray: The ray from ACam through this screen point (the window's size). C: GetScreenToWorldRay Parameters: ACam the camera. Returns: the ray from ACam through this screen point (the window's size)
  • const method ScreenToRay(const ACam: Camera3D; const AWidth: int32; const AHeight: int32): Ray: The ray from ACam through this point of a AWidth x AHeight view. C: GetScreenToWorldRayEx Parameters: ACam the camera; AWidth the width; AHeight the height. Returns: the ray from ACam through this point of a AWidth x AHeight view

extend Vector3

text
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: A the left operand; B the right operand. Returns: the component-wise sum
  • operator +(const A: Vector3; const S: float32): Vector3: S added to each component. C: Vector3AddValue Parameters: A the left operand; S the right operand. Returns: S added to each component
  • operator -(const A: Vector3; const B: Vector3): Vector3: Component-wise difference. C: Vector3Subtract Parameters: A the left operand; B the right operand. Returns: the component-wise difference
  • operator -(const A: Vector3; const S: float32): Vector3: S taken from each component. C: Vector3SubtractValue Parameters: A the left operand; S the right operand. Returns: S taken from each component
  • operator *(const A: Vector3; const B: Vector3): Vector3: Component-wise product. C: Vector3Multiply Parameters: A the left operand; B the right operand. Returns: the component-wise product
  • operator *(const A: Vector3; const S: float32): Vector3: The vector scaled by S. C: Vector3Scale Parameters: A the left operand; S the right operand. Returns: the vector scaled by S
  • operator /(const A: Vector3; const B: Vector3): Vector3: Component-wise quotient. C: Vector3Divide Parameters: A the left operand; B the right operand. Returns: the component-wise quotient
  • operator /(const A: Vector3; const S: float32): Vector3: The vector divided by S. C: Vector3Scale by 1 / S Parameters: A the left operand; S the right operand. Returns: the vector divided by S
  • operator =(const A: Vector3; const B: Vector3): bool: True when equal within raymath's epsilon. C: Vector3Equals Parameters: A the left operand; B the right operand. Returns: true when equal within raymath's epsilon
  • operator <>(const A: Vector3; const B: Vector3): bool: True when they differ beyond raymath's epsilon. C: Vector3Equals Parameters: A the left operand; B the right operand. Returns: true when they differ beyond raymath's epsilon
  • const method Negate(): Vector3: The vector negated. C: Vector3Negate Returns: the vector negated
  • const method Invert(): Vector3: Each component's reciprocal. C: Vector3Invert Returns: each component's reciprocal
  • const method Length(): float32: The vector's length. C: Vector3Length Returns: the vector's length
  • const method LengthSqr(): float32: The squared length. C: Vector3LengthSqr Returns: the squared length
  • const 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 one
  • const method Dot(const B: Vector3): float32: The dot product with B. C: Vector3DotProduct Parameters: B the other Vector3. Returns: the dot product with B
  • const method Cross(const B: Vector3): Vector3: The cross product with B. C: Vector3CrossProduct Parameters: B the other Vector3. Returns: the cross product with B
  • const method Distance(const B: Vector3): float32: The distance to B. C: Vector3Distance Parameters: B the other Vector3. Returns: the distance to B
  • const method DistanceSqr(const B: Vector3): float32: The squared distance to B. C: Vector3DistanceSqr Parameters: B the other Vector3. Returns: the squared distance to B
  • const method Angle(const B: Vector3): float32: The angle in radians between this vector and B. C: Vector3Angle Parameters: B the other Vector3. Returns: the angle in radians between this vector and B
  • const method Project(const B: Vector3): Vector3: This vector projected onto B. C: Vector3Project Parameters: B the other Vector3. Returns: this vector projected onto B
  • const method Reject(const B: Vector3): Vector3: This vector's part perpendicular to B. C: Vector3Reject Parameters: B the other Vector3. Returns: this vector's part perpendicular to B
  • static method OrthoNormalize(var AV1: Vector3; var AV2: Vector3): Makes AV1 and AV2 normalized and orthogonal (Gram-Schmidt). C: Vector3OrthoNormalize Parameters: AV1 the first vector; AV2 the second vector.
  • const method Transform(const M: Matrix): Vector3: The point transformed by M. C: Vector3Transform Parameters: M the matrix. Returns: the point transformed by M
  • const method RotateBy(const Q: Quaternion): Vector3: The vector rotated by the quaternion Q. C: Vector3RotateByQuaternion Parameters: Q the rotation. Returns: the vector rotated by the quaternion Q
  • const method RotateBy(const AAxis: Vector3; const AAngle: float32): Vector3: The vector rotated AAngle radians about AAxis. C: Vector3RotateByAxisAngle Parameters: AAxis the axis; AAngle the angle. Returns: the vector rotated AAngle radians about AAxis
  • const method MoveTowards(const ATarget: Vector3; const AMaxDistance: float32): Vector3: The point moved toward ATarget by at most AMaxDistance. C: Vector3MoveTowards Parameters: ATarget the target; AMaxDistance the max distance. Returns: the point moved toward ATarget by at most AMaxDistance
  • const method Lerp(const B: Vector3; const T: float32): Vector3: The point T of the way to B. C: Vector3Lerp Parameters: B the other Vector3; T how far along, 0 to 1. Returns: the point T of the way to B
  • static method CubicHermite(const AV1: Vector3; const ATangent1: Vector3; const AV2: Vector3; const ATangent2: Vector3; const AAmount: float32): Vector3: The cubic Hermite point at AAmount between AV1 and AV2. C: Vector3CubicHermite Parameters: AV1 the first vector; ATangent1 the tangent1; AV2 the second vector; ATangent2 the tangent2; AAmount the amount. Returns: the cubic Hermite point at AAmount between AV1 and AV2
  • const method Reflect(const ANormal: Vector3): Vector3: The vector reflected off a surface of normal ANormal. C: Vector3Reflect Parameters: ANormal the normal. Returns: the vector reflected off a surface of normal ANormal
  • const method Refract(const ANormal: Vector3; const R: float32): Vector3: The (normalized) vector refracted through a surface of normal ANormal, R the ratio of the refractive indices. C: Vector3Refract Parameters: ANormal the normal; R the ratio of the refractive indices. Returns: the (normalized) vector refracted through a surface of normal ANormal, R the ratio of the refractive indices
  • const method Min(const B: Vector3): Vector3: Component-wise minimum with B. C: Vector3Min Parameters: B the other Vector3. Returns: the component-wise minimum with B
  • const method Max(const B: Vector3): Vector3: Component-wise maximum with B. C: Vector3Max Parameters: B the other Vector3. Returns: the component-wise maximum with B
  • const method Clamp(const ALo: Vector3; const AHi: Vector3): Vector3: Each component clamped between ALo's and AHi's. C: Vector3Clamp Parameters: ALo the lowest components; AHi the highest components. Returns: each component clamped between ALo's and AHi's
  • const method Clamp(const ALo: float32; const AHi: float32): Vector3: The vector with its length clamped between ALo and AHi. C: Vector3ClampValue Parameters: ALo the shortest length; AHi the longest length. Returns: the vector with its length clamped between ALo and AHi
  • static method Barycenter(const AP: Vector3; const AA: Vector3; const AB: Vector3; const AC: Vector3): Vector3: The barycentric coordinates (u, v, w) of AP in the triangle. C: Vector3Barycenter Parameters: AP the point; AA the first corner; AB the second corner; AC the third corner. Returns: the barycentric coordinates (u, v, w) of AP in the triangle
  • const method Unproject(const AProjection: Matrix; const AView: Matrix): Vector3: The point unprojected from normalized device space. C: Vector3Unproject Parameters: AProjection the projection matrix; AView the view matrix. Returns: the point unprojected from normalized device space
  • const 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 of ACam (the window's size). C: GetWorldToScreen Parameters: ACam the camera. Returns: the world point as a screen point of ACam (the window's size)
  • const method WorldToScreen(const ACam: Camera3D; const AWidth: int32; const AHeight: int32): Vector2: The world point as a point of a AWidth x AHeight view. C: GetWorldToScreenEx Parameters: ACam the camera; AWidth the width; AHeight the height. Returns: the world point as a point of a AWidth x AHeight view

extend Vector4

text
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: A the left operand; B the right operand. Returns: the component-wise sum
  • operator +(const A: Vector4; const S: float32): Vector4: S added to each component. C: Vector4AddValue Parameters: A the left operand; S the right operand. Returns: S added to each component
  • operator -(const A: Vector4; const B: Vector4): Vector4: Component-wise difference. C: Vector4Subtract Parameters: A the left operand; B the right operand. Returns: the component-wise difference
  • operator -(const A: Vector4; const S: float32): Vector4: S taken from each component. C: Vector4SubtractValue Parameters: A the left operand; S the right operand. Returns: S taken from each component
  • operator *(const A: Vector4; const B: Vector4): Vector4: Component-wise product (not the quaternion product: Product). C: Vector4Multiply Parameters: A the left operand; B the right operand. Returns: the component-wise product (not the quaternion product: Product)
  • operator *(const A: Vector4; const S: float32): Vector4: The vector scaled by S. C: Vector4Scale Parameters: A the left operand; S the right operand. Returns: the vector scaled by S
  • operator /(const A: Vector4; const B: Vector4): Vector4: Component-wise quotient. C: Vector4Divide Parameters: A the left operand; B the right operand. Returns: the component-wise quotient
  • operator /(const A: Vector4; const S: float32): Vector4: The vector divided by S. C: Vector4Scale by 1 / S Parameters: A the left operand; S the right operand. Returns: the vector divided by S
  • operator =(const A: Vector4; const B: Vector4): bool: True when equal within raymath's epsilon. C: Vector4Equals Parameters: A the left operand; B the right operand. Returns: true when equal within raymath's epsilon
  • operator <>(const A: Vector4; const B: Vector4): bool: True when they differ beyond raymath's epsilon. C: Vector4Equals Parameters: A the left operand; B the right operand. Returns: true when they differ beyond raymath's epsilon
  • const method Negate(): Vector4: The vector negated. C: Vector4Negate Returns: the vector negated
  • const method Invert(): Vector4: Each component's reciprocal. C: Vector4Invert Returns: each component's reciprocal
  • const method Length(): float32: The vector's length. C: Vector4Length Returns: the vector's length
  • const method LengthSqr(): float32: The squared length. C: Vector4LengthSqr Returns: the squared length
  • const method Normalize(): Vector4: The vector (or quaternion) at length 1. C: Vector4Normalize Returns: the vector (or quaternion) at length 1
  • const method Dot(const B: Vector4): float32: The dot product with B. C: Vector4DotProduct Parameters: B the other Vector4. Returns: the dot product with B
  • const method Distance(const B: Vector4): float32: The distance to B. C: Vector4Distance Parameters: B the other Vector4. Returns: the distance to B
  • const method DistanceSqr(const B: Vector4): float32: The squared distance to B. C: Vector4DistanceSqr Parameters: B the other Vector4. Returns: the squared distance to B
  • const method Min(const B: Vector4): Vector4: Component-wise minimum with B. C: Vector4Min Parameters: B the other Vector4. Returns: the component-wise minimum with B
  • const method Max(const B: Vector4): Vector4: Component-wise maximum with B. C: Vector4Max Parameters: B the other Vector4. Returns: the component-wise maximum with B
  • const method Lerp(const B: Vector4; const T: float32): Vector4: The point T of the way to B (component-wise; a quaternion's is Nlerp / Slerp). C: Vector4Lerp Parameters: B the other Vector4; T how far along, 0 to 1. Returns: the point T of the way to B (component-wise; a quaternion's is Nlerp / Slerp)
  • const method MoveTowards(const ATarget: Vector4; const AMaxDistance: float32): Vector4: The point moved toward ATarget by at most AMaxDistance. C: Vector4MoveTowards Parameters: ATarget the target; AMaxDistance the max distance. Returns: the point moved toward ATarget by at most AMaxDistance
  • const method Product(const B: Quaternion): Quaternion: The quaternion product (Hamilton) self x B. C: QuaternionMultiply Parameters: B the quaternion it is multiplied by. Returns: the quaternion product (Hamilton) self x B
  • const 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 interpolation T of the way to B. C: QuaternionNlerp Parameters: B the quaternion it turns towards; T how far along, 0 to 1. Returns: the normalized linear interpolation T of the way to B
  • const method Slerp(const B: Quaternion; const T: float32): Quaternion: The spherical linear interpolation T of the way to B. C: QuaternionSlerp Parameters: B the quaternion it turns towards; T how far along, 0 to 1. Returns: the spherical linear interpolation T of the way to B
  • static method CubicHermite(const AQ1: Quaternion; const AOutTangent1: Quaternion; const AQ2: Quaternion; const AInTangent2: Quaternion; const T: float32): Quaternion: The cubic Hermite spline point at T. C: QuaternionCubicHermiteSpline Parameters: AQ1 the first rotation; AOutTangent1 the out tangent1; AQ2 the second rotation; AInTangent2 the in tangent2; T how far along, 0 to 1. Returns: the cubic Hermite spline point at T
  • static method FromTo(const AFrom: Vector3; const ATo: Vector3): Quaternion: The rotation that turns AFrom onto ATo. C: QuaternionFromVector3ToVector3 Parameters: AFrom the direction turned from; ATo the direction turned onto. Returns: the rotation that turns AFrom onto ATo
  • static method FromMatrix(const M: Matrix): Quaternion: The rotation of a matrix. C: QuaternionFromMatrix Parameters: M the matrix. Returns: the rotation of a matrix
  • const method ToMatrix(): Matrix: The quaternion's rotation matrix. C: QuaternionToMatrix Returns: the quaternion's rotation matrix
  • static method FromAxisAngle(const AAxis: Vector3; const AAngle: float32): Quaternion: The rotation of AAngle radians about AAxis. C: QuaternionFromAxisAngle Parameters: AAxis the axis; AAngle the angle. Returns: the rotation of AAngle radians about AAxis
  • const method ToAxisAngle(var AAxis: Vector3; var AAngle: float32): The quaternion's rotation as an axis and an angle in radians. C: QuaternionToAxisAngle Parameters: AAxis set to the axis; AAngle set 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: APitch the pitch angle, in radians; AYaw the yaw; ARoll the roll. Returns: the rotation of the Euler angles in radians
  • const 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 by M. C: QuaternionTransform Parameters: M the matrix. Returns: the quaternion transformed by M

extend Matrix

text
extend Matrix

Members

  • static method Identity(): Matrix: The identity matrix. C: MatrixIdentity Returns: the identity matrix
  • static method Translate(const AX: float32; const AY: float32; const AZ: float32): Matrix: A translation. C: MatrixTranslate Parameters: AX the x coordinate; AY the y coordinate; AZ the z coordinate. Returns: a translation
  • static method Rotate(const AAxis: Vector3; const AAngle: float32): Matrix: A rotation of AAngle radians about AAxis. C: MatrixRotate Parameters: AAxis the axis; AAngle the angle. Returns: a rotation of AAngle radians about AAxis
  • static method RotateX(const AAngle: float32): Matrix: A rotation about x, radians. C: MatrixRotateX Parameters: AAngle the angle. Returns: a rotation about x, radians
  • static method RotateY(const AAngle: float32): Matrix: A rotation about y, radians. C: MatrixRotateY Parameters: AAngle the angle. Returns: a rotation about y, radians
  • static method RotateZ(const AAngle: float32): Matrix: A rotation about z, radians. C: MatrixRotateZ Parameters: AAngle the angle. Returns: a rotation about z, radians
  • static method RotateXYZ(const AAngles: Vector3): Matrix: The rotations about x, y then z, radians. C: MatrixRotateXYZ Parameters: AAngles the angles. Returns: the rotations about x, y then z, radians
  • static method RotateZYX(const AAngles: Vector3): Matrix: The rotations about z, y then x, radians. C: MatrixRotateZYX Parameters: AAngles the angles. Returns: the rotations about z, y then x, radians
  • static method Scale(const AX: float32; const AY: float32; const AZ: float32): Matrix: A scaling. C: MatrixScale Parameters: AX the x coordinate; AY the y coordinate; AZ the z coordinate. Returns: a scaling
  • static 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: ALeft the left of the view volume; ARight the right of the view volume; ABottom the bottom of the view volume; ATop the top of the view volume; ANear the near clip distance; AFar the far clip distance. Returns: a perspective frustum
  • static method Perspective(const AFovY: float64; const AAspect: float64; const ANear: float64; const AFar: float64): Matrix: A perspective projection, AFovY in radians. C: MatrixPerspective Parameters: AFovY the fov Y; AAspect the aspect; ANear the near clip distance; AFar the far clip distance. Returns: a perspective projection, AFovY in radians
  • static 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: ALeft the left of the view volume; ARight the right of the view volume; ABottom the bottom of the view volume; ATop the top of the view volume; ANear the near clip distance; AFar the far clip distance. Returns: an orthographic projection
  • static method LookAt(const AEye: Vector3; const ATarget: Vector3; const AUp: Vector3): Matrix: A view matrix from AEye looking at ATarget. C: MatrixLookAt Parameters: AEye the eye position; ATarget the target; AUp the up direction. Returns: a view matrix from AEye looking at ATarget
  • static 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: AT the translation; AR the rotation; AS the scale. Returns: the transform of a translation, a rotation and a scale
  • operator +(const A: Matrix; const B: Matrix): Matrix: Element-wise sum. C: MatrixAdd Parameters: A the left operand; B the right operand. Returns: element-wise sum
  • operator -(const A: Matrix; const B: Matrix): Matrix: Element-wise difference. C: MatrixSubtract Parameters: A the left operand; B the right operand. Returns: element-wise difference
  • operator *(const A: Matrix; const B: Matrix): Matrix: The matrix product: A applied first, then B (raymath's order). C: MatrixMultiply Parameters: A the left operand; B the right operand. Returns: the matrix product: A applied first, then B (raymath's order)
  • operator *(const A: Matrix; const S: float32): Matrix: Each element scaled by S. C: MatrixMultiplyValue Parameters: A the left operand; S the right operand. Returns: each element scaled by S
  • const method Determinant(): float32: The determinant. C: MatrixDeterminant Returns: the determinant
  • const 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 transpose
  • const method Invert(): Matrix: The inverse. C: MatrixInvert Returns: the inverse
  • const method Decompose(var AT: Vector3; var AR: Quaternion; var AS: Vector3): The matrix as a translation, a rotation and a scale. C: MatrixDecompose Parameters: AT receives the translation; AR receives the rotation; AS receives 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

text
extend Color

Members

  • static method Hex(const AHex: string; const ADefault: Color): Color: The colour web pages and Raven themes write: #RGB, #RGBA, #RRGGBB or #RRGGBBAA (the # optional, digits in either case; no alpha is opaque). Parameters: AHex the colour's text; ADefault returned when AHex is none of those forms. Returns: the colour, or ADefault
  • static method FromInt(const AHex: uint32): Color: The colour of a 0xRRGGBBAA value. C: GetColor Parameters: AHex the hex. Returns: the colour of a 0xRRGGBBAA value
  • const method ToInt(): int32: The colour as 0xRRGGBBAA. C: ColorToInt Returns: the colour as 0xRRGGBBAA
  • static 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: AH the hue, in degrees (0 to 360); AS the saturation, 0 to 1; AV the 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: AN the colour as (r, g, b, a), each 0 to 1. Returns: the colour of components 0..1
  • const method Normalized(): Vector4: The colour's components 0..1. C: ColorNormalize Returns: the colour's components 0..1
  • operator =(const A: Color; const B: Color): bool: True when every component is equal. C: ColorIsEqual Parameters: A the left operand; B the right operand. Returns: true when every component is equal
  • operator <>(const A: Color; const B: Color): bool: True when any component differs. C: ColorIsEqual Parameters: A the left operand; B the right operand. Returns: true when any component differs
  • const method Fade(const AAlpha: float32): Color: The colour with its alpha times AAlpha (0..1). C: Fade Parameters: AAlpha the alpha. Returns: the colour with its alpha times AAlpha (0..1)
  • const method Alpha(const AAlpha: float32): Color: The colour with its alpha set to AAlpha (0..1). C: ColorAlpha Parameters: AAlpha the alpha. Returns: the colour with its alpha set to AAlpha (0..1)
  • const method Tint(const ATint: Color): Color: The colour multiplied by ATint. C: ColorTint Parameters: ATint the tint colour. Returns: the colour multiplied by ATint
  • const method Brightness(const AFactor: float32): Color: The colour brightened (> 0) or darkened (< 0) by AFactor (-1..1). C: ColorBrightness Parameters: AFactor the factor. Returns: the colour brightened (> 0) or darkened (< 0) by AFactor (-1..1)
  • const method Contrast(const AContrast: float32): Color: The colour's contrast changed by AContrast (-1..1). C: ColorContrast Parameters: AContrast the contrast. Returns: the colour's contrast changed by AContrast (-1..1)
  • const method Lerp(const B: Color; const T: float32): Color: The colour T of the way to B. C: ColorLerp Parameters: B the other Color; T how far along, 0 to 1. Returns: the colour T of the way to B
  • const method AlphaBlend(const ASrc: Color; const ATint: Color): Color: ASrc tinted by ATint blended over this colour. C: ColorAlphaBlend Parameters: ASrc the src; ATint the tint colour. Returns: ASrc tinted by ATint blended over this colour
  • static method FromPixel(const AP: ptr to const; const AFormat: Pixel): Color: The colour of one pixel in format AFormat at AP. C: GetPixelColor Parameters: AP where the pixel is read; AFormat the pixel format. Returns: the colour of one pixel in format AFormat at AP
  • const method ToPixel(const AP: ptr; const AFormat: Pixel): Writes the colour as one pixel in format AFormat at AP. C: SetPixelColor Parameters: AP where the pixel is written; AFormat the pixel format.
  • static method PixelDataSize(const AWidth: int32; const AHeight: int32; const AFormat: Pixel): int32: The bytes of a AWidth x AHeight image in format AFormat. C: GetPixelDataSize Parameters: AWidth the width; AHeight the height; AFormat the pixel format. Returns: the bytes of a AWidth x AHeight image in format AFormat

extend Rectangle

text
extend Rectangle

Members

  • const method Overlaps(const B: Rectangle): bool: True when the rectangles overlap. C: CheckCollisionRecs Parameters: B the other Rectangle. Returns: true when the rectangles overlap
  • const method Overlap(const B: Rectangle): Rectangle: The rectangle where both overlap (empty when they do not). C: GetCollisionRec Parameters: B the other Rectangle. 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: ACenter the centre; ARadius the radius. Returns: true when the circle overlaps the rectangle
  • const method Contains(const AP: Vector2): bool: True when AP is inside. C: CheckCollisionPointRec Parameters: AP the point. Returns: true when AP is inside
  • const method Position(): Vector2: The top-left corner. Returns: the top-left corner
  • const method Size(): Vector2: The width and height. Returns: the width and height
  • const method Center(): Vector2: The centre point. Returns: the centre point
  • const method Moved(const AD: Vector2): Rectangle: The rectangle moved by AD. Parameters: AD the offset. Returns: the rectangle moved by AD
  • const method Grown(const AD: float32): Rectangle: The rectangle grown by AD on every side (shrunk when AD < 0). Parameters: AD how much on each side. Returns: the rectangle grown by AD on every side (shrunk when AD < 0)

extend Ray

text
extend Ray

Members

  • const method HitSphere(const ACenter: Vector3; const ARadius: float32): RayCollision: Where the ray hits the sphere. C: GetRayCollisionSphere Parameters: ACenter the centre; ARadius the radius. Returns: where the ray hits the sphere
  • const method HitBox(const ABox: BoundingBox): RayCollision: Where the ray hits the box. C: GetRayCollisionBox Parameters: ABox the box. Returns: where the ray hits the box
  • const method HitTriangle(const AP1: Vector3; const AP2: Vector3; const AP3: Vector3): RayCollision: Where the ray hits the triangle. C: GetRayCollisionTriangle Parameters: AP1 the first point; AP2 the second point; AP3 the third point. Returns: where the ray hits the triangle
  • const method HitQuad(const AP1: Vector3; const AP2: Vector3; const AP3: Vector3; const AP4: Vector3): RayCollision: Where the ray hits the quad. C: GetRayCollisionQuad Parameters: AP1 the first point; AP2 the second point; AP3 the third point; AP4 the fourth point. Returns: where the ray hits the quad
  • const method HitMesh(const AMesh: MeshRes; const ATransform: Matrix): RayCollision: Where the ray meets AMesh placed by ATransform (its vertex data). C: GetRayCollisionMesh Parameters: AMesh the mesh; ATransform the transform. Returns: where the ray meets AMesh placed by ATransform (its vertex data)

extend BoundingBox

text
extend BoundingBox

Members

  • const method Overlaps(const B: BoundingBox): bool: True when the boxes overlap. C: CheckCollisionBoxes Parameters: B the other BoundingBox. Returns: true when the boxes overlap
  • const method OverlapsSphere(const ACenter: Vector3; const ARadius: float32): bool: True when the sphere overlaps the box. C: CheckCollisionBoxSphere Parameters: ACenter the centre; ARadius the radius. Returns: true when the sphere overlaps the box
  • static method SpheresOverlap(const AC1: Vector3; const AR1: float32; const AC2: Vector3; const AR2: float32): bool: True when the two spheres overlap. C: CheckCollisionSpheres Parameters: AC1 the first sphere's centre; AR1 the first sphere's radius; AC2 the second sphere's centre; AR2 the second sphere's radius. Returns: true when the two spheres overlap

extend Camera2D

text
extend Camera2D

Members

  • static method Make(const ATarget: Vector2; const AOffset: Vector2; const ARotation: float32; const AZoom: float32): Camera2D: A camera looking at ATarget, shown at AOffset of the screen. Parameters: ATarget the target; AOffset the offset; ARotation the rotation; AZoom the zoom. Returns: a camera looking at ATarget, shown at AOffset of the screen
  • const method Matrix(): Matrix: The camera's view matrix. C: GetCameraMatrix2D Returns: the camera's view matrix
  • const method Begin(): Starts drawing through this camera inside the frame. C: BeginMode2D, letterboxed
  • static method End(): Ends the camera's drawing. C: EndMode2D

extend Camera3D

text
extend Camera3D

Members

  • static method Make(const APosition: Vector3; const ATarget: Vector3; const AUp: Vector3; const AFovY: float32; const AProjection: Projection): Camera3D: A camera at APosition looking at ATarget, AFovY in degrees. Parameters: APosition the position; ATarget the target; AUp the up direction; AFovY the fov Y; AProjection the projection. Returns: a camera at APosition looking at ATarget, AFovY in degrees
  • const method Matrix(): Matrix: The camera's view matrix. C: GetCameraMatrix Returns: the camera's view matrix
  • method Update(const AStyle: CameraStyle): Moves the camera by raylib's built-in controls for AStyle. C: UpdateCamera Parameters: AStyle the 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: AMovement the movement; ARotation the rotation; AZoom the zoom.
  • const method Begin(): Starts drawing through this camera inside the frame. C: BeginMode3D, letterboxed
  • static method End(): Ends the camera's drawing. C: EndMode3D

extend AutomationEvent

text
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

text
extend ImageRes

Members

  • static method FromTexture(const ATexture: TextureRes): ImageRes: ATexture's pixels as a new image. C: LoadImageFromTexture Parameters: ATexture the texture. Returns: ATexture's pixels as a new image
  • static method FromText(const AWidth: int32; const AHeight: int32; const AText: string): ImageRes: An image AWidth x AHeight holding AText (raylib's test pattern). C: GenImageText Parameters: AWidth the width; AHeight the height; AText the text. Returns: an image AWidth x AHeight holding AText (raylib's test pattern)
  • static method FromText(const AText: string; const ASize: int32; const AColor: Color): ImageRes: An image of AText in raylib's default font at ASize. C: ImageText Parameters: AText the text; ASize the size; AColor the colour. Returns: an image of AText in raylib's default font at ASize
  • static method FromText(const AFont: FontRes; const AText: string; const ASize: float32; const ASpacing: float32; const ATint: Color): ImageRes: An image of AText in AFont at ASize, ASpacing between glyphs. C: ImageTextEx Parameters: AFont the font; AText the text; ASize the size; ASpacing the spacing; ATint the tint colour. Returns: an image of AText in AFont at ASize, ASpacing between glyphs
  • method Text(const AText: string; const APos: Vector2; const ASize: int32; const AColor: Color): ImageRes: AText in raylib's default font at ASize pixels. C: ImageDrawText Parameters: AText the text; APos the position; ASize the size; AColor the colour. Returns: AText in raylib's default font at ASize pixels
  • method Text(const AFont: FontRes; const AText: string; const APos: Vector2; const ASize: float32; const ASpacing: float32; const ATint: Color): ImageRes: AText in AFont at ASize, ASpacing between glyphs. C: ImageDrawTextEx Parameters: AFont the font; AText the text; APos the position; ASize the size; ASpacing the spacing; ATint the tint colour. Returns: AText in AFont at ASize, ASpacing between glyphs
  • 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): ImageRes: AText in AFont turned ARotation degrees about AOrigin. C: ImageDrawTextPro Parameters: AFont the font; AText the text; APos the position; AOrigin the origin; ARotation the rotation; ASize the size; ASpacing the spacing; ATint the tint colour. Returns: AText in AFont turned ARotation degrees about AOrigin
  • const 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 as ALayout, as a cubemap. C: LoadTextureCubemap Parameters: ALayout the layout. Returns: the image's six faces, laid out as ALayout, as a cubemap

extend WaveRes

text
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

text
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

NameDeclarationDescription
ADAM_RAYLIB_DPI_CHECK_SECONDSconst ADAM_RAYLIB_DPI_CHECK_SECONDS: float64 = 1.0How often the frame asks the DPI again, in seconds: once a second.

Routines

dlsym

text
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

text
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

text
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

text
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

text
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

NameDeclarationDescription
ADAM_RAYLIB_DPI_CHECK_SECONDSconst ADAM_RAYLIB_DPI_CHECK_SECONDS: float64 = 0.0How often the frame asks the DPI again, in seconds: each frame.

Routines

RaylibPlatformSetWindowGone

text
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

text
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

text
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

text
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 style
  • AClassName: the window class's name
  • AWindowName: the window's title
  • AStyle: the window style
  • AX: the x position
  • AY: the y position
  • AWidth: the width
  • AHeight: the height
  • AParent: the parent or owner window
  • AMenu: the menu or child id
  • AInstance: the module instance
  • AParam: the creation parameter

Returns: the new window (nil on a failure)

DestroyWindow

text
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

text
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

NameDeclarationDescription
ADAM_RESDATA_COMPILER_PREFIXconst 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_KEYconst ADAM_RESDATA_EXEICON_KEY: string = "adam/exeicon"The key @exeicon's image is stored under.
ADAM_RESDATA_EXEICON_HEADERconst ADAM_RESDATA_EXEICON_HEADER: int64 = 8The bytes before the @exeicon entry's pixels.

Routines

ResDataCount

text
func cpplink ResDataCount(): int64

How many @addresdata keys this binary holds.

Returns: the key count (a key two tables hold counted once)

ResDataKey

text
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

text
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

text
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

text
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 held
  • const method HasPublic(): bool: The key can verify (its public key is held). Returns: a public key is held
  • const 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 form minisign -P takes. 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: AText the line. Returns: false (the key cleared) when the text is no minisign public key
  • const method SavePublicKey(const APath: string): bool: Writes the public key file (minisign's: an untrusted comment line, the Base64 line). Parameters: APath the file (e.g. release.pub). Returns: false when no public key is held or the file cannot be written
  • method LoadPublicKey(const APath: string): bool: Reads a public key file (minisign's form). Parameters: APath the file. Returns: false (the key cleared) when it cannot be read or holds no public key
  • const 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: APath the file (e.g. release.key). Returns: false when no secret is held or the file cannot be written
  • method LoadSecretKey(const APath: string): bool: Reads a secret key file (SaveSecretKey's form, StdApp's packer's too): both halves. Parameters: APath the file. Returns: false (the key cleared) when it cannot be read, is no such key, or its public half is not its seed's
  • const method SignFile(const APath: string; const ATrustedComment: string; const AUntrustedComment: string): bool: Signs a file: writes <APath>.minisig in 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: APath the file signed; ATrustedComment the signed comment ("" gives file:<name> and hashed, tab apart); AUntrustedComment the unsigned first line ("" gives minisign's own wording). Returns: false when no secret is held, or the file cannot be read or the signature written
  • const method VerifyFile(const APath: string; const ASignaturePath: string): bool: Checks a file against its minisign signature (prehashed ED, or the legacy Ed form 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: APath the file; ASignaturePath its 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

text
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. from SecureRandomBytes(32, LSeed))

Returns: the 32-byte public key; empty when the seed is not 32 bytes

Example: LPublic := Ed25519PublicKey(LSeed);

Ed25519Sign

text
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

text
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 signed
  • ASignature: the 64-byte signature
  • APublicKey: 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

text
type StringArray = array of string

A list of names or arguments.

ByteArray

text
type ByteArray = array of uint8

A list of bytes (a file's contents, an object's image).

Int64Array

text
type Int64Array = array of int64

A list of 64-bit integers (ids, offsets, per-id maps).

BoolArray

text
type BoolArray = array of bool

A list of flags (a set over ids).

CodepointArray

text
type CodepointArray = array of uint32

Unicode code points, one a character (StringToCodepoints / StringFromCodepoints)

CString

text
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 CString points at the same text, which lives until the last copy ends.
  • Ptr is never nil: an empty text is an empty C string.

Members

  • init(): An empty C string (Ptr is the empty C string, never nil)
  • init(const AText: string): A C string of AText Parameters: AText the text.
  • property Text: string read FText: The text, as an Adam string
  • property Ptr: ptr to const char read: The text as a C string, valid while this CString (or a copy) lives
  • property OrNil: ptr to const char read: Ptr, or nil when the text is "": for a C parameter where NULL means "none" (a password, a prefix, an optional id), valid while this CString (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

text
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 (Ptr points at its one nil)
  • init(const ATexts: StringArray): A list of ATexts, in order Parameters: ATexts the texts.
  • method Add(const AText: string): AText added at the end Parameters: AText the text.
  • property Count: int64 read: How many texts it holds (the nil after them not counted)
  • property Item[const AIndex: int64]: ptr to const char read: Text AIndex (0-based) as a C string
  • property Ptr: ptr to const ptr to const char read: The C strings, then nil: C's const 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

NameDeclarationDescription
ADAM_SYSUTILS_REPLACEMENTconst ADAM_SYSUTILS_REPLACEMENT: uint32 = 0xFFFDThe code point a malformed UTF-8 sequence or a lone UTF-16 surrogate becomes.
ADAM_SYSUTILS_FNV_OFFSETconst ADAM_SYSUTILS_FNV_OFFSET: uint64 = 0xCBF29CE484222325FNV-1a 64's offset basis (Fnv1a64).
ADAM_SYSUTILS_FNV_PRIMEconst ADAM_SYSUTILS_FNV_PRIME: uint64 = 0x100000001B3FNV-1a 64's prime (Fnv1a64).
Kilobyteconst Kilobyte: int64 = 1024The bytes in a kilobyte (1024, binary): 4 * Kilobyte is 4096.
Megabyteconst Megabyte: int64 = 1024 * 1024The bytes in a megabyte (1024 x 1024, binary).
Gigabyteconst Gigabyte: int64 = 1024 * 1024 * 1024The bytes in a gigabyte (1024 x 1024 x 1024, binary).

Routines

DecodeUTF8Char

text
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 text
  • AIndex: the byte index of the sequence; moved past it

Returns: the code point

EncodeUTF8Char

text
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 written
  • ACode: the code point

EncodeUTF8Bytes

text
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 written
  • ACode: the code point

StringToCodepoints

text
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

text
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

text
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

text
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 text
  • AIndex: a byte offset above 0 and at most len(AText); moved back

Returns: the code point before it

Example: LAt := len(LText); LLast := DecodeUTF8CharBefore(LText, LAt);

WholeUTF8Length

text
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

text
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

text
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

text
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 written
  • ACode: the code point

StringOfChar

text
func cpplink StringOfChar(const AChar: char; const ACount: int64): string

ACount copies of AChar ("" when ACount is 0 or less).

Parameters

  • AChar: the character
  • ACount: how many copies

Returns: the text

StringFromC

text
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

text
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

text
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

text
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 char parameter is borrowed for the call (BNF sec 6);
  • a ptr to const char field of a trackable record keeps its text with the variable;
  • CString / CStringArray keep 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

text
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 text
  • AFrom: the first byte, from 0
  • ACount: how many bytes

Returns: the part

Trim

text
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

text
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

text
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

text
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 cut
  • ADelimiters: the bytes that cut it, any of them

Returns: the parts, in order

StartsStr

text
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 for
  • AText: the text

Returns: true when AText starts with it

StartsText

text
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 for
  • AText: the text

Returns: true when AText starts with it, ASCII case aside

EndsStr

text
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 for
  • AText: the text

Returns: true when AText ends with it

LowerCase

text
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

text
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 strings
  • ASeparator: the text put between each two
  • AFirst: the first index joined
  • ACount: how many are joined

Returns: the joined text

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 strings
  • ASeparator: the text put between each two

Returns: the joined text

IndexStr

text
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 find
  • AValues: the strings to search

Returns: its index, or -1

UpperCase

text
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

text
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 find
  • AText: the text searched
  • AFrom: the byte offset the search starts at

Returns: the byte offset found, or -1

NormalizePath

text
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

text
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 read
  • AValue: receives the number (unchanged on failure)

Returns: true when AText is exactly a decimal int64

StrToIntDef

text
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 read
  • ADefault: the value when it is not a number

Returns: the number, or ADefault

MatchesGlob

text
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 text
  • AMask: the mask, with * and ?

Returns: true when it matches

ReplaceStr

text
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 text
  • AFromText: what to replace
  • AToText: what goes in its place

Returns: the new text

Example: LUnix := ReplaceStr(LText, "\r\n", "\n");

MatchesPathGlob

text
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

text
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

text
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

text
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

text
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 text
  • ABegin: the marker the slot starts after
  • AEnd: the marker the slot ends before
  • AReplacement: what goes in the slot

Returns: the new text

Example: ReplaceBetween("<b>old</b>", "<b>", "</b>", "new") is "<b>new</b>"

Between

text
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 text
  • ABegin: the marker the slot starts after
  • AEnd: the marker the slot ends before

Returns: the slot's text

Example: Between("<b>hi</b>", "<b>", "</b>") is "hi"

SortStrings

text
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

text
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

text
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

text
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 path
  • AExt: the new extension, with its dot (or "" to drop it)

Returns: the changed path

ExtractFileExt

text
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

text
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

text
func cpplink UIntToStr(const AValue: uint64): string

AValue in decimal.

Parameters

  • AValue: the number

Returns: its decimal text

IntToHex

text
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 number
  • AMinDigits: the fewest digits written

Returns: its hex text

TryHexToRGBA

text
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

text
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 colour
  • AAlpha: true to write the alpha too

Returns: the text

Example: RGBAToHex(0x3A7BD5FF, false) is "#3A7BD5"

IntToStr

text
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

text
func cpplink BoolToStr(const AValue: bool): string

"true" or "false", as println prints a bool.

Parameters

  • AValue: the bool

Returns: "true" or "false"

Float64ToBits

text
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

text
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

text
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

text
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

text
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

text
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 text
  • AValue: receives the value (0 on failure)

Returns: true when AText is a float literal

TryStrToFloat32

text
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 text
  • AValue: receives the float32 value (0 on failure)

Returns: true when AText is a float literal

PutLe

text
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 into
  • AAt: the index of the first byte
  • AValue: the number
  • ACount: how many of its bytes, 1..8

GetLe

text
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 bytes
  • AAt: the index of the first byte
  • ACount: how many bytes, 1..8

Returns: the number

ReadLowBits

text
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 value
  • AWidth: how many low bits, 1..64
  • ASigned: true to read them as two's complement

Returns: the integer they are

BitMask

text
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..64
  • AAt: the lowest bit set

Returns: the mask

AlignUp

text
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 value
  • AAlign: the alignment, a power of two

Returns: the rounded value

Fnv1a64

text
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

text
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

text
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

text
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

text
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

text
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

text
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: ALine the line (0: not known); ACol the column (0: not known); AText the message. Returns: false, always (what a failing getter returns)
  • method ParseText(const AText: string; const ASourceName: string): bool: Parses TOML text. Parameters: AText the TOML text; ASourceName the name errors are placed at ("" for <text>). Returns: false with ErrorText when it is no valid TOML
  • method ParseFile(const APath: string): bool: Reads and parses a TOML file, its path naming it in errors. Parameters: APath the file (relative to the working folder). Returns: false with ErrorText when it cannot be read or is no valid TOML
  • const method ErrorText(): string: The last failure, in file(line,col): message form. Returns: the reason, or "" after a success
  • const method IsParsed(): bool: Whether the last parse succeeded. Returns: true when it did
  • method 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: APath the path (keys joined by ., an item as [N]; "" the top table); ADatum receives the value. Returns: false with ErrorText (at the value it is about) on a failure
  • const method Has(const APath: string): bool: Whether a path names a value (no error recorded either way). Parameters: APath the path (keys joined by ., an item as [N]; "" the top table). Returns: true when it does
  • const method KindOf(const APath: string): TOMLKind: The kind of the value a path names (no error recorded). Parameters: APath the path (keys joined by ., an item as [N]; "" the top table). Returns: the kind; Missing when it names none
  • method GetString(const APath: string; var AValue: string): bool: Reads the string a path names. Parameters: APath the path (keys joined by ., an item as [N]; "" the top table); AValue receives the string. Returns: false with ErrorText (at the value it is about) on a failure
  • method GetInt64(const APath: string; var AValue: int64): bool: Reads the integer a path names. Parameters: APath the path (keys joined by ., an item as [N]; "" the top table); AValue receives the integer. Returns: false with ErrorText (at the value it is about) on a failure
  • method 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: APath the path (keys joined by ., an item as [N]; "" the top table); AValue receives the float. Returns: false with ErrorText (at the value it is about) on a failure
  • method GetBool(const APath: string; var AValue: bool): bool: Reads the boolean a path names. Parameters: APath the path (keys joined by ., an item as [N]; "" the top table); AValue receives the boolean. Returns: false with ErrorText (at the value it is about) on a failure
  • method GetDateTime(const APath: string; var AValue: TOMLDateTime): bool: Reads the date / time a path names (any of the four kinds). Parameters: APath the path (keys joined by ., an item as [N]; "" the top table); AValue receives its parts. Returns: false with ErrorText (at the value it is about) on a failure
  • method Count(const APath: string; var ACount: int64): bool: How many items the array, or keys the table, a path names holds. Parameters: APath the path (keys joined by ., an item as [N]; "" the top table); ACount receives the count. Returns: false with ErrorText (at the value it is about) on a failure
  • method 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 at APath + "." + TOMLQuoteKey(AKey). Parameters: APath the path (keys joined by ., an item as [N]; "" the top table); AIndex the key's place (0-based); AKey receives 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

text
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

text
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

text
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; image embeds the file as a data URI.
  • TextKind.Markdown: Markdown's marks get a backslash; image writes ![alt](src).
  • TextKind.Text: Nothing is escaped; image writes its alt text.

TemplateArgs

text
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: AKind the template's kind of text; AFolder the 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: AValue the argument.
  • method Add(const AName: string; const AValue: JSON): Adds a named argument (one already of that name is replaced). Parameters: AName the name; AValue the argument.
  • const method Count(): int64: How many positional arguments there are. Returns: the count
  • const method Get(const AIndex: int64): JSON: A positional argument. Parameters: AIndex its index, from 0. Returns: its value; null when there is no such argument
  • const method Has(const AName: string): bool: Whether a named argument was given. Parameters: AName the name. Returns: true when it was
  • const method Get(const AName: string): JSON: A named argument. Parameters: AName the name. Returns: its value; null when it was not given
  • const method Text(const AIndex: int64): string: A positional argument's text (a string as itself, a number as written, null as ""). Parameters: AIndex its index, from 0. Returns: the text; "" when there is no such argument
  • const method Text(const AName: string; const AFallback: string): string: A named argument's text (a string as itself, a number as written). Parameters: AName the name; AFallback the text when it was not given (or is null). Returns: the text, or AFallback
  • const method Kind(): TextKind: The kind of text the template writes (what a helper's own output must be). Returns: the kind
  • const 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

text
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

text
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

text
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: AText the template; AKind the 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: APath the 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: AIO the IO, read to its end; AKind the 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 well
  • const method Kind(): TextKind: The kind of text the template writes. Returns: the kind
  • method 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: AName the name the tags use; AHelper the routine. Returns: the template, for chaining
  • method 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: AName the name the tags use; AFilter the routine. Returns: the template, for chaining
  • method Render(const AData: JSON): string: The template filled from data. Parameters: AData the 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: AData the data; APath the 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: AData the data; AIO the 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

text
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 entities
  • Markdown: \ ` * _ [ ] < > | # get a backslash
  • Text: unchanged

Parameters

  • AText: the text
  • AKind: the kind of text it goes into

Returns: the escaped text

Example: EscapeText("a < b", TextKind.HTML) gives a &lt; 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

text
type WideBuffer = array[0..32767] of uint16

A NUL-terminated UTF-16 text as Win32 reads and writes it

WideBox

text
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

text
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: ACols the columns; ARows the lines. Returns: 0, else Windows' reason
  • method IsOpen(): bool: Made and not yet closed Returns: true while open
  • method Output(): uint64: The output pipe's read end (0 when not open): read with WinReadAvailable / WinReadSome Returns: the read end, or 0
  • method 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: AStdin the one handle the program inherits, or 0. Returns: the list, or nil
  • method 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: AText the keys, UTF-8. Returns: false when not open or the pipe is gone
  • method 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: ACols the columns; ARows the lines. Returns: false when not open or refused
  • method 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: ATail gets its last output appended.
  • done: One still open at the end is closed (its last output dropped)

Constants

NameDeclarationDescription
ADAM_WINDOWS_WIDE_MAXconst ADAM_WINDOWS_WIDE_MAX: int32 = 32767The UTF-16 units a Win32 path or command line holds, its NUL not counted
ADAM_WINDOWS_SHORT_PATH_MAXconst ADAM_WINDOWS_SHORT_PATH_MAX: int64 = 247The 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_DATAconst ADAM_WINDOWS_ENV_LOCAL_APP_DATA: string = "LOCALAPPDATA"The environment variable naming this user's local (not roaming) application data folder
ADAM_WINDOWS_IO_SIZEconst ADAM_WINDOWS_IO_SIZE: uint32 = 4096The bytes one pipe read takes (WinReadAvailable's reads).
ADAM_WINDOWS_REPLACE_TRIESconst ADAM_WINDOWS_REPLACE_TRIES: int32 = 10The 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_MSconst ADAM_WINDOWS_REPLACE_WAIT_MS: int32 = 10WinReplaceFile's first wait between tries, in milliseconds: each wait doubles, up to ADAM_WINDOWS_REPLACE_WAIT_MAX_MS
ADAM_WINDOWS_REPLACE_WAIT_MAX_MSconst ADAM_WINDOWS_REPLACE_WAIT_MAX_MS: int32 = 160WinReplaceFile's longest wait between tries, in milliseconds
ADAM_WINDOWS_CPU_KEYconst 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_VALUEconst ADAM_WINDOWS_CPU_NAME_VALUE: wstring = "ProcessorNameString"The value of ADAM_WINDOWS_CPU_KEY that names the processor (its brand string)

Routines

GetLastError

text
func clink GetLastError(): uint32

Windows' GetLastError.

Returns: as Windows' GetLastError returns it

GetStdHandle

text
func clink GetStdHandle(AStdHandle: uint32): uint64

Windows' GetStdHandle.

Parameters

  • AStdHandle: as Windows' GetStdHandle takes it

Returns: as Windows' GetStdHandle returns it

GetConsoleMode

text
func clink GetConsoleMode(AConsole: uint64; var AMode: uint32): int32

Windows' GetConsoleMode.

Parameters

  • AConsole: as Windows' GetConsoleMode takes it
  • AMode: as Windows' GetConsoleMode takes it

Returns: as Windows' GetConsoleMode returns it

GetModuleHandleW

text
func clink GetModuleHandleW(AModuleName: ptr to const uint16): uint64

Windows' GetModuleHandleW.

Parameters

  • AModuleName: as Windows' GetModuleHandleW takes it

Returns: as Windows' GetModuleHandleW returns it

LoadIconW

text
func clink LoadIconW(AInstance: uint64; AIconName: ptr to const uint16): uint64

Windows' LoadIconW.

Parameters

  • AInstance: as Windows' LoadIconW takes it
  • AIconName: as Windows' LoadIconW takes it

Returns: as Windows' LoadIconW returns it

SendMessageW

text
func clink SendMessageW(AWindow: uint64; AMsg: uint32; AWParam: uint64; ALParam: int64): int64

Windows' SendMessageW.

Parameters

  • AWindow: as Windows' SendMessageW takes it
  • AMsg: as Windows' SendMessageW takes it
  • AWParam: as Windows' SendMessageW takes it
  • ALParam: as Windows' SendMessageW takes it

Returns: as Windows' SendMessageW returns it

LoadImageW

text
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' LoadImageW takes it
  • AName: as Windows' LoadImageW takes it
  • AType: as Windows' LoadImageW takes it
  • ACx: as Windows' LoadImageW takes it
  • ACy: as Windows' LoadImageW takes it
  • ALoad: as Windows' LoadImageW takes it

Returns: as Windows' LoadImageW returns it

DestroyIcon

text
func clink DestroyIcon(AIcon: uint64): int32

Windows' DestroyIcon.

Parameters

  • AIcon: as Windows' DestroyIcon takes it

Returns: as Windows' DestroyIcon returns it

GetSystemMetrics

text
func clink GetSystemMetrics(AIndex: int32): int32

Windows' GetSystemMetrics.

Parameters

  • AIndex: as Windows' GetSystemMetrics takes it

Returns: as Windows' GetSystemMetrics returns it

SetTimer

text
func clink SetTimer(AWindow: uint64; AIdEvent: uint64; AElapse: uint32; ATimerFunc: TIMERPROC): uint64

Windows' SetTimer.

Parameters

  • AWindow: as Windows' SetTimer takes it
  • AIdEvent: as Windows' SetTimer takes it
  • AElapse: as Windows' SetTimer takes it
  • ATimerFunc: as Windows' SetTimer takes it

Returns: as Windows' SetTimer returns it

KillTimer

text
func clink KillTimer(AWindow: uint64; AIdEvent: uint64): int32

Windows' KillTimer.

Parameters

  • AWindow: as Windows' KillTimer takes it
  • AIdEvent: as Windows' KillTimer takes it

Returns: as Windows' KillTimer returns it

GetTickCount64

text
func clink GetTickCount64(): uint64

Windows' GetTickCount64.

Returns: as Windows' GetTickCount64 returns it

GetSystemTimeAsFileTime

text
func clink GetSystemTimeAsFileTime(var ASystemTimeAsFileTime: FILETIME)

Windows' GetSystemTimeAsFileTime.

Parameters

  • ASystemTimeAsFileTime: as Windows' GetSystemTimeAsFileTime takes it

CreatePipe

text
func clink CreatePipe(var ARead: uint64; var AWrite: uint64; var AAttributes: SECURITY_ATTRIBUTES; ASize: uint32): int32

Windows' CreatePipe.

Parameters

  • ARead: as Windows' CreatePipe takes it
  • AWrite: as Windows' CreatePipe takes it
  • AAttributes: as Windows' CreatePipe takes it
  • ASize: as Windows' CreatePipe takes it

Returns: as Windows' CreatePipe returns it

SetHandleInformation

text
func clink SetHandleInformation(AHandle: uint64; AMask: uint32; AFlags: uint32): int32

Windows' SetHandleInformation.

Parameters

  • AHandle: as Windows' SetHandleInformation takes it
  • AMask: as Windows' SetHandleInformation takes it
  • AFlags: as Windows' SetHandleInformation takes it

Returns: as Windows' SetHandleInformation returns it

CreateFileW

text
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' CreateFileW takes it
  • AAccess: as Windows' CreateFileW takes it
  • AShare: as Windows' CreateFileW takes it
  • AAttributes: as Windows' CreateFileW takes it
  • ADisposition: as Windows' CreateFileW takes it
  • AFlags: as Windows' CreateFileW takes it
  • ATemplate: as Windows' CreateFileW takes it

Returns: as Windows' CreateFileW returns it

CreateProcessW

text
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' CreateProcessW takes it
  • ACommandLine: as Windows' CreateProcessW takes it
  • AProcessAttributes: as Windows' CreateProcessW takes it
  • AThreadAttributes: as Windows' CreateProcessW takes it
  • AInheritHandles: as Windows' CreateProcessW takes it
  • AFlags: as Windows' CreateProcessW takes it
  • AEnvironment: as Windows' CreateProcessW takes it
  • ACurrentDirectory: as Windows' CreateProcessW takes it
  • AStartup: as Windows' CreateProcessW takes it
  • AInfo: as Windows' CreateProcessW takes it

Returns: as Windows' CreateProcessW returns it

LoadLibraryExW

text
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' LoadLibraryExW takes it
  • AFile: as Windows' LoadLibraryExW takes it
  • AFlags: as Windows' LoadLibraryExW takes it

Returns: as Windows' LoadLibraryExW returns it

FreeLibrary

text
func clink FreeLibrary(AModule: uint64): int32

Windows' FreeLibrary.

Parameters

  • AModule: as Windows' FreeLibrary takes it

Returns: as Windows' FreeLibrary returns it

EnumResourceNamesW

text
func clink EnumResourceNamesW(AModule: uint64; AType: uint64; AEnum: ENUMRESNAMEPROCW; AParam: ptr): int32

Windows' EnumResourceNamesW.

Parameters

  • AModule: as Windows' EnumResourceNamesW takes it
  • AType: as Windows' EnumResourceNamesW takes it
  • AEnum: as Windows' EnumResourceNamesW takes it
  • AParam: as Windows' EnumResourceNamesW takes it

Returns: as Windows' EnumResourceNamesW returns it

EnumResourceLanguagesW

text
func clink EnumResourceLanguagesW(AModule: uint64; AType: uint64; AName: uint64; AEnum: ENUMRESLANGPROCW; AParam: ptr): int32

Windows' EnumResourceLanguagesW.

Parameters

  • AModule: as Windows' EnumResourceLanguagesW takes it
  • AType: as Windows' EnumResourceLanguagesW takes it
  • AName: as Windows' EnumResourceLanguagesW takes it
  • AEnum: as Windows' EnumResourceLanguagesW takes it
  • AParam: as Windows' EnumResourceLanguagesW takes it

Returns: as Windows' EnumResourceLanguagesW returns it

BeginUpdateResourceW

text
func clink BeginUpdateResourceW(var AFileName: WideBuffer; ADeleteExisting: int32): uint64

Windows' BeginUpdateResourceW.

Parameters

  • AFileName: as Windows' BeginUpdateResourceW takes it
  • ADeleteExisting: as Windows' BeginUpdateResourceW takes it

Returns: as Windows' BeginUpdateResourceW returns it

UpdateResourceW

text
func clink UpdateResourceW(AUpdate: uint64; AType: uint64; AName: uint64; ALanguage: uint16; AData: ptr to const; ASize: uint32): int32

Windows' UpdateResourceW.

Parameters

  • AUpdate: as Windows' UpdateResourceW takes it
  • AType: as Windows' UpdateResourceW takes it
  • AName: as Windows' UpdateResourceW takes it
  • ALanguage: as Windows' UpdateResourceW takes it
  • AData: as Windows' UpdateResourceW takes it
  • ASize: as Windows' UpdateResourceW takes it

Returns: as Windows' UpdateResourceW returns it

EndUpdateResourceW

text
func clink EndUpdateResourceW(AUpdate: uint64; ADiscard: int32): int32

Windows' EndUpdateResourceW.

Parameters

  • AUpdate: as Windows' EndUpdateResourceW takes it
  • ADiscard: as Windows' EndUpdateResourceW takes it

Returns: as Windows' EndUpdateResourceW returns it

ReadFile

text
func clink ReadFile(AFile: uint64; ABuffer: ptr; AToRead: uint32; var ARead: uint32; AOverlapped: ptr): int32

Windows' ReadFile.

Parameters

  • AFile: as Windows' ReadFile takes it
  • ABuffer: as Windows' ReadFile takes it
  • AToRead: as Windows' ReadFile takes it
  • ARead: as Windows' ReadFile takes it
  • AOverlapped: as Windows' ReadFile takes it

Returns: as Windows' ReadFile returns it

WriteFile

text
func clink WriteFile(AFile: uint64; ABuffer: ptr to const; AToWrite: uint32; var AWritten: uint32; AOverlapped: ptr): int32

Windows' WriteFile.

Parameters

  • AFile: as Windows' WriteFile takes it
  • ABuffer: as Windows' WriteFile takes it
  • AToWrite: as Windows' WriteFile takes it
  • AWritten: as Windows' WriteFile takes it
  • AOverlapped: as Windows' WriteFile takes it

Returns: as Windows' WriteFile returns it

PeekNamedPipe

text
func clink PeekNamedPipe(APipe: uint64; ABuffer: ptr; ASize: uint32; ARead: ptr; var AAvailable: uint32; ALeft: ptr): int32

Windows' PeekNamedPipe.

Parameters

  • APipe: as Windows' PeekNamedPipe takes it
  • ABuffer: as Windows' PeekNamedPipe takes it
  • ASize: as Windows' PeekNamedPipe takes it
  • ARead: as Windows' PeekNamedPipe takes it
  • AAvailable: as Windows' PeekNamedPipe takes it
  • ALeft: as Windows' PeekNamedPipe takes it

Returns: as Windows' PeekNamedPipe returns it

GetFileType

text
func clink GetFileType(AFile: uint64): uint32

Windows' GetFileType.

Parameters

  • AFile: as Windows' GetFileType takes it

Returns: as Windows' GetFileType returns it

CreatePseudoConsole

text
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' CreatePseudoConsole takes it
  • AInput: as Windows' CreatePseudoConsole takes it
  • AOutput: as Windows' CreatePseudoConsole takes it
  • AFlags: as Windows' CreatePseudoConsole takes it
  • AConsole: as Windows' CreatePseudoConsole takes it

Returns: as Windows' CreatePseudoConsole returns it

ResizePseudoConsole

text
func clink ResizePseudoConsole(AConsole: uint64; ASize: COORD): int32

Windows' ResizePseudoConsole.

Parameters

  • AConsole: as Windows' ResizePseudoConsole takes it
  • ASize: as Windows' ResizePseudoConsole takes it

Returns: as Windows' ResizePseudoConsole returns it

ClosePseudoConsole

text
func clink ClosePseudoConsole(AConsole: uint64)

Windows' ClosePseudoConsole.

Parameters

  • AConsole: as Windows' ClosePseudoConsole takes it

InitializeProcThreadAttributeList

text
func clink InitializeProcThreadAttributeList(AList: ptr; ACount: uint32; AFlags: uint32; var ASize: uint64): int32

Windows' InitializeProcThreadAttributeList.

Parameters

  • AList: as Windows' InitializeProcThreadAttributeList takes it
  • ACount: as Windows' InitializeProcThreadAttributeList takes it
  • AFlags: as Windows' InitializeProcThreadAttributeList takes it
  • ASize: as Windows' InitializeProcThreadAttributeList takes it

Returns: as Windows' InitializeProcThreadAttributeList returns it

UpdateProcThreadAttribute

text
func clink UpdateProcThreadAttribute(AList: ptr; AFlags: uint32; AAttribute: uint64; AValue: ptr; ASize: uint64; APrevious: ptr; AReturnSize: ptr): int32

Windows' UpdateProcThreadAttribute.

Parameters

  • AList: as Windows' UpdateProcThreadAttribute takes it
  • AFlags: as Windows' UpdateProcThreadAttribute takes it
  • AAttribute: as Windows' UpdateProcThreadAttribute takes it
  • AValue: as Windows' UpdateProcThreadAttribute takes it
  • ASize: as Windows' UpdateProcThreadAttribute takes it
  • APrevious: as Windows' UpdateProcThreadAttribute takes it
  • AReturnSize: as Windows' UpdateProcThreadAttribute takes it

Returns: as Windows' UpdateProcThreadAttribute returns it

DeleteProcThreadAttributeList

text
func clink DeleteProcThreadAttributeList(AList: ptr)

Windows' DeleteProcThreadAttributeList.

Parameters

  • AList: as Windows' DeleteProcThreadAttributeList takes it

GetCurrentProcess

text
func clink GetCurrentProcess(): uint64

Windows' GetCurrentProcess.

Returns: as Windows' GetCurrentProcess returns it

DuplicateHandle

text
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' DuplicateHandle takes it
  • ASource: as Windows' DuplicateHandle takes it
  • ATargetProcess: as Windows' DuplicateHandle takes it
  • ATarget: as Windows' DuplicateHandle takes it
  • AAccess: as Windows' DuplicateHandle takes it
  • AInherit: as Windows' DuplicateHandle takes it
  • AOptions: as Windows' DuplicateHandle takes it

Returns: as Windows' DuplicateHandle returns it

MultiByteToWideChar

text
func clink MultiByteToWideChar(ACodePage: uint32; AFlags: uint32; ASource: ptr to const; ASourceSize: int32; AWide: ptr; AWideSize: int32): int32

Windows' MultiByteToWideChar.

Parameters

  • ACodePage: as Windows' MultiByteToWideChar takes it
  • AFlags: as Windows' MultiByteToWideChar takes it
  • ASource: as Windows' MultiByteToWideChar takes it
  • ASourceSize: as Windows' MultiByteToWideChar takes it
  • AWide: as Windows' MultiByteToWideChar takes it
  • AWideSize: as Windows' MultiByteToWideChar takes it

Returns: as Windows' MultiByteToWideChar returns it

IsDBCSLeadByteEx

text
func clink IsDBCSLeadByteEx(ACodePage: uint32; AByte: uint8): int32

Windows' IsDBCSLeadByteEx.

Parameters

  • ACodePage: as Windows' IsDBCSLeadByteEx takes it
  • AByte: as Windows' IsDBCSLeadByteEx takes it

Returns: as Windows' IsDBCSLeadByteEx returns it

GetConsoleScreenBufferInfo

text
func clink GetConsoleScreenBufferInfo(AConsole: uint64; var AInfo: CONSOLE_SCREEN_BUFFER_INFO): int32

Windows' GetConsoleScreenBufferInfo.

Parameters

  • AConsole: as Windows' GetConsoleScreenBufferInfo takes it
  • AInfo: as Windows' GetConsoleScreenBufferInfo takes it

Returns: as Windows' GetConsoleScreenBufferInfo returns it

WaitForSingleObject

text
func clink WaitForSingleObject(AHandle: uint64; AMilliseconds: uint32): uint32

Windows' WaitForSingleObject.

Parameters

  • AHandle: as Windows' WaitForSingleObject takes it
  • AMilliseconds: as Windows' WaitForSingleObject takes it

Returns: as Windows' WaitForSingleObject returns it

CreateThread

text
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' CreateThread takes it
  • AStackSize: as Windows' CreateThread takes it
  • AStart: as Windows' CreateThread takes it
  • AParameter: as Windows' CreateThread takes it
  • AFlags: as Windows' CreateThread takes it
  • AThreadId: as Windows' CreateThread takes it

Returns: as Windows' CreateThread returns it

GetExitCodeProcess

text
func clink GetExitCodeProcess(AProcess: uint64; var AExitCode: uint32): int32

Windows' GetExitCodeProcess.

Parameters

  • AProcess: as Windows' GetExitCodeProcess takes it
  • AExitCode: as Windows' GetExitCodeProcess takes it

Returns: as Windows' GetExitCodeProcess returns it

CloseHandle

text
func clink CloseHandle(AHandle: uint64): int32

Windows' CloseHandle.

Parameters

  • AHandle: as Windows' CloseHandle takes it

Returns: as Windows' CloseHandle returns it

UTF8ToWide

text
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 text
  • ABuffer: receives the UTF-16 text

Returns: false when it does not fit

WideToUTF8

text
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 text
  • ALength: the most units to read

Returns: the UTF-8 text

QuoteArg

text
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

text
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 path
  • ABaseDir: the folder a relative path (and $S:) is resolved against

Returns: the full path, or "" when it does not fit

text
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

text
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 path
  • ASecond: the other

Returns: true when they name the same path

WinExeDir

text
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

text
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

text
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

text
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

text
func WinCPUCount(): int64

The logical processors this process may run on, every processor group's (GetActiveProcessorCount); at least 1

Returns: the count

WinMemoryTotal

text
func WinMemoryTotal(): int64

The physical memory installed, in bytes (GlobalMemoryStatusEx's ullTotalPhys); 0 when it cannot be asked

Returns: the bytes, or 0

WinSystemDir

text
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

text
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

text
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

text
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

text
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

text
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

text
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

text
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 file
  • ANewPath: its new name

Returns: true when it was renamed

WinReplaceFile

text
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 file
  • ATargetPath: the place it takes

Returns: true when the file is at ATargetPath afterwards

WinSetFileReadOnly

text
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 path
  • AReadOnly: true for read-only, false for writable

Returns: true when the file has that state afterwards

WinIsFileHidden

text
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

text
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

text
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 copied
  • ATargetPath: the copy
  • AOverwrite: true to replace a file there

Returns: true when it was copied

WinOpenURL

text
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

text
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

text
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 variable
  • AValue: its new value

Returns: true when it has that value afterwards

WinUserCacheDir

text
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

text
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

text
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

text
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 bytes
  • ABytes: receives them

Returns: false when the generator fails

WinGetFiles

text
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 folder
  • AList: receives the names

Returns: false when the folder cannot be read

WinGetDirectories

text
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 folder
  • AList: receives the names

Returns: false when the folder cannot be read

WinRemoveTree

text
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

text
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 program
  • AArgs: its arguments
  • AWorkDir: the folder it runs in ("" for this process's)
  • AApplication: receives the application
  • ACommandLine: receives the command line
  • ADirectory: receives the folder

Returns: false when one cannot be made

WinRunAttached

text
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 program
  • AArgs: its arguments
  • AWorkDir: 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

text
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 end
  • AText: gets what it holds appended

Returns: false when the pipe is closed or broken

WinReadSome

text
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 end
  • AText: gets the bytes appended

Returns: false when the pipe is closed or broken

WinOemToUTF8

text
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

text
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 program
  • AArgs: its arguments
  • AWorkDir: the folder it runs in ("" for this process's)
  • AWait: true to wait for it
  • AShowCmd: 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

text
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 program
  • AArgs: its arguments
  • AWorkDir: the folder it runs in ("" for this process's)
  • AOutput: receives its output
  • AExitCode: receives its exit code

Returns: false when it cannot start

WinDelay

text
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

text
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

text
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

text
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

text
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

text
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 format
  • AArgs: 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

text
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

text
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

text
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

text
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

text
type EXIT_THREAD_DEBUG_INFO = record

Windows' EXIT_THREAD_DEBUG_INFO.

Members

  • dwExitCode: uint32: Windows' EXIT_THREAD_DEBUG_INFO.dwExitCode.

EXIT_PROCESS_DEBUG_INFO

text
type EXIT_PROCESS_DEBUG_INFO = record

Windows' EXIT_PROCESS_DEBUG_INFO.

Members

  • dwExitCode: uint32: Windows' EXIT_PROCESS_DEBUG_INFO.dwExitCode.

LOAD_DLL_DEBUG_INFO

text
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

text
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

text
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

text
type RIP_INFO = record

Windows' RIP_INFO: RIP_INFO

Members

  • dwError: uint32: Windows' RIP_INFO.dwError.
  • dwType: uint32: Windows' RIP_INFO.dwType.

DEBUG_EVENT

text
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

text
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 bytes
  • VectorRegister: array[0..51] of uint64: Windows' CONTEXT.VectorRegister: VectorRegister[26] (M128A each), as its bytes
  • VectorControl: uint64: Windows' CONTEXT.VectorControl: VectorRegister[26] (M128A each), as its bytes
  • DebugControl: uint64: Windows' CONTEXT.DebugControl: VectorRegister[26] (M128A each), as its bytes
  • LastBranchToRip: uint64: Windows' CONTEXT.LastBranchToRip: VectorRegister[26] (M128A each), as its bytes
  • LastBranchFromRip: uint64: Windows' CONTEXT.LastBranchFromRip: VectorRegister[26] (M128A each), as its bytes
  • LastExceptionToRip: uint64: Windows' CONTEXT.LastExceptionToRip: VectorRegister[26] (M128A each), as its bytes
  • LastExceptionFromRip: uint64: Windows' CONTEXT.LastExceptionFromRip: VectorRegister[26] (M128A each), as its bytes

DebugSymbolInfo

text
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's SizeOfStruct: set to ADAM_WINDOWS_SYMBOL_INFO_SIZE.
  • TypeIndex: uint32: SYMBOL_INFOW's TypeIndex: the symbol's type.
  • Reserved: array[0..1] of uint64: SYMBOL_INFOW's Reserved.
  • Index: uint32: SYMBOL_INFOW's Index.
  • Size: uint32: SYMBOL_INFOW's Size: the symbol's size in bytes.
  • ModBase: uint64: SYMBOL_INFOW's ModBase: the base of its module.
  • Flags: uint32: SYMBOL_INFOW's Flags (SYMFLAG_*).
  • Value: uint64: SYMBOL_INFOW's Value.
  • Address: uint64: SYMBOL_INFOW's Address.
  • Register: uint32: SYMBOL_INFOW's Register.
  • Scope: uint32: SYMBOL_INFOW's Scope.
  • Tag: uint32: SYMBOL_INFOW's Tag (a SymTag* value).
  • NameLen: uint32: SYMBOL_INFOW's NameLen: the units of Name used.
  • MaxNameLen: uint32: SYMBOL_INFOW's MaxNameLen: set to MAX_SYM_NAME.
  • Name: array[0..1999] of uint16: SYMBOL_INFOW's Name, with room for MAX_SYM_NAME units (DbgSymbolName reads it).

IMAGEHLP_LINEW64

text
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

text
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

text
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

text
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

text
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

text
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's vt: the value's kind.
  • Reserved1: uint16: VARIANT's wReserved1.
  • Reserved2: uint16: VARIANT's wReserved2.
  • Reserved3: uint16: VARIANT's wReserved3.
  • Value: uint64: The value's first 8 bytes.
  • Extra: uint64: The value's next 8 bytes.

ADDRESS64

text
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

text
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

text
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

text
type PFUNCTION_TABLE_ACCESS_ROUTINE64 = func clink(AProcess: uint64; AAddress: uint64): ptr

Windows' PFUNCTION_TABLE_ACCESS_ROUTINE64.

PGET_MODULE_BASE_ROUTINE64

text
type PGET_MODULE_BASE_ROUTINE64 = func clink(AProcess: uint64; AAddress: uint64): uint64

Windows' PGET_MODULE_BASE_ROUTINE64.

PHANDLER_ROUTINE

text
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

NameDeclarationDescription
DEBUG_ONLY_THIS_PROCESSconst DEBUG_ONLY_THIS_PROCESS: uint32 = 0x2Windows' DEBUG_ONLY_THIS_PROCESS: CreateProcessW's flags: the new process is debugged by this one (not its children)
CREATE_NEW_PROCESS_GROUPconst CREATE_NEW_PROCESS_GROUP: uint32 = 0x200Windows' 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_EVENTconst EXCEPTION_DEBUG_EVENT: uint32 = 1Windows' EXCEPTION_DEBUG_EVENT: DEBUG_EVENT's dwDebugEventCode
CREATE_THREAD_DEBUG_EVENTconst CREATE_THREAD_DEBUG_EVENT: uint32 = 2Windows' CREATE_THREAD_DEBUG_EVENT: DEBUG_EVENT's dwDebugEventCode
CREATE_PROCESS_DEBUG_EVENTconst CREATE_PROCESS_DEBUG_EVENT: uint32 = 3Windows' CREATE_PROCESS_DEBUG_EVENT: DEBUG_EVENT's dwDebugEventCode
EXIT_THREAD_DEBUG_EVENTconst EXIT_THREAD_DEBUG_EVENT: uint32 = 4Windows' EXIT_THREAD_DEBUG_EVENT: DEBUG_EVENT's dwDebugEventCode
EXIT_PROCESS_DEBUG_EVENTconst EXIT_PROCESS_DEBUG_EVENT: uint32 = 5Windows' EXIT_PROCESS_DEBUG_EVENT: DEBUG_EVENT's dwDebugEventCode
LOAD_DLL_DEBUG_EVENTconst LOAD_DLL_DEBUG_EVENT: uint32 = 6Windows' LOAD_DLL_DEBUG_EVENT: DEBUG_EVENT's dwDebugEventCode
UNLOAD_DLL_DEBUG_EVENTconst UNLOAD_DLL_DEBUG_EVENT: uint32 = 7Windows' UNLOAD_DLL_DEBUG_EVENT: DEBUG_EVENT's dwDebugEventCode
OUTPUT_DEBUG_STRING_EVENTconst OUTPUT_DEBUG_STRING_EVENT: uint32 = 8Windows' OUTPUT_DEBUG_STRING_EVENT: DEBUG_EVENT's dwDebugEventCode
RIP_EVENTconst RIP_EVENT: uint32 = 9Windows' RIP_EVENT: DEBUG_EVENT's dwDebugEventCode
DBG_CONTINUEconst DBG_CONTINUE: uint32 = 0x00010002Windows' DBG_CONTINUE: ContinueDebugEvent's status: the event is handled / an exception goes to the program
DBG_EXCEPTION_NOT_HANDLEDconst DBG_EXCEPTION_NOT_HANDLED: uint32 = 0x80010001Windows' DBG_EXCEPTION_NOT_HANDLED: ContinueDebugEvent's status: the event is handled / an exception goes to the program
EXCEPTION_BREAKPOINTconst EXCEPTION_BREAKPOINT: uint32 = 0x80000003Windows' EXCEPTION_BREAKPOINT: EXCEPTION_RECORD's ExceptionCode: an int3, a trap-flag step
EXCEPTION_SINGLE_STEPconst EXCEPTION_SINGLE_STEP: uint32 = 0x80000004Windows' EXCEPTION_SINGLE_STEP: EXCEPTION_RECORD's ExceptionCode: an int3, a trap-flag step
CONTEXT_ALLconst CONTEXT_ALL: uint32 = 0x0010001FWindows' CONTEXT_ALL: CONTEXT's ContextFlags: CONTEXT_ALL for AMD64 (control, integer, segments, floating point, debug registers)
ADAM_WINDOWS_TRAP_FLAGconst ADAM_WINDOWS_TRAP_FLAG: uint32 = 0x100The trap flag in EFlags: one instruction, then a single-step exception
ADAM_WINDOWS_CONTEXT_SIZEconst ADAM_WINDOWS_CONTEXT_SIZE: int64 = 1232The bytes of a CONTEXT and the alignment GetThreadContext / SetThreadContext need
ADAM_WINDOWS_CONTEXT_ALIGNconst ADAM_WINDOWS_CONTEXT_ALIGN: int64 = 16The alignment GetThreadContext / SetThreadContext need for a CONTEXT.
PAGE_EXECUTE_READWRITEconst PAGE_EXECUTE_READWRITE: uint32 = 0x40Windows' PAGE_EXECUTE_READWRITE: VirtualProtectEx's protection for a code byte the debugger writes
ERROR_SEM_TIMEOUTconst ERROR_SEM_TIMEOUT: uint32 = 121Windows' ERROR_SEM_TIMEOUT: WaitForDebugEvent's error when no event came in time
ERROR_FILENAME_EXCED_RANGEconst ERROR_FILENAME_EXCED_RANGE: uint32 = 206Windows' ERROR_FILENAME_EXCED_RANGE: The error of a path or command line too long for Win32
ADAM_WINDOWS_THREAD_FAILEDconst ADAM_WINDOWS_THREAD_FAILED: uint32 = 0xFFFFFFFFSuspendThread / ResumeThread's failure
ADAM_WINDOWS_DEBUG_TEXT_MAXconst ADAM_WINDOWS_DEBUG_TEXT_MAX: uint32 = 32767The UTF-16 units GetFinalPathNameByHandleW and WinErrorText write at most
FORMAT_MESSAGE_FROM_SYSTEMconst FORMAT_MESSAGE_FROM_SYSTEM: uint32 = 0x1000Windows' FORMAT_MESSAGE_FROM_SYSTEM: FormatMessageW: the system's message table, its inserts left as they are
FORMAT_MESSAGE_IGNORE_INSERTSconst FORMAT_MESSAGE_IGNORE_INSERTS: uint32 = 0x200Windows' FORMAT_MESSAGE_IGNORE_INSERTS: FormatMessageW: the system's message table, its inserts left as they are
CTRL_C_EVENTconst CTRL_C_EVENT: uint32 = 0Windows' CTRL_C_EVENT: A console control handler's events: Ctrl+C, Ctrl+Break
CTRL_BREAK_EVENTconst CTRL_BREAK_EVENT: uint32 = 1Windows' CTRL_BREAK_EVENT: A console control handler's events: Ctrl+C, Ctrl+Break
SYMOPT_UNDNAMEconst SYMOPT_UNDNAME: uint32 = 0x2Windows' SYMOPT_UNDNAME: DbgHelp: SymSetOptions' options (undecorated names, source lines, no error box, no _NT_SYMBOL_PATH, no prompt)
SYMOPT_LOAD_LINESconst SYMOPT_LOAD_LINES: uint32 = 0x10Windows' SYMOPT_LOAD_LINES: DbgHelp: SymSetOptions' options (undecorated names, source lines, no error box, no _NT_SYMBOL_PATH, no prompt)
SYMOPT_FAIL_CRITICAL_ERRORSconst SYMOPT_FAIL_CRITICAL_ERRORS: uint32 = 0x200Windows' SYMOPT_FAIL_CRITICAL_ERRORS: DbgHelp: SymSetOptions' options (undecorated names, source lines, no error box, no _NT_SYMBOL_PATH, no prompt)
SYMOPT_IGNORE_NT_SYMPATHconst SYMOPT_IGNORE_NT_SYMPATH: uint32 = 0x1000Windows' SYMOPT_IGNORE_NT_SYMPATH: DbgHelp: SymSetOptions' options (undecorated names, source lines, no error box, no _NT_SYMBOL_PATH, no prompt)
SYMOPT_NO_PROMPTSconst SYMOPT_NO_PROMPTS: uint32 = 0x80000Windows' SYMOPT_NO_PROMPTS: DbgHelp: SymSetOptions' options (undecorated names, source lines, no error box, no _NT_SYMBOL_PATH, no prompt)
SYMFLAG_REGRELconst SYMFLAG_REGREL: uint32 = 0x10Windows' SYMFLAG_REGREL: SYMBOL_INFOW's Flags: a value relative to a register, a parameter, a local
SYMFLAG_TLSRELconst SYMFLAG_TLSREL: uint32 = 0x4000Windows' SYMFLAG_TLSREL: A thread-local value (its Address the offset in the module's TLS block)
SYMFLAG_PARAMETERconst SYMFLAG_PARAMETER: uint32 = 0x40Windows' SYMFLAG_PARAMETER: a SYMBOL_INFOW flag: the symbol is a parameter of its function
SYMFLAG_LOCALconst SYMFLAG_LOCAL: uint32 = 0x80Windows' SYMFLAG_LOCAL: a SYMBOL_INFOW flag: the symbol is a local variable of its function
SymTagFunctionconst SymTagFunction: uint32 = 5Windows' SymTagFunction: SymTagEnum: a symbol's or a type's kind (SYMBOL_INFOW's Tag, TI_GET_SYMTAG)
SymTagDataconst SymTagData: uint32 = 7Windows' SymTagData: SymTagEnum: a symbol's or a type's kind (SYMBOL_INFOW's Tag, TI_GET_SYMTAG)
SymTagLabelconst SymTagLabel: uint32 = 9Windows' SymTagLabel: SymTagEnum: a symbol's or a type's kind (SYMBOL_INFOW's Tag, TI_GET_SYMTAG)
SymTagPublicSymbolconst SymTagPublicSymbol: uint32 = 10Windows' SymTagPublicSymbol: SymTagEnum: a symbol's or a type's kind (SYMBOL_INFOW's Tag, TI_GET_SYMTAG)
SymTagUDTconst SymTagUDT: uint32 = 11Windows' SymTagUDT: SymTagEnum: a symbol's or a type's kind (SYMBOL_INFOW's Tag, TI_GET_SYMTAG)
SymTagEnumconst SymTagEnum: uint32 = 12Windows' SymTagEnum: SymTagEnum: a symbol's or a type's kind (SYMBOL_INFOW's Tag, TI_GET_SYMTAG)
SymTagFunctionTypeconst SymTagFunctionType: uint32 = 13Windows' SymTagFunctionType: SymTagEnum: a symbol's or a type's kind (SYMBOL_INFOW's Tag, TI_GET_SYMTAG)
SymTagPointerTypeconst SymTagPointerType: uint32 = 14Windows' SymTagPointerType: SymTagEnum: a symbol's or a type's kind (SYMBOL_INFOW's Tag, TI_GET_SYMTAG)
SymTagArrayTypeconst SymTagArrayType: uint32 = 15Windows' SymTagArrayType: SymTagEnum: a symbol's or a type's kind (SYMBOL_INFOW's Tag, TI_GET_SYMTAG)
SymTagBaseTypeconst SymTagBaseType: uint32 = 16Windows' SymTagBaseType: SymTagEnum: a symbol's or a type's kind (SYMBOL_INFOW's Tag, TI_GET_SYMTAG)
SymTagTypedefconst SymTagTypedef: uint32 = 17Windows' SymTagTypedef: SymTagEnum: a symbol's or a type's kind (SYMBOL_INFOW's Tag, TI_GET_SYMTAG)
SymTagThunkconst SymTagThunk: uint32 = 27Windows' SymTagThunk: SymTagEnum: a symbol's or a type's kind (SYMBOL_INFOW's Tag, TI_GET_SYMTAG)
TI_GET_SYMTAGconst TI_GET_SYMTAG: uint32 = 0Windows' 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_SYMNAMEconst TI_GET_SYMNAME: uint32 = 1Windows' 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_LENGTHconst TI_GET_LENGTH: uint32 = 2Windows' 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_TYPEconst TI_GET_TYPE: uint32 = 3Windows' 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_BASETYPEconst TI_GET_BASETYPE: uint32 = 5Windows' 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_FINDCHILDRENconst TI_FINDCHILDREN: uint32 = 7Windows' 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_OFFSETconst TI_GET_OFFSET: uint32 = 10Windows' 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_VALUEconst TI_GET_VALUE: uint32 = 11Windows' 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_COUNTconst TI_GET_COUNT: uint32 = 12Windows' 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_CHILDRENCOUNTconst TI_GET_CHILDRENCOUNT: uint32 = 13Windows' 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_BITPOSITIONconst TI_GET_BITPOSITION: uint32 = 14Windows' TI_GET_BITPOSITION: a bitfield member's first bit in its unit (fails for any other member)
TI_GET_ADDRESSconst TI_GET_ADDRESS: uint32 = 22Windows' TI_GET_ADDRESS: a symbol's address (a uint64)
SYMSEARCH_ALLITEMSconst SYMSEARCH_ALLITEMS: uint32 = 0x08Windows' SYMSEARCH_ALLITEMS: SymSearchW's options: nested symbols too (a routine's labels)
VT_I2const VT_I2: uint16 = 2Windows' VT_I2: TI_GET_VALUE's VARIANT kinds (DebugVariant.Kind) an enum value comes as
VT_I4const VT_I4: uint16 = 3Windows' VT_I4: TI_GET_VALUE's VARIANT kinds (DebugVariant.Kind) an enum value comes as
VT_I1const VT_I1: uint16 = 16Windows' VT_I1: TI_GET_VALUE's VARIANT kinds (DebugVariant.Kind) an enum value comes as
VT_UI1const VT_UI1: uint16 = 17Windows' VT_UI1: TI_GET_VALUE's VARIANT kinds (DebugVariant.Kind) an enum value comes as
VT_UI2const VT_UI2: uint16 = 18Windows' VT_UI2: TI_GET_VALUE's VARIANT kinds (DebugVariant.Kind) an enum value comes as
VT_UI4const VT_UI4: uint16 = 19Windows' VT_UI4: TI_GET_VALUE's VARIANT kinds (DebugVariant.Kind) an enum value comes as
VT_I8const VT_I8: uint16 = 20Windows' VT_I8: TI_GET_VALUE's VARIANT kinds (DebugVariant.Kind) an enum value comes as
VT_UI8const VT_UI8: uint16 = 21Windows' VT_UI8: TI_GET_VALUE's VARIANT kinds (DebugVariant.Kind) an enum value comes as
VT_INTconst VT_INT: uint16 = 22Windows' VT_INT: TI_GET_VALUE's VARIANT kinds (DebugVariant.Kind) an enum value comes as
VT_UINTconst VT_UINT: uint16 = 23Windows' VT_UINT: TI_GET_VALUE's VARIANT kinds (DebugVariant.Kind) an enum value comes as
btVoidconst btVoid: uint32 = 1Windows' btVoid: BasicType (TI_GET_BASETYPE): DbgHelp's kinds of a builtin type
btCharconst btChar: uint32 = 2Windows' btChar: BasicType (TI_GET_BASETYPE): DbgHelp's kinds of a builtin type
btWCharconst btWChar: uint32 = 3Windows' btWChar: BasicType (TI_GET_BASETYPE): DbgHelp's kinds of a builtin type
btIntconst btInt: uint32 = 6Windows' btInt: BasicType (TI_GET_BASETYPE): DbgHelp's kinds of a builtin type
btUIntconst btUInt: uint32 = 7Windows' btUInt: BasicType (TI_GET_BASETYPE): DbgHelp's kinds of a builtin type
btFloatconst btFloat: uint32 = 8Windows' btFloat: BasicType (TI_GET_BASETYPE): DbgHelp's kinds of a builtin type
btBoolconst btBool: uint32 = 10Windows' btBool: BasicType (TI_GET_BASETYPE): DbgHelp's kinds of a builtin type
btLongconst btLong: uint32 = 13Windows' btLong: BasicType (TI_GET_BASETYPE): DbgHelp's kinds of a builtin type
btULongconst btULong: uint32 = 14Windows' btULong: BasicType (TI_GET_BASETYPE): DbgHelp's kinds of a builtin type
btChar16const btChar16: uint32 = 30Windows' btChar16: BasicType (TI_GET_BASETYPE): DbgHelp's kinds of a builtin type
btChar32const btChar32: uint32 = 31Windows' btChar32: BasicType (TI_GET_BASETYPE): DbgHelp's kinds of a builtin type
btChar8const btChar8: uint32 = 32Windows' btChar8: BasicType (TI_GET_BASETYPE): DbgHelp's kinds of a builtin type
AddrModeFlatconst AddrModeFlat: uint32 = 3Windows' AddrModeFlat: StackWalk64's flat addresses (its machine, IMAGE_FILE_MACHINE_AMD64, is System.Windows')
ADAM_WINDOWS_SYMBOL_INFO_SIZEconst ADAM_WINDOWS_SYMBOL_INFO_SIZE: uint32 = 88The 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_SIZEconst ADAM_WINDOWS_LINE_INFO_SIZE: uint32 = 40The bytes of an IMAGEHLP_LINEW64 (its SizeOfStruct).
MAX_SYM_NAMEconst MAX_SYM_NAME: uint32 = 2000Windows' MAX_SYM_NAME.
ADAM_WINDOWS_FIND_CHILDREN_MAXconst ADAM_WINDOWS_FIND_CHILDREN_MAX: uint32 = 256The children a DebugFindChildren holds.

Routines

WaitForDebugEvent

text
func clink WaitForDebugEvent(var AEvent: DEBUG_EVENT; AMilliseconds: uint32): int32

Windows' WaitForDebugEvent.

Parameters

  • AEvent: as Windows' WaitForDebugEvent takes it
  • AMilliseconds: as Windows' WaitForDebugEvent takes it

Returns: as Windows' WaitForDebugEvent returns it

ContinueDebugEvent

text
func clink ContinueDebugEvent(AProcessId: uint32; AThreadId: uint32; AStatus: uint32): int32

Windows' ContinueDebugEvent.

Parameters

  • AProcessId: as Windows' ContinueDebugEvent takes it
  • AThreadId: as Windows' ContinueDebugEvent takes it
  • AStatus: as Windows' ContinueDebugEvent takes it

Returns: as Windows' ContinueDebugEvent returns it

DebugBreakProcess

text
func clink DebugBreakProcess(AProcess: uint64): int32

Windows' DebugBreakProcess.

Parameters

  • AProcess: as Windows' DebugBreakProcess takes it

Returns: as Windows' DebugBreakProcess returns it

TerminateProcess

text
func clink TerminateProcess(AProcess: uint64; AExitCode: uint32): int32

Windows' TerminateProcess.

Parameters

  • AProcess: as Windows' TerminateProcess takes it
  • AExitCode: as Windows' TerminateProcess takes it

Returns: as Windows' TerminateProcess returns it

GetThreadContext

text
func clink GetThreadContext(AThread: uint64; AContext: ptr): int32

Windows' GetThreadContext.

Parameters

  • AThread: as Windows' GetThreadContext takes it
  • AContext: as Windows' GetThreadContext takes it

Returns: as Windows' GetThreadContext returns it

SetThreadContext

text
func clink SetThreadContext(AThread: uint64; AContext: ptr): int32

Windows' SetThreadContext.

Parameters

  • AThread: as Windows' SetThreadContext takes it
  • AContext: as Windows' SetThreadContext takes it

Returns: as Windows' SetThreadContext returns it

ReadProcessMemory

text
func clink ReadProcessMemory(AProcess: uint64; AAddress: uint64; ABuffer: ptr; ASize: uint64; var ARead: uint64): int32

Windows' ReadProcessMemory.

Parameters

  • AProcess: as Windows' ReadProcessMemory takes it
  • AAddress: as Windows' ReadProcessMemory takes it
  • ABuffer: as Windows' ReadProcessMemory takes it
  • ASize: as Windows' ReadProcessMemory takes it
  • ARead: as Windows' ReadProcessMemory takes it

Returns: as Windows' ReadProcessMemory returns it

WriteProcessMemory

text
func clink WriteProcessMemory(AProcess: uint64; AAddress: uint64; ABuffer: ptr to const; ASize: uint64; var AWritten: uint64): int32

Windows' WriteProcessMemory.

Parameters

  • AProcess: as Windows' WriteProcessMemory takes it
  • AAddress: as Windows' WriteProcessMemory takes it
  • ABuffer: as Windows' WriteProcessMemory takes it
  • ASize: as Windows' WriteProcessMemory takes it
  • AWritten: as Windows' WriteProcessMemory takes it

Returns: as Windows' WriteProcessMemory returns it

VirtualProtectEx

text
func clink VirtualProtectEx(AProcess: uint64; AAddress: uint64; ASize: uint64; ANewProtect: uint32; var AOldProtect: uint32): int32

Windows' VirtualProtectEx.

Parameters

  • AProcess: as Windows' VirtualProtectEx takes it
  • AAddress: as Windows' VirtualProtectEx takes it
  • ASize: as Windows' VirtualProtectEx takes it
  • ANewProtect: as Windows' VirtualProtectEx takes it
  • AOldProtect: as Windows' VirtualProtectEx takes it

Returns: as Windows' VirtualProtectEx returns it

FlushInstructionCache

text
func clink FlushInstructionCache(AProcess: uint64; AAddress: uint64; ASize: uint64): int32

Windows' FlushInstructionCache.

Parameters

  • AProcess: as Windows' FlushInstructionCache takes it
  • AAddress: as Windows' FlushInstructionCache takes it
  • ASize: as Windows' FlushInstructionCache takes it

Returns: as Windows' FlushInstructionCache returns it

SuspendThread

text
func clink SuspendThread(AThread: uint64): uint32

Windows' SuspendThread.

Parameters

  • AThread: as Windows' SuspendThread takes it

Returns: as Windows' SuspendThread returns it

ResumeThread

text
func clink ResumeThread(AThread: uint64): uint32

Windows' ResumeThread.

Parameters

  • AThread: as Windows' ResumeThread takes it

Returns: as Windows' ResumeThread returns it

GetFinalPathNameByHandleW

text
func clink GetFinalPathNameByHandleW(AFile: uint64; var ABuffer: WideBuffer; ASize: uint32; AFlags: uint32): uint32

Windows' GetFinalPathNameByHandleW.

Parameters

  • AFile: as Windows' GetFinalPathNameByHandleW takes it
  • ABuffer: as Windows' GetFinalPathNameByHandleW takes it
  • ASize: as Windows' GetFinalPathNameByHandleW takes it
  • AFlags: as Windows' GetFinalPathNameByHandleW takes it

Returns: as Windows' GetFinalPathNameByHandleW returns it

SetConsoleCtrlHandler

text
func clink SetConsoleCtrlHandler(AHandler: PHANDLER_ROUTINE; AAdd: int32): int32

Windows' SetConsoleCtrlHandler.

Parameters

  • AHandler: as Windows' SetConsoleCtrlHandler takes it
  • AAdd: as Windows' SetConsoleCtrlHandler takes it

Returns: as Windows' SetConsoleCtrlHandler returns it

SymSetOptions

text
func clink SymSetOptions(AOptions: uint32): uint32

Windows' SymSetOptions.

Parameters

  • AOptions: as Windows' SymSetOptions takes it

Returns: as Windows' SymSetOptions returns it

SymInitializeW

text
func clink SymInitializeW(AProcess: uint64; ASearchPath: ptr to const uint16; AInvadeProcess: int32): int32

Windows' SymInitializeW.

Parameters

  • AProcess: as Windows' SymInitializeW takes it
  • ASearchPath: as Windows' SymInitializeW takes it
  • AInvadeProcess: as Windows' SymInitializeW takes it

Returns: as Windows' SymInitializeW returns it

SymLoadModuleExW

text
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' SymLoadModuleExW takes it
  • AFile: as Windows' SymLoadModuleExW takes it
  • AImageName: as Windows' SymLoadModuleExW takes it
  • AModuleName: as Windows' SymLoadModuleExW takes it
  • ABase: as Windows' SymLoadModuleExW takes it
  • ASize: as Windows' SymLoadModuleExW takes it
  • AData: as Windows' SymLoadModuleExW takes it
  • AFlags: as Windows' SymLoadModuleExW takes it

Returns: as Windows' SymLoadModuleExW returns it

SymFromNameW

text
func clink SymFromNameW(AProcess: uint64; ASymbolName: ptr to const uint16; var ASymbol: DebugSymbolInfo): int32

Windows' SymFromNameW.

Parameters

  • AProcess: as Windows' SymFromNameW takes it
  • ASymbolName: as Windows' SymFromNameW takes it
  • ASymbol: as Windows' SymFromNameW takes it

Returns: as Windows' SymFromNameW returns it

SymFromAddrW

text
func clink SymFromAddrW(AProcess: uint64; AAddress: uint64; var ADisplacement: uint64; var ASymbol: DebugSymbolInfo): int32

Windows' SymFromAddrW.

Parameters

  • AProcess: as Windows' SymFromAddrW takes it
  • AAddress: as Windows' SymFromAddrW takes it
  • ADisplacement: as Windows' SymFromAddrW takes it
  • ASymbol: as Windows' SymFromAddrW takes it

Returns: as Windows' SymFromAddrW returns it

SymGetLineFromAddrW64

text
func clink SymGetLineFromAddrW64(AProcess: uint64; AAddress: uint64; var ADisplacement: uint32; var ALine: IMAGEHLP_LINEW64): int32

Windows' SymGetLineFromAddrW64.

Parameters

  • AProcess: as Windows' SymGetLineFromAddrW64 takes it
  • AAddress: as Windows' SymGetLineFromAddrW64 takes it
  • ADisplacement: as Windows' SymGetLineFromAddrW64 takes it
  • ALine: as Windows' SymGetLineFromAddrW64 takes it

Returns: as Windows' SymGetLineFromAddrW64 returns it

SymGetLineFromNameW64

text
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' SymGetLineFromNameW64 takes it
  • AModuleName: as Windows' SymGetLineFromNameW64 takes it
  • AFileName: as Windows' SymGetLineFromNameW64 takes it
  • ALineNumber: as Windows' SymGetLineFromNameW64 takes it
  • ADisplacement: as Windows' SymGetLineFromNameW64 takes it
  • ALine: as Windows' SymGetLineFromNameW64 takes it

Returns: as Windows' SymGetLineFromNameW64 returns it

SymSetScopeFromAddr

text
func clink SymSetScopeFromAddr(AProcess: uint64; AAddress: uint64): int32

Windows' SymSetScopeFromAddr.

Parameters

  • AProcess: as Windows' SymSetScopeFromAddr takes it
  • AAddress: as Windows' SymSetScopeFromAddr takes it

Returns: as Windows' SymSetScopeFromAddr returns it

SymEnumSymbolsW

text
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' SymEnumSymbolsW takes it
  • ABase: as Windows' SymEnumSymbolsW takes it
  • AMask: as Windows' SymEnumSymbolsW takes it
  • ACallback: as Windows' SymEnumSymbolsW takes it
  • AContext: as Windows' SymEnumSymbolsW takes it

Returns: as Windows' SymEnumSymbolsW returns it

SymSearchW

text
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' SymSearchW takes it
  • ABase: as Windows' SymSearchW takes it
  • AIndex: as Windows' SymSearchW takes it
  • ATag: as Windows' SymSearchW takes it
  • AMask: as Windows' SymSearchW takes it
  • AAddress: as Windows' SymSearchW takes it
  • ACallback: as Windows' SymSearchW takes it
  • AContext: as Windows' SymSearchW takes it
  • AOptions: as Windows' SymSearchW takes it

Returns: as Windows' SymSearchW returns it

SymGetTypeInfo

text
func clink SymGetTypeInfo(AProcess: uint64; ABase: uint64; ATypeId: uint32; AKind: uint32; AInfo: ptr): int32

Windows' SymGetTypeInfo.

Parameters

  • AProcess: as Windows' SymGetTypeInfo takes it
  • ABase: as Windows' SymGetTypeInfo takes it
  • ATypeId: as Windows' SymGetTypeInfo takes it
  • AKind: as Windows' SymGetTypeInfo takes it
  • AInfo: as Windows' SymGetTypeInfo takes it

Returns: as Windows' SymGetTypeInfo returns it

SymGetLineNextW64

text
func clink SymGetLineNextW64(AProcess: uint64; var ALine: IMAGEHLP_LINEW64): int32

Windows' SymGetLineNextW64.

Parameters

  • AProcess: as Windows' SymGetLineNextW64 takes it
  • ALine: as Windows' SymGetLineNextW64 takes it

Returns: as Windows' SymGetLineNextW64 returns it

SymEnumSourceFilesW

text
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' SymEnumSourceFilesW takes it
  • ABase: as Windows' SymEnumSourceFilesW takes it
  • AMask: as Windows' SymEnumSourceFilesW takes it
  • ACallback: as Windows' SymEnumSourceFilesW takes it
  • AContext: as Windows' SymEnumSourceFilesW takes it

Returns: as Windows' SymEnumSourceFilesW returns it

SymFunctionTableAccess64

text
func clink SymFunctionTableAccess64(AProcess: uint64; AAddress: uint64): ptr

Windows' SymFunctionTableAccess64.

Parameters

  • AProcess: as Windows' SymFunctionTableAccess64 takes it
  • AAddress: as Windows' SymFunctionTableAccess64 takes it

Returns: as Windows' SymFunctionTableAccess64 returns it

SymGetModuleBase64

text
func clink SymGetModuleBase64(AProcess: uint64; AAddress: uint64): uint64

Windows' SymGetModuleBase64.

Parameters

  • AProcess: as Windows' SymGetModuleBase64 takes it
  • AAddress: as Windows' SymGetModuleBase64 takes it

Returns: as Windows' SymGetModuleBase64 returns it

StackWalk64

text
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' StackWalk64 takes it
  • AProcess: as Windows' StackWalk64 takes it
  • AThread: as Windows' StackWalk64 takes it
  • AFrame: as Windows' StackWalk64 takes it
  • AContext: as Windows' StackWalk64 takes it
  • AReadMemory: as Windows' StackWalk64 takes it
  • AFunctionTable: as Windows' StackWalk64 takes it
  • AModuleBase: as Windows' StackWalk64 takes it
  • ATranslate: as Windows' StackWalk64 takes it

Returns: as Windows' StackWalk64 returns it

SymUnloadModule64

text
func clink SymUnloadModule64(AProcess: uint64; ABase: uint64): int32

Windows' SymUnloadModule64.

Parameters

  • AProcess: as Windows' SymUnloadModule64 takes it
  • ABase: as Windows' SymUnloadModule64 takes it

Returns: as Windows' SymUnloadModule64 returns it

SymCleanup

text
func clink SymCleanup(AProcess: uint64): int32

Windows' SymCleanup.

Parameters

  • AProcess: as Windows' SymCleanup takes it

Returns: as Windows' SymCleanup returns it

WinErrorText

text
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

text
func WinLastErrorText(): string

WinErrorText of the calling thread's last error

Returns: the message

DbgWideText

text
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

text
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

text
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 on
  • ABase: the module's base
  • ATypeId: 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

text
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

text
type ENUMRESLANGPROCW = func clink(AModule: uint64; AType: uint64; AName: uint64;

The Windows SDK's ENUMRESLANGPROCW.

TIMERPROC

text
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

text
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

text
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

text
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

text
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

text
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's FILETIME.dwLowDateTime.
  • dwHighDateTime: uint32: The Windows SDK's FILETIME.dwHighDateTime.

WIN32_FIND_DATAW

text
type WIN32_FIND_DATAW = record

The Windows SDK's WIN32_FIND_DATAW.

Members

  • dwFileAttributes: uint32: The Windows SDK's WIN32_FIND_DATAW.dwFileAttributes.
  • ftCreationTime: FILETIME: The Windows SDK's WIN32_FIND_DATAW.ftCreationTime.
  • ftLastAccessTime: FILETIME: The Windows SDK's WIN32_FIND_DATAW.ftLastAccessTime.
  • ftLastWriteTime: FILETIME: The Windows SDK's WIN32_FIND_DATAW.ftLastWriteTime.
  • nFileSizeHigh: uint32: The Windows SDK's WIN32_FIND_DATAW.nFileSizeHigh.
  • nFileSizeLow: uint32: The Windows SDK's WIN32_FIND_DATAW.nFileSizeLow.
  • dwReserved0: uint32: The Windows SDK's WIN32_FIND_DATAW.dwReserved0.
  • dwReserved1: uint32: The Windows SDK's WIN32_FIND_DATAW.dwReserved1.
  • cFileName: array[0..259] of uint16: The Windows SDK's WIN32_FIND_DATAW.cFileName.
  • cAlternateFileName: array[0..13] of uint16: The Windows SDK's WIN32_FIND_DATAW.cAlternateFileName.

WIN32_FILE_ATTRIBUTE_DATA

text
type WIN32_FILE_ATTRIBUTE_DATA = record

The Windows SDK's WIN32_FILE_ATTRIBUTE_DATA.

Members

  • dwFileAttributes: uint32: The Windows SDK's WIN32_FILE_ATTRIBUTE_DATA.dwFileAttributes.
  • ftCreationTime: FILETIME: The Windows SDK's WIN32_FILE_ATTRIBUTE_DATA.ftCreationTime.
  • ftLastAccessTime: FILETIME: The Windows SDK's WIN32_FILE_ATTRIBUTE_DATA.ftLastAccessTime.
  • ftLastWriteTime: FILETIME: The Windows SDK's WIN32_FILE_ATTRIBUTE_DATA.ftLastWriteTime.
  • nFileSizeHigh: uint32: The Windows SDK's WIN32_FILE_ATTRIBUTE_DATA.nFileSizeHigh.
  • nFileSizeLow: uint32: The Windows SDK's WIN32_FILE_ATTRIBUTE_DATA.nFileSizeLow.

SECURITY_ATTRIBUTES

text
type SECURITY_ATTRIBUTES = record

The Windows SDK's SECURITY_ATTRIBUTES.

Members

  • nLength: uint32: The Windows SDK's SECURITY_ATTRIBUTES.nLength.
  • lpSecurityDescriptor: ptr: The Windows SDK's SECURITY_ATTRIBUTES.lpSecurityDescriptor.
  • bInheritHandle: int32: The Windows SDK's SECURITY_ATTRIBUTES.bInheritHandle.

STARTUPINFOW

text
type STARTUPINFOW = record

The Windows SDK's STARTUPINFOW.

Members

  • cb: uint32: The Windows SDK's STARTUPINFOW.cb.
  • lpReserved: ptr: The Windows SDK's STARTUPINFOW.lpReserved.
  • lpDesktop: ptr: The Windows SDK's STARTUPINFOW.lpDesktop.
  • lpTitle: ptr: The Windows SDK's STARTUPINFOW.lpTitle.
  • dwX: uint32: The Windows SDK's STARTUPINFOW.dwX.
  • dwY: uint32: The Windows SDK's STARTUPINFOW.dwY.
  • dwXSize: uint32: The Windows SDK's STARTUPINFOW.dwXSize.
  • dwYSize: uint32: The Windows SDK's STARTUPINFOW.dwYSize.
  • dwXCountChars: uint32: The Windows SDK's STARTUPINFOW.dwXCountChars.
  • dwYCountChars: uint32: The Windows SDK's STARTUPINFOW.dwYCountChars.
  • dwFillAttribute: uint32: The Windows SDK's STARTUPINFOW.dwFillAttribute.
  • dwFlags: uint32: The Windows SDK's STARTUPINFOW.dwFlags.
  • wShowWindow: uint16: The Windows SDK's STARTUPINFOW.wShowWindow.
  • cbReserved2: uint16: The Windows SDK's STARTUPINFOW.cbReserved2.
  • lpReserved2: ptr: The Windows SDK's STARTUPINFOW.lpReserved2.
  • hStdInput: uint64: The Windows SDK's STARTUPINFOW.hStdInput.
  • hStdOutput: uint64: The Windows SDK's STARTUPINFOW.hStdOutput.
  • hStdError: uint64: The Windows SDK's STARTUPINFOW.hStdError.

STARTUPINFOEXW

text
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's STARTUPINFOEXW.StartupInfo.
  • lpAttributeList: ptr: The Windows SDK's STARTUPINFOEXW.lpAttributeList.

COORD

text
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's COORD.X.
  • Y: int16: The Windows SDK's COORD.Y.

SMALL_RECT

text
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's SMALL_RECT.Left.
  • Top: int16: The Windows SDK's SMALL_RECT.Top.
  • Right: int16: The Windows SDK's SMALL_RECT.Right.
  • Bottom: int16: The Windows SDK's SMALL_RECT.Bottom.

CONSOLE_SCREEN_BUFFER_INFO

text
type CONSOLE_SCREEN_BUFFER_INFO = record

The Windows SDK's CONSOLE_SCREEN_BUFFER_INFO.

Members

  • dwSize: COORD: The Windows SDK's CONSOLE_SCREEN_BUFFER_INFO.dwSize.
  • dwCursorPosition: COORD: The Windows SDK's CONSOLE_SCREEN_BUFFER_INFO.dwCursorPosition.
  • wAttributes: uint16: The Windows SDK's CONSOLE_SCREEN_BUFFER_INFO.wAttributes.
  • srWindow: SMALL_RECT: The Windows SDK's CONSOLE_SCREEN_BUFFER_INFO.srWindow.
  • dwMaximumWindowSize: COORD: The Windows SDK's CONSOLE_SCREEN_BUFFER_INFO.dwMaximumWindowSize.

PROCESS_INFORMATION

text
type PROCESS_INFORMATION = record

The Windows SDK's PROCESS_INFORMATION.

Members

  • hProcess: uint64: The Windows SDK's PROCESS_INFORMATION.hProcess.
  • hThread: uint64: The Windows SDK's PROCESS_INFORMATION.hThread.
  • dwProcessId: uint32: The Windows SDK's PROCESS_INFORMATION.dwProcessId.
  • dwThreadId: uint32: The Windows SDK's PROCESS_INFORMATION.dwThreadId.

OSVERSIONINFOW

text
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's OSVERSIONINFOW.dwOSVersionInfoSize: the record's size, set by the caller.
  • dwMajorVersion: uint32: The Windows SDK's OSVERSIONINFOW.dwMajorVersion.
  • dwMinorVersion: uint32: The Windows SDK's OSVERSIONINFOW.dwMinorVersion.
  • dwBuildNumber: uint32: The Windows SDK's OSVERSIONINFOW.dwBuildNumber.
  • dwPlatformId: uint32: The Windows SDK's OSVERSIONINFOW.dwPlatformId.
  • szCSDVersion: array[0..127] of uint16: The Windows SDK's OSVERSIONINFOW.szCSDVersion: the service pack, NUL-terminated UTF-16.

MEMORYSTATUSEX

text
type MEMORYSTATUSEX = record

The Windows SDK's MEMORYSTATUSEX (sysinfoapi.h): GlobalMemoryStatusEx's answer, in bytes

Members

  • dwLength: uint32: The Windows SDK's MEMORYSTATUSEX.dwLength: the record's size, set by the caller.
  • dwMemoryLoad: uint32: The Windows SDK's MEMORYSTATUSEX.dwMemoryLoad.
  • ullTotalPhys: uint64: The Windows SDK's MEMORYSTATUSEX.ullTotalPhys: the physical memory installed.
  • ullAvailPhys: uint64: The Windows SDK's MEMORYSTATUSEX.ullAvailPhys.
  • ullTotalPageFile: uint64: The Windows SDK's MEMORYSTATUSEX.ullTotalPageFile.
  • ullAvailPageFile: uint64: The Windows SDK's MEMORYSTATUSEX.ullAvailPageFile.
  • ullTotalVirtual: uint64: The Windows SDK's MEMORYSTATUSEX.ullTotalVirtual.
  • ullAvailVirtual: uint64: The Windows SDK's MEMORYSTATUSEX.ullAvailVirtual.
  • ullAvailExtendedVirtual: uint64: The Windows SDK's MEMORYSTATUSEX.ullAvailExtendedVirtual.

Constants

NameDeclarationDescription
INVALID_HANDLE_VALUEconst INVALID_HANDLE_VALUE: uint64 = 0xFFFFFFFFFFFFFFFFThe Windows SDK's INVALID_HANDLE_VALUE.
STD_INPUT_HANDLEconst STD_INPUT_HANDLE: uint32 = 0xFFFFFFF6The Windows SDK's STD_INPUT_HANDLE: GetStdHandle's standard input (DWORD)-10, output (DWORD)-11 and error (DWORD)-12
STD_OUTPUT_HANDLEconst STD_OUTPUT_HANDLE: uint32 = 0xFFFFFFF5The Windows SDK's STD_OUTPUT_HANDLE: GetStdHandle's standard input (DWORD)-10, output (DWORD)-11 and error (DWORD)-12
STD_ERROR_HANDLEconst STD_ERROR_HANDLE: uint32 = 0xFFFFFFF4The Windows SDK's STD_ERROR_HANDLE: GetStdHandle's standard input (DWORD)-10, output (DWORD)-11 and error (DWORD)-12
EXTENDED_STARTUPINFO_PRESENTconst EXTENDED_STARTUPINFO_PRESENT: uint32 = 0x00080000The Windows SDK's EXTENDED_STARTUPINFO_PRESENT: CreateProcessW's flag for a STARTUPINFOEXW; the pseudo console attribute (ProcThreadAttributeValue(22, FALSE, TRUE, FALSE))
PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLEconst PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE: uint64 = 0x00020016The 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_LISTconst PROC_THREAD_ATTRIBUTE_HANDLE_LIST: uint64 = 0x00020002The Windows SDK's PROC_THREAD_ATTRIBUTE_HANDLE_LIST: The handles a child inherits, only these (ProcThreadAttributeValue(2, FALSE, TRUE, FALSE))
DUPLICATE_SAME_ACCESSconst DUPLICATE_SAME_ACCESS: uint32 = 0x2The Windows SDK's DUPLICATE_SAME_ACCESS: DuplicateHandle: the copy has the source's access
WAIT_TIMEOUTconst WAIT_TIMEOUT: uint32 = 0x102The Windows SDK's WAIT_TIMEOUT: WaitForSingleObject: the wait ran out with the object not signaled
CP_OEMCPconst CP_OEMCP: uint32 = 1The Windows SDK's CP_OEMCP: The OEM code page (MultiByteToWideChar): what a console tool writes when it is not UTF-8
FILE_TYPE_UNKNOWNconst FILE_TYPE_UNKNOWN: uint32 = 0The Windows SDK's FILE_TYPE_UNKNOWN: GetFileType's answers
FILE_TYPE_DISKconst FILE_TYPE_DISK: uint32 = 1The Windows SDK's FILE_TYPE_DISK: GetFileType's answers
FILE_TYPE_CHARconst FILE_TYPE_CHAR: uint32 = 2The Windows SDK's FILE_TYPE_CHAR: GetFileType's answers
FILE_TYPE_PIPEconst FILE_TYPE_PIPE: uint32 = 3The Windows SDK's FILE_TYPE_PIPE: GetFileType's answers
INVALID_FILE_ATTRIBUTESconst INVALID_FILE_ATTRIBUTES: uint32 = 0xFFFFFFFFThe Windows SDK's INVALID_FILE_ATTRIBUTES: GetFileAttributesW's answer for a path that is not there or cannot be read
FILE_ATTRIBUTE_DIRECTORYconst FILE_ATTRIBUTE_DIRECTORY: uint32 = 0x10The Windows SDK's FILE_ATTRIBUTE_DIRECTORY: a file attribute: the path is a folder
FILE_ATTRIBUTE_READONLYconst FILE_ATTRIBUTE_READONLY: uint32 = 0x1The Windows SDK's FILE_ATTRIBUTE_READONLY: a file attribute: the file is read-only (never written, replaced or deleted until cleared)
FILE_ATTRIBUTE_HIDDENconst FILE_ATTRIBUTE_HIDDEN: uint32 = 0x2The 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_POINTconst FILE_ATTRIBUTE_REPARSE_POINT: uint32 = 0x400The Windows SDK's FILE_ATTRIBUTE_REPARSE_POINT: a file attribute: the path is a reparse point (a junction or symbolic link)
CSTR_EQUALconst CSTR_EQUAL: int32 = 2The Windows SDK's CSTR_EQUAL: CompareStringOrdinal's result for two equal texts
FILE_ATTRIBUTE_NORMALconst FILE_ATTRIBUTE_NORMAL: uint32 = 0x80The Windows SDK's FILE_ATTRIBUTE_NORMAL: a file attribute: none of the others set (SetFileAttributesW's way to clear them all)
HANDLE_FLAG_INHERITconst HANDLE_FLAG_INHERIT: uint32 = 0x1The Windows SDK's HANDLE_FLAG_INHERIT: SetHandleInformation's flag: a child process started with handle inheritance gets the handle
MOVEFILE_REPLACE_EXISTINGconst MOVEFILE_REPLACE_EXISTING: uint32 = 0x1The 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_THROUGHconst MOVEFILE_WRITE_THROUGH: uint32 = 0x8The 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_ALLOWEDconst MOVEFILE_COPY_ALLOWED: uint32 = 0x2The Windows SDK's MOVEFILE_COPY_ALLOWED: MoveFileExW: a move to another volume copies the file, then deletes it
STARTF_USESHOWWINDOWconst STARTF_USESHOWWINDOW: uint32 = 0x1The Windows SDK's STARTF_USESHOWWINDOW: STARTUPINFOW's flag: its wShowWindow field is used
STARTF_USESTDHANDLESconst STARTF_USESTDHANDLES: uint32 = 0x100The Windows SDK's STARTF_USESTDHANDLES: STARTUPINFOW's flag: its hStdInput / hStdOutput / hStdError fields are the child's standard handles
SW_HIDEconst SW_HIDE: uint16 = 0The Windows SDK's SW_HIDE: ShowWindow's / STARTUPINFOW's show state: the window is hidden
NORMAL_PRIORITY_CLASSconst NORMAL_PRIORITY_CLASS: uint32 = 0x20The Windows SDK's NORMAL_PRIORITY_CLASS: CreateProcessW's priority class: the normal one
CREATE_UNICODE_ENVIRONMENTconst CREATE_UNICODE_ENVIRONMENT: uint32 = 0x400The Windows SDK's CREATE_UNICODE_ENVIRONMENT: CreateProcessW's flag: the environment block given is UTF-16
SW_SHOWNORMALconst SW_SHOWNORMAL: uint16 = 1The Windows SDK's SW_SHOWNORMAL: ShowWindow's / ShellExecuteW's show state: the window is shown at its normal size and place
GENERIC_READconst GENERIC_READ: uint32 = 0x80000000The Windows SDK's GENERIC_READ: CreateFileW's access right: the handle reads
FILE_SHARE_READconst FILE_SHARE_READ: uint32 = 0x1The Windows SDK's FILE_SHARE_READ: CreateFileW's share mode: other handles may read the file while this one is open
FILE_SHARE_WRITEconst FILE_SHARE_WRITE: uint32 = 0x2The Windows SDK's FILE_SHARE_WRITE: CreateFileW's share mode: other handles may write the file while this one is open
OPEN_EXISTINGconst OPEN_EXISTING: uint32 = 3The Windows SDK's OPEN_EXISTING: CreateFileW's disposition: the file must already exist
INFINITEconst INFINITE: uint32 = 0xFFFFFFFFThe Windows SDK's INFINITE: a wait with no time limit (WaitForSingleObject and the other wait calls)
ERROR_FILE_NOT_FOUNDconst ERROR_FILE_NOT_FOUND: uint32 = 2The Windows SDK's ERROR_FILE_NOT_FOUND: GetLastError's code: the file named is not there
ERROR_NO_MORE_FILESconst ERROR_NO_MORE_FILES: uint32 = 18The Windows SDK's ERROR_NO_MORE_FILES: GetLastError's code after FindNextFileW: the listing has no more entries
ERROR_ACCESS_DENIEDconst ERROR_ACCESS_DENIED: uint32 = 5The 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_VIOLATIONconst ERROR_SHARING_VIOLATION: uint32 = 32The Windows SDK's ERROR_SHARING_VIOLATION: another process holds the file in a way the call cannot share
ERROR_LOCK_VIOLATIONconst ERROR_LOCK_VIOLATION: uint32 = 33The Windows SDK's ERROR_LOCK_VIOLATION: another process holds a lock on part of the file
ERROR_PROC_NOT_FOUNDconst ERROR_PROC_NOT_FOUND: uint32 = 127The Windows SDK's ERROR_PROC_NOT_FOUND: GetLastError's code after GetProcAddress: the module has no routine of that name
ERROR_NO_UNICODE_TRANSLATIONconst ERROR_NO_UNICODE_TRANSLATION: uint32 = 1113The 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)
GetFileExInfoStandardconst GetFileExInfoStandard: int32 = 0The Windows SDK's GetFileExInfoStandard: GET_FILEEX_INFO_LEVELS' GetFileExInfoStandard
BCRYPT_USE_SYSTEM_PREFERRED_RNGconst BCRYPT_USE_SYSTEM_PREFERRED_RNG: uint32 = 0x2The 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_PROCESSINGconst ENABLE_VIRTUAL_TERMINAL_PROCESSING: uint32 = 0x0004The Windows SDK's ENABLE_VIRTUAL_TERMINAL_PROCESSING: SetConsoleMode's ENABLE_VIRTUAL_TERMINAL_PROCESSING (an output handle's mode)
CP_UTF8const CP_UTF8: uint32 = 65001The Windows SDK's CP_UTF8: UTF-8's code page (SetConsoleOutputCP, MultiByteToWideChar)
KEY_EVENTconst KEY_EVENT: uint16 = 0x0001The Windows SDK's KEY_EVENT: INPUT_RECORD's EventType for a key
IMAGE_SIZEOF_FILE_HEADERconst IMAGE_SIZEOF_FILE_HEADER: int32 = 20The 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_HEADERconst IMAGE_SIZEOF_SECTION_HEADER: int32 = 40The 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_RELOCATIONconst IMAGE_SIZEOF_RELOCATION: int32 = 10The 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_SYMBOLconst IMAGE_SIZEOF_SYMBOL: int32 = 18The 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_NAMEconst IMAGE_SIZEOF_SHORT_NAME: int32 = 8The 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_AMD64const IMAGE_FILE_MACHINE_AMD64: uint16 = 0x8664The Windows SDK's IMAGE_FILE_MACHINE_AMD64: The Machine field (also StackWalk64's machine) and the x64 relocation types
IMAGE_REL_AMD64_ADDR64const IMAGE_REL_AMD64_ADDR64: uint16 = 0x0001The Windows SDK's IMAGE_REL_AMD64_ADDR64: The Machine field (also StackWalk64's machine) and the x64 relocation types
IMAGE_REL_AMD64_ADDR32NBconst IMAGE_REL_AMD64_ADDR32NB: uint16 = 0x0003The Windows SDK's IMAGE_REL_AMD64_ADDR32NB: The Machine field (also StackWalk64's machine) and the x64 relocation types
IMAGE_REL_AMD64_REL32const IMAGE_REL_AMD64_REL32: uint16 = 0x0004The Windows SDK's IMAGE_REL_AMD64_REL32: The Machine field (also StackWalk64's machine) and the x64 relocation types
IMAGE_REL_AMD64_SECTIONconst IMAGE_REL_AMD64_SECTION: uint16 = 0x000AThe Windows SDK's IMAGE_REL_AMD64_SECTION: The Machine field (also StackWalk64's machine) and the x64 relocation types
IMAGE_REL_AMD64_SECRELconst IMAGE_REL_AMD64_SECREL: uint16 = 0x000BThe Windows SDK's IMAGE_REL_AMD64_SECREL: The Machine field (also StackWalk64's machine) and the x64 relocation types
IMAGE_SCN_CNT_CODEconst IMAGE_SCN_CNT_CODE: uint32 = 0x00000020The Windows SDK's IMAGE_SCN_CNT_CODE: Section Flags
IMAGE_SCN_CNT_INITIALIZED_DATAconst IMAGE_SCN_CNT_INITIALIZED_DATA: uint32 = 0x00000040The Windows SDK's IMAGE_SCN_CNT_INITIALIZED_DATA: Section Flags
IMAGE_SCN_CNT_UNINITIALIZED_DATAconst IMAGE_SCN_CNT_UNINITIALIZED_DATA: uint32 = 0x00000080The Windows SDK's IMAGE_SCN_CNT_UNINITIALIZED_DATA: Section Flags
IMAGE_SCN_LNK_INFOconst IMAGE_SCN_LNK_INFO: uint32 = 0x00000200The Windows SDK's IMAGE_SCN_LNK_INFO: An Info section: comments / compiler data no linker puts in an image
IMAGE_SCN_LNK_REMOVEconst IMAGE_SCN_LNK_REMOVE: uint32 = 0x00000800The 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_COMDATconst IMAGE_SCN_LNK_COMDAT: uint32 = 0x00001000The 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_16BITconst IMAGE_SCN_MEM_16BIT: uint32 = 0x00020000The Windows SDK's IMAGE_SCN_MEM_16BIT: The 16-bit flag a PDB's section map entries carry
IMAGE_SCN_LNK_NRELOC_OVFLconst IMAGE_SCN_LNK_NRELOC_OVFL: uint32 = 0x01000000The 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_DISCARDABLEconst IMAGE_SCN_MEM_DISCARDABLE: uint32 = 0x02000000The Windows SDK's IMAGE_SCN_MEM_DISCARDABLE: a section flag: the loader may discard the section once the image is loaded
IMAGE_SCN_MEM_EXECUTEconst IMAGE_SCN_MEM_EXECUTE: uint32 = 0x20000000The Windows SDK's IMAGE_SCN_MEM_EXECUTE: a section flag: the section's memory can run as code
IMAGE_SCN_MEM_READconst IMAGE_SCN_MEM_READ: uint32 = 0x40000000The Windows SDK's IMAGE_SCN_MEM_READ: a section flag: the section's memory can be read
IMAGE_SCN_MEM_WRITEconst IMAGE_SCN_MEM_WRITE: uint32 = 0x80000000The Windows SDK's IMAGE_SCN_MEM_WRITE: a section flag: the section's memory can be written
IMAGE_SYM_CLASS_EXTERNALconst IMAGE_SYM_CLASS_EXTERNAL: uint8 = 2The Windows SDK's IMAGE_SYM_CLASS_EXTERNAL: Storage classes (COFF Symbol Table)
IMAGE_SYM_CLASS_STATICconst IMAGE_SYM_CLASS_STATIC: uint8 = 3The Windows SDK's IMAGE_SYM_CLASS_STATIC: Storage classes (COFF Symbol Table)
IMAGE_SYM_CLASS_LABELconst IMAGE_SYM_CLASS_LABEL: uint8 = 6The Windows SDK's IMAGE_SYM_CLASS_LABEL: Storage classes (COFF Symbol Table)
IMAGE_SYM_CLASS_FILEconst IMAGE_SYM_CLASS_FILE: uint8 = 103The Windows SDK's IMAGE_SYM_CLASS_FILE: Storage classes (COFF Symbol Table)
IMAGE_SYM_CLASS_SECTIONconst IMAGE_SYM_CLASS_SECTION: uint8 = 104The Windows SDK's IMAGE_SYM_CLASS_SECTION: Storage classes (COFF Symbol Table)
IMAGE_SYM_CLASS_WEAK_EXTERNALconst IMAGE_SYM_CLASS_WEAK_EXTERNAL: uint8 = 105The Windows SDK's IMAGE_SYM_CLASS_WEAK_EXTERNAL: Storage classes (COFF Symbol Table)
IMAGE_COMDAT_SELECT_NODUPLICATESconst IMAGE_COMDAT_SELECT_NODUPLICATES: uint8 = 1The Windows SDK's IMAGE_COMDAT_SELECT_NODUPLICATES: COMDAT selections (COMDAT Sections)
IMAGE_COMDAT_SELECT_ANYconst IMAGE_COMDAT_SELECT_ANY: uint8 = 2The Windows SDK's IMAGE_COMDAT_SELECT_ANY: COMDAT selections (COMDAT Sections)
IMAGE_COMDAT_SELECT_SAME_SIZEconst IMAGE_COMDAT_SELECT_SAME_SIZE: uint8 = 3The Windows SDK's IMAGE_COMDAT_SELECT_SAME_SIZE: COMDAT selections (COMDAT Sections)
IMAGE_COMDAT_SELECT_EXACT_MATCHconst IMAGE_COMDAT_SELECT_EXACT_MATCH: uint8 = 4The Windows SDK's IMAGE_COMDAT_SELECT_EXACT_MATCH: COMDAT selections (COMDAT Sections)
IMAGE_COMDAT_SELECT_ASSOCIATIVEconst IMAGE_COMDAT_SELECT_ASSOCIATIVE: uint8 = 5The Windows SDK's IMAGE_COMDAT_SELECT_ASSOCIATIVE: COMDAT selections (COMDAT Sections)
IMAGE_COMDAT_SELECT_LARGESTconst IMAGE_COMDAT_SELECT_LARGEST: uint8 = 6The Windows SDK's IMAGE_COMDAT_SELECT_LARGEST: COMDAT selections (COMDAT Sections)
IMAGE_SYM_UNDEFINEDconst IMAGE_SYM_UNDEFINED: int16 = 0The Windows SDK's IMAGE_SYM_UNDEFINED: Section Number Values ((SHORT) in winnt.h)
IMAGE_SYM_ABSOLUTEconst IMAGE_SYM_ABSOLUTE: int16 = -1The Windows SDK's IMAGE_SYM_ABSOLUTE: Section Number Values ((SHORT) in winnt.h)
IMAGE_SYM_DEBUGconst IMAGE_SYM_DEBUG: int16 = -2The Windows SDK's IMAGE_SYM_DEBUG: Section Number Values ((SHORT) in winnt.h)
UNW_FLAG_EHANDLERconst UNW_FLAG_EHANDLER: uint8 = 1The 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_UHANDLERconst UNW_FLAG_UHANDLER: uint8 = 2The 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_CHAININFOconst UNW_FLAG_CHAININFO: uint8 = 4The 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_NOLIBRARYconst IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY: uint32 = 1The Windows SDK's IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY: Weak external search kinds (Auxiliary Format 3's Characteristics)
IMAGE_WEAK_EXTERN_SEARCH_LIBRARYconst IMAGE_WEAK_EXTERN_SEARCH_LIBRARY: uint32 = 2The Windows SDK's IMAGE_WEAK_EXTERN_SEARCH_LIBRARY: Weak external search kinds (Auxiliary Format 3's Characteristics)
IMAGE_WEAK_EXTERN_SEARCH_ALIASconst IMAGE_WEAK_EXTERN_SEARCH_ALIAS: uint32 = 3The Windows SDK's IMAGE_WEAK_EXTERN_SEARCH_ALIAS: Weak external search kinds (Auxiliary Format 3's Characteristics)
IMAGE_DOS_SIGNATUREconst IMAGE_DOS_SIGNATURE: uint16 = 0x5A4DThe 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_SIGNATUREconst IMAGE_NT_SIGNATURE: uint32 = 0x00004550The 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_STRIPPEDconst IMAGE_FILE_RELOCS_STRIPPED: uint16 = 0x0001The 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_IMAGEconst IMAGE_FILE_EXECUTABLE_IMAGE: uint16 = 0x0002The 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_AWAREconst IMAGE_FILE_LARGE_ADDRESS_AWARE: uint16 = 0x0020The 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_DLLconst IMAGE_FILE_DLL: uint16 = 0x2000The 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_MAGICconst IMAGE_NT_OPTIONAL_HDR64_MAGIC: uint16 = 0x20BThe 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_ENTRIESconst IMAGE_NUMBEROF_DIRECTORY_ENTRIES: int32 = 16The 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_EXPORTconst IMAGE_DIRECTORY_ENTRY_EXPORT: int32 = 0The 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_IMPORTconst IMAGE_DIRECTORY_ENTRY_IMPORT: int32 = 1The 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_RESOURCEconst IMAGE_DIRECTORY_ENTRY_RESOURCE: int32 = 2The 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_EXCEPTIONconst IMAGE_DIRECTORY_ENTRY_EXCEPTION: int32 = 3The 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_BASERELOCconst IMAGE_DIRECTORY_ENTRY_BASERELOC: int32 = 5The 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_DEBUGconst IMAGE_DIRECTORY_ENTRY_DEBUG: int32 = 6The 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_TLSconst IMAGE_DIRECTORY_ENTRY_TLS: int32 = 9The 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_IATconst IMAGE_DIRECTORY_ENTRY_IAT: int32 = 12The 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_GUIconst IMAGE_SUBSYSTEM_WINDOWS_GUI: uint16 = 2The 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_CUIconst IMAGE_SUBSYSTEM_WINDOWS_CUI: uint16 = 3The 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_VAconst IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA: uint16 = 0x0020The 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_BASEconst IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE: uint16 = 0x0040The 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_COMPATconst IMAGE_DLLCHARACTERISTICS_NX_COMPAT: uint16 = 0x0100The 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_CODEVIEWconst IMAGE_DEBUG_TYPE_CODEVIEW: uint32 = 2The 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_DIR64const IMAGE_REL_BASED_DIR64: uint16 = 10The Windows SDK's IMAGE_REL_BASED_DIR64: A base relocation's type (Base Relocation Types)
IMAGE_ARCHIVE_STARTconst 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_HDRconst IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR: int32 = 60The Windows SDK's IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR: Archives (Archive (Library) File Format) and short import headers (Import Library Format)
IMPORT_OBJECT_HDR_SIG2const IMPORT_OBJECT_HDR_SIG2: uint16 = 0xFFFFThe Windows SDK's IMPORT_OBJECT_HDR_SIG2: Archives (Archive (Library) File Format) and short import headers (Import Library Format)
IMPORT_OBJECT_CODEconst IMPORT_OBJECT_CODE: int32 = 0The Windows SDK's IMPORT_OBJECT_CODE: Archives (Archive (Library) File Format) and short import headers (Import Library Format)
IMPORT_OBJECT_DATAconst IMPORT_OBJECT_DATA: int32 = 1The Windows SDK's IMPORT_OBJECT_DATA: Archives (Archive (Library) File Format) and short import headers (Import Library Format)
IMPORT_OBJECT_NAMEconst IMPORT_OBJECT_NAME: int32 = 1The Windows SDK's IMPORT_OBJECT_NAME: Archives (Archive (Library) File Format) and short import headers (Import Library Format)
RT_ICONconst RT_ICON: uint16 = 3The 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_ICONconst RT_GROUP_ICON: uint16 = 14The 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_VERSIONconst RT_VERSION: uint16 = 16The 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_NEUTRALconst LANG_NEUTRAL: uint16 = 0The 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_INFOconst VS_VERSION_INFO: uint16 = 1The 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_SIGNATUREconst VS_FFI_SIGNATURE: uint32 = 0xFEEF04BDThe 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_STRUCVERSIONconst VS_FFI_STRUCVERSION: uint32 = 0x00010000The 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_FILEFLAGSMASKconst VS_FFI_FILEFLAGSMASK: uint32 = 0x3FThe 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_WINDOWS32const VOS_NT_WINDOWS32: uint32 = 0x00040004The 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_APPconst VFT_APP: uint32 = 1The 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_DLLconst VFT_DLL: uint32 = 2The 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_DATAFILEconst LOAD_LIBRARY_AS_DATAFILE: uint32 = 0x00000002The 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_RESOURCEconst LOAD_LIBRARY_AS_IMAGE_RESOURCE: uint32 = 0x00000020The Windows SDK's LOAD_LIBRARY_AS_IMAGE_RESOURCE: LoadLibraryExW's flags for an image whose resources are read, never run (libloaderapi.h)
WS_CHILDconst WS_CHILD: uint32 = 0x40000000The 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_APPWINDOWconst WS_EX_APPWINDOW: uint32 = 0x00040000The Windows SDK's WS_EX_APPWINDOW: The extended style of a window the taskbar shows a button for (winuser.h)
WM_GETICONconst WM_GETICON: uint32 = 0x007FThe Windows SDK's WM_GETICON: the window message that asks a window for its small or big icon (winuser.h)
WM_SETICONconst WM_SETICON: uint32 = 0x0080The Windows SDK's WM_SETICON: the window message that sets a window's small or big icon (winuser.h)
ICON_SMALLconst ICON_SMALL: uint64 = 0The Windows SDK's ICON_SMALL: WM_GETICON / WM_SETICON's which: the small icon (title bar, Alt+Tab's small list)
ICON_BIGconst ICON_BIG: uint64 = 1The Windows SDK's ICON_BIG: WM_GETICON / WM_SETICON's which: the big icon (Alt+Tab, the taskbar)
IMAGE_ICONconst IMAGE_ICON: uint32 = 1The Windows SDK's IMAGE_ICON: LoadImageW's image type and load flags, GetSystemMetrics' icon sizes (winuser.h)
LR_DEFAULTCOLORconst LR_DEFAULTCOLOR: uint32 = 0x00000000The Windows SDK's LR_DEFAULTCOLOR: LoadImageW's image type and load flags, GetSystemMetrics' icon sizes (winuser.h)
SM_CXICONconst SM_CXICON: int32 = 11The Windows SDK's SM_CXICON: LoadImageW's image type and load flags, GetSystemMetrics' icon sizes (winuser.h)
SM_CYICONconst SM_CYICON: int32 = 12The Windows SDK's SM_CYICON: LoadImageW's image type and load flags, GetSystemMetrics' icon sizes (winuser.h)
SM_CXSMICONconst SM_CXSMICON: int32 = 49The Windows SDK's SM_CXSMICON: LoadImageW's image type and load flags, GetSystemMetrics' icon sizes (winuser.h)
SM_CYSMICONconst SM_CYSMICON: int32 = 50The Windows SDK's SM_CYSMICON: LoadImageW's image type and load flags, GetSystemMetrics' icon sizes (winuser.h)
_O_RDONLYconst _O_RDONLY: int32 = 0x0000The 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_WRONLYconst _O_WRONLY: int32 = 0x0001The 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_RDWRconst _O_RDWR: int32 = 0x0002The 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_ACCMODEconst _O_ACCMODE: int32 = 0x0003The 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_APPENDconst _O_APPEND: int32 = 0x0008The 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_RANDOMconst _O_RANDOM: int32 = 0x0010The 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_SEQUENTIALconst _O_SEQUENTIAL: int32 = 0x0020The 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_TEMPORARYconst _O_TEMPORARY: int32 = 0x0040The 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_NOINHERITconst _O_NOINHERIT: int32 = 0x0080The 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_CREATconst _O_CREAT: int32 = 0x0100The 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_TRUNCconst _O_TRUNC: int32 = 0x0200The 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_EXCLconst _O_EXCL: int32 = 0x0400The 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_LIVEDconst _O_SHORT_LIVED: int32 = 0x1000The 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_DIRconst _O_OBTAIN_DIR: int32 = 0x2000The 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_TEXTconst _O_TEXT: int32 = 0x4000The 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_BINARYconst _O_BINARY: int32 = 0x8000The 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_WTEXTconst _O_WTEXT: int32 = 0x10000The 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_U16TEXTconst _O_U16TEXT: int32 = 0x20000The 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_U8TEXTconst _O_U8TEXT: int32 = 0x40000The 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_DENYRWconst _SH_DENYRW: int32 = 0x10The 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_DENYWRconst _SH_DENYWR: int32 = 0x20The 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_DENYRDconst _SH_DENYRD: int32 = 0x30The 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_DENYNOconst _SH_DENYNO: int32 = 0x40The 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_SECUREconst _SH_SECURE: int32 = 0x80The 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_IFMTconst _S_IFMT: uint16 = 0xF000The 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_IFDIRconst _S_IFDIR: uint16 = 0x4000The 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_IFCHRconst _S_IFCHR: uint16 = 0x2000The 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_IFIFOconst _S_IFIFO: uint16 = 0x1000The 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_IFREGconst _S_IFREG: uint16 = 0x8000The 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_IREADconst _S_IREAD: uint16 = 0x0100The 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_IWRITEconst _S_IWRITE: uint16 = 0x0080The 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_IEXECconst _S_IEXEC: uint16 = 0x0040The 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_OKconst W_OK: int32 = 2The Windows SDK's W_OK: mingw-w64's io.h: _access' write mode
_IOFBFconst _IOFBF: int32 = 0x0000The 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
_IOLBFconst _IOLBF: int32 = 0x0040The 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
_IONBFconst _IONBF: int32 = 0x0004The 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
BUFSIZconst BUFSIZ: uint64 = 512uThe 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_MAXconst MB_LEN_MAX: int32 = 5The 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_MAXconst INT_MAX: int32 = 2147483647The 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_MAXconst LONG_MAX: int32 = 2147483647The 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
_ARGMAXconst _ARGMAX: int32 = 100The 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_BEHAVIORconst _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR: uint64 = 2uThe 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_SPECIFIERSconst _CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS: uint64 = 4uThe 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_COMPATIBILITYconst _CRT_INTERNAL_PRINTF_LEGACY_MSVCRT_COMPATIBILITY: uint64 = 8uThe 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_MACHINEconst HKEY_LOCAL_MACHINE: uint64 = 0x80000002The Windows SDK's HKEY_LOCAL_MACHINE (winreg.h): the machine's registry hive, a predefined key
RRF_RT_REG_SZconst RRF_RT_REG_SZ: uint32 = 0x00000002The Windows SDK's RRF_RT_REG_SZ (winreg.h): RegGetValueW takes a REG_SZ value only
ALL_PROCESSOR_GROUPSconst ALL_PROCESSOR_GROUPS: uint16 = 0xFFFFThe 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

text
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

text
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

text
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

text
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 fault
  • Column: int64: The column at fault; 0 when libxml2 gives none
  • Message: string: What is wrong, in libxml2's words
  • IsWarning: bool: Whether it is only a warning (the document still validates)

Example: for LFinding in LFindings do println("{}: {}", LFinding.Line, LFinding.Message); end;

XMLFindings

text
type XMLFindings = array of XMLFinding

Every finding of one validation, in the order found.

XMLKind

text
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

text
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

text
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

text
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: AExpression the 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: APrefix the 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; ANamespaceURI the 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: AName the name without its $ ("id" for $id); AValue the 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: AName the name without its $; AValue the 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: AName the name without its $; AValue the 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: AName the name without its $; AValue the 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: AName the name without its $; AValue the 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: ADoc the document; ANode the 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

text
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: AKind what it is written in; APath the 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: AKind what it is written in; AText the 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: AKind what it is written in; AIO the 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: ADoc the document; AFindings every 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

text
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: AText the 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: AText the XML text; AOptions what 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: APath the 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: APath the file; AOptions what 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: AIO the 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: AIO the IO; AOptions what 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: AText the 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: APath the 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: AIO the 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: AText the 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: AText the XML text; AOptions what 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: APath the 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: APath the file; AOptions what 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: AIO the 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: AIO the IO (stays the caller's); AOptions what 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: AText the XML text; AXML the 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: AText the XML text; AOptions what the read does besides parsing; AXML the 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: AText the 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: APath the 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: AIO the 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: AName the 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: AName the 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: AName the attribute's name; ADefault the 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: AName the attribute's name; ADefault the 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: AName the attribute's name; ADefault the 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: AName the attribute's name; ADefault the 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: AName the attribute's name; ADefault the 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: AName the attribute's name; AValue the 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: AName the attribute's name; AValue the 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: AName the attribute's name; AValue the 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: AName the attribute's name; AValue the 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: AName the attribute's name; AValue the 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: AName the 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: AName the 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: AName the 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: APath the compiled expression (its ErrorText says why a run failed). Returns: the nodes as a for .. in sequence; 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: AExpression the expression ("item[@price > 10]", "//p:title", "@*" ...). Returns: the nodes as a for .. in sequence; 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: APath the 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: AExpression the 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: APath the compiled expression; ADefault what 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: APath the 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: APath the compiled expression; ADefault what 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: APath the compiled expression; ADefault what 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: APath the compiled expression; ADefault what 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: APath the compiled expression; ADefault what 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: AExpression the 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: AExpression the expression; ADefault what 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: AExpression the expression ("sum(item/@price)" ...); ADefault what 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: AExpression the expression ("count(item)" ...); ADefault what 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: AExpression the expression; ADefault what 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: AExpression the expression ("boolean(item[@sold])" ...); ADefault what 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: AFindings every 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: ASchema the schema (a DTD, an XSD or a RelaxNG one); AFindings every 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: ASchema the 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: AName the 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); See XML.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: AName the root element's name, "local" or "prefix:local"; ANamespaceURI the 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: APrefix the prefix ("" for the default namespace); ANamespaceURI the 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: AName as AddElement takes it; AText the 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: AText the 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: AText the 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: AText the 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: AText the 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; AValue the 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: AName as the string form takes it; AValue the 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: AName as the string form takes it; AValue the 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: AName as the string form takes it; AValue the 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: AName as the string form takes it; AValue the 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: APath the 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: APath the file; APretty whether 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: APath the file; APretty whether a line per element; AEncoding libxml2'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: AIO the 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: AIO the IO written; APretty whether 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: AIO the IO written; APretty whether a line per element; AEncoding libxml2'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: AForm C14N, ExclusiveC14N or C14N11; AWithComments whether 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: APath the 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: APath the file; AForm C14N, ExclusiveC14N or C14N11; AWithComments whether 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: AIO the 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: AIO the IO written; AForm C14N, ExclusiveC14N or C14N11; AWithComments whether 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: ADoc the 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

text
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

text
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: APath the 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: APath the file; AOptions what 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: AText the 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: AText the XML text; AOptions what 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: AIO the 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: AIO the IO; AOptions what 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: AName the attribute's name as written ("id", "xlink:href"); AValue its 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: AName the 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: AName the 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: AName the attribute's name as written; ADefault what 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: AName the attribute's name as written; ADefault what 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: AName the attribute's name as written; ADefault what 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: AName the attribute's name as written; ADefault what 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

text
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: APath the 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: APath the file; APretty whether 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: AIO the 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: AIO the IO written; APretty whether 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: APretty whether 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: AEncoding libxml2'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: AName the 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"; ANamespaceURI the 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: AName the name as written; AText its 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: AName the name as written ("id", "xmlns:p", "p:kind"); AValue its 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: AName the name as written; AValue the 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: AName the name as written; AValue the 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: AName the name as written; AValue the 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: AName the name as written; AValue the 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: AText the 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: AText the text (it must not hold "]]>"). Returns: this writer Example: LOut.WriteCData("<raw>");
  • const method WriteComment(const AText: string): XMLWriter: Writes the comment <!--AText-->. Parameters: AText the 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: ATarget its target ("xml-stylesheet" ...); AContent its 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: AName the root element's name; APublicId the public id; "" for none; ASystemId the 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: AText the 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

text
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

text
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

text
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 bytes
  • AFormat: the framing written around the data
  • ALevel: Z_DEFAULT_COMPRESSION, or 0 (none) .. 9 (best)
  • AOut: the compressed bytes
  • AErrorText: 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

text
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 stream
  • AFormat: the framing around it
  • AOut: the decompressed bytes
  • AErrorText: 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

↑ ↓ moveEnter openEsc close