59 lines
1.6 KiB
Rust
59 lines
1.6 KiB
Rust
use eframe::egui;
|
|
|
|
use crate::highlight::HighlightManager;
|
|
use crate::tab_manager::IndexingState;
|
|
|
|
pub struct TopMenuActions{
|
|
pub open_file_requested: bool,
|
|
}
|
|
|
|
pub fn render_top_menu(
|
|
ctx: &egui::Context,
|
|
highlight_manager: &mut HighlightManager,
|
|
indexing_state: &IndexingState,
|
|
|
|
) -> TopMenuActions {
|
|
|
|
let mut top_menu_actions = TopMenuActions{open_file_requested: false};
|
|
|
|
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
|
|
ui.horizontal(|ui| {
|
|
if ui.button("📂 Open File").clicked() {
|
|
top_menu_actions.open_file_requested = true;
|
|
}
|
|
|
|
if ui.button("🎨 Highlights").clicked() {
|
|
highlight_manager.toggle_editor();
|
|
}
|
|
|
|
ui.separator();
|
|
|
|
let mut to_toggle = None;
|
|
for (idx, rule) in highlight_manager.rules.iter().enumerate() {
|
|
let color = egui::Color32::from_rgb(rule.color[0], rule.color[1], rule.color[2]);
|
|
let button_text = egui::RichText::new(&rule.pattern)
|
|
.background_color(color)
|
|
.color(egui::Color32::BLACK);
|
|
|
|
if ui.selectable_label(rule.enabled, button_text).clicked() {
|
|
to_toggle = Some(idx);
|
|
}
|
|
}
|
|
|
|
if let Some(idx) = to_toggle {
|
|
highlight_manager.toggle_rule(idx);
|
|
// Signal that config should be saved
|
|
}
|
|
|
|
ui.separator();
|
|
|
|
if indexing_state.is_indexing() {
|
|
ui.spinner();
|
|
ui.label("Indexing...");
|
|
}
|
|
});
|
|
});
|
|
|
|
top_menu_actions
|
|
}
|