From 0b79287132d351016d60ea4fe2729c517080edf1 Mon Sep 17 00:00:00 2001 From: Jeff Date: Wed, 30 Aug 2023 18:18:06 -0400 Subject: [PATCH] Implement basic dust GUI --- src/bin/gui.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/bin/gui.rs b/src/bin/gui.rs index 608beed..1be2f88 100644 --- a/src/bin/gui.rs +++ b/src/bin/gui.rs @@ -1,5 +1,5 @@ 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 once_cell::sync::Lazy; @@ -47,6 +47,11 @@ impl Application for DustGui { Message::Evaluate => { 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![]) } } @@ -60,7 +65,19 @@ impl Application for DustGui { .padding(15) .size(30); - scrollable(container(column![input])).into() + let result_display: Column = { + 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() } }