summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs69
1 files changed, 1 insertions, 68 deletions
diff --git a/src/main.rs b/src/main.rs
index 9e7d545..f997c06 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,80 +1,13 @@
-use imgui::*;
-use rlua::{Lua, MultiValue};
-
+mod rusbtmc;
mod support;
mod testbench;
-#[derive(Default)]
-struct State {
- lua: Lua,
- console: Vec<ImString>,
- repl_input: ImString,
-}
-
-impl State {
- fn new() -> State {
- State {
- lua: Lua::new(),
- console: Vec::new(),
- repl_input: ImString::with_capacity(256),
- }
- }
-}
-
-fn draw_console(_run: &mut bool, ui: &mut Ui, state: &mut State) {
- let win = Window::new(im_str!("Lua Console"))
- .size([400., 500.], Condition::Appearing)
- .position([440., 20.], Condition::Appearing);
-
- win.build(&ui, || {
- ChildWindow::new("console")
- .size([0., 400.])
- .scrollable(true)
- .build(&ui, || {
- for line in &state.console {
- ui.text(line);
- }
- });
-
- ui.separator();
- ui.input_text(im_str!("Lua"), &mut state.repl_input).build();
- ui.same_line(0.);
- if ui.button(im_str!("Eval"), [0., 0.]) {
- let input = state.repl_input.to_str().clone();
- let mut new_text = String::new();
-
- state.lua.context(|ctx| {
- match ctx.load(input).eval::<MultiValue>() {
- Ok(values) => {
- new_text.push_str(
- &values
- .iter()
- .map(|value| format!("{:?}", value))
- .collect::<Vec<_>>()
- .join("\t"),
- );
- }
- Err(e) => {
- new_text.push_str(&e.to_string());
- }
- };
- });
-
- state.console.push(ImString::new(format!("> {}", input)));
- state.console.push(ImString::new(new_text));
- state.repl_input.clear();
- }
- });
-}
-
fn main() {
let system = support::init(file!());
- let mut state = State::new();
let mut bench = testbench::Bench::new();
system.main_loop(move |run, ui| {
// ui.show_demo_window(run);
bench.draw(run, ui);
- draw_console(run, ui, &mut state);
});
}