mirror of
https://github.com/mfontanini/presenterm.git
synced 2025-05-05 23:42:59 +00:00
fix: truly center +exec_replace +no_background
snippet output
This commit is contained in:
parent
8d54fe225a
commit
e2dab4d7ef
@ -1,5 +1,3 @@
|
|||||||
use itertools::Itertools;
|
|
||||||
|
|
||||||
use super::{BuildError, BuildResult, ExecutionMode, PresentationBuilderOptions};
|
use super::{BuildError, BuildResult, ExecutionMode, PresentationBuilderOptions};
|
||||||
use crate::{
|
use crate::{
|
||||||
ImageRegistry,
|
ImageRegistry,
|
||||||
@ -18,13 +16,14 @@ use crate::{
|
|||||||
properties::WindowSize,
|
properties::WindowSize,
|
||||||
},
|
},
|
||||||
resource::Resources,
|
resource::Resources,
|
||||||
theme::{CodeBlockStyle, PresentationTheme},
|
theme::{Alignment, CodeBlockStyle, PresentationTheme},
|
||||||
third_party::{ThirdPartyRender, ThirdPartyRenderRequest},
|
third_party::{ThirdPartyRender, ThirdPartyRenderRequest},
|
||||||
ui::execution::{
|
ui::execution::{
|
||||||
RunAcquireTerminalSnippet, RunImageSnippet, RunSnippetOperation, SnippetExecutionDisabledOperation,
|
RunAcquireTerminalSnippet, RunImageSnippet, RunSnippetOperation, SnippetExecutionDisabledOperation,
|
||||||
disabled::ExecutionType, snippet::DisplaySeparator,
|
disabled::ExecutionType, snippet::DisplaySeparator,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
use itertools::Itertools;
|
||||||
use std::{cell::RefCell, rc::Rc, sync::Arc};
|
use std::{cell::RefCell, rc::Rc, sync::Arc};
|
||||||
|
|
||||||
pub(crate) struct SnippetProcessorState<'a> {
|
pub(crate) struct SnippetProcessorState<'a> {
|
||||||
@ -308,7 +307,15 @@ impl<'a> SnippetProcessor<'a> {
|
|||||||
ExecutionMode::AlongSnippet => DisplaySeparator::On,
|
ExecutionMode::AlongSnippet => DisplaySeparator::On,
|
||||||
ExecutionMode::ReplaceSnippet => DisplaySeparator::Off,
|
ExecutionMode::ReplaceSnippet => DisplaySeparator::Off,
|
||||||
};
|
};
|
||||||
let alignment = self.code_style(&snippet).alignment;
|
let default_alignment = self.code_style(&snippet).alignment;
|
||||||
|
// If we're replacing the snippet output and we have center alignment, use center alignment but
|
||||||
|
// without any margins and minimum sizes so we truly center the output.
|
||||||
|
let alignment = match (&mode, default_alignment) {
|
||||||
|
(ExecutionMode::ReplaceSnippet, Alignment::Center { .. }) => {
|
||||||
|
Alignment::Center { minimum_margin: Default::default(), minimum_size: 0 }
|
||||||
|
}
|
||||||
|
(_, alignment) => alignment,
|
||||||
|
};
|
||||||
let default_colors = self.theme.default_style.style.colors;
|
let default_colors = self.theme.default_style.style.colors;
|
||||||
let mut execution_output_style = self.theme.execution_output.clone();
|
let mut execution_output_style = self.theme.execution_output.clone();
|
||||||
if snippet.attributes.no_background {
|
if snippet.attributes.no_background {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user