From 9bda297b565829d83565394a1a42f96568d195dd Mon Sep 17 00:00:00 2001 From: Matias Fontanini Date: Sun, 4 Aug 2024 12:22:03 -0700 Subject: [PATCH] feat: always show snippet execution bar --- src/processing/execution.rs | 13 ++++++------- src/theme.rs | 4 ++++ themes/catppuccin-frappe.yaml | 2 ++ themes/catppuccin-latte.yaml | 2 ++ themes/catppuccin-macchiato.yaml | 2 ++ themes/catppuccin-mocha.yaml | 2 ++ themes/dark.yaml | 2 ++ themes/light.yaml | 2 ++ themes/terminal-dark.yaml | 2 ++ themes/terminal-light.yaml | 8 +++++--- themes/tokyonight-storm.yaml | 2 ++ 11 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/processing/execution.rs b/src/processing/execution.rs index dbfe077..f7d3121 100644 --- a/src/processing/execution.rs +++ b/src/processing/execution.rs @@ -47,7 +47,7 @@ impl RunSnippetOperation { let default_colors = theme.default_style.colors; let block_colors = theme.execution_output.colors; let status_colors = theme.execution_output.status.clone(); - let running_colors = status_colors.running; + let not_started_colors = status_colors.not_started; let alignment = theme.code.alignment.clone().unwrap_or_default(); let block_length = match &alignment { Alignment::Left { .. } | Alignment::Right { .. } => block_length, @@ -69,7 +69,7 @@ impl RunSnippetOperation { block_length, alignment, inner: Rc::new(RefCell::new(inner)), - state_description: Text::new("running", TextStyle::default().colors(running_colors)).into(), + state_description: Text::new("not started", TextStyle::default().colors(not_started_colors)).into(), } } } @@ -77,9 +77,6 @@ impl RunSnippetOperation { impl AsRenderOperations for RunSnippetOperation { fn as_render_operations(&self, _dimensions: &WindowSize) -> Vec { let inner = self.inner.borrow(); - if matches!(inner.state, RenderAsyncState::NotStarted) { - return Vec::new(); - } let description = self.state_description.borrow(); let heading = TextBlock(vec![" [".into(), description.clone(), "] ".into()]); let separator_width = match &self.alignment { @@ -91,9 +88,11 @@ impl AsRenderOperations for RunSnippetOperation { RenderOperation::RenderLineBreak, RenderOperation::RenderDynamic(Rc::new(separator)), RenderOperation::RenderLineBreak, - RenderOperation::RenderLineBreak, - RenderOperation::SetColors(self.block_colors), ]; + if matches!(inner.state, RenderAsyncState::NotStarted) { + return operations; + } + operations.extend([RenderOperation::RenderLineBreak, RenderOperation::SetColors(self.block_colors)]); let block_length = self.block_length.max(inner.max_line_length.saturating_add(1)); for line in &inner.output_lines { diff --git a/src/theme.rs b/src/theme.rs index dd1a080..0995732 100644 --- a/src/theme.rs +++ b/src/theme.rs @@ -528,6 +528,10 @@ pub(crate) struct ExecutionStatusBlockStyle { /// The colors for the "finished with error" status. #[serde(default)] pub(crate) failure: Colors, + + /// The colors for the "not started" status. + #[serde(default)] + pub(crate) not_started: Colors, } /// The style for inline code. diff --git a/themes/catppuccin-frappe.yaml b/themes/catppuccin-frappe.yaml index b9538ad..ba7009f 100644 --- a/themes/catppuccin-frappe.yaml +++ b/themes/catppuccin-frappe.yaml @@ -35,6 +35,8 @@ execution_output: foreground: "a6d189" failure: foreground: "e78284" + not_started: + foreground: "e5c890" inline_code: colors: diff --git a/themes/catppuccin-latte.yaml b/themes/catppuccin-latte.yaml index 949e1a8..d91618a 100644 --- a/themes/catppuccin-latte.yaml +++ b/themes/catppuccin-latte.yaml @@ -35,6 +35,8 @@ execution_output: foreground: "40a02b" failure: foreground: "d20f39" + not_started: + foreground: "df8e1d" inline_code: colors: diff --git a/themes/catppuccin-macchiato.yaml b/themes/catppuccin-macchiato.yaml index ace1f8c..90e0b75 100644 --- a/themes/catppuccin-macchiato.yaml +++ b/themes/catppuccin-macchiato.yaml @@ -35,6 +35,8 @@ execution_output: foreground: "a6da95" failure: foreground: "ed8796" + not_started: + foreground: "eed49f" inline_code: colors: diff --git a/themes/catppuccin-mocha.yaml b/themes/catppuccin-mocha.yaml index b653afd..0874bf3 100644 --- a/themes/catppuccin-mocha.yaml +++ b/themes/catppuccin-mocha.yaml @@ -35,6 +35,8 @@ execution_output: foreground: "a6e3a1" failure: foreground: "f38ba8" + not_started: + foreground: "f9e2af" inline_code: colors: diff --git a/themes/dark.yaml b/themes/dark.yaml index bee612f..01edb22 100644 --- a/themes/dark.yaml +++ b/themes/dark.yaml @@ -35,6 +35,8 @@ execution_output: foreground: "a8df8e" failure: foreground: "f78ca2" + not_started: + foreground: "ee9322" inline_code: colors: diff --git a/themes/light.yaml b/themes/light.yaml index 5891d5b..79d574e 100644 --- a/themes/light.yaml +++ b/themes/light.yaml @@ -35,6 +35,8 @@ execution_output: foreground: "52b788" failure: foreground: "f07167" + not_started: + foreground: "f77f00" inline_code: colors: diff --git a/themes/terminal-dark.yaml b/themes/terminal-dark.yaml index 025ce91..8c209fe 100644 --- a/themes/terminal-dark.yaml +++ b/themes/terminal-dark.yaml @@ -34,6 +34,8 @@ execution_output: foreground: "green" failure: foreground: "red" + not_started: + foreground: "yellow" inline_code: colors: diff --git a/themes/terminal-light.yaml b/themes/terminal-light.yaml index eb30e53..aaaf732 100644 --- a/themes/terminal-light.yaml +++ b/themes/terminal-light.yaml @@ -29,11 +29,13 @@ execution_output: background: grey status: running: - foreground: "dark_blue" + foreground: dark_blue success: - foreground: "dark_green" + foreground: dark_green failure: - foreground: "dark_red" + foreground: dark_red + not_started: + foreground: dark_yellow inline_code: colors: diff --git a/themes/tokyonight-storm.yaml b/themes/tokyonight-storm.yaml index adc7728..fed2846 100644 --- a/themes/tokyonight-storm.yaml +++ b/themes/tokyonight-storm.yaml @@ -35,6 +35,8 @@ execution_output: foreground: "9ece6a" failure: foreground: "f7768e" + not_started: + foreground: "e0af68" inline_code: colors: