move gui sending to output_stream into func
parent
b710080497
commit
de2b4f4da6
89
src/gui.rs
89
src/gui.rs
|
|
@ -4,6 +4,8 @@ use iced::keyboard;
|
||||||
use iced::subscription;
|
use iced::subscription;
|
||||||
use iced::{Alignment, Element, Application, Settings, Subscription, Theme, Command};
|
use iced::{Alignment, Element, Application, Settings, Subscription, Theme, Command};
|
||||||
use iced_futures::backend::native::async_std::time::every;
|
use iced_futures::backend::native::async_std::time::every;
|
||||||
|
use handlebars::Handlebars;
|
||||||
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
use crate::stream::OutputStream;
|
use crate::stream::OutputStream;
|
||||||
use crate::config::GUI;
|
use crate::config::GUI;
|
||||||
|
|
@ -95,6 +97,48 @@ impl Main {
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn exchange(&mut self) {
|
||||||
|
let mut s = vec![];
|
||||||
|
for key_code in self.keys_newly_down.iter() {
|
||||||
|
match self.key_code_to_string(key_code) {
|
||||||
|
Some(x) => {
|
||||||
|
for c in self.flags.cfg.press.prefix.chars() {
|
||||||
|
s.push(c);
|
||||||
|
}
|
||||||
|
for c in x.chars() {
|
||||||
|
s.push(c);
|
||||||
|
}
|
||||||
|
for c in self.flags.cfg.press.suffix.chars() {
|
||||||
|
s.push(c);
|
||||||
|
}
|
||||||
|
self.keys_already_down.push(*key_code);
|
||||||
|
},
|
||||||
|
None => {},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
self.keys_newly_down.clear();
|
||||||
|
for key_code in self.keys_up.iter() {
|
||||||
|
match self.key_code_to_string(key_code) {
|
||||||
|
Some(x) => {
|
||||||
|
for c in x.chars() {
|
||||||
|
for c in self.flags.cfg.release.prefix.chars() {
|
||||||
|
s.push(c);
|
||||||
|
}
|
||||||
|
s.push(c);
|
||||||
|
for c in self.flags.cfg.release.suffix.chars() {
|
||||||
|
s.push(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
None => {},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if s.len() > 0 {
|
||||||
|
self.flags.output_stream.put(s);
|
||||||
|
}
|
||||||
|
self.keys_up.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Application for Main {
|
impl Application for Main {
|
||||||
|
|
@ -135,50 +179,7 @@ impl Application for Main {
|
||||||
fn update(&mut self, msg: Message) -> Command<Message> {
|
fn update(&mut self, msg: Message) -> Command<Message> {
|
||||||
match msg.clone() {
|
match msg.clone() {
|
||||||
Message::Tick => {
|
Message::Tick => {
|
||||||
let mut s = vec![];
|
self.exchange();
|
||||||
for key_code in self.keys_newly_down.iter() {
|
|
||||||
match self.key_code_to_string(key_code) {
|
|
||||||
Some(x) => {
|
|
||||||
for c in self.flags.cfg.press.prefix.chars() {
|
|
||||||
s.push(c);
|
|
||||||
}
|
|
||||||
for c in x.chars() {
|
|
||||||
s.push(c);
|
|
||||||
}
|
|
||||||
for c in self.flags.cfg.press.suffix.chars() {
|
|
||||||
s.push(c);
|
|
||||||
}
|
|
||||||
self.keys_already_down.push(*key_code);
|
|
||||||
},
|
|
||||||
None => {},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if s.len() > 0 {
|
|
||||||
self.flags.output_stream.put(s);
|
|
||||||
}
|
|
||||||
self.keys_newly_down.clear();
|
|
||||||
|
|
||||||
let mut s = vec![];
|
|
||||||
for key_code in self.keys_up.iter() {
|
|
||||||
match self.key_code_to_string(key_code) {
|
|
||||||
Some(x) => {
|
|
||||||
for c in x.chars() {
|
|
||||||
for c in self.flags.cfg.release.prefix.chars() {
|
|
||||||
s.push(c);
|
|
||||||
}
|
|
||||||
s.push(c);
|
|
||||||
for c in self.flags.cfg.release.suffix.chars() {
|
|
||||||
s.push(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
None => {},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if s.len() > 0 {
|
|
||||||
self.flags.output_stream.put(s);
|
|
||||||
}
|
|
||||||
self.keys_up.clear();
|
|
||||||
},
|
},
|
||||||
Message::EventOccurred(event) if self.configuring.is_some() => {
|
Message::EventOccurred(event) if self.configuring.is_some() => {
|
||||||
match event {
|
match event {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue