From 67df88853835ca1646a953f1bcec1ccf3893f3c6 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sat, 6 Mar 2021 23:25:32 -0500 Subject: add methods to retrieve the current drawing state attributes --- src/screen.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/screen.rs b/src/screen.rs index 4d91bfe..3d242aa 100644 --- a/src/screen.rs +++ b/src/screen.rs @@ -568,6 +568,46 @@ impl Screen { self.mouse_protocol_encoding } + /// Returns the currently active foreground color. + #[must_use] + pub fn fgcolor(&self) -> crate::attrs::Color { + self.attrs.fgcolor + } + + /// Returns the currently active background color. + #[must_use] + pub fn bgcolor(&self) -> crate::attrs::Color { + self.attrs.bgcolor + } + + /// Returns whether newly drawn text should be rendered with the bold text + /// attribute. + #[must_use] + pub fn bold(&self) -> bool { + self.attrs.bold() + } + + /// Returns whether newly drawn text should be rendered with the italic + /// text attribute. + #[must_use] + pub fn italic(&self) -> bool { + self.attrs.italic() + } + + /// Returns whether newly drawn text should be rendered with the + /// underlined text attribute. + #[must_use] + pub fn underline(&self) -> bool { + self.attrs.underline() + } + + /// Returns whether newly drawn text should be rendered with the inverse + /// text attribute. + #[must_use] + pub fn inverse(&self) -> bool { + self.attrs.inverse() + } + fn grid(&self) -> &crate::grid::Grid { if self.mode(Mode::AlternateScreen) { &self.alternate_grid -- cgit v1.2.3