Fix colors, some update of buttons bindings, eol_clear implementation,
quit button
This commit is contained in:
parent
3c45aff96e
commit
0c64c43278
2
build.rs
2
build.rs
@ -38,6 +38,7 @@ fn main() {
|
||||
.entry("less", "\"<\"")
|
||||
.entry("greater", "\">\"")
|
||||
.entry("comma", "\",\"")
|
||||
.entry("colon", "\":\"")
|
||||
.entry("period", "\".\"")
|
||||
.entry("BackSpace", "\"BS\"")
|
||||
.entry("space", "\"space\"")
|
||||
@ -47,6 +48,7 @@ fn main() {
|
||||
.entry("Page_Up", "\"PageUp\"")
|
||||
.entry("Page_Down", "\"PageDown\"")
|
||||
.entry("Enter", "\"CR\"")
|
||||
.entry("Tab", "\"Tab\"")
|
||||
.entry("ISO_Left_Tab", "\"Tab\"")
|
||||
.build(&mut file)
|
||||
.unwrap();
|
||||
|
@ -21,6 +21,8 @@ pub trait RedrawEvents {
|
||||
fn on_redraw(&self);
|
||||
|
||||
fn on_highlight_set(&mut self, attrs: &HashMap<String, Value>);
|
||||
|
||||
fn on_eol_clear(&mut self);
|
||||
}
|
||||
|
||||
macro_rules! try_str {
|
||||
@ -129,6 +131,12 @@ fn call(method: &str, args: Vec<Value>) {
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
"eol_clear" => {
|
||||
safe_call(move |ui| {
|
||||
ui.on_eol_clear();
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
_ => println!("Event {}({:?})", method, args),
|
||||
};
|
||||
}
|
||||
|
@ -77,6 +77,7 @@ impl Ui {
|
||||
|
||||
let exit_image = Image::new_from_icon_name("application-exit", 50);
|
||||
let exit_btn = ToolButton::new(Some(&exit_image), None);
|
||||
exit_btn.connect_clicked(|_| gtk::main_quit());
|
||||
button_bar.add(&exit_btn);
|
||||
|
||||
grid.attach(&button_bar, 0, 0, 1, 1);
|
||||
@ -231,6 +232,10 @@ impl RedrawEvents for Ui {
|
||||
self.model.clear();
|
||||
}
|
||||
|
||||
fn on_eol_clear(&mut self) {
|
||||
self.model.eol_clear();
|
||||
}
|
||||
|
||||
fn on_resize(&mut self, columns: u64, rows: u64) {
|
||||
self.model = UiModel::new(rows, columns);
|
||||
}
|
||||
@ -260,5 +265,5 @@ fn split_color(indexed_color: u64) -> Color {
|
||||
let r = ((indexed_color >> 16) & 0xff) as f64;
|
||||
let g = ((indexed_color >> 8) & 0xff) as f64;
|
||||
let b = (indexed_color & 0xff) as f64;
|
||||
Color(255.0 / r, 255.0 / g, 255.0 / b)
|
||||
Color(r / 255.0, g / 255.0, b / 255.0)
|
||||
}
|
||||
|
@ -22,6 +22,13 @@ impl Attrs {
|
||||
bold: false,
|
||||
}
|
||||
}
|
||||
|
||||
fn clear(&mut self) {
|
||||
self.italic = false;
|
||||
self.bold = false;
|
||||
self.foreground = COLOR_WHITE;
|
||||
self.background = COLOR_BLACK;
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Cell {
|
||||
@ -39,6 +46,7 @@ impl Cell {
|
||||
|
||||
fn clear(&mut self) {
|
||||
self.ch = ' ';
|
||||
self.attrs.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,4 +104,17 @@ impl UiModel {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn eol_clear(&mut self) {
|
||||
let (cur_row, cur_col, columns) = (self.cur_row, self.cur_col, self.columns);
|
||||
self.clear_region(cur_row, cur_row, cur_col, columns - 1);
|
||||
}
|
||||
|
||||
fn clear_region(&mut self, top: usize, bot: usize, left: usize, right: usize) {
|
||||
for row in top..bot + 1 {
|
||||
for col in left..right + 1 {
|
||||
self.model[row][col].clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user