OutputCommand

Enum OutputCommand 

Source
pub enum OutputCommand {
Show 43 variants MoveTo(u16, u16), MoveUp(u16), MoveDown(u16), MoveLeft(u16), MoveRight(u16), MoveToNextLine(u16), MoveToPreviousLine(u16), MoveToColumn(u16), SavePosition, RestorePosition, GetPosition, Hide, Show, EnableBlinking, DisableBlinking, SetCursorStyle(CursorStyle), Print(String), PrintLine(String), PrintStyled(StyledText), SetForegroundColor(Color), SetBackgroundColor(Color), ResetColor, SetColors(Color, Color), SetAttribute(Attribute), ResetAttributes, SetLineWrap(bool), Clear(ClearType), ScrollUp(u16), ScrollDown(u16), SetSize(u16, u16), GetSize, EnterAlternateScreen, LeaveAlternateScreen, SetTitle(String), EnableMouseCapture, DisableMouseCapture, EnableFocusReporting, DisableFocusReporting, PushKeyboardEvent(KeyEvent), PushMouseEvent(MouseEvent), Batch(Vec<OutputCommand>), If(bool, Box<OutputCommand>, Option<Box<OutputCommand>>), Repeat(u32, Box<OutputCommand>),
}
Expand description

完整的终端控制命令枚举

Variants§

§

MoveTo(u16, u16)

移动光标到指定位置 (列, 行),从 (1,1) 开始

§

MoveUp(u16)

光标上移 n 行

§

MoveDown(u16)

光标下移 n 行

§

MoveLeft(u16)

光标左移 n 列

§

MoveRight(u16)

光标右移 n 列

§

MoveToNextLine(u16)

光标移动到下一行,列位置不变

§

MoveToPreviousLine(u16)

光标移动到上一行,列位置不变

§

MoveToColumn(u16)

光标移动到指定列

§

SavePosition

保存光标位置

§

RestorePosition

恢复光标位置

§

GetPosition

获取光标位置(返回 (列, 行))

§

Hide

隐藏光标

§

Show

显示光标

§

EnableBlinking

启用光标闪烁

§

DisableBlinking

禁用光标闪烁

§

SetCursorStyle(CursorStyle)

设置光标形状

§

Print(String)

打印文本

§

PrintLine(String)

打印一行文本(自动换行)

§

PrintStyled(StyledText)

打印带样式的文本

§

SetForegroundColor(Color)

设置前景色

§

SetBackgroundColor(Color)

设置背景色

§

ResetColor

重置颜色(前景和背景)

§

SetColors(Color, Color)

同时设置前景和背景色

§

SetAttribute(Attribute)

设置文本属性

§

ResetAttributes

重置所有样式

§

SetLineWrap(bool)

启用/禁用自动换行

§

Clear(ClearType)

清除屏幕

§

ScrollUp(u16)

滚动屏幕

§

ScrollDown(u16)

§

SetSize(u16, u16)

设置终端大小

§

GetSize

获取终端大小

§

EnterAlternateScreen

进入备用屏幕缓冲区

§

LeaveAlternateScreen

退出备用屏幕缓冲区

§

SetTitle(String)

设置终端标题

§

EnableMouseCapture

启用鼠标捕获

§

DisableMouseCapture

禁用鼠标捕获

§

EnableFocusReporting

启用焦点事件报告

§

DisableFocusReporting

禁用焦点事件报告

§

PushKeyboardEvent(KeyEvent)

推送键盘事件(用于模拟输入)

§

PushMouseEvent(MouseEvent)

推送鼠标事件(用于模拟输入)

§

Batch(Vec<OutputCommand>)

执行多个命令

§

If(bool, Box<OutputCommand>, Option<Box<OutputCommand>>)

条件执行

§

Repeat(u32, Box<OutputCommand>)

循环执行

Implementations§

Source§

impl OutputCommand

Source

pub fn execute(&self, writer: &mut dyn Write) -> Result<()>

执行命令

Source

pub fn queue(&self, writer: &mut dyn Write) -> Result<()>

排队命令(不立即刷新)

Source

pub fn print<S: Into<String>>(text: S) -> Self

创建打印命令

Source

pub fn print_line<S: Into<String>>(text: S) -> Self

创建打印行命令

Source

pub fn move_to(col: u16, row: u16) -> Self

创建移动光标命令

Source

pub fn clear(clear_type: ClearType) -> Self

创建清屏命令

Source

pub fn set_colors(foreground: Color, background: Color) -> Self

创建设置颜色命令

Source

pub fn batch<I>(commands: I) -> Self
where I: IntoIterator<Item = OutputCommand>,

创建批处理命令

Source

pub fn if_then_else<C, T, E>( condition: bool, then_cmd: C, else_cmd: Option<E>, ) -> Self

创建条件命令

Source

pub fn repeat<C>(count: u32, cmd: C) -> Self
where C: Into<OutputCommand>,

创建重复命令

Source

pub fn styled_text<S, F, B, A>( text: S, foreground: Option<F>, background: Option<B>, attributes: A, ) -> StyledText
where S: Into<String>, F: Into<Color>, B: Into<Color>, A: IntoIterator<Item = Attribute>,

创建带样式的文本

Source

pub fn print_styled(styled: StyledText) -> Self

从带样式的文本创建命令

Trait Implementations§

Source§

impl Clone for OutputCommand

Source§

fn clone(&self) -> OutputCommand

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for OutputCommand

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for OutputCommand

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.