Add screen model

This commit is contained in:
daa 2016-03-19 11:47:23 +03:00
parent 64d4746545
commit bd9dde064e
4 changed files with 46 additions and 1 deletions

View File

@ -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");
}
}

View File

@ -1,6 +1,7 @@
extern crate gtk;
extern crate cairo;
mod ui_model;
mod ui;
use ui::Ui;

View File

@ -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 {

40
src/ui_model.rs Normal file
View File

@ -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<Cell>,
}
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;
}
}