Module cmd

Source
Expand description

A library of useful terminal commands.

This module provides a number of straight-forward struct and enum types that implement the Command trait and, where needed, also the Sgr and Query traits. Organized by topic, this library covers the following 86 commands:

Most commands are implemented by zero-sized unit structs and enum variants. Commands that require arguments may come in one or both of two flavors, a static flavor relying on const generics and a dynamic flavor storing the arguments. The command name for the latter flavor starts with Dyn; it obviously is not zero-sized.

If a command name starts with Request, it also implements the Query trait and hence knows how to parse the response’s payload. When implementing your own queries, you may find util::ByteParser useful.

You can easily combine several commands into a compound command with the fuse! and fuse_sgr! macros.

§Example

Executing a command is as simple as writing its display:

println!(
    "{}Wow!{}",
    fuse_sgr!(Format::Bold, Format::Underlined, SetForeground8::<124>),
    ResetStyle
);

The invocation of the fuse_sgr! macro in the above example is not strictly necessary. Separately writing Format::Bold, Format::Underlined, and SetForeground8::<124> to the console would set the same style. However, that would also write three distinct ANSI escape sequences, whereas fuse_sgr! returns a value that writes only one ANSI escape sequence. After receiving the above text, the terminal prints wow!. Wow indeed 😜

Structs§

BeginBatch
The unit BeginBatch command.
BeginPaste
The unit BeginPaste command.
DisableAutowrap
The unit DisableAutowrap command.
DisableReverseMode
The unit DisableReverseMode command.
DynLink
The dynamic DynLink(ID, HREF, TEXT) command.
DynMoveDown
The dynamic DynMoveDown(ROWS) command.
DynMoveLeft
The dynamic DynMoveLeft(COLUMNS) command.
DynMoveRight
The dynamic DynMoveRight(COLUMNS) command.
DynMoveTo
The dynamic DynMoveTo(ROW, COLUMN) command.
DynMoveToColumn
The dynamic DynMoveToColumn(COLUMN) command.
DynMoveToRow
The dynamic DynMoveToRow(ROW) command.
DynMoveUp
The dynamic DynMoveUp(ROWS) command.
DynScrollDown
The dynamic DynScrollDown(ROWS) command.
DynScrollUp
The dynamic DynScrollUp(ROWS) command.
DynSetBackground8
The dynamic DynSetBackground8(COLOR) command.
DynSetBackground24
The dynamic DynSetBackground24(R, G, B) command.
DynSetForeground8
The dynamic DynSetForeground8(COLOR) command.
DynSetForeground24
The dynamic DynSetForeground24(R, G, B) command.
DynSetScrollRegion
The dynamic DynSetScrollRegion(TOP, BOTTOM) command.
DynSetWindowTitle
The dynamic DynSetWindowTitle(String) command.
EnableAutowrap
The unit EnableAutowrap command.
EnableReverseMode
The unit EnableReverseMode command.
EndBatch
The unit EndBatch command.
EndPaste
The unit EndPaste command.
EnterAlternateScreen
The unit EnterAlternateScreen command.
EraseLine
The unit EraseLine command.
EraseRestOfLine
The unit EraseRestOfLine command.
EraseScreen
The unit EraseScreen command.
ExitAlternateScreen
The unit ExitAlternateScreen command.
HideCursor
The unit HideCursor command.
MoveDown
The static MoveDown<ROWS> command.
MoveLeft
The static MoveLeft<COLUMNS> command.
MoveRight
The static MoveRight<COLUMNS> command.
MoveTo
The static MoveTo<ROW, COLUMN> command.
MoveToColumn
The static MoveToColumn<COLUMN> command.
MoveToRow
The static MoveToRow<ROW> command.
MoveUp
The static MoveUp<ROWS> command.
RequestActiveStyle
The unit RequestActiveStyle command.
RequestBatchMode
The unit RequestBatchMode command.
RequestCursorPosition
The unit RequestCursorPosition command.
RequestScreenSize
The unit RequestScreenSize command.
RequestTerminalId
The unit RequestTerminalId command.
ResetScrollRegion
The unit ResetScrollRegion command.
ResetStyle
The unit ResetStyle command.
RestoreCursorPosition
The unit RestoreCursorPosition command.
RestoreWindowTitle
The unit RestoreWindowTitle command.
SaveCursorPosition
The unit SaveCursorPosition command.
SaveWindowTitle
The unit SaveWindowTitle command.
ScrollDown
The static ScrollDown<ROWS> command.
ScrollUp
The static ScrollUp<ROWS> command.
SetBackground8
The static SetBackground8<COLOR> command.
SetBackground24
The static SetBackground24<R, G, B> command.
SetDefaultBackground
The unit SetDefaultBackground command.
SetDefaultForeground
The unit SetDefaultForeground command.
SetForeground8
The static SetForeground8<COLOR> command.
SetForeground24
The static SetForeground24<R, G, B> command.
SetScrollRegion
The static SetScrollRegion<TOP, BOTTOM> command.
ShowCursor
The unit ShowCursor command.

Enums§

BatchMode
The current batch processing mode.
Format
The enumeration of unit Format commands.
RequestColor
The enumeration of unit RequestColor commands.
SetCursor