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 87
commands:
- Terminal identification:
- Window title management:
- Screen management:
- Scrolling:
- Cursor management:
SetCursor::Default,SetCursor::BlinkingBlock,SetCursor::SteadyBlock,SetCursor::BlinkingUnderscore,SetCursor::SteadyUnderscore,SetCursor::BlinkingBar, andSetCursor::SteadyBar.HideCursorandShowCursorRequestCursorPosition- Relative
MoveUp,MoveDown,MoveLeft,MoveRight,DynMoveUp,DynMoveDown,DynMoveLeft, andDynMoveRight - Absolute
MoveToColumn,MoveToRow,MoveTo,DynMoveToColumn,DynMoveToRow, andDynMoveTo SaveCursorPositionandRestoreCursorPosition
- Managing content:
EraseLineandEraseRestOfLineBeginBatchandEndBatchto group updatesBeginPasteandEndPasteto perform bracketed paste operationsDynLinkto add hyperlinks
- Managing modes:
RequestModeandDynRequestModeto query the status of a mode.
- Styling content:
ResetStyleRequestActiveStyleSetDefaultForeground,SetForeground8,SetForeground24,DynSetForeground8, andDynSetForeground24SetDefaultBackground,SetBackground8,SetBackground24,DynSetBackground8, andDynSetBackground24Format::Bold,Format::Thin, andFormat::RegularFormat::ItalicandFormat::UprightFormat::UnderlinedandFormat::NotUnderlinedFormat::BlinkingandFormat::NotBlinkingFormat::ReversedandFormat::NotReversedFormat::HiddenandFormat::NotHiddenFormat::NotStrickenandFormat::NotStrickenRequestColor::Black,RequestColor::Red, and so on for all 16 ANSI colors, alsoRequestColor::Foreground,RequestColor::Background,RequestColor::Cursor, andRequestColor::Selection
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 indeed 😜
Structs§
- Begin
Batch - The unit
BeginBatchcommand. - Begin
Paste - The unit
BeginPastecommand. - Disable
Autowrap - The unit
DisableAutowrapcommand. - Disable
Reverse Mode - The unit
DisableReverseModecommand. - DynLink
- The dynamic
DynLink(ID, HREF, TEXT)command. - DynMove
Down - The dynamic
DynMoveDown(ROWS)command. - DynMove
Left - The dynamic
DynMoveLeft(COLUMNS)command. - DynMove
Right - The dynamic
DynMoveRight(COLUMNS)command. - DynMove
To - The dynamic
DynMoveTo(ROW, COLUMN)command. - DynMove
ToColumn - The dynamic
DynMoveToColumn(COLUMN)command. - DynMove
ToRow - The dynamic
DynMoveToRow(ROW)command. - DynMove
Up - The dynamic
DynMoveUp(ROWS)command. - DynRequest
Mode - The dynamic
DynRequestMode(MODE)command. - DynScroll
Down - The dynamic
DynScrollDown(ROWS)command. - DynScroll
Up - The dynamic
DynScrollUp(ROWS)command. - DynSet
Background8 - The dynamic
DynSetBackground8(COLOR)command. - DynSet
Background24 - The dynamic
DynSetBackground24(R, G, B)command. - DynSet
Foreground8 - The dynamic
DynSetForeground8(COLOR)command. - DynSet
Foreground24 - The dynamic
DynSetForeground24(R, G, B)command. - DynSet
Scroll Region - The dynamic
DynSetScrollRegion(TOP, BOTTOM)command. - DynSet
Window Title - The dynamic
DynSetWindowTitle(String)command. - Enable
Autowrap - The unit
EnableAutowrapcommand. - Enable
Reverse Mode - The unit
EnableReverseModecommand. - EndBatch
- The unit
EndBatchcommand. - EndPaste
- The unit
EndPastecommand. - Enter
Alternate Screen - The unit
EnterAlternateScreencommand. - Erase
Line - The unit
EraseLinecommand. - Erase
Rest OfLine - The unit
EraseRestOfLinecommand. - Erase
Screen - The unit
EraseScreencommand. - Exit
Alternate Screen - The unit
ExitAlternateScreencommand. - Hide
Cursor - The unit
HideCursorcommand. - Move
Down - The static
MoveDown<ROWS>command. - Move
Left - The static
MoveLeft<COLUMNS>command. - Move
Right - The static
MoveRight<COLUMNS>command. - MoveTo
- The static
MoveTo<ROW, COLUMN>command. - Move
ToColumn - The static
MoveToColumn<COLUMN>command. - Move
ToRow - The static
MoveToRow<ROW>command. - MoveUp
- The static
MoveUp<ROWS>command. - Request
Active Style - The unit
RequestActiveStylecommand. - Request
Cursor Position - The unit
RequestCursorPositioncommand. - Request
Mode - The static
RequestMode<MODE>command. - Request
Screen Size - The unit
RequestScreenSizecommand. - Request
Terminal Id - The unit
RequestTerminalIdcommand. - Reset
Scroll Region - The unit
ResetScrollRegioncommand. - Reset
Style - The unit
ResetStylecommand. - Restore
Cursor Position - The unit
RestoreCursorPositioncommand. - Restore
Window Title - The unit
RestoreWindowTitlecommand. - Save
Cursor Position - The unit
SaveCursorPositioncommand. - Save
Window Title - The unit
SaveWindowTitlecommand. - Scroll
Down - The static
ScrollDown<ROWS>command. - Scroll
Up - The static
ScrollUp<ROWS>command. - SetBackground8
- The static
SetBackground8<COLOR>command. - SetBackground24
- The static
SetBackground24<R, G, B>command. - SetDefault
Background - The unit
SetDefaultBackgroundcommand. - SetDefault
Foreground - The unit
SetDefaultForegroundcommand. - SetForeground8
- The static
SetForeground8<COLOR>command. - SetForeground24
- The static
SetForeground24<R, G, B>command. - SetScroll
Region - The static
SetScrollRegion<TOP, BOTTOM>command. - Show
Cursor - The unit
ShowCursorcommand.
Enums§
- Format
- The enumeration of unit
Formatcommands. - Mode
Status - The current batch processing mode.
- Request
Color - The enumeration of unit
RequestColorcommands. - SetCursor