diff --git a/build.rs b/build.rs index 8e12b51..afc333b 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,6 @@ fn main() { - println!("cargo:rustc-link-search=native=C:\\msys64\\mingw64\\lib"); + if cfg!(target = "windows") { + println!("cargo:rustc-link-search=native=C:\\msys64\\mingw64\\lib"); + } } diff --git a/src/main.rs b/src/main.rs index 18932b4..21a6425 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ extern crate gtk; extern crate cairo; +mod ui_model; mod ui; use ui::Ui; diff --git a/src/ui.rs b/src/ui.rs index ecb1924..bea65c9 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -3,6 +3,8 @@ use gtk; use gtk::prelude::*; use gtk::{Window, WindowType, DrawingArea, Grid, Button, ButtonBox, Orientation}; +use ui_model::UiModel; + pub struct Ui; impl Ui { diff --git a/src/ui_model.rs b/src/ui_model.rs new file mode 100644 index 0000000..18705a6 --- /dev/null +++ b/src/ui_model.rs @@ -0,0 +1,40 @@ +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, +} + +impl UiModel { + 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, + } + } + + pub fn set_cursor(&mut self, col: u64, row: u64) { + self.cur_col = col; + self.cur_row = row; + } +}