added high cursor and show cursor

This commit is contained in:
David Bittner
2019-05-02 23:46:46 -04:00
parent 3c393326d4
commit a8d429d223
3 changed files with 27 additions and 4 deletions

2
Cargo.lock generated
View File

@@ -2,7 +2,7 @@
# It is not intended for manual editing.
[[package]]
name = "ansi-parser"
version = "0.5.0"
version = "0.5.1"
dependencies = [
"nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
]

View File

@@ -16,13 +16,14 @@ pub enum AnsiSequence {
SetGraphicsMode(Vec<u32>),
SetMode(u8),
ResetMode(u8),
// HideCursor,
HideCursor,
ShowCursor
}
use std::fmt::Display;
impl Display for AnsiSequence {
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(formatter, "\x1b[")?;
write!(formatter, "\u{1b}[")?;
use AnsiSequence::*;
match self {
@@ -56,7 +57,11 @@ impl Display for AnsiSequence {
SetMode(mode)
=> write!(formatter, "={}h", mode),
ResetMode(mode)
=> write!(formatter, "={}l", mode)
=> write!(formatter, "={}l", mode),
ShowCursor
=> write!(formatter, "?25h"),
HideCursor
=> write!(formatter, "?25l")
}
}
}

View File

@@ -159,6 +159,22 @@ named!(
)
);
named!(
hide_cursor<&str, AnsiSequence>,
do_parse!(
tag!("?25l") >>
(AnsiSequence::HideCursor)
)
);
named!(
show_cursor<&str, AnsiSequence>,
do_parse!(
tag!("?25h") >>
(AnsiSequence::ShowCursor)
)
);
named!(
combined<&str, AnsiSequence>,
alt!(
@@ -174,6 +190,8 @@ named!(
| graphics_mode
| set_mode
| reset_mode
| hide_cursor
| show_cursor
)
);