Skip to content

Commit

Permalink
feat: always show snippet execution bar
Browse files Browse the repository at this point in the history
  • Loading branch information
mfontanini committed Aug 4, 2024
1 parent 322fad6 commit 9bda297
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 10 deletions.
13 changes: 6 additions & 7 deletions src/processing/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -69,17 +69,14 @@ 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(),
}
}
}

impl AsRenderOperations for RunSnippetOperation {
fn as_render_operations(&self, _dimensions: &WindowSize) -> Vec<RenderOperation> {
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 {
Expand All @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions src/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions themes/catppuccin-frappe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ execution_output:
foreground: "a6d189"
failure:
foreground: "e78284"
not_started:
foreground: "e5c890"

inline_code:
colors:
Expand Down
2 changes: 2 additions & 0 deletions themes/catppuccin-latte.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ execution_output:
foreground: "40a02b"
failure:
foreground: "d20f39"
not_started:
foreground: "df8e1d"

inline_code:
colors:
Expand Down
2 changes: 2 additions & 0 deletions themes/catppuccin-macchiato.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ execution_output:
foreground: "a6da95"
failure:
foreground: "ed8796"
not_started:
foreground: "eed49f"

inline_code:
colors:
Expand Down
2 changes: 2 additions & 0 deletions themes/catppuccin-mocha.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ execution_output:
foreground: "a6e3a1"
failure:
foreground: "f38ba8"
not_started:
foreground: "f9e2af"

inline_code:
colors:
Expand Down
2 changes: 2 additions & 0 deletions themes/dark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ execution_output:
foreground: "a8df8e"
failure:
foreground: "f78ca2"
not_started:
foreground: "ee9322"

inline_code:
colors:
Expand Down
2 changes: 2 additions & 0 deletions themes/light.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ execution_output:
foreground: "52b788"
failure:
foreground: "f07167"
not_started:
foreground: "f77f00"

inline_code:
colors:
Expand Down
2 changes: 2 additions & 0 deletions themes/terminal-dark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ execution_output:
foreground: "green"
failure:
foreground: "red"
not_started:
foreground: "yellow"

inline_code:
colors:
Expand Down
8 changes: 5 additions & 3 deletions themes/terminal-light.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions themes/tokyonight-storm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ execution_output:
foreground: "9ece6a"
failure:
foreground: "f7768e"
not_started:
foreground: "e0af68"

inline_code:
colors:
Expand Down

0 comments on commit 9bda297

Please sign in to comment.