adding a lot more sequences

This commit is contained in:
David Bittner
2019-05-06 16:18:46 -04:00
parent 8c1408cefe
commit 38a5f31e47
4 changed files with 71 additions and 25 deletions

2
Cargo.lock generated
View File

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

View File

@@ -29,6 +29,14 @@ pub enum AnsiSequence {
SetInterlacing, SetInterlacing,
SetLineFeedMode, SetLineFeedMode,
SetCursorKeyToCursor, SetCursorKeyToCursor,
SetVT52,
SetCol80,
SetJumpScrolling,
SetNormalVideo,
SetOriginAbsolute,
ResetAutoWrap,
ResetAutoRepeat,
ResetInterlacing,
} }
use std::fmt::Display; use std::fmt::Display;
@@ -94,7 +102,23 @@ impl Display for AnsiSequence {
SetLineFeedMode SetLineFeedMode
=> write!(formatter, "20l"), => write!(formatter, "20l"),
SetCursorKeyToCursor SetCursorKeyToCursor
=> write!(formatter, "?1l") => write!(formatter, "?1l"),
SetVT52
=> write!(formatter, "?2l"),
SetCol80
=> write!(formatter, "?3l"),
SetJumpScrolling
=> write!(formatter, "?4l"),
SetNormalVideo
=> write!(formatter, "?5l"),
SetOriginAbsolute
=> write!(formatter, "?6l"),
ResetAutoWrap
=> write!(formatter, "?7l"),
ResetAutoRepeat
=> write!(formatter, "?8l"),
ResetInterlacing
=> write!(formatter, "?9l"),
} }
} }
} }

View File

@@ -1,3 +1,5 @@
#![recursion_limit="256"]
mod enums; mod enums;
mod parsers; mod parsers;

View File

@@ -139,21 +139,31 @@ named!(
) )
); );
tag_parser!(cursor_save, "s", AnsiSequence::CursorSave); tag_parser!(cursor_save, "s", AnsiSequence::CursorSave);
tag_parser!(cursor_restore, "u", AnsiSequence::CursorRestore); tag_parser!(cursor_restore, "u", AnsiSequence::CursorRestore);
tag_parser!(erase_display, "2J", AnsiSequence::EraseDisplay); tag_parser!(erase_display, "2J", AnsiSequence::EraseDisplay);
tag_parser!(erase_line, "K", AnsiSequence::EraseLine); tag_parser!(erase_line, "K", AnsiSequence::EraseLine);
tag_parser!(hide_cursor, "?25l", AnsiSequence::HideCursor); tag_parser!(hide_cursor, "?25l", AnsiSequence::HideCursor);
tag_parser!(show_cursor, "?25h", AnsiSequence::ShowCursor); tag_parser!(show_cursor, "?25h", AnsiSequence::ShowCursor);
tag_parser!(cursor_to_app, "?1h", AnsiSequence::CursorToApp); tag_parser!(cursor_to_app, "?1h", AnsiSequence::CursorToApp);
tag_parser!(new_line_mode, "20h", AnsiSequence::SetNewLineMode); tag_parser!(set_new_line_mode, "20h", AnsiSequence::SetNewLineMode);
tag_parser!(col_132, "?3h", AnsiSequence::SetCol132); tag_parser!(set_col_132, "?3h", AnsiSequence::SetCol132);
tag_parser!(smooth_scroll, "?4h", AnsiSequence::SetSmoothScroll); tag_parser!(set_smooth_scroll, "?4h", AnsiSequence::SetSmoothScroll);
tag_parser!(reverse_video, "?5h", AnsiSequence::SetReverseVideo); tag_parser!(set_reverse_video, "?5h", AnsiSequence::SetReverseVideo);
tag_parser!(origin_relative,"?6h", AnsiSequence::SetOriginRelative); tag_parser!(set_origin_rel, "?6h", AnsiSequence::SetOriginRelative);
tag_parser!(auto_wrap, "?7h", AnsiSequence::SetAutoWrap); tag_parser!(set_auto_wrap, "?7h", AnsiSequence::SetAutoWrap);
tag_parser!(auto_repeat, "?8h", AnsiSequence::SetAutoRepeat); tag_parser!(set_auto_repeat, "?8h", AnsiSequence::SetAutoRepeat);
tag_parser!(interlacing, "?9h", AnsiSequence::SetInterlacing); tag_parser!(set_interlacing, "?9h", AnsiSequence::SetInterlacing);
tag_parser!(set_linefeed, "20l", AnsiSequence::SetLineFeedMode);
tag_parser!(set_cursorkey, "?1l", AnsiSequence::SetCursorKeyToCursor);
tag_parser!(set_vt52, "?2l", AnsiSequence::SetVT52);
tag_parser!(set_col80, "?3l", AnsiSequence::SetCol80);
tag_parser!(set_jump_scroll, "?4l", AnsiSequence::SetJumpScrolling);
tag_parser!(set_normal_video, "?5l", AnsiSequence::SetNormalVideo);
tag_parser!(set_origin_abs, "?6l", AnsiSequence::SetOriginAbsolute);
tag_parser!(reset_auto_wrap, "?7l", AnsiSequence::ResetAutoWrap);
tag_parser!(reset_auto_repeat, "?8l", AnsiSequence::ResetAutoRepeat);
tag_parser!(reset_interlacing, "?9l", AnsiSequence::ResetInterlacing);
named!( named!(
combined<&str, AnsiSequence>, combined<&str, AnsiSequence>,
@@ -173,14 +183,24 @@ named!(
| hide_cursor | hide_cursor
| show_cursor | show_cursor
| cursor_to_app | cursor_to_app
| new_line_mode | set_new_line_mode
| col_132 | set_col_132
| smooth_scroll | set_smooth_scroll
| reverse_video | set_reverse_video
| origin_relative | set_origin_rel
| auto_wrap | set_auto_wrap
| auto_repeat | set_auto_repeat
| interlacing | set_interlacing
| set_linefeed
| set_cursorkey
| set_vt52
| set_col80
| set_jump_scroll
| set_normal_video
| set_origin_abs
| reset_auto_wrap
| reset_auto_repeat
| reset_interlacing
) )
); );