gotta find differnet update interval
parent
68a496e920
commit
1f110c82e6
13
src/gui.rs
13
src/gui.rs
|
|
@ -1,7 +1,6 @@
|
||||||
use iced::widget::{button, column, text};
|
use iced::widget::{button, column, text};
|
||||||
use iced::executor;
|
use iced::executor;
|
||||||
use iced::keyboard;
|
use iced::keyboard;
|
||||||
use iced::event;
|
|
||||||
use iced::subscription;
|
use iced::subscription;
|
||||||
use iced::{Alignment, Element, Application, Settings, Subscription, Theme, Command};
|
use iced::{Alignment, Element, Application, Settings, Subscription, Theme, Command};
|
||||||
|
|
||||||
|
|
@ -138,9 +137,8 @@ impl Application for Main {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Message::EventOccurred(event) => {
|
Message::EventOccurred(event) => {
|
||||||
eprintln!("{:?}", event);
|
|
||||||
match event {
|
match event {
|
||||||
iced::event::Event::Keyboard(keyboard::Event::KeyPressed{ // TODO key released
|
iced::event::Event::Keyboard(keyboard::Event::KeyPressed{
|
||||||
key_code,
|
key_code,
|
||||||
modifiers: _,
|
modifiers: _,
|
||||||
..
|
..
|
||||||
|
|
@ -148,6 +146,15 @@ impl Application for Main {
|
||||||
self.keys_down.push(key_code);
|
self.keys_down.push(key_code);
|
||||||
self.keys_down.dedup();
|
self.keys_down.dedup();
|
||||||
},
|
},
|
||||||
|
iced::event::Event::Keyboard(keyboard::Event::KeyReleased{
|
||||||
|
key_code,
|
||||||
|
..
|
||||||
|
}) => {
|
||||||
|
match self.keys_down.iter().position(|x| *x == key_code) {
|
||||||
|
Some(idx) => { self.keys_down.remove(idx); },
|
||||||
|
None => {},
|
||||||
|
};
|
||||||
|
},
|
||||||
_ => {},
|
_ => {},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -226,7 +226,7 @@ impl OutputStream for OutputStreamFormatted {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sprintf(x: &String, v: Vec<char>) -> Vec<char> {
|
fn sprintf(x: &String, v: Vec<char>) -> Vec<char> {
|
||||||
let mut reg = Handlebars::new();
|
let reg = Handlebars::new();
|
||||||
return reg.render_template(x, &json!({
|
return reg.render_template(x, &json!({
|
||||||
"VALUE": v.iter().collect::<String>(),
|
"VALUE": v.iter().collect::<String>(),
|
||||||
"ms_since_epoch": SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_millis(),
|
"ms_since_epoch": SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_millis(),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue