exec .zenshell files + shell extensions

Co-authored-by: Tristan Poland (Trident_For_U) <tristanpoland@users.noreply.github.com>
This commit is contained in:
Chance 2024-12-06 15:54:31 -05:00 committed by BitSyndicate
parent 8cf6716a09
commit 0cf7e3e60d
Signed by: bitsyndicate
GPG key ID: 443E4198D6BBA6DE
16 changed files with 494 additions and 37 deletions

77
plugin_api/src/lib.rs Normal file
View file

@ -0,0 +1,77 @@
use std::collections::HashMap;
pub use horizon_plugin_api::{get_plugin, LoadedPlugin, Plugin, Pluginstate, Version};
pub mod plugin_imports;
// Define the current plugin version
const PLUGIN_API_VERSION: Version = Version {
major: 0,
minor: 1,
hotfix: 0,
};
#[derive(Clone)]
pub struct PluginManager {
plugins: HashMap<String, (Pluginstate, Plugin)>,
}
#[macro_export]
macro_rules! load_plugins {
($($plugin:ident),* $(,)?) => {
{
let mut plugins = HashMap::new();
$(
plugins.insert(
stringify!($plugin).to_string(),
(Pluginstate::ACTIVE, <$plugin::Plugin as $plugin::PluginConstruct>::new(plugins.clone())),
);
)*
plugins
}
};
}
impl PluginManager {
/// Allow instantiation of the ``PluginManager`` struct
pub fn new() -> PluginManager {
let new_manager = PluginManager {
plugins: HashMap::new(),
};
new_manager
}
pub fn load_plugin(mut self, name: String, plugin: Plugin) {
self.plugins.insert(name, (Pluginstate::ACTIVE, plugin));
}
pub fn unload_plugin(mut self, name: String) {
self.plugins.remove(&name);
}
pub fn get_plugins(self) -> HashMap<String, (Pluginstate, Plugin)> {
self.plugins
}
pub fn load_all(&mut self) -> HashMap<String, LoadedPlugin> {
self.plugins = plugin_imports::load_plugins();
//let my_test_plugin = get_plugin!(test_plugin, plugins);
//let result = my_test_plugin.thing();
let mut loaded_plugins = HashMap::new();
for (name, (state, plugin)) in &self.plugins {
if *state == Pluginstate::ACTIVE {
loaded_plugins.insert(
name.clone(),
LoadedPlugin {
instance: plugin.clone(),
},
);
}
}
loaded_plugins
}
}

View file

@ -0,0 +1,18 @@
// This file is automatically generated by build.rs
// Do not edit this file manually!
use horizon_plugin_api::{Pluginstate, LoadedPlugin, Plugin};
use std::collections::HashMap;
pub use player_lib;
pub use player_lib::*;
pub use player_lib::Plugin as player_lib_plugin;
// Invoke the macro with all discovered plugins
pub fn load_plugins() -> HashMap<String, (Pluginstate, Plugin)> {
let plugins = crate::load_plugins!(
player_lib
);
plugins
}