Implement basic dust GUI
This commit is contained in:
parent
ca7051d24d
commit
0b79287132
@ -1,5 +1,5 @@
|
|||||||
use dust_lib::eval;
|
use dust_lib::eval;
|
||||||
use iced::widget::{button, column, container, scrollable, text, text_input};
|
use iced::widget::{button, column, container, scrollable, text, text_input, Column, Text};
|
||||||
use iced::{executor, Alignment, Application, Command, Element, Sandbox, Settings, Theme};
|
use iced::{executor, Alignment, Application, Command, Element, Sandbox, Settings, Theme};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
@ -47,6 +47,11 @@ impl Application for DustGui {
|
|||||||
Message::Evaluate => {
|
Message::Evaluate => {
|
||||||
let eval_result = eval(&self.text_buffer);
|
let eval_result = eval(&self.text_buffer);
|
||||||
|
|
||||||
|
match eval_result {
|
||||||
|
Ok(result) => self.results.push(result.to_string()),
|
||||||
|
Err(error) => self.results.push(error.to_string()),
|
||||||
|
}
|
||||||
|
|
||||||
Command::batch(vec![])
|
Command::batch(vec![])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -60,7 +65,19 @@ impl Application for DustGui {
|
|||||||
.padding(15)
|
.padding(15)
|
||||||
.size(30);
|
.size(30);
|
||||||
|
|
||||||
scrollable(container(column![input])).into()
|
let result_display: Column<Message> = {
|
||||||
|
let mut text_widgets = Vec::new();
|
||||||
|
|
||||||
|
for result in &self.results {
|
||||||
|
text_widgets.push(text(result).into());
|
||||||
|
}
|
||||||
|
|
||||||
|
text_widgets.reverse();
|
||||||
|
|
||||||
|
Column::with_children(text_widgets)
|
||||||
|
};
|
||||||
|
|
||||||
|
container(column![input, result_display]).into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user