initial commit - v0.1.0
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
use egui_commonmark::{CommonMarkCache, CommonMarkViewer};
|
||||
|
||||
pub struct MainEditor {
|
||||
preview: bool,
|
||||
text: String,
|
||||
}
|
||||
|
||||
impl MainEditor {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
preview: true,
|
||||
text: String::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn ui(&mut self, ctx: &egui::Context) {
|
||||
if self.preview {
|
||||
egui::TopBottomPanel::bottom("bottom_panel")
|
||||
.resizable(true)
|
||||
.default_height(250.0)
|
||||
.show(ctx, |ui| {
|
||||
egui::ScrollArea::vertical()
|
||||
.stick_to_bottom(true)
|
||||
.auto_shrink(false)
|
||||
.show(ui, |ui| {
|
||||
let mut cache = CommonMarkCache::default();
|
||||
CommonMarkViewer::new().show(ui, &mut cache, &self.text);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
egui::ScrollArea::vertical()
|
||||
.enable_scrolling(true)
|
||||
.auto_shrink(false)
|
||||
.show(ui, |ui| {
|
||||
ui.add(
|
||||
egui::TextEdit::multiline(&mut self.text)
|
||||
.id_source("MainEditor_numlines")
|
||||
.font(egui::TextStyle::Monospace)
|
||||
.interactive(true)
|
||||
.frame(false)
|
||||
.lock_focus(true)
|
||||
.hint_text("Type here...")
|
||||
.desired_width(256.0),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user