IMPL EXISTS U DOG
parent
f310b53a98
commit
df0e16797c
BIN
src/.gui.rs.swp
BIN
src/.gui.rs.swp
Binary file not shown.
21
src/gui.rs
21
src/gui.rs
|
|
@ -5,14 +5,26 @@ use iced::event;
|
|||
use iced::subscription;
|
||||
use iced::{Alignment, Element, Application, Settings, Subscription, Theme, Command};
|
||||
|
||||
pub fn main() -> iced::Result {
|
||||
Main::run(Settings::default())
|
||||
pub fn main(outputEngine: dyn FnMut(Vec<char>)) -> iced::Result {
|
||||
let settings = Settings{
|
||||
flags: Flags {
|
||||
outputEngine: outputEngine,
|
||||
},
|
||||
..Settings::<Flags>::default()
|
||||
};
|
||||
Main::run(settings)
|
||||
}
|
||||
|
||||
struct Main {
|
||||
ntfy: String,
|
||||
configuring: Option<Message>,
|
||||
inputs: Inputs,
|
||||
flags: Flags,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct Flags {
|
||||
outputEngine: dyn FnMut(Vec<char>),
|
||||
}
|
||||
|
||||
struct Inputs {
|
||||
|
|
@ -53,11 +65,11 @@ fn controller_button_to_string(msg: Message) -> String {
|
|||
|
||||
impl Application for Main {
|
||||
type Message = Message;
|
||||
type Flags = ();
|
||||
type Flags = Flags;
|
||||
type Theme = Theme;
|
||||
type Executor = executor::Default;
|
||||
|
||||
fn new(_flags: ()) -> (Self, Command<Message>) {
|
||||
fn new(flags: Self::Flags) -> (Self, Command<Message>) {
|
||||
return (Self {
|
||||
ntfy: String::from(":wave:"),
|
||||
configuring: None,
|
||||
|
|
@ -75,6 +87,7 @@ impl Application for Main {
|
|||
l: iced::keyboard::KeyCode::Q,
|
||||
r: iced::keyboard::KeyCode::E,
|
||||
},
|
||||
flags: flags,
|
||||
}, Command::none())
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@ mod gui;
|
|||
fn main() {
|
||||
let cfg = config::build_config().unwrap();
|
||||
if cfg.streams.input.engine.name == "gui" {
|
||||
gui::main().unwrap();
|
||||
let output_engine = engine::build_output_engine(&cfg.streams.output.engine);
|
||||
let mut output_engine = output_engine.unwrap();
|
||||
let cb = |v: Vec<char>| output_engine.put(v);
|
||||
gui::main(cb).unwrap();
|
||||
} else {
|
||||
main_cli(cfg);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue