wisp/src/main.rs

58 lines
1.4 KiB
Rust
Raw Normal View History

#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
// hide console window on Windows in release
2022-07-03 17:55:19 -05:00
use web_lisp::node::Node;
use web_lisp::{
lexer::{self, Token},
parser,
};
fn main() {
let abc = lexer::lex_string(include_str!("../web_lisp_src/hello_world.wisp").to_string());
let alksjdhfhlkj = parser::parse_vec(abc.as_slice());
eframe::run_native(
"Web Lisp Browser",
eframe::NativeOptions::default(),
Box::new(|_cc| Box::new(MyApp::new(abc))),
);
}
2022-07-03 17:55:19 -05:00
use eframe::egui::{self, Label, RichText, TextEdit};
struct MyApp {
2022-07-03 17:55:19 -05:00
omnibar: String,
tokens: Vec<Token>,
2022-07-03 17:55:19 -05:00
root_node: Node,
}
impl MyApp {
fn new(tokens: Vec<Token>) -> Self {
2022-07-03 17:55:19 -05:00
let mut root_node = Node::default();
root_node.text = "hi".to_string();
root_node.size = Some(30.0);
Self {
omnibar: "".to_string(),
tokens,
root_node,
}
}
}
impl eframe::App for MyApp {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
2022-07-03 17:55:19 -05:00
_frame.set_window_title("title");
ui.text_edit_singleline(&mut self.omnibar);
ui.separator();
let rn = &self.root_node;
let tx = RichText::new(rn.text.clone())
.size(rn.size.unwrap_or(12.0))
.underline();
ui.add(Label::new(tx));
});
}
}