From 4a6ddf107064c8b80b64346c15ae86f11e2fb0b7 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Wed, 7 Apr 2021 13:13:32 +0200 Subject: Delete demo lua console, start usbtmc driver --- src/main.rs | 69 +------------------------------------------------------------ 1 file changed, 1 insertion(+), 68 deletions(-) (limited to 'src/main.rs') 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, - 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::() { - Ok(values) => { - new_text.push_str( - &values - .iter() - .map(|value| format!("{:?}", value)) - .collect::>() - .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); }); } -- cgit v1.2.1