pub struct Ansi;
ui_term
only.Expand description
ANSI escape codes.
§List of escape codes
Implementations§
source§impl Ansi
impl Ansi
sourcepub const CSI: [u8; 2] = _
pub const CSI: [u8; 2] = _
Control Sequence Introducer (CSI).
https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_(Control_Sequence_Introducer)_sequences
source§impl Ansi
impl Ansi
§Screen escape codes
sourcepub const ENABLE_ALT_SCREEN: [u8; 7] = _
pub const ENABLE_ALT_SCREEN: [u8; 7] = _
Code to enable the alternative screen.
sourcepub const DISABLE_ALT_SCREEN: [u8; 7] = _
pub const DISABLE_ALT_SCREEN: [u8; 7] = _
Code to disable the alternative screen.
source§impl Ansi
impl Ansi
§Erase escape codes
sourcepub const ERASE_LINE_END: [u8; 3] = _
pub const ERASE_LINE_END: [u8; 3] = _
Code to erase from the cursor to the end of the line.
sourcepub const ERASE_LINE_START: [u8; 4] = _
pub const ERASE_LINE_START: [u8; 4] = _
Code to erase from the cursor to the start of the line.
sourcepub const ERASE_LINE: [u8; 4] = _
pub const ERASE_LINE: [u8; 4] = _
Code to erase the entire line.
sourcepub const ERASE_SCREEN_END: [u8; 3] = _
pub const ERASE_SCREEN_END: [u8; 3] = _
Code to erase from the cursor to the end of the screen.
sourcepub const ERASE_SCREEN_START: [u8; 4] = _
pub const ERASE_SCREEN_START: [u8; 4] = _
Code to erase from the cursor to the start of the screen.
sourcepub const ERASE_SCREEN: [u8; 4] = _
pub const ERASE_SCREEN: [u8; 4] = _
Code to erase the entire screen.
source§impl Ansi
impl Ansi
§Cursor escape codes
sourcepub const CURSOR_INVISIBLE: [u8; 6] = _
pub const CURSOR_INVISIBLE: [u8; 6] = _
Code to make the cursor invisible.
sourcepub const CURSOR_VISIBLE: [u8; 6] = _
pub const CURSOR_VISIBLE: [u8; 6] = _
Code to make the cursor visible.
sourcepub const CURSOR_SAVE: [u8; 3] = _
pub const CURSOR_SAVE: [u8; 3] = _
Code to save the cursor position.
sourcepub const CURSOR_RESTORE: [u8; 3] = _
pub const CURSOR_RESTORE: [u8; 3] = _
Code to restore the cursor position.
sourcepub const CURSOR_HOME: [u8; 3] = _
pub const CURSOR_HOME: [u8; 3] = _
Code to move the cursor to the home position (1, 1).
sourcepub const fn CURSOR_MOVE1(row: u8, col: u8) -> [u8; 6]
pub const fn CURSOR_MOVE1(row: u8, col: u8) -> [u8; 6]
Code to move the cursor to the specified 1-digit position (row, col).
§Panics
Panics in debug if either row
or col
> 9.
sourcepub const fn CURSOR_MOVE2(row: u8, col: u8) -> [u8; 8]
pub const fn CURSOR_MOVE2(row: u8, col: u8) -> [u8; 8]
Code to move the cursor to the specified 2-digit position (row, col).
§Panics
Panics in debug if either row
or col
> 99.
sourcepub const fn CURSOR_MOVE3(row: u16, col: u16) -> [u8; 10]
pub const fn CURSOR_MOVE3(row: u16, col: u16) -> [u8; 10]
Code to move the cursor to the specified 3-digit position (row, col).
§Panics
Panics in debug if either row
or col
> 999.
sourcepub const fn CURSOR_MOVE4(row: u16, col: u16) -> [u8; 12]
pub const fn CURSOR_MOVE4(row: u16, col: u16) -> [u8; 12]
Code to move the cursor to the specified 4-digit position (row, col).
§Panics
Panics in debug if either row
or col
> 9999.
sourcepub fn CURSOR_MOVE_N(buffer: &mut [u8], row: u32, col: u32) -> &[u8] ⓘ
pub fn CURSOR_MOVE_N(buffer: &mut [u8], row: u32, col: u32) -> &[u8] ⓘ
Returns a slice with the code to move the cursor to the specified position (row, col).
It needs a buffer
where to store the bytes.
§Panics
Panics if the buffer is not big enough.
sourcepub const fn CURSOR_UP1(n: u8) -> [u8; 4]
pub const fn CURSOR_UP1(n: u8) -> [u8; 4]
sourcepub const fn CURSOR_UP2(n: u8) -> [u8; 5]
pub const fn CURSOR_UP2(n: u8) -> [u8; 5]
sourcepub const fn CURSOR_UP3(n: u16) -> [u8; 6]
pub const fn CURSOR_UP3(n: u16) -> [u8; 6]
sourcepub const fn CURSOR_UP4(n: u16) -> [u8; 7]
pub const fn CURSOR_UP4(n: u16) -> [u8; 7]
sourcepub fn CURSOR_UP_N(buffer: &mut [u8], n: u32) -> &[u8] ⓘ
pub fn CURSOR_UP_N(buffer: &mut [u8], n: u32) -> &[u8] ⓘ
Returns a slice with the code to move the cursor up by n
lines.
It needs a buffer
where to store the bytes.
§Panics
Panics if the buffer is not big enough.
sourcepub const CURSOR_DOWN: [u8; 3] = _
pub const CURSOR_DOWN: [u8; 3] = _
Code to move the cursor down by one line.
sourcepub const fn CURSOR_DOWN1(n: u8) -> [u8; 4]
pub const fn CURSOR_DOWN1(n: u8) -> [u8; 4]
sourcepub const fn CURSOR_DOWN2(n: u8) -> [u8; 5]
pub const fn CURSOR_DOWN2(n: u8) -> [u8; 5]
sourcepub const fn CURSOR_DOWN3(n: u16) -> [u8; 6]
pub const fn CURSOR_DOWN3(n: u16) -> [u8; 6]
sourcepub const fn CURSOR_DOWN4(n: u16) -> [u8; 7]
pub const fn CURSOR_DOWN4(n: u16) -> [u8; 7]
sourcepub fn CURSOR_DOWN_N(buffer: &mut [u8], n: u32) -> &[u8] ⓘ
pub fn CURSOR_DOWN_N(buffer: &mut [u8], n: u32) -> &[u8] ⓘ
Returns a slice with the code to move the cursor down by n
lines.
It needs a buffer
where to store the bytes.
§Panics
Panics if the buffer is not big enough.
sourcepub const CURSOR_RIGHT: [u8; 3] = _
pub const CURSOR_RIGHT: [u8; 3] = _
Code to move the cursor right by one column.
sourcepub const fn CURSOR_RIGHT1(n: u8) -> [u8; 4]
pub const fn CURSOR_RIGHT1(n: u8) -> [u8; 4]
sourcepub const fn CURSOR_RIGHT2(n: u8) -> [u8; 5]
pub const fn CURSOR_RIGHT2(n: u8) -> [u8; 5]
sourcepub const fn CURSOR_RIGHT3(n: u16) -> [u8; 6]
pub const fn CURSOR_RIGHT3(n: u16) -> [u8; 6]
sourcepub const fn CURSOR_RIGHT4(n: u16) -> [u8; 7]
pub const fn CURSOR_RIGHT4(n: u16) -> [u8; 7]
sourcepub fn CURSOR_RIGHT_N(buffer: &mut [u8], n: u32) -> &[u8] ⓘ
pub fn CURSOR_RIGHT_N(buffer: &mut [u8], n: u32) -> &[u8] ⓘ
Returns a slice with the code to move the cursor right by n
lines.
It needs a buffer
where to store the bytes.
§Panics
Panics if the buffer is not big enough.
sourcepub const CURSOR_LEFT: [u8; 3] = _
pub const CURSOR_LEFT: [u8; 3] = _
Code to move the cursor left by one column.
sourcepub const fn CURSOR_LEFT1(n: u8) -> [u8; 4]
pub const fn CURSOR_LEFT1(n: u8) -> [u8; 4]
sourcepub const fn CURSOR_LEFT2(n: u8) -> [u8; 5]
pub const fn CURSOR_LEFT2(n: u8) -> [u8; 5]
sourcepub const fn CURSOR_LEFT3(n: u16) -> [u8; 6]
pub const fn CURSOR_LEFT3(n: u16) -> [u8; 6]
sourcepub const fn CURSOR_LEFT4(n: u16) -> [u8; 7]
pub const fn CURSOR_LEFT4(n: u16) -> [u8; 7]
sourcepub fn CURSOR_LEFT_N(buffer: &mut [u8], n: u32) -> &[u8] ⓘ
pub fn CURSOR_LEFT_N(buffer: &mut [u8], n: u32) -> &[u8] ⓘ
Returns a slice with the code to move the cursor left by n
lines.
It needs a buffer
where to store the bytes.
§Panics
Panics if the buffer is not big enough.
sourcepub const CURSOR_NEXT_LINE: [u8; 3] = _
pub const CURSOR_NEXT_LINE: [u8; 3] = _
Code to move the cursor to the beginning of the next line.
sourcepub const fn CURSOR_NEXT_LINE1(n: u8) -> [u8; 4]
pub const fn CURSOR_NEXT_LINE1(n: u8) -> [u8; 4]
Code to move the cursor to the beginning of the next 1-digit n
lines.
§Panics
Panics in debug if n
> 9.
sourcepub const fn CURSOR_NEXT_LINE2(n: u8) -> [u8; 5]
pub const fn CURSOR_NEXT_LINE2(n: u8) -> [u8; 5]
Code to move the cursor to the beginning of the next 2-digit n
lines.
§Panics
Panics in debug if n
> 99.
sourcepub const fn CURSOR_NEXT_LINE3(n: u16) -> [u8; 6]
pub const fn CURSOR_NEXT_LINE3(n: u16) -> [u8; 6]
Code to move the cursor to the beginning of the next 3-digit n
lines.
§Panics
Panics in debug if n
> 999.
sourcepub const fn CURSOR_NEXT_LINE4(n: u16) -> [u8; 7]
pub const fn CURSOR_NEXT_LINE4(n: u16) -> [u8; 7]
Code to move the cursor to the beginning of the next 4-digit n
lines.
§Panics
Panics in debug if n
> 999.
sourcepub fn CURSOR_NEXT_LINE_N(buffer: &mut [u8], n: u32) -> &[u8] ⓘ
pub fn CURSOR_NEXT_LINE_N(buffer: &mut [u8], n: u32) -> &[u8] ⓘ
Returns a slice with the code to move the cursor to the beginning of the next n
lines.
It needs a buffer
where to store the bytes.
§Panics
Panics if the buffer is not big enough.
sourcepub const CURSOR_PREV_LINE: [u8; 3] = _
pub const CURSOR_PREV_LINE: [u8; 3] = _
Code to move the cursor to the beginning of the previous line.
sourcepub const fn CURSOR_PREV_LINE1(n: u8) -> [u8; 4]
pub const fn CURSOR_PREV_LINE1(n: u8) -> [u8; 4]
Code to move the cursor to the beginning of the previous 1-digit n
lines.
§Panics
Panics in debug if n
> 9.
sourcepub const fn CURSOR_PREV_LINE2(n: u8) -> [u8; 5]
pub const fn CURSOR_PREV_LINE2(n: u8) -> [u8; 5]
Code to move the cursor to the beginning of the previous 2-digit n
lines.
§Panics
Panics in debug if n
> 99.
sourcepub const fn CURSOR_PREV_LINE3(n: u16) -> [u8; 6]
pub const fn CURSOR_PREV_LINE3(n: u16) -> [u8; 6]
Code to move the cursor to the beginning of the previous 3-digit n
lines.
§Panics
Panics in debug if n
> 999.
source§impl Ansi
impl Ansi
§Font effects escape codes
sourcepub const ITALIC_OFF: [u8; 5] = _
pub const ITALIC_OFF: [u8; 5] = _
Code to unset italic and fraktur effects.
sourcepub const UNDERLINE_OFF: [u8; 5] = _
pub const UNDERLINE_OFF: [u8; 5] = _
Code to unset underline effect.
sourcepub const INVERSE_OFF: [u8; 5] = _
pub const INVERSE_OFF: [u8; 5] = _
Code to unset inverse effect.
sourcepub const CROSSED_OFF: [u8; 5] = _
pub const CROSSED_OFF: [u8; 5] = _
Code to unset crossed effect.
source§impl Ansi
impl Ansi
§3-bit Color escape codes
sourcepub const fn COLORS(fg: AnsiColor3b, bg: AnsiColor3b) -> [u8; 8]
pub const fn COLORS(fg: AnsiColor3b, bg: AnsiColor3b) -> [u8; 8]
Code to set the foreground color to fg
and the background to bg
.
sourcepub const fn COLORS_BRIGHT(fg: AnsiColor3b, bg: AnsiColor3b) -> [u8; 9]
pub const fn COLORS_BRIGHT(fg: AnsiColor3b, bg: AnsiColor3b) -> [u8; 9]
Code to set the foreground color to bright fg
and the background to bright bg
.
sourcepub const fn COLORS_BRIGHT_FG(fg: AnsiColor3b, bg: AnsiColor3b) -> [u8; 8]
pub const fn COLORS_BRIGHT_FG(fg: AnsiColor3b, bg: AnsiColor3b) -> [u8; 8]
Code to set the foreground color to bright fg
and the background to bg
.
sourcepub const fn COLORS_BRIGHT_BG(fg: AnsiColor3b, bg: AnsiColor3b) -> [u8; 9]
pub const fn COLORS_BRIGHT_BG(fg: AnsiColor3b, bg: AnsiColor3b) -> [u8; 9]
Code to set the foreground color to fg
and the background to bright bg
.
sourcepub const MAGENTA_BG: [u8; 5] = _
pub const MAGENTA_BG: [u8; 5] = _
Code to set the background color to magenta.
sourcepub const BRIGHT_BLACK: [u8; 5] = _
pub const BRIGHT_BLACK: [u8; 5] = _
Code to set the foreground color to bright black.
sourcepub const BRIGHT_RED: [u8; 5] = _
pub const BRIGHT_RED: [u8; 5] = _
Code to set the foreground color to bright red.
sourcepub const BRIGHT_GREEN: [u8; 5] = _
pub const BRIGHT_GREEN: [u8; 5] = _
Code to set the foreground color to bright green.
sourcepub const BRIGHT_YELLOW: [u8; 5] = _
pub const BRIGHT_YELLOW: [u8; 5] = _
Code to set the foreground color to bright yellow.
sourcepub const BRIGHT_BLUE: [u8; 5] = _
pub const BRIGHT_BLUE: [u8; 5] = _
Code to set the foreground color to bright blue.
sourcepub const BRIGHT_MAGENTA: [u8; 5] = _
pub const BRIGHT_MAGENTA: [u8; 5] = _
Code to set the foreground color to bright magenta.
sourcepub const BRIGHT_CYAN: [u8; 5] = _
pub const BRIGHT_CYAN: [u8; 5] = _
Code to set the foreground color to bright cyan.
sourcepub const BRIGHT_WHITE: [u8; 5] = _
pub const BRIGHT_WHITE: [u8; 5] = _
Code to set the foreground color to bright white.
sourcepub const BRIGHT_BLACK_BG: [u8; 6] = _
pub const BRIGHT_BLACK_BG: [u8; 6] = _
Code to set the background color to bright black.
sourcepub const BRIGHT_RED_BG: [u8; 6] = _
pub const BRIGHT_RED_BG: [u8; 6] = _
Code to set the background color to bright red.
sourcepub const BRIGHT_GREEN_BG: [u8; 6] = _
pub const BRIGHT_GREEN_BG: [u8; 6] = _
Code to set the background color to bright green.
sourcepub const BRIGHT_YELLOW_BG: [u8; 6] = _
pub const BRIGHT_YELLOW_BG: [u8; 6] = _
Code to set the background color to bright yellow.
sourcepub const BRIGHT_BLUE_BG: [u8; 6] = _
pub const BRIGHT_BLUE_BG: [u8; 6] = _
Code to set the background color to bright blue.
sourcepub const BRIGHT_MAGENTA_BG: [u8; 6] = _
pub const BRIGHT_MAGENTA_BG: [u8; 6] = _
Code to set the background color to bright magenta.
sourcepub const BRIGHT_CYAN_BG: [u8; 6] = _
pub const BRIGHT_CYAN_BG: [u8; 6] = _
Code to set the background color to bright cyan.
sourcepub const BRIGHT_WHITE_BG: [u8; 6] = _
pub const BRIGHT_WHITE_BG: [u8; 6] = _
Code to set the background color to bright white.
source§impl Ansi
impl Ansi
§8-bit Color escape codes
sourcepub const fn COLORS8(fg: AnsiColor8b, bg: AnsiColor8b) -> [u8; 19]
pub const fn COLORS8(fg: AnsiColor8b, bg: AnsiColor8b) -> [u8; 19]
Code to set the foreground color to fg
and the background to bg
.
sourcepub const fn COLOR8_FG(fg: AnsiColor8b) -> [u8; 11]
pub const fn COLOR8_FG(fg: AnsiColor8b) -> [u8; 11]
Code to set the foreground color to fg
.
sourcepub const fn COLOR8_BG(bg: AnsiColor8b) -> [u8; 11]
pub const fn COLOR8_BG(bg: AnsiColor8b) -> [u8; 11]
Code to set the background color to bg
.
sourcepub const fn GRAY(fg: u8, bg: u8) -> [u8; 19]
pub const fn GRAY(fg: u8, bg: u8) -> [u8; 19]
Code to set the foreground and background to 24-point grayscale.
A value of 0 is almost black, and 24 (or more) is almost white.
sourcepub const GRAY10_BG: [u8; 11] = _
pub const GRAY10_BG: [u8; 11] = _
ANSI gray background 10/23 8-bit color (44% white, 56% black).
sourcepub const GRAY11_BG: [u8; 11] = _
pub const GRAY11_BG: [u8; 11] = _
ANSI gray background 11/23 8-bit color (48% white, 52% black).
sourcepub const GRAY12_BG: [u8; 11] = _
pub const GRAY12_BG: [u8; 11] = _
ANSI gray background 12/23 8-bit color (52% white, 48% black).
sourcepub const GRAY13_BG: [u8; 11] = _
pub const GRAY13_BG: [u8; 11] = _
ANSI gray background 13/23 8-bit color (56% white, 44% black).
sourcepub const GRAY14_BG: [u8; 11] = _
pub const GRAY14_BG: [u8; 11] = _
ANSI gray background 14/23 8-bit color (60% white, 40% black).
sourcepub const GRAY15_BG: [u8; 11] = _
pub const GRAY15_BG: [u8; 11] = _
ANSI gray background 15/23 8-bit color (64% white, 36% black).
sourcepub const GRAY16_BG: [u8; 11] = _
pub const GRAY16_BG: [u8; 11] = _
ANSI gray background 16/23 8-bit color (68% white, 32% black).
sourcepub const GRAY17_BG: [u8; 11] = _
pub const GRAY17_BG: [u8; 11] = _
ANSI gray background 17/23 8-bit color (72% white, 28% black).
sourcepub const GRAY18_BG: [u8; 11] = _
pub const GRAY18_BG: [u8; 11] = _
ANSI gray background 18/23 8-bit color (76% white, 24% black).
sourcepub const GRAY19_BG: [u8; 11] = _
pub const GRAY19_BG: [u8; 11] = _
ANSI gray background 19/23 8-bit color (80% white, 20% black).
sourcepub const GRAY20_BG: [u8; 11] = _
pub const GRAY20_BG: [u8; 11] = _
ANSI gray background 20/23 8-bit color (84% white, 16% black).
sourcepub const GRAY21_BG: [u8; 11] = _
pub const GRAY21_BG: [u8; 11] = _
ANSI gray background 21/23 8-bit color (88% white, 12% black).
source§impl Ansi
impl Ansi
§RGB Color escape codes
source§impl Ansi
impl Ansi
§Print method
sourcepub fn print(sequence: &[u8]) -> Result<()>
Available on crate feature std
only.
pub fn print(sequence: &[u8]) -> Result<()>
std
only.Convenience method to print an ANSI escape sequence
of bytes to stdout
.
It uses the Write
trait on std
.
§Example
use devela::ui::term::{Ansi, AnsiColor3b};
Ansi::print(&Ansi::ERASE_SCREEN);
Ansi::print(&Ansi::CURSOR_MOVE3(120, 80));
Ansi::print(&Ansi::COLORS_BRIGHT_BG(AnsiColor3b::Blue, AnsiColor3b::Black));
Auto Trait Implementations§
impl Freeze for Ansi
impl RefUnwindSafe for Ansi
impl Send for Ansi
impl Sync for Ansi
impl Unpin for Ansi
impl UnwindSafe for Ansi
Blanket Implementations§
source§impl<T> Also for T
impl<T> Also for T
source§impl<T, Res> Apply<Res> for Twhere
T: ?Sized,
impl<T, Res> Apply<Res> for Twhere
T: ?Sized,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> ByteSize for T
impl<T> ByteSize for T
source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
source§fn byte_align(&self) -> usize
fn byte_align(&self) -> usize
source§impl<T> ExtAny for Twhere
T: Any,
impl<T> ExtAny for Twhere
T: Any,
source§fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
source§impl<T> Mem for Twhere
T: ?Sized,
impl<T> Mem for Twhere
T: ?Sized,
source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true
if dropping values of this type matters.source§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self
without running its destructor.source§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
self
with other, returning the previous value of self
.source§fn mem_take(&mut self) -> Selfwhere
Self: Default,
fn mem_take(&mut self) -> Selfwhere
Self: Default,
self
with its default value, returning the previous value of self
.source§fn mem_swap(&mut self, other: &mut Self)where
Self: Sized,
fn mem_swap(&mut self, other: &mut Self)where
Self: Sized,
self
and other
without deinitializing either one.source§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
unsafe_slice
only.