used wrong escape code, whoops...
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
#[cfg(test)]
|
||||||
|
mod tests;
|
||||||
|
|
||||||
use num_derive::FromPrimitive;
|
use num_derive::FromPrimitive;
|
||||||
use num_derive::ToPrimitive;
|
use num_derive::ToPrimitive;
|
||||||
|
|
||||||
@@ -63,7 +66,7 @@ pub enum AnsiSequence {
|
|||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
impl Display for AnsiSequence {
|
impl Display for AnsiSequence {
|
||||||
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
|
fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||||
write!(formatter, "\x27[")?;
|
write!(formatter, "\x1b[")?;
|
||||||
|
|
||||||
use AnsiSequence::*;
|
use AnsiSequence::*;
|
||||||
match self {
|
match self {
|
||||||
|
14
src/enums/tests.rs
Normal file
14
src/enums/tests.rs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
use super::*;
|
||||||
|
|
||||||
|
use std::fmt::Write;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_cursor_pos() {
|
||||||
|
let pos = AnsiSequence::CursorPos(5, 20);
|
||||||
|
let mut buff = String::new();
|
||||||
|
|
||||||
|
write!(&mut buff, "{}", pos)
|
||||||
|
.expect("failed to write");
|
||||||
|
|
||||||
|
assert_eq!(buff, "\x1b[5;20H");
|
||||||
|
}
|
@@ -190,7 +190,7 @@ named!(
|
|||||||
named!(
|
named!(
|
||||||
parse_escape<Output>,
|
parse_escape<Output>,
|
||||||
do_parse!(
|
do_parse!(
|
||||||
tag_s!("\x27[") >>
|
tag_s!("\x1b[") >>
|
||||||
seq: combined >>
|
seq: combined >>
|
||||||
(Output::Escape(seq))
|
(Output::Escape(seq))
|
||||||
)
|
)
|
||||||
@@ -200,7 +200,7 @@ named!(
|
|||||||
parse_str<Output>,
|
parse_str<Output>,
|
||||||
do_parse!(
|
do_parse!(
|
||||||
text: map_res!(
|
text: map_res!(
|
||||||
take_until!("\x27["),
|
take_until!("\x1b["),
|
||||||
std::str::from_utf8
|
std::str::from_utf8
|
||||||
) >>
|
) >>
|
||||||
(Output::TextBlock(text))
|
(Output::TextBlock(text))
|
||||||
|
@@ -33,7 +33,7 @@ fn test_reset_mode() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_parser_iterator() {
|
fn test_parser_iterator() {
|
||||||
let parse_str = "Hello, world? How are \x27[=7lyou? I hope you're doing well.";
|
let parse_str = "Hello, world? How are \x1b[=7lyou? I hope you're doing well.";
|
||||||
|
|
||||||
let strings: Vec<Output> = ParserIterator::new(parse_str)
|
let strings: Vec<Output> = ParserIterator::new(parse_str)
|
||||||
.collect();
|
.collect();
|
||||||
|
Reference in New Issue
Block a user