aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-11-08 12:47:30 -0500
committerJesse Luehrs <doy@tozt.net>2019-11-08 12:51:02 -0500
commit82fa0389acde185744a33fa92e35fd0f6e3b79e9 (patch)
tree2f9c8c4ef972914f097bc1b16d5c9d28e7a14290
parent6abfaac01daa6f1ba959c8e522d4fd439babaaee (diff)
downloadvt100-rust-82fa0389acde185744a33fa92e35fd0f6e3b79e9.tar.gz
vt100-rust-82fa0389acde185744a33fa92e35fd0f6e3b79e9.zip
remove unnecessary accessors
nobody should be caring about the terminal state internals
-rw-r--r--CHANGELOG.md7
-rw-r--r--src/screen.rs52
-rw-r--r--tests/attr.rs60
-rw-r--r--tests/escape.rs24
-rw-r--r--tests/init.rs8
-rw-r--r--tests/mode.rs14
6 files changed, 7 insertions, 158 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4f97f97..31c2872 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,13 @@
## Unreleased
+### Removed
+
+* `Screen::fgcolor`, `Screen::bgcolor`, `Screen::bold`, `Screen::italic`,
+ `Screen::underline`, `Screen::inverse`, and `Screen::alternate_screen`:
+ these are just implementation details that people shouldn't need to care
+ about.
+
### Fixed
* Fixed cursor movement when the cursor position is already outside of an
diff --git a/src/screen.rs b/src/screen.rs
index 7abd72c..88e5b44 100644
--- a/src/screen.rs
+++ b/src/screen.rs
@@ -255,53 +255,6 @@ impl Screen {
(pos.row, pos.col)
}
- /// Returns the currently active foreground color.
- ///
- /// This is the foreground color which will be used when writing text to a
- /// new cell.
- pub fn fgcolor(&self) -> crate::attrs::Color {
- self.attrs.fgcolor
- }
-
- /// Returns the currently active background color.
- ///
- /// This is the background color which will be used when writing text to a
- /// new cell.
- pub fn bgcolor(&self) -> crate::attrs::Color {
- self.attrs.bgcolor
- }
-
- /// Returns whether the bold text attribute is active.
- ///
- /// If true, text written to a new cell will have the bold text attribute.
- pub fn bold(&self) -> bool {
- self.attrs.bold()
- }
-
- /// Returns whether the italic text attribute is active.
- ///
- /// If true, text written to a new cell will have the italic text
- /// attribute.
- pub fn italic(&self) -> bool {
- self.attrs.italic()
- }
-
- /// Returns whether the underline text attribute is active.
- ///
- /// If true, text written to a new cell will have the underline text
- /// attribute.
- pub fn underline(&self) -> bool {
- self.attrs.underline()
- }
-
- /// Returns whether the inverse text attribute is active.
- ///
- /// If true, text written to a new cell will have the inverse text
- /// attribute.
- pub fn inverse(&self) -> bool {
- self.attrs.inverse()
- }
-
/// Returns the terminal's window title.
pub fn title(&self) -> &str {
&self.title
@@ -339,11 +292,6 @@ impl Screen {
self.mode(Mode::HideCursor)
}
- /// Returns whether the terminal should be in alternate screen mode.
- pub fn alternate_screen(&self) -> bool {
- self.mode(Mode::AlternateScreen)
- }
-
/// Returns whether the terminal should be in bracketed paste mode.
pub fn bracketed_paste(&self) -> bool {
self.mode(Mode::BracketedPaste)
diff --git a/tests/attr.rs b/tests/attr.rs
index 18d20a2..1446bc5 100644
--- a/tests/attr.rs
+++ b/tests/attr.rs
@@ -3,8 +3,6 @@
#[test]
fn colors() {
let mut parser = vt100::Parser::new(24, 80);
- assert_eq!(parser.screen().fgcolor(), vt100::Color::Default);
- assert_eq!(parser.screen().bgcolor(), vt100::Color::Default);
parser.process(b"foo\x1b[31mbar");
@@ -28,9 +26,6 @@ fn colors() {
vt100::Color::Default
);
- assert_eq!(parser.screen().fgcolor(), vt100::Color::Idx(1));
- assert_eq!(parser.screen().bgcolor(), vt100::Color::Default);
-
parser.process(b"\x1b[2D\x1b[45mab");
assert_eq!(parser.screen().cell(0, 4).unwrap().contents(), "a");
@@ -43,14 +38,8 @@ fn colors() {
vt100::Color::Idx(5)
);
- assert_eq!(parser.screen().fgcolor(), vt100::Color::Idx(1));
- assert_eq!(parser.screen().bgcolor(), vt100::Color::Idx(5));
-
parser.process(b"\x1b[m");
- assert_eq!(parser.screen().fgcolor(), vt100::Color::Default);
- assert_eq!(parser.screen().bgcolor(), vt100::Color::Default);
-
parser.process(b"\x1b[15;15Hfoo\x1b[31mbar\x1b[m");
assert_eq!(parser.screen().cell(14, 14).unwrap().contents(), "f");
@@ -73,9 +62,6 @@ fn colors() {
vt100::Color::Default
);
- assert_eq!(parser.screen().fgcolor(), vt100::Color::Default);
- assert_eq!(parser.screen().bgcolor(), vt100::Color::Default);
-
parser.process(b"\x1b[2D\x1b[45mab");
assert_eq!(parser.screen().cell(14, 18).unwrap().contents(), "a");
@@ -88,15 +74,9 @@ fn colors() {
vt100::Color::Idx(5)
);
- assert_eq!(parser.screen().fgcolor(), vt100::Color::Default);
- assert_eq!(parser.screen().bgcolor(), vt100::Color::Idx(5));
-
parser.process(b"\x1b[m\x1b[2J\x1b[H");
parser.process(b"a\x1b[38;5;123mb\x1b[48;5;158mc");
- assert_eq!(parser.screen().fgcolor(), vt100::Color::Idx(123));
- assert_eq!(parser.screen().bgcolor(), vt100::Color::Idx(158));
-
assert_eq!(
parser.screen().cell(0, 0).unwrap().fgcolor(),
vt100::Color::Default
@@ -126,9 +106,6 @@ fn colors() {
parser.process(b"\x1b[38;2;50;75;100md\x1b[48;2;125;150;175me");
- assert_eq!(parser.screen().fgcolor(), vt100::Color::Rgb(50, 75, 100));
- assert_eq!(parser.screen().bgcolor(), vt100::Color::Rgb(125, 150, 175));
-
assert_eq!(
parser.screen().cell(0, 3).unwrap().fgcolor(),
vt100::Color::Rgb(50, 75, 100)
@@ -150,9 +127,6 @@ fn colors() {
parser.process(b"\x1b[m\x1b[2J\x1b[H");
parser.process(b"\x1b[32;47mfoo");
- assert_eq!(parser.screen().fgcolor(), vt100::Color::Idx(2));
- assert_eq!(parser.screen().bgcolor(), vt100::Color::Idx(7));
-
assert_eq!(
parser.screen().cell(0, 1).unwrap().fgcolor(),
vt100::Color::Idx(2)
@@ -165,9 +139,6 @@ fn colors() {
parser.process(b"\x1b[2J\x1b[H");
parser.process(b"\x1b[39mfoo");
- assert_eq!(parser.screen().fgcolor(), vt100::Color::Default);
- assert_eq!(parser.screen().bgcolor(), vt100::Color::Idx(7));
-
assert_eq!(
parser.screen().cell(0, 1).unwrap().fgcolor(),
vt100::Color::Default
@@ -180,9 +151,6 @@ fn colors() {
parser.process(b"\x1b[2J\x1b[H");
parser.process(b"\x1b[49mfoo");
- assert_eq!(parser.screen().fgcolor(), vt100::Color::Default);
- assert_eq!(parser.screen().bgcolor(), vt100::Color::Default);
-
assert_eq!(
parser.screen().cell(0, 1).unwrap().fgcolor(),
vt100::Color::Default
@@ -195,9 +163,6 @@ fn colors() {
parser.process(b"\x1b[m\x1b[2J\x1b[H");
parser.process(b"\x1b[92;107mfoo");
- assert_eq!(parser.screen().fgcolor(), vt100::Color::Idx(10));
- assert_eq!(parser.screen().bgcolor(), vt100::Color::Idx(15));
-
assert_eq!(
parser.screen().cell(0, 1).unwrap().fgcolor(),
vt100::Color::Idx(10)
@@ -211,16 +176,8 @@ fn colors() {
#[test]
fn attrs() {
let mut parser = vt100::Parser::new(24, 80);
- assert!(!parser.screen().bold());
- assert!(!parser.screen().italic());
- assert!(!parser.screen().underline());
- assert!(!parser.screen().inverse());
parser.process(b"f\x1b[1mo\x1b[3mo\x1b[4mo\x1b[7mo");
- assert!(parser.screen().bold());
- assert!(parser.screen().italic());
- assert!(parser.screen().underline());
- assert!(parser.screen().inverse());
assert!(!parser.screen().cell(0, 0).unwrap().bold());
assert!(!parser.screen().cell(0, 0).unwrap().italic());
assert!(!parser.screen().cell(0, 0).unwrap().underline());
@@ -243,27 +200,14 @@ fn attrs() {
assert!(parser.screen().cell(0, 4).unwrap().inverse());
parser.process(b"\x1b[m");
- assert!(!parser.screen().bold());
- assert!(!parser.screen().italic());
- assert!(!parser.screen().underline());
- assert!(!parser.screen().inverse());
-
parser.process(b"\x1b[2J\x1b[H");
parser.process(b"\x1b[1;4mf");
- assert!(parser.screen().bold());
- assert!(!parser.screen().italic());
- assert!(parser.screen().underline());
- assert!(!parser.screen().inverse());
assert!(parser.screen().cell(0, 0).unwrap().bold());
assert!(!parser.screen().cell(0, 0).unwrap().italic());
assert!(parser.screen().cell(0, 0).unwrap().underline());
assert!(!parser.screen().cell(0, 0).unwrap().inverse());
parser.process(b"\x1b[22mo\x1b[24mo");
- assert!(!parser.screen().bold());
- assert!(!parser.screen().italic());
- assert!(!parser.screen().underline());
- assert!(!parser.screen().inverse());
assert!(!parser.screen().cell(0, 1).unwrap().bold());
assert!(!parser.screen().cell(0, 1).unwrap().italic());
assert!(parser.screen().cell(0, 1).unwrap().underline());
@@ -274,10 +218,6 @@ fn attrs() {
assert!(!parser.screen().cell(0, 2).unwrap().inverse());
parser.process(b"\x1b[1;3;4;7mo");
- assert!(parser.screen().bold());
- assert!(parser.screen().italic());
- assert!(parser.screen().underline());
- assert!(parser.screen().inverse());
assert!(parser.screen().cell(0, 3).unwrap().bold());
assert!(parser.screen().cell(0, 3).unwrap().italic());
assert!(parser.screen().cell(0, 3).unwrap().underline());
diff --git a/tests/escape.rs b/tests/escape.rs
index 5ab8581..2b7b9e4 100644
--- a/tests/escape.rs
+++ b/tests/escape.rs
@@ -40,14 +40,6 @@ fn ris() {
assert_eq!(parser.screen().title(), "");
assert_eq!(parser.screen().icon_name(), "");
- assert_eq!(parser.screen().fgcolor(), vt100::Color::Default);
- assert_eq!(parser.screen().bgcolor(), vt100::Color::Default);
-
- assert!(!parser.screen().bold());
- assert!(!parser.screen().italic());
- assert!(!parser.screen().underline());
- assert!(!parser.screen().inverse());
-
assert!(!parser.screen_mut().check_visual_bell());
assert!(!parser.screen_mut().check_audible_bell());
assert!(!parser.screen().application_keypad());
@@ -79,14 +71,6 @@ fn ris() {
assert_eq!(parser.screen().title(), "window title");
assert_eq!(parser.screen().icon_name(), "window icon name");
- assert_eq!(parser.screen().fgcolor(), vt100::Color::Idx(1));
- assert_eq!(parser.screen().bgcolor(), vt100::Color::Idx(7));
-
- assert!(parser.screen().bold());
- assert!(parser.screen().italic());
- assert!(parser.screen().underline());
- assert!(parser.screen().inverse());
-
assert!(parser.screen_mut().check_visual_bell());
assert!(parser.screen_mut().check_audible_bell());
assert!(parser.screen().application_keypad());
@@ -118,14 +102,6 @@ fn ris() {
assert_eq!(parser.screen().title(), "window title");
assert_eq!(parser.screen().icon_name(), "window icon name");
- assert_eq!(parser.screen().fgcolor(), vt100::Color::Default);
- assert_eq!(parser.screen().bgcolor(), vt100::Color::Default);
-
- assert!(!parser.screen().bold());
- assert!(!parser.screen().italic());
- assert!(!parser.screen().underline());
- assert!(!parser.screen().inverse());
-
// bell states don't change with reset
assert!(parser.screen_mut().check_visual_bell());
assert!(parser.screen_mut().check_audible_bell());
diff --git a/tests/init.rs b/tests/init.rs
index 7359c65..f26eb22 100644
--- a/tests/init.rs
+++ b/tests/init.rs
@@ -24,14 +24,6 @@ fn init() {
assert_eq!(parser.screen().title(), "");
assert_eq!(parser.screen().icon_name(), "");
- assert_eq!(parser.screen().fgcolor(), vt100::Color::Default);
- assert_eq!(parser.screen().bgcolor(), vt100::Color::Default);
-
- assert!(!parser.screen().bold());
- assert!(!parser.screen().italic());
- assert!(!parser.screen().underline());
- assert!(!parser.screen().inverse());
-
assert!(!parser.screen_mut().check_visual_bell());
assert!(!parser.screen_mut().check_audible_bell());
assert!(!parser.screen().application_keypad());
diff --git a/tests/mode.rs b/tests/mode.rs
index dfc8490..e6305a2 100644
--- a/tests/mode.rs
+++ b/tests/mode.rs
@@ -326,72 +326,58 @@ fn alternate_buffer() {
parser.process(b"\x1bc");
assert_eq!(parser.screen().contents(), "");
assert_eq!(parser.screen().cursor_position(), (0, 0));
- assert!(!parser.screen().alternate_screen());
parser.process(b"\x1b[m\x1b[2J\x1b[H1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n13\r\n14\r\n15\r\n16\r\n17\r\n18\r\n19\r\n20\r\n21\r\n22\r\n23\r\n24");
assert_eq!(parser.screen().contents(), "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24");
assert_eq!(parser.screen().cursor_position(), (23, 2));
- assert!(!parser.screen().alternate_screen());
parser.process(b"\x1b[?47h");
assert_eq!(parser.screen().contents(), "");
assert_eq!(parser.screen().cursor_position(), (0, 0));
- assert!(parser.screen().alternate_screen());
parser.process(b"foobar");
assert_eq!(parser.screen().contents(), "foobar");
assert_eq!(parser.screen().cursor_position(), (0, 6));
- assert!(parser.screen().alternate_screen());
parser.process(b"\x1b[?47l");
assert_eq!(parser.screen().contents(), "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24");
assert_eq!(parser.screen().cursor_position(), (23, 2));
- assert!(!parser.screen().alternate_screen());
parser.process(b"\x1b[?47h");
assert_eq!(parser.screen().contents(), "foobar");
assert_eq!(parser.screen().cursor_position(), (0, 6));
- assert!(parser.screen().alternate_screen());
parser.process(b"\x1b[?47l");
assert_eq!(parser.screen().contents(), "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24");
assert_eq!(parser.screen().cursor_position(), (23, 2));
- assert!(!parser.screen().alternate_screen());
// 1049
parser.process(b"\x1bc");
assert_eq!(parser.screen().contents(), "");
assert_eq!(parser.screen().cursor_position(), (0, 0));
- assert!(!parser.screen().alternate_screen());
parser.process(b"\x1b[m\x1b[2J\x1b[H1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11\r\n12\r\n13\r\n14\r\n15\r\n16\r\n17\r\n18\r\n19\r\n20\r\n21\r\n22\r\n23\r\n24");
assert_eq!(parser.screen().contents(), "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24");
assert_eq!(parser.screen().cursor_position(), (23, 2));
- assert!(!parser.screen().alternate_screen());
parser.process(b"\x1b[?1049h");
assert_eq!(parser.screen().contents(), "");
assert_eq!(parser.screen().cursor_position(), (0, 0));
- assert!(parser.screen().alternate_screen());
parser.process(b"foobar");
assert_eq!(parser.screen().contents(), "foobar");
assert_eq!(parser.screen().cursor_position(), (0, 6));
- assert!(parser.screen().alternate_screen());
parser.process(b"\x1b[?1049l");
assert_eq!(parser.screen().contents(), "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24");
assert_eq!(parser.screen().cursor_position(), (23, 2));
- assert!(!parser.screen().alternate_screen());
parser.process(b"\x1b[?1049h");
assert_eq!(parser.screen().contents(), "");
assert_eq!(parser.screen().cursor_position(), (0, 0));
- assert!(parser.screen().alternate_screen());
parser.process(b"\x1b[?1049l");
assert_eq!(parser.screen().contents(), "1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16\n17\n18\n19\n20\n21\n22\n23\n24");
assert_eq!(parser.screen().cursor_position(), (23, 2));
- assert!(!parser.screen().alternate_screen());
}