aboutsummaryrefslogtreecommitdiffstats
path: root/src/screen.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-03-09 01:46:51 -0500
committerJesse Luehrs <doy@tozt.net>2021-03-09 01:46:51 -0500
commitc9b957bcdfcd1cedbd8a1f3c5e16d1e4382b54c2 (patch)
tree34bcb2429f31c404f63139406c0c460b75b37243 /src/screen.rs
parent0d69a14a273176c8405602f7543694b65966c7e0 (diff)
downloadvt100-rust-c9b957bcdfcd1cedbd8a1f3c5e16d1e4382b54c2.tar.gz
vt100-rust-c9b957bcdfcd1cedbd8a1f3c5e16d1e4382b54c2.zip
fix attributes_formatted, remove attributes_diff
also improve the documentation and add more tests
Diffstat (limited to 'src/screen.rs')
-rw-r--r--src/screen.rs21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/screen.rs b/src/screen.rs
index cb6b970..9affeef 100644
--- a/src/screen.rs
+++ b/src/screen.rs
@@ -485,6 +485,12 @@ impl Screen {
/// * italic
/// * underline
/// * inverse
+ ///
+ /// This is not typically necessary, since `contents_formatted` will leave
+ /// the current active drawing attributes in the correct state, but this
+ /// can be useful in the case of drawing additional things on top of a
+ /// terminal output, since you will need to restore the terminal state
+ /// without the terminal contents necessarily being the same.
#[must_use]
pub fn attributes_formatted(&self) -> Vec<u8> {
let mut contents = vec![];
@@ -493,26 +499,13 @@ impl Screen {
}
fn write_attributes_formatted(&self, contents: &mut Vec<u8>) {
+ crate::term::ClearAttrs::default().write_buf(contents);
self.attrs.write_escape_code_diff(
contents,
&crate::attrs::Attrs::default(),
);
}
- /// Returns terminal escape sequences sufficient to change the previous
- /// terminal's drawing attributes to the drawing attributes enabled in the
- /// current terminal.
- #[must_use]
- pub fn attributes_diff(&self, prev: &Self) -> Vec<u8> {
- let mut contents = vec![];
- self.write_attributes_diff(&mut contents, prev);
- contents
- }
-
- fn write_attributes_diff(&self, contents: &mut Vec<u8>, prev: &Self) {
- self.attrs.write_escape_code_diff(contents, &prev.attrs);
- }
-
/// Returns the `Cell` object at the given location in the terminal, if it
/// exists.
#[must_use]