pub const KNOTWORK_NAME: &str = "Knotwork";
pub const MEDIA_PREVIEW_PLUGIN_ID: &str = "knotlook-media";
pub const TEXT_PREVIEW_PLUGIN_ID: &str = "knotread-text";
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PluginSlot {
Overlay,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct PluginDescriptor {
pub id: &'static str,
pub name: &'static str,
pub slot: PluginSlot,
pub shortcut: &'static str,
pub description: &'static str,
}
#[derive(Clone, Copy, Debug, Default)]
pub struct PluginRegistry;
const BUILTIN_PLUGINS: [PluginDescriptor; 2] = [
PluginDescriptor {
id: MEDIA_PREVIEW_PLUGIN_ID,
name: "Knotlook Media",
slot: PluginSlot::Overlay,
shortcut: "Space",
description: "Inline image and video preview using native Guth surfaces.",
},
PluginDescriptor {
id: TEXT_PREVIEW_PLUGIN_ID,
name: "Knotread Text",
slot: PluginSlot::Overlay,
shortcut: "Space",
description: "Bounded inline text, code, markdown, CSV, and log preview.",
},
];
impl PluginRegistry {
pub fn builtin() -> Self {
Self
}
pub fn all(self) -> &'static [PluginDescriptor] {
&BUILTIN_PLUGINS
}
pub fn media_preview(self) -> PluginDescriptor {
BUILTIN_PLUGINS[0]
}
pub fn text_preview(self) -> PluginDescriptor {
BUILTIN_PLUGINS[1]
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn builtin_registry_exposes_media_preview_plugin() {
let registry = PluginRegistry::builtin();
let plugin = registry.media_preview();
assert_eq!(plugin.id, MEDIA_PREVIEW_PLUGIN_ID);
assert_eq!(registry.all()[0], plugin);
assert_eq!(registry.text_preview().id, TEXT_PREVIEW_PLUGIN_ID);
}
}