aboutsummaryrefslogtreecommitdiffstats
path: root/src/cell.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-11-04 09:17:05 -0500
committerJesse Luehrs <doy@tozt.net>2019-11-04 09:19:42 -0500
commit8cd3ca2c07b29e61f18c0c34db8b34b36a42e03b (patch)
tree7331c8dbaa7132751df0b03f2030058a20d239d4 /src/cell.rs
parentd52d752af9a4bde993af7b0cb871e60b41eca2e0 (diff)
downloadvt100-rust-8cd3ca2c07b29e61f18c0c34db8b34b36a42e03b.tar.gz
vt100-rust-8cd3ca2c07b29e61f18c0c34db8b34b36a42e03b.zip
docs
Diffstat (limited to 'src/cell.rs')
-rw-r--r--src/cell.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/cell.rs b/src/cell.rs
index 2f83d73..3c92076 100644
--- a/src/cell.rs
+++ b/src/cell.rs
@@ -1,5 +1,6 @@
use unicode_normalization::UnicodeNormalization as _;
+/// Represents a single terminal cell.
#[derive(Clone, Debug, Default)]
pub struct Cell {
contents: String,
@@ -7,6 +8,7 @@ pub struct Cell {
}
impl Cell {
+ /// Creates a new cell.
pub fn new() -> Self {
Self::default()
}
@@ -31,14 +33,21 @@ impl Cell {
self.attrs.clear();
}
+ /// Returns the text contents of the cell.
+ ///
+ /// Can include multiple unicode characters if combining characters are
+ /// used, but will contain at most one character with a non-zero character
+ /// width.
pub fn contents(&self) -> &str {
&self.contents
}
+ /// Returns whether the cell contains any text data.
pub fn has_contents(&self) -> bool {
self.contents != ""
}
+ /// Returns whether the text data in the cell represents a wide character.
pub fn is_wide(&self) -> bool {
crate::unicode::str_width(&self.contents) > 1
}
@@ -47,26 +56,36 @@ impl Cell {
&self.attrs
}
+ /// Returns the foreground color of the cell.
pub fn fgcolor(&self) -> crate::attrs::Color {
self.attrs.fgcolor
}
+ /// Returns the background color of the cell.
pub fn bgcolor(&self) -> crate::attrs::Color {
self.attrs.bgcolor
}
+ /// Returns whether the cell should be rendered with the bold text
+ /// attribute.
pub fn bold(&self) -> bool {
self.attrs.bold()
}
+ /// Returns whether the cell should be rendered with the italic text
+ /// attribute.
pub fn italic(&self) -> bool {
self.attrs.italic()
}
+ /// Returns whether the cell should be rendered with the underlined text
+ /// attribute.
pub fn underline(&self) -> bool {
self.attrs.underline()
}
+ /// Returns whether the cell should be rendered with the inverse text
+ /// attribute.
pub fn inverse(&self) -> bool {
self.attrs.inverse()
}