neovim-gtk/src/ui_model.rs

45 lines
823 B
Rust
Raw Normal View History

2016-03-19 08:47:23 +00:00
pub struct Cell {
ch: char,
}
impl Cell {
pub fn new(ch: char) -> Cell {
Cell { ch: ch }
}
}
pub struct UiModel {
columns: u64,
rows: u64,
cur_row: u64,
cur_col: u64,
model: Vec<Cell>,
}
impl UiModel {
2016-03-19 10:27:39 +00:00
pub fn empty() -> UiModel {
UiModel::new(0, 0)
}
2016-03-19 08:47:23 +00:00
pub fn new(columns: u64, rows: u64) -> UiModel {
let cells = (columns * rows) as usize;
let mut model = Vec::with_capacity(cells);
for i in 0..cells {
model[i] = Cell::new(' ');
}
UiModel {
columns: columns,
rows: rows,
cur_row: 0,
cur_col: 0,
model: model,
}
}
2016-03-28 14:03:21 +00:00
pub fn set_cursor(&mut self, row: u64, col: u64) {
2016-03-19 08:47:23 +00:00
self.cur_col = col;
self.cur_row = row;
}
}