pub mod config;
#[cfg(any(feature = "egui-backend", feature = "webview-backend"))]
pub mod icon;
pub mod image_validation;
#[cfg(feature = "webview-backend")]
pub mod markdown;
pub mod mermaid;
#[cfg(any(feature = "egui-backend", feature = "webview-backend"))]
pub mod net;
pub mod paths;
#[cfg(feature = "webview-backend")]
pub mod sanitize;
pub mod slug;
pub mod toc;
pub mod watcher;
use std::sync::atomic::{AtomicBool, AtomicU8, Ordering};
static VERBOSE: AtomicBool = AtomicBool::new(false);
pub fn set_verbose(v: bool) {
VERBOSE.store(v, Ordering::Relaxed);
}
pub fn verbose() -> bool {
VERBOSE.load(Ordering::Relaxed)
}
static OFFLINE: AtomicBool = AtomicBool::new(false);
pub fn set_offline(v: bool) {
OFFLINE.store(v, Ordering::Relaxed);
}
#[cfg(any(feature = "egui-backend", feature = "webview-backend"))]
pub fn offline() -> bool {
OFFLINE.load(Ordering::Relaxed)
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum Theme {
#[default]
Auto,
Dark,
Light,
}
impl Theme {
pub fn parse(s: &str) -> Option<Self> {
match s {
"auto" => Some(Theme::Auto),
"dark" => Some(Theme::Dark),
"light" => Some(Theme::Light),
_ => None,
}
}
}
static THEME: AtomicU8 = AtomicU8::new(0);
pub fn set_theme(theme: Theme) {
THEME.store(
match theme {
Theme::Auto => 0,
Theme::Dark => 1,
Theme::Light => 2,
},
Ordering::Relaxed,
);
}
#[cfg(feature = "tui-backend")]
pub fn theme() -> Theme {
match THEME.load(Ordering::Relaxed) {
1 => Theme::Dark,
2 => Theme::Light,
_ => Theme::Auto,
}
}
#[macro_export]
macro_rules! vlog {
($($arg:tt)*) => {
if $crate::core::verbose() {
eprintln!("[mdr] {}", format!($($arg)*));
}
};
}