Console v0.1.0

Source
Allocating, reading and writing the console.

WriteConsoleW

pub extern func WriteConsoleW(
    consoleOutput: *var opaque,
    buffer: *opaque,
    numberOfCharsToWrite: uint32,
    numberOfCharsWritten: *var uint32,
    reserved: *var opaque
) -> int32

pub extern func WriteConsoleW(
    consoleOutput: *opaque,
    buffer: *char16,
    numberOfCharsToWrite: uint32,
    numberOfCharsWritten: *uint32,
    reserved: *opaque
) -> bool32

Writes a character string to a console screen buffer beginning at the current cursor location.

OverloadSummary
pub extern func WriteConsoleW(consoleOutput: *var opaque, buffer: *opaque, numberOfCharsToWrite: uint32, numberOfCharsWritten: *var uint32, reserved: *var opaque) -> int32Writes UTF-16 to a console screen buffer.
pub extern func WriteConsoleW(consoleOutput: *opaque, buffer: *char16, numberOfCharsToWrite: uint32, numberOfCharsWritten: *uint32, reserved: *opaque) -> bool32Writes a character string to a console screen buffer beginning at the current cursor location.

See also: https://learn.microsoft.com/en-us/windows/console/writeconsole

Source

Parameters

NameTypeDescription
consoleOutput*var opaque / *opaquea console output handle
buffer*opaque / *char16the bytes
numberOfCharsToWriteuint32how many units to write
numberOfCharsWritten*var uint32 / *uint32receives how many were written
reserved*var opaque / *opaquereserved; pass null

Returns: non-zero on success, and zero on failure with the reason in GetLastError

ReadConsoleW

pub extern func ReadConsoleW(
    consoleInput: *var opaque,
    buffer: *var opaque,
    numberOfCharsToRead: uint32,
    numberOfCharsRead: *var uint32,
    inputControl: *var opaque
) -> int32

Reads UTF-16 from a console input buffer.

See also: https://learn.microsoft.com/en-us/windows/console/readconsole

Source

Parameters

NameTypeDescription
consoleInput*var opaquea console input handle
buffer*var opaquethe bytes
numberOfCharsToReaduint32how many units to ask for
numberOfCharsRead*var uint32receives how many were read
inputControl*var opaquean input-control record, or null

Returns: non-zero on success

AllocConsole

pub extern func AllocConsole() -> bool32

Allocates a new console for the calling process.

See also: https://learn.microsoft.com/en-us/windows/console/allocconsole

Source

Returns: non-zero on success, and zero on failure with the reason in GetLastError

Beep

pub extern func Beep(
    freq: uint32,
    duration: uint32
) -> bool32

Generates simple tones on the speaker.

See also: https://learn.microsoft.com/en-us/windows/win32/api/utilapiset/nf-utilapiset-beep

Source

Parameters

NameTypeDescription
frequint32the tone's frequency in hertz
durationuint32how long to sound it, in milliseconds

Returns: non-zero on success, and zero on failure with the reason in GetLastError

GetConsoleMode

pub extern func GetConsoleMode(
    consoleHandle: *opaque,
    mode: *uint32
) -> bool32

Retrieves the current input or output mode of a console screen buffer.

See also: https://learn.microsoft.com/en-us/windows/console/getconsolemode

Source

Parameters

NameTypeDescription
consoleHandle*opaquea console handle
mode*uint32receives the console mode bits

Returns: non-zero on success, and zero on failure with the reason in GetLastError

GetStdHandle

pub extern func GetStdHandle(stdHandle: uint32) -> *opaque

Retrieves a handle to the specified standard device (standard input, standard output, or standard error).

See also: https://learn.microsoft.com/en-us/windows/console/getstdhandle

Source

Parameters

NameTypeDescription
stdHandleuint32one of StdInputHandle, StdOutputHandle or StdErrorHandle

Returns: the standard handle, or InvalidHandleValue

ReadConsoleA

pub extern func ReadConsoleA(
    consoleInput: *opaque,
    buffer: *opaque,
    numberOfCharsToRead: uint32,
    numberOfCharsRead: *uint32,
    inputControl: *opaque
) -> bool32

Reads characters from a console input buffer.

See also: https://learn.microsoft.com/en-us/windows/console/readconsole

Source

Parameters

NameTypeDescription
consoleInput*opaquea console input handle
buffer*opaquethe bytes
numberOfCharsToReaduint32how many units to ask for
numberOfCharsRead*uint32receives how many were read
inputControl*opaquean input-control record, or null

Returns: non-zero on success, and zero on failure with the reason in GetLastError

WriteConsoleA

pub extern func WriteConsoleA(
    consoleOutput: *opaque,
    buffer: *char8,
    numberOfCharsToWrite: uint32,
    numberOfCharsWritten: *uint32,
    reserved: *opaque
) -> bool32

Writes a character string to a console screen buffer beginning at the current cursor location.

See also: https://learn.microsoft.com/en-us/windows/console/writeconsole

Source

Parameters

NameTypeDescription
consoleOutput*opaquea console output handle
buffer*char8the bytes
numberOfCharsToWriteuint32how many units to write
numberOfCharsWritten*uint32receives how many were written
reserved*opaquereserved; pass null

Returns: non-zero on success, and zero on failure with the reason in GetLastError

StdInputHandle

pub const StdInputHandle: uint32 = 0xFFFFFFF6;

The public StdInputHandle value.

Source

StdOutputHandle

pub const StdOutputHandle: uint32 = 0xFFFFFFF5;

The public StdOutputHandle value.

Source

StdErrorHandle

pub const StdErrorHandle: uint32 = 0xFFFFFFF4;

The public StdErrorHandle value.

Source