aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/errors.rs
diff options
context:
space:
mode:
authorBrooks Rady <b.j.rady@gmail.com>2021-03-26 13:20:06 +0000
committerGitHub <noreply@github.com>2021-03-26 13:20:06 +0000
commitd818661c727a59312e1a43432e84fbeec79fc145 (patch)
treee8ab04124ee7f5c87cd88be63c1867c7d9b2289c /src/common/errors.rs
parentfix(render): various rendering issues (#238) (diff)
parentFix some overzealous format!() removals and a stray comment (diff)
downloadsl0ppij-d818661c727a59312e1a43432e84fbeec79fc145.tar.gz
sl0ppij-d818661c727a59312e1a43432e84fbeec79fc145.tar.xz
sl0ppij-d818661c727a59312e1a43432e84fbeec79fc145.zip
feat(plugin): refactored to a new and more general plugin API
- Changed `init()` to `load()` - Deduplicated structs that are in both `zellij` and `zellij-tile` - WASM thread now keeps a mapping of plugins and event subscriptions - Added host-functions for subscribing and unsubscribing from events - Introduced the `update(event)` callback into the API (which is called to handle plugin events) - Made mode changes send an event to the WASM thread - Removed the `AppInstruction::Get/SetState` calls (and any global state) - Removed the `get_help()` host function - Added an event system for key-presses - Added an event for updating tabs - Ported support for renaming tabs - Removed every plugin callback other than `load()`, `update(event)`, and `draw(rows, cols)` - Removed every WASM thread event other than Load, Draw, Update, Unload, and Quit - Calls render after a plugin is updated - Switched back to upstream `termion` - Loads of lint fixing - Shrunk and simplified the code!
Diffstat (limited to 'src/common/errors.rs')
-rw-r--r--src/common/errors.rs22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/common/errors.rs b/src/common/errors.rs
index eeebf93f..f5aeae85 100644
--- a/src/common/errors.rs
+++ b/src/common/errors.rs
@@ -133,7 +133,7 @@ pub enum ContextType {
Plugin(PluginContext),
/// An app-related call.
App(AppContext),
- IPCServer,
+ IpcServer,
StdinHandler,
AsyncTask,
/// An empty, placeholder call. This should be thought of as representing no call at all.
@@ -152,7 +152,7 @@ impl Display for ContextType {
ContextType::Plugin(c) => write!(f, "{}plugin_thread: {}{:?}", purple, green, c),
ContextType::App(c) => write!(f, "{}main_thread: {}{:?}", purple, green, c),
- ContextType::IPCServer => write!(f, "{}ipc_server: {}AcceptInput", purple, green),
+ ContextType::IpcServer => write!(f, "{}ipc_server: {}AcceptInput", purple, green),
ContextType::StdinHandler => {
write!(f, "{}stdin_handler_thread: {}AcceptInput", purple, green)
}
@@ -164,6 +164,7 @@ impl Display for ContextType {
}
}
+// FIXME: Just deriving EnumDiscriminants from strum will remove the need for any of this!!!
/// Stack call representations corresponding to the different types of [`ScreenInstruction`]s.
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum ScreenContext {
@@ -202,6 +203,7 @@ pub enum ScreenContext {
ChangeInputMode,
}
+// FIXME: Just deriving EnumDiscriminants from strum will remove the need for any of this!!!
impl From<&ScreenInstruction> for ScreenContext {
fn from(screen_instruction: &ScreenInstruction) -> Self {
match *screen_instruction {
@@ -278,24 +280,20 @@ use crate::wasm_vm::PluginInstruction;
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum PluginContext {
Load,
- Draw,
- Input,
- GlobalInput,
+ Update,
+ Render,
Unload,
Quit,
- Tabs,
}
impl From<&PluginInstruction> for PluginContext {
fn from(plugin_instruction: &PluginInstruction) -> Self {
match *plugin_instruction {
PluginInstruction::Load(..) => PluginContext::Load,
- PluginInstruction::Draw(..) => PluginContext::Draw,
- PluginInstruction::Input(..) => PluginContext::Input,
- PluginInstruction::GlobalInput(_) => PluginContext::GlobalInput,
+ PluginInstruction::Update(..) => PluginContext::Update,
+ PluginInstruction::Render(..) => PluginContext::Render,
PluginInstruction::Unload(_) => PluginContext::Unload,
PluginInstruction::Quit => PluginContext::Quit,
- PluginInstruction::UpdateTabs(..) => PluginContext::Tabs,
}
}
}
@@ -303,8 +301,6 @@ impl From<&PluginInstruction> for PluginContext {
/// Stack call representations corresponding to the different types of [`AppInstruction`]s.
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum AppContext {
- GetState,
- SetState,
Exit,
Error,
}
@@ -312,8 +308,6 @@ pub enum AppContext {
impl From<&AppInstruction> for AppContext {
fn from(app_instruction: &AppInstruction) -> Self {
match *app_instruction {
- AppInstruction::GetState(_) => AppContext::GetState,
- AppInstruction::SetState(_) => AppContext::SetState,
AppInstruction::Exit => AppContext::Exit,
AppInstruction::Error(_) => AppContext::Error,
}