use eframe::egui; use nac3parser::parser; fn main() -> eframe::Result { let options = eframe::NativeOptions { viewport: egui::ViewportBuilder::default().with_inner_size([1024.0, 768.0]), ..Default::default() }; let mut code = String::new(); eframe::run_simple_native("Cells", options, move |ctx, _frame| { let submit_key = egui::KeyboardShortcut::new(egui::Modifiers::CTRL, egui::Key::Enter); if ctx.input_mut(|i| i.consume_shortcut(&submit_key)) { match parser::parse_program(code.as_str(), String::from("cell1").into()) { Ok(parser_result) => println!("{:?}", parser_result), Err(err) => println!("parse error: {}", err), } } egui::CentralPanel::default().show(ctx, |ui| { let theme = egui_extras::syntax_highlighting::CodeTheme::from_memory(ui.ctx()); let mut layouter = |ui: &egui::Ui, string: &str, wrap_width: f32| { let mut layout_job = egui_extras::syntax_highlighting::highlight(ui.ctx(), &theme, string, "Python"); layout_job.wrap.max_width = wrap_width; layout_job.sections = layout_job .sections .iter() .map(|layout_section| { let mut section = layout_section.clone(); section.format.font_id = egui::FontId::monospace(16.0); section }) .collect(); ui.fonts(|f| f.layout_job(layout_job)) }; ui.add( egui::TextEdit::multiline(&mut code) .code_editor() .desired_rows(4) .lock_focus(true) .desired_width(f32::INFINITY) .layouter(&mut layouter) .font(egui::FontId::monospace(16.0)), ); }); }) }