diff options
| author | denis <denismaximov98@gmail.com> | 2021-04-22 11:45:29 +0300 |
|---|---|---|
| committer | denis <denismaximov98@gmail.com> | 2021-04-22 11:45:29 +0300 |
| commit | 8d98ca7da0bc278a832e4e7de23ff63a84deb529 (patch) | |
| tree | e7fdfaa6c1ae25e7737dbb36bd1dbcb94d62ab47 /src/common/errors.rs | |
| parent | wip: fixing the first arrow (diff) | |
| parent | fix(cargo): reduce crate size by 4.8MB using `cargo diet`, to 77kB (diff) | |
| download | sl0ppij-8d98ca7da0bc278a832e4e7de23ff63a84deb529.tar.gz sl0ppij-8d98ca7da0bc278a832e4e7de23ff63a84deb529.tar.xz sl0ppij-8d98ca7da0bc278a832e4e7de23ff63a84deb529.zip | |
wip: merge main in
Diffstat (limited to 'src/common/errors.rs')
| -rw-r--r-- | src/common/errors.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/common/errors.rs b/src/common/errors.rs index 9801428c..dd675738 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)); } } @@ -188,6 +196,8 @@ pub enum ScreenContext { Quit, ScrollUp, ScrollDown, + PageScrollUp, + PageScrollDown, ClearScroll, CloseFocusedPane, ToggleActiveTerminalFullscreen, @@ -230,6 +240,8 @@ impl From<&ScreenInstruction> for ScreenContext { ScreenInstruction::Quit => ScreenContext::Quit, ScreenInstruction::ScrollUp => ScreenContext::ScrollUp, ScreenInstruction::ScrollDown => ScreenContext::ScrollDown, + ScreenInstruction::PageScrollUp => ScreenContext::PageScrollUp, + ScreenInstruction::PageScrollDown => ScreenContext::PageScrollDown, ScreenInstruction::ClearScroll => ScreenContext::ClearScroll, ScreenInstruction::CloseFocusedPane => ScreenContext::CloseFocusedPane, ScreenInstruction::ToggleActiveTerminalFullscreen => { |
