aboutsummaryrefslogtreecommitdiffstats
path: root/src/common/errors.rs
diff options
context:
space:
mode:
authora-kenji <aks.kenji@protonmail.com>2021-04-17 00:15:52 +0200
committera-kenji <aks.kenji@protonmail.com>2021-04-17 00:15:52 +0200
commit60ad7494739b4cbcd857e74df9d05830459323eb (patch)
tree772d24c71de04d150a7b7a447842429e5a82e786 /src/common/errors.rs
parentAdd Unbind Setting for Keybinds (diff)
parentMerge branch 'main' of github.com:zellij-org/zellij (diff)
downloadsl0ppij-60ad7494739b4cbcd857e74df9d05830459323eb.tar.gz
sl0ppij-60ad7494739b4cbcd857e74df9d05830459323eb.tar.xz
sl0ppij-60ad7494739b4cbcd857e74df9d05830459323eb.zip
Merge branch 'main' of https://github.com/zellij-org/zellij into unbind-default-keys
Diffstat (limited to 'src/common/errors.rs')
-rw-r--r--src/common/errors.rs24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/common/errors.rs b/src/common/errors.rs
index 00284cd4..d0b748ab 100644
--- a/src/common/errors.rs
+++ b/src/common/errors.rs
@@ -1,7 +1,7 @@
//! Error context system based on a thread-local representation of the call stack, itself based on
//! the instructions that are sent between threads.
-use super::{AppInstruction, OPENCALLS};
+use super::{AppInstruction, ASYNCOPENCALLS, OPENCALLS};
use crate::pty_bus::PtyInstruction;
use crate::screen::ScreenInstruction;
@@ -72,6 +72,12 @@ pub fn handle_panic(
}
}
+pub fn get_current_ctx() -> ErrorContext {
+ ASYNCOPENCALLS
+ .try_with(|ctx| *ctx.borrow())
+ .unwrap_or_else(|_| OPENCALLS.with(|ctx| *ctx.borrow()))
+}
+
/// A representation of the call stack.
#[derive(Clone, Copy)]
pub struct ErrorContext {
@@ -95,7 +101,9 @@ impl ErrorContext {
break;
}
}
- OPENCALLS.with(|ctx| *ctx.borrow_mut() = *self);
+ ASYNCOPENCALLS
+ .try_with(|ctx| *ctx.borrow_mut() = *self)
+ .unwrap_or_else(|_| OPENCALLS.with(|ctx| *ctx.borrow_mut() = *self));
}
}
@@ -168,7 +176,7 @@ impl Display for ContextType {
/// Stack call representations corresponding to the different types of [`ScreenInstruction`]s.
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum ScreenContext {
- HandlePtyEvent,
+ HandlePtyBytes,
Render,
NewPane,
HorizontalSplit,
@@ -178,7 +186,9 @@ pub enum ScreenContext {
ResizeRight,
ResizeDown,
ResizeUp,
- MoveFocus,
+ SwitchFocus,
+ FocusNextPane,
+ FocusPreviousPane,
MoveFocusLeft,
MoveFocusDown,
MoveFocusUp,
@@ -208,7 +218,7 @@ pub enum ScreenContext {
impl From<&ScreenInstruction> for ScreenContext {
fn from(screen_instruction: &ScreenInstruction) -> Self {
match *screen_instruction {
- ScreenInstruction::Pty(..) => ScreenContext::HandlePtyEvent,
+ ScreenInstruction::PtyBytes(..) => ScreenContext::HandlePtyBytes,
ScreenInstruction::Render => ScreenContext::Render,
ScreenInstruction::NewPane(_) => ScreenContext::NewPane,
ScreenInstruction::HorizontalSplit(_) => ScreenContext::HorizontalSplit,
@@ -218,7 +228,9 @@ impl From<&ScreenInstruction> for ScreenContext {
ScreenInstruction::ResizeRight => ScreenContext::ResizeRight,
ScreenInstruction::ResizeDown => ScreenContext::ResizeDown,
ScreenInstruction::ResizeUp => ScreenContext::ResizeUp,
- ScreenInstruction::MoveFocus => ScreenContext::MoveFocus,
+ ScreenInstruction::SwitchFocus => ScreenContext::SwitchFocus,
+ ScreenInstruction::FocusNextPane => ScreenContext::FocusNextPane,
+ ScreenInstruction::FocusPreviousPane => ScreenContext::FocusPreviousPane,
ScreenInstruction::MoveFocusLeft => ScreenContext::MoveFocusLeft,
ScreenInstruction::MoveFocusDown => ScreenContext::MoveFocusDown,
ScreenInstruction::MoveFocusUp => ScreenContext::MoveFocusUp,