neovim-gtk/src/ui_model/cell.rs

67 lines
1.3 KiB
Rust
Raw Normal View History

2017-08-23 09:45:56 +00:00
use color::Color;
#[derive(Clone)]
pub struct Attrs {
pub italic: bool,
pub bold: bool,
pub underline: bool,
pub undercurl: bool,
pub foreground: Option<Color>,
pub background: Option<Color>,
pub special: Option<Color>,
pub reverse: bool,
pub double_width: bool,
}
impl Attrs {
pub fn new() -> Attrs {
Attrs {
foreground: None,
background: None,
special: None,
italic: false,
bold: false,
underline: false,
undercurl: false,
reverse: false,
double_width: false,
}
}
fn clear(&mut self) {
self.italic = false;
self.bold = false;
self.underline = false;
self.undercurl = false;
self.reverse = false;
self.foreground = None;
self.background = None;
self.special = None;
self.double_width = false;
}
}
#[derive(Clone)]
pub struct Cell {
pub attrs: Attrs,
2017-08-25 15:32:30 +00:00
pub ch: char,
pub dirty: bool,
2017-08-23 09:45:56 +00:00
}
impl Cell {
pub fn new(ch: char) -> Cell {
Cell {
attrs: Attrs::new(),
2017-08-25 15:32:30 +00:00
ch: ch,
2017-08-31 15:37:55 +00:00
dirty: true,
2017-08-23 09:45:56 +00:00
}
}
pub fn clear(&mut self) {
self.ch = ' ';
self.attrs.clear();
2017-08-31 15:37:55 +00:00
self.dirty = true;
2017-08-23 09:45:56 +00:00
}
}