diff --git a/src/builder.rs b/src/builder.rs index ccb3a337..183f985d 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -30,7 +30,7 @@ static DEFAULT_BOTTOM_SLIDE_MARGIN: u16 = 3; /// /// This type transforms [MarkdownElement]s and turns them into a presentation, which is made up of /// render operations. -pub struct PresentationBuilder<'a> { +pub(crate) struct PresentationBuilder<'a> { slide_operations: Vec, slides: Vec, highlighter: CodeHighlighter, @@ -45,7 +45,7 @@ pub struct PresentationBuilder<'a> { impl<'a> PresentationBuilder<'a> { /// Construct a new builder. - pub fn new( + pub(crate) fn new( default_highlighter: CodeHighlighter, default_theme: &'a PresentationTheme, resources: &'a mut Resources, @@ -65,7 +65,7 @@ impl<'a> PresentationBuilder<'a> { } /// Build a presentation. - pub fn build(mut self, elements: Vec) -> Result { + pub(crate) fn build(mut self, elements: Vec) -> Result { if let Some(MarkdownElement::FrontMatter(contents)) = elements.first() { self.process_front_matter(contents)?; } @@ -724,7 +724,7 @@ struct RunCodeOperationInner { } #[derive(Debug)] -pub struct RunCodeOperation { +pub(crate) struct RunCodeOperation { code: Code, default_colors: Colors, block_colors: Colors, diff --git a/src/diff.rs b/src/diff.rs index 3556c3aa..4709ee18 100644 --- a/src/diff.rs +++ b/src/diff.rs @@ -2,13 +2,13 @@ use crate::presentation::{Presentation, RenderOperation, Slide}; use std::{cmp::Ordering, mem}; /// Allow diffing presentations. -pub struct PresentationDiffer; +pub(crate) struct PresentationDiffer; impl PresentationDiffer { /// Find the first modified slide between original and updated. /// /// This tries to take into account both content and style changes such that changing - pub fn first_modified_slide(original: &Presentation, updated: &Presentation) -> Option { + pub(crate) fn first_modified_slide(original: &Presentation, updated: &Presentation) -> Option { let original_slides = original.iter_slides(); let updated_slides = updated.iter_slides(); for (index, (original, updated)) in original_slides.zip(updated_slides).enumerate() { diff --git a/src/execute.rs b/src/execute.rs index a1ea64aa..fe94372f 100644 --- a/src/execute.rs +++ b/src/execute.rs @@ -10,11 +10,11 @@ use std::{ use tempfile::NamedTempFile; /// Allows executing code. -pub struct CodeExecuter; +pub(crate) struct CodeExecuter; impl CodeExecuter { /// Execute a piece of code. - pub fn execute(code: &Code) -> Result { + pub(crate) fn execute(code: &Code) -> Result { if !code.language.supports_execution() { return Err(CodeExecuteError::UnsupportedExecution); } @@ -49,7 +49,7 @@ impl CodeExecuter { /// An error during the execution of some code. #[derive(thiserror::Error, Debug)] -pub enum CodeExecuteError { +pub(crate) enum CodeExecuteError { #[error("code language doesn't support execution")] UnsupportedExecution, @@ -65,7 +65,7 @@ pub enum CodeExecuteError { /// A handle for the execution of a piece of code. #[derive(Debug)] -pub struct ExecutionHandle { +pub(crate) struct ExecutionHandle { state: Arc>, #[allow(dead_code)] reader_handle: thread::JoinHandle<()>, @@ -73,7 +73,7 @@ pub struct ExecutionHandle { impl ExecutionHandle { /// Get the current state of the process. - pub fn state(&self) -> ExecutionState { + pub(crate) fn state(&self) -> ExecutionState { self.state.lock().unwrap().clone() } } @@ -123,21 +123,14 @@ impl ProcessReader { /// The state of the execution of a process. #[derive(Clone, Default, Debug)] -pub struct ExecutionState { - pub output: Vec, - pub status: ProcessStatus, -} - -impl ExecutionState { - /// Extract the lines printed so far. - pub fn into_lines(self) -> Vec { - self.output - } +pub(crate) struct ExecutionState { + pub(crate) output: Vec, + pub(crate) status: ProcessStatus, } /// The status of a process. #[derive(Clone, Debug, Default)] -pub enum ProcessStatus { +pub(crate) enum ProcessStatus { #[default] Running, Success, @@ -146,7 +139,7 @@ pub enum ProcessStatus { impl ProcessStatus { /// Check whether the underlying process is finished. - pub fn is_finished(&self) -> bool { + pub(crate) fn is_finished(&self) -> bool { matches!(self, ProcessStatus::Success | ProcessStatus::Failure) } } @@ -172,7 +165,7 @@ echo 'bye'" }; let expected_lines = vec!["hello world", "bye"]; - assert_eq!(state.into_lines(), expected_lines); + assert_eq!(state.output, expected_lines); } #[test] diff --git a/src/input/fs.rs b/src/input/fs.rs index 435a05b2..a407f76e 100644 --- a/src/input/fs.rs +++ b/src/input/fs.rs @@ -5,21 +5,21 @@ use std::{fs, io, path::PathBuf, time::SystemTime}; /// This uses polling rather than something fancier like `inotify`. The latter turned out to make /// code too complex for little added gain. This instead keeps the last modified time for the given /// path and uses that to determine if it's changed. -pub struct PresentationFileWatcher { +pub(crate) struct PresentationFileWatcher { path: PathBuf, last_modification: SystemTime, } impl PresentationFileWatcher { /// Create a watcher over the given file path. - pub fn new>(path: P) -> Self { + pub(crate) fn new>(path: P) -> Self { let path = path.into(); let last_modification = fs::metadata(&path).and_then(|m| m.modified()).unwrap_or(SystemTime::UNIX_EPOCH); Self { path, last_modification } } /// Checker whether this file has modifications. - pub fn has_modifications(&mut self) -> io::Result { + pub(crate) fn has_modifications(&mut self) -> io::Result { let metadata = fs::metadata(&self.path)?; let modified_time = metadata.modified()?; if modified_time > self.last_modification { diff --git a/src/input/mod.rs b/src/input/mod.rs index 8fea67fb..155e95f6 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -1,3 +1,3 @@ -pub mod fs; -pub mod source; -pub mod user; +pub(crate) mod fs; +pub(crate) mod source; +pub(crate) mod user; diff --git a/src/input/source.rs b/src/input/source.rs index 4e7a2003..89859015 100644 --- a/src/input/source.rs +++ b/src/input/source.rs @@ -20,19 +20,10 @@ impl CommandSource { Self { watcher, user_input: UserInput::default() } } - /// Block until the next command arrives. - pub fn next_command(&mut self) -> io::Result { - loop { - if let Some(command) = self.try_next_command()? { - return Ok(command); - } - } - } - /// Try to get the next command. /// /// This attempts to get a command and returns `Ok(None)` on timeout. - pub fn try_next_command(&mut self) -> io::Result> { + pub(crate) fn try_next_command(&mut self) -> io::Result> { match self.user_input.poll_next_command(Duration::from_millis(250)) { Ok(Some(command)) => { return Ok(Some(Command::User(command))); @@ -48,7 +39,7 @@ impl CommandSource { /// A command. #[derive(Clone, Debug)] -pub enum Command { +pub(crate) enum Command { /// A user input command. User(UserCommand), diff --git a/src/input/user.rs b/src/input/user.rs index e98cbbd9..64da5216 100644 --- a/src/input/user.rs +++ b/src/input/user.rs @@ -3,18 +3,18 @@ use std::{io, mem, time::Duration}; /// A user input handler. #[derive(Default)] -pub struct UserInput { +pub(crate) struct UserInput { state: InputState, } impl UserInput { /// Polls for the next input command coming from the keyboard. - pub fn poll_next_command(&mut self, timeout: Duration) -> io::Result> { + pub(crate) fn poll_next_command(&mut self, timeout: Duration) -> io::Result> { if poll(timeout)? { self.next_command() } else { Ok(None) } } /// Blocks waiting for the next command. - pub fn next_command(&mut self) -> io::Result> { + pub(crate) fn next_command(&mut self) -> io::Result> { let current_state = mem::take(&mut self.state); let (command, next_state) = match read()? { Event::Key(event) => Self::apply_key_event(event, current_state), @@ -87,7 +87,7 @@ impl UserInput { /// A command from the user. #[derive(Clone, Debug, PartialEq, Eq)] -pub enum UserCommand { +pub(crate) enum UserCommand { /// Redraw the presentation. /// /// This can happen on terminal resize. diff --git a/src/lib.rs b/src/lib.rs index eab30eac..5e9f330f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,15 +2,23 @@ //! //! This is not meant to be used as a crate! -pub mod builder; -pub mod diff; -pub mod execute; -pub mod input; -pub mod markdown; -pub mod presentation; -pub mod presenter; -pub mod render; -pub mod resource; -pub mod splash; -pub mod style; -pub mod theme; +pub(crate) mod builder; +pub(crate) mod diff; +pub(crate) mod execute; +pub(crate) mod input; +pub(crate) mod markdown; +pub(crate) mod presentation; +pub(crate) mod presenter; +pub(crate) mod render; +pub(crate) mod resource; +pub(crate) mod style; +pub(crate) mod theme; + +pub use crate::{ + input::source::CommandSource, + markdown::parse::MarkdownParser, + presenter::{PresentMode, Presenter}, + render::highlighting::CodeHighlighter, + resource::Resources, + theme::PresentationTheme, +}; diff --git a/src/main.rs b/src/main.rs index c60d748e..d0e29f07 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,13 +1,8 @@ use clap::{error::ErrorKind, CommandFactory, Parser}; +use colored::Colorize; use comrak::Arena; use presenterm::{ - input::source::CommandSource, - markdown::parse::MarkdownParser, - presenter::{PresentMode, Presenter}, - render::highlighting::CodeHighlighter, - resource::Resources, - splash::show_splashes, - theme::PresentationTheme, + CodeHighlighter, CommandSource, MarkdownParser, PresentMode, PresentationTheme, Presenter, Resources, }; use std::path::{Path, PathBuf}; @@ -28,6 +23,24 @@ struct Cli { theme: String, } +fn show_splashes() -> String { + let crate_version = env!("CARGO_PKG_VERSION"); + + let logo = format!( + r#" + ┌─┐┬─┐┌─┐┌─┐┌─┐┌┐┌┌┬┐┌─┐┬─┐┌┬┐ + ├─┘├┬┘├┤ └─┐├┤ │││ │ ├┤ ├┬┘│││ + ┴ ┴└─└─┘└─┘└─┘┘└┘ ┴ └─┘┴└─┴ ┴ v{} + A terminal slideshow tool + @mfontanini/presenterm +"#, + crate_version, + ) + .bold() + .purple(); + format!("{logo}") +} + fn run(cli: Cli) -> Result<(), Box> { let Some(default_theme) = PresentationTheme::from_name(&cli.theme) else { let mut cmd = Cli::command(); diff --git a/src/markdown/elements.rs b/src/markdown/elements.rs index 7f6f2d8e..6b97311c 100644 --- a/src/markdown/elements.rs +++ b/src/markdown/elements.rs @@ -8,7 +8,7 @@ use unicode_width::UnicodeWidthStr; /// This represents each of the supported markdown elements. The structure here differs a bit from /// the spec, mostly in how inlines are handled, to simplify its processing. #[derive(Clone, Debug)] -pub enum MarkdownElement { +pub(crate) enum MarkdownElement { /// The front matter that optionally shows up at the beginning of the file. FrontMatter(String), @@ -51,7 +51,7 @@ pub enum MarkdownElement { /// style) and line breaks. Any other inlines that could show up on a paragraph, such as images, /// are a [MarkdownElement] on their own. #[derive(Clone, Debug, PartialEq, Eq)] -pub enum ParagraphElement { +pub(crate) enum ParagraphElement { /// A block of text. Text(Text), @@ -63,19 +63,19 @@ pub enum ParagraphElement { /// /// Text is represented as a series of chunks, each with their own formatting. #[derive(Clone, Debug, PartialEq, Eq)] -pub struct Text { +pub(crate) struct Text { /// The chunks that make up this text. - pub chunks: Vec, + pub(crate) chunks: Vec, } impl Text { /// Get the total width for this text. - pub fn width(&self) -> usize { + pub(crate) fn width(&self) -> usize { self.chunks.iter().map(|text| text.text.width()).sum() } /// Applies the given style to this text. - pub fn apply_style(&mut self, style: &TextStyle) { + pub(crate) fn apply_style(&mut self, style: &TextStyle) { for text in &mut self.chunks { text.style.merge(style); } @@ -92,14 +92,14 @@ impl> From for Text { /// /// This is the most granular text representation: a `String` and a style. #[derive(Clone, Debug, PartialEq, Eq)] -pub struct StyledText { - pub text: String, - pub style: TextStyle, +pub(crate) struct StyledText { + pub(crate) text: String, + pub(crate) style: TextStyle, } impl StyledText { /// Construct a new styled text. - pub fn new>(text: S, style: TextStyle) -> Self { + pub(crate) fn new>(text: S, style: TextStyle) -> Self { Self { text: text.into(), style } } } @@ -118,22 +118,22 @@ impl From<&str> for StyledText { /// A list item. #[derive(Clone, Debug, PartialEq, Eq)] -pub struct ListItem { +pub(crate) struct ListItem { /// The depth of this item. /// /// This increases by one for every nested list level. - pub depth: u8, + pub(crate) depth: u8, /// The contents of this list item. - pub contents: Text, + pub(crate) contents: Text, /// The type of list item. - pub item_type: ListItemType, + pub(crate) item_type: ListItemType, } /// The type of a list item. #[derive(Clone, Debug, PartialEq, Eq)] -pub enum ListItemType { +pub(crate) enum ListItemType { /// A list item for an unordered list. Unordered, @@ -146,20 +146,20 @@ pub enum ListItemType { /// A piece of code. #[derive(Clone, Debug, PartialEq, Eq)] -pub struct Code { +pub(crate) struct Code { /// The code itself. - pub contents: String, + pub(crate) contents: String, /// The programming language this code is written in. - pub language: CodeLanguage, + pub(crate) language: CodeLanguage, /// The flags used for this code. - pub flags: CodeFlags, + pub(crate) flags: CodeFlags, } /// The language of a piece of code. #[derive(Clone, Debug, PartialEq, Eq, EnumIter)] -pub enum CodeLanguage { +pub(crate) enum CodeLanguage { Asp, Bash, BatchFile, @@ -196,38 +196,38 @@ pub enum CodeLanguage { } impl CodeLanguage { - pub fn supports_execution(&self) -> bool { + pub(crate) fn supports_execution(&self) -> bool { matches!(self, Self::Shell(_)) } } /// Flags for code blocks. #[derive(Clone, Debug, Default, PartialEq, Eq)] -pub struct CodeFlags { +pub(crate) struct CodeFlags { /// Whether a code block is marked as executable. - pub execute: bool, + pub(crate) execute: bool, } /// A table. #[derive(Clone, Debug, PartialEq, Eq)] -pub struct Table { +pub(crate) struct Table { /// The table's header. - pub header: TableRow, + pub(crate) header: TableRow, /// All of the rows in this table, excluding the header. - pub rows: Vec, + pub(crate) rows: Vec, } impl Table { /// gets the number of columns in this table. - pub fn columns(&self) -> usize { + pub(crate) fn columns(&self) -> usize { self.header.0.len() } /// Iterates all the text entries in a column. /// /// This includes the header. - pub fn iter_column(&self, column: usize) -> impl Iterator { + pub(crate) fn iter_column(&self, column: usize) -> impl Iterator { let header_element = &self.header.0[column]; let row_elements = self.rows.iter().map(move |row| &row.0[column]); iter::once(header_element).chain(row_elements) @@ -236,4 +236,4 @@ impl Table { /// A table row. #[derive(Clone, Debug, PartialEq, Eq)] -pub struct TableRow(pub Vec); +pub(crate) struct TableRow(pub(crate) Vec); diff --git a/src/markdown/mod.rs b/src/markdown/mod.rs index 524b096e..665f1c0c 100644 --- a/src/markdown/mod.rs +++ b/src/markdown/mod.rs @@ -1,3 +1,3 @@ -pub mod elements; -pub mod parse; -pub mod text; +pub(crate) mod elements; +pub(crate) mod parse; +pub(crate) mod text; diff --git a/src/markdown/parse.rs b/src/markdown/parse.rs index aba735a3..8f1f725d 100644 --- a/src/markdown/parse.rs +++ b/src/markdown/parse.rs @@ -19,7 +19,7 @@ use std::{ }; /// The result of parsing a markdown file. -pub type ParseResult = Result; +pub(crate) type ParseResult = Result; struct ParserOptions(ComrakOptions); @@ -48,7 +48,7 @@ impl<'a> MarkdownParser<'a> { } /// Parse the contents of a markdown file. - pub fn parse(&self, contents: &str) -> ParseResult> { + pub(crate) fn parse(&self, contents: &str) -> ParseResult> { let node = parse_document(self.arena, contents, &self.options); let mut elements = Vec::new(); for node in node.children() { @@ -381,10 +381,10 @@ impl Inline { #[derive(thiserror::Error, Debug)] pub struct ParseError { /// The kind of error. - pub kind: ParseErrorKind, + pub(crate) kind: ParseErrorKind, /// The position in the source file this error originated from. - pub sourcepos: Sourcepos, + pub(crate) sourcepos: Sourcepos, } impl Display for ParseError { @@ -401,7 +401,7 @@ impl ParseError { /// The kind of error. #[derive(Debug)] -pub enum ParseErrorKind { +pub(crate) enum ParseErrorKind { /// We don't support parsing this element. UnsupportedElement(&'static str), diff --git a/src/markdown/text.rs b/src/markdown/text.rs index a1dcbfae..1b4e5cb4 100644 --- a/src/markdown/text.rs +++ b/src/markdown/text.rs @@ -6,21 +6,22 @@ use unicode_width::UnicodeWidthChar; /// /// The weight of a character is its given by its width in unicode. #[derive(Clone, Debug, Default, PartialEq, Eq)] -pub struct WeightedLine(Vec); +pub(crate) struct WeightedLine(Vec); impl WeightedLine { /// Split this line into chunks of at most `max_length` width. - pub fn split(&self, max_length: usize) -> SplitTextIter { + pub(crate) fn split(&self, max_length: usize) -> SplitTextIter { SplitTextIter::new(&self.0, max_length) } /// The total width of this line. - pub fn width(&self) -> usize { + pub(crate) fn width(&self) -> usize { self.0.iter().map(|text| text.width()).sum() } /// Get an iterator to the underlying text chunks. - pub fn iter_texts(&self) -> impl Iterator { + #[cfg(test)] + pub(crate) fn iter_texts(&self) -> impl Iterator { self.0.iter() } } @@ -46,8 +47,8 @@ struct CharAccumulator { /// A piece of weighted text. #[derive(Clone, Debug, PartialEq, Eq)] -pub struct WeightedText { - pub text: StyledText, +pub(crate) struct WeightedText { + pub(crate) text: StyledText, accumulators: Vec, } @@ -77,7 +78,7 @@ impl From for WeightedText { } /// An iterator over the chunks in a [WeightedLine]. -pub struct SplitTextIter<'a> { +pub(crate) struct SplitTextIter<'a> { texts: &'a [WeightedText], max_length: usize, current: Option>, @@ -125,7 +126,7 @@ impl<'a> Iterator for SplitTextIter<'a> { /// A reference of a peice of a [WeightedText]. #[derive(Clone, Debug)] -pub struct WeightedTextRef<'a> { +pub(crate) struct WeightedTextRef<'a> { text: &'a str, accumulators: &'a [CharAccumulator], style: TextStyle, @@ -133,7 +134,7 @@ pub struct WeightedTextRef<'a> { impl<'a> WeightedTextRef<'a> { /// Decompose this into its parts. - pub fn into_parts(self) -> (&'a str, TextStyle) { + pub(crate) fn into_parts(self) -> (&'a str, TextStyle) { (self.text, self.style) } diff --git a/src/presentation.rs b/src/presentation.rs index 49718f08..48da20bf 100644 --- a/src/presentation.rs +++ b/src/presentation.rs @@ -8,39 +8,40 @@ use serde::Deserialize; use std::rc::Rc; /// A presentation. -pub struct Presentation { +pub(crate) struct Presentation { slides: Vec, current_slide_index: usize, } impl Presentation { /// Construct a new presentation. - pub fn new(slides: Vec) -> Self { + pub(crate) fn new(slides: Vec) -> Self { Self { slides, current_slide_index: 0 } } /// Iterate the slides in this presentation. - pub fn iter_slides(&self) -> impl Iterator { + pub(crate) fn iter_slides(&self) -> impl Iterator { self.slides.iter() } /// Consume this presentation and return its slides. - pub fn into_slides(self) -> Vec { + #[cfg(test)] + pub(crate) fn into_slides(self) -> Vec { self.slides } /// Get the current slide. - pub fn current_slide(&self) -> &Slide { + pub(crate) fn current_slide(&self) -> &Slide { &self.slides[self.current_slide_index] } /// Get the current slide index. - pub fn current_slide_index(&self) -> usize { + pub(crate) fn current_slide_index(&self) -> usize { self.current_slide_index } /// Jump to the next slide. - pub fn jump_next_slide(&mut self) -> bool { + pub(crate) fn jump_next_slide(&mut self) -> bool { if self.current_slide_index < self.slides.len() - 1 { self.current_slide_index += 1; true @@ -50,7 +51,7 @@ impl Presentation { } /// Jump to the previous slide. - pub fn jump_previous_slide(&mut self) -> bool { + pub(crate) fn jump_previous_slide(&mut self) -> bool { if self.current_slide_index > 0 { self.current_slide_index -= 1; true @@ -60,7 +61,7 @@ impl Presentation { } /// Jump to the first slide. - pub fn jump_first_slide(&mut self) -> bool { + pub(crate) fn jump_first_slide(&mut self) -> bool { if self.current_slide_index != 0 { self.current_slide_index = 0; true @@ -70,7 +71,7 @@ impl Presentation { } /// Jump to the last slide. - pub fn jump_last_slide(&mut self) -> bool { + pub(crate) fn jump_last_slide(&mut self) -> bool { let last_slide_index = self.slides.len().saturating_sub(1); if self.current_slide_index != last_slide_index { self.current_slide_index = last_slide_index; @@ -81,7 +82,7 @@ impl Presentation { } /// Jump to a specific slide. - pub fn jump_slide(&mut self, slide_index: usize) -> bool { + pub(crate) fn jump_slide(&mut self, slide_index: usize) -> bool { if slide_index < self.slides.len() { self.current_slide_index = slide_index; true @@ -91,7 +92,7 @@ impl Presentation { } /// Render all widgets in this slide. - pub fn render_slide_widgets(&mut self) -> bool { + pub(crate) fn render_slide_widgets(&mut self) -> bool { let slide = self.current_slide_mut(); let mut any_rendered = false; for operation in &mut slide.render_operations { @@ -103,7 +104,7 @@ impl Presentation { } /// Poll every widget in the current slide and check whether they're rendered. - pub fn widgets_rendered(&mut self) -> bool { + pub(crate) fn widgets_rendered(&mut self) -> bool { let slide = self.current_slide_mut(); let mut all_rendered = true; for operation in &mut slide.render_operations { @@ -124,52 +125,52 @@ impl Presentation { /// Slides are composed of render operations that can be carried out to materialize this slide into /// the terminal's screen. #[derive(Clone, Debug)] -pub struct Slide { - pub render_operations: Vec, +pub(crate) struct Slide { + pub(crate) render_operations: Vec, } /// The metadata for a presentation. #[derive(Clone, Debug, Deserialize)] -pub struct PresentationMetadata { +pub(crate) struct PresentationMetadata { /// The presentation title. - pub title: Option, + pub(crate) title: Option, /// The presentation sub-title. #[serde(default)] - pub sub_title: Option, + pub(crate) sub_title: Option, /// The presentation author. #[serde(default)] - pub author: Option, + pub(crate) author: Option, /// The presentation's theme metadata. #[serde(default)] - pub theme: PresentationThemeMetadata, + pub(crate) theme: PresentationThemeMetadata, } /// A presentation's theme metadata. #[derive(Clone, Debug, Default, Deserialize)] -pub struct PresentationThemeMetadata { +pub(crate) struct PresentationThemeMetadata { /// The theme name. #[serde(default)] - pub name: Option, + pub(crate) name: Option, /// the theme path. #[serde(default)] - pub path: Option, + pub(crate) path: Option, /// Any specific overrides for the presentation's theme. #[serde(default, rename = "override")] - pub overrides: Option, + pub(crate) overrides: Option, } /// A line of preformatted text to be rendered. #[derive(Clone, Debug, PartialEq)] -pub struct PreformattedLine { - pub text: String, - pub unformatted_length: usize, - pub block_length: usize, - pub alignment: Alignment, +pub(crate) struct PreformattedLine { + pub(crate) text: String, + pub(crate) unformatted_length: usize, + pub(crate) block_length: usize, + pub(crate) alignment: Alignment, } /// A render operation. @@ -177,7 +178,7 @@ pub struct PreformattedLine { /// Render operations are primitives that allow the input markdown file to be decoupled with what /// we draw on the screen. #[derive(Clone, Debug)] -pub enum RenderOperation { +pub(crate) enum RenderOperation { /// Clear the entire screen. ClearScreen, @@ -241,22 +242,22 @@ pub enum RenderOperation { /// Slide properties, set on initialization. #[derive(Clone, Debug, Default)] -pub struct MarginProperties { +pub(crate) struct MarginProperties { /// The horizontal margin. - pub horizontal_margin: Margin, + pub(crate) horizontal_margin: Margin, /// The margin at the bottom of the slide. - pub bottom_slide_margin: u16, + pub(crate) bottom_slide_margin: u16, } /// A type that can generate render operations. -pub trait AsRenderOperations: std::fmt::Debug { +pub(crate) trait AsRenderOperations: std::fmt::Debug { /// Generate render operations. fn as_render_operations(&self, dimensions: &WindowSize) -> Vec; } /// A type that can be rendered on demand. -pub trait RenderOnDemand: AsRenderOperations { +pub(crate) trait RenderOnDemand: AsRenderOperations { /// Start the on demand render for this operation. fn start_render(&self) -> bool; @@ -266,7 +267,7 @@ pub trait RenderOnDemand: AsRenderOperations { /// The state of a [RenderOnDemand]. #[derive(Clone, Debug, Default)] -pub enum RenderOnDemandState { +pub(crate) enum RenderOnDemandState { #[default] NotStarted, Rendering, diff --git a/src/render/draw.rs b/src/render/draw.rs index 910c5dbc..29162134 100644 --- a/src/render/draw.rs +++ b/src/render/draw.rs @@ -12,10 +12,10 @@ use crate::{ use std::io; /// The result of a render operation. -pub type RenderResult = Result<(), RenderError>; +pub(crate) type RenderResult = Result<(), RenderError>; /// Allows drawing elements in the terminal. -pub struct TerminalDrawer { +pub(crate) struct TerminalDrawer { terminal: Terminal, } @@ -24,13 +24,13 @@ where W: io::Write, { /// Construct a drawer over a [std::io::Write]. - pub fn new(handle: W) -> io::Result { + pub(crate) fn new(handle: W) -> io::Result { let terminal = Terminal::new(handle)?; Ok(Self { terminal }) } /// Render a slide. - pub fn render_slide(&mut self, presentation: &Presentation) -> RenderResult { + pub(crate) fn render_slide(&mut self, presentation: &Presentation) -> RenderResult { let window_dimensions = WindowSize::current()?; let slide = presentation.current_slide(); let operator = RenderOperator::new(&mut self.terminal, window_dimensions); @@ -40,7 +40,7 @@ where } /// Render an error. - pub fn render_error(&mut self, message: &str) -> RenderResult { + pub(crate) fn render_error(&mut self, message: &str) -> RenderResult { let dimensions = WindowSize::current()?; let heading = vec![ WeightedText::from(StyledText::new("Error loading presentation", TextStyle::default().bold())), diff --git a/src/render/highlighting.rs b/src/render/highlighting.rs index a8a1e8f7..28f8ca47 100644 --- a/src/render/highlighting.rs +++ b/src/render/highlighting.rs @@ -26,7 +26,7 @@ impl CodeHighlighter { /// Highlight a piece of code. /// /// This splits the given piece of code into lines, highlights them individually, and returns them. - pub fn highlight<'a>(&self, code: &'a str, language: &CodeLanguage) -> Vec> { + pub(crate) fn highlight<'a>(&self, code: &'a str, language: &CodeLanguage) -> Vec> { let extension = Self::language_extension(language); let syntax = SYNTAX_SET.find_syntax_by_extension(extension).unwrap(); let mut highlight_lines = HighlightLines::new(syntax, self.theme); @@ -82,14 +82,14 @@ impl CodeHighlighter { } /// A line of highlighted code. -pub struct CodeLine<'a> { +pub(crate) struct CodeLine<'a> { /// The original line of code. - pub original: &'a str, + pub(crate) original: &'a str, /// The formatted line of code. /// /// This uses terminal escape codes internally and is ready to be printed. - pub formatted: String, + pub(crate) formatted: String, } /// A theme could not be found. diff --git a/src/render/media.rs b/src/render/media.rs index f2fc9661..0767b7b3 100644 --- a/src/render/media.rs +++ b/src/render/media.rs @@ -9,7 +9,7 @@ use super::properties::CursorPosition; /// /// This stores the image in an [std::rc::Rc] so it's cheap to clone. #[derive(Clone, PartialEq)] -pub struct Image(Rc); +pub(crate) struct Image(Rc); impl Debug for Image { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { @@ -19,7 +19,7 @@ impl Debug for Image { impl Image { /// Construct a new image from a byte sequence. - pub fn new(contents: &[u8]) -> Result { + pub(crate) fn new(contents: &[u8]) -> Result { let contents = image::load_from_memory(contents)?; let contents = Rc::new(contents); Ok(Self(contents)) @@ -27,7 +27,7 @@ impl Image { } /// A media render. -pub struct MediaRender; +pub(crate) struct MediaRender; impl MediaRender { /// Draw an image. @@ -38,7 +38,7 @@ impl MediaRender { /// /// In case the image does not fit, it will be resized to fit the screen, preserving the aspect /// ratio. - pub fn draw_image( + pub(crate) fn draw_image( &self, image: &Image, position: CursorPosition, diff --git a/src/render/mod.rs b/src/render/mod.rs index a5dee067..8b5b5e86 100644 --- a/src/render/mod.rs +++ b/src/render/mod.rs @@ -1,8 +1,8 @@ -pub mod draw; -pub mod highlighting; +pub(crate) mod draw; +pub(crate) mod highlighting; pub(crate) mod layout; -pub mod media; -pub mod operator; -pub mod properties; +pub(crate) mod media; +pub(crate) mod operator; +pub(crate) mod properties; pub(crate) mod terminal; pub(crate) mod text; diff --git a/src/render/properties.rs b/src/render/properties.rs index 523610ea..c8f14989 100644 --- a/src/render/properties.rs +++ b/src/render/properties.rs @@ -6,17 +6,17 @@ use std::io::{self, ErrorKind}; /// This is the same as [crossterm::terminal::window_size] except with some added functionality, /// like implementing `Clone`. #[derive(Debug, Clone)] -pub struct WindowSize { - pub rows: u16, - pub columns: u16, - pub height: u16, - pub width: u16, - pub has_pixels: bool, +pub(crate) struct WindowSize { + pub(crate) rows: u16, + pub(crate) columns: u16, + pub(crate) height: u16, + pub(crate) width: u16, + pub(crate) has_pixels: bool, } impl WindowSize { /// Get the current window size. - pub fn current() -> io::Result { + pub(crate) fn current() -> io::Result { match terminal::window_size() { Ok(size) => Ok(size.into()), Err(e) if e.kind() == ErrorKind::Unsupported => { @@ -31,7 +31,7 @@ impl WindowSize { /// Shrink a window by the given number of rows. /// /// This preserves the relationship between rows and pixels. - pub fn shrink_rows(&self, amount: u16) -> WindowSize { + pub(crate) fn shrink_rows(&self, amount: u16) -> WindowSize { let pixels_per_row = self.pixels_per_row(); let height_to_shrink = (pixels_per_row * amount as f64) as u16; WindowSize { @@ -46,7 +46,7 @@ impl WindowSize { /// Shrink a window by the given number of columns. /// /// This preserves the relationship between columns and pixels. - pub fn shrink_columns(&self, amount: u16) -> WindowSize { + pub(crate) fn shrink_columns(&self, amount: u16) -> WindowSize { let pixels_per_column = self.pixels_per_column(); let width_to_shrink = (pixels_per_column * amount as f64) as u16; WindowSize { @@ -59,12 +59,12 @@ impl WindowSize { } /// The number of pixels per column. - pub fn pixels_per_column(&self) -> f64 { + pub(crate) fn pixels_per_column(&self) -> f64 { self.width as f64 / self.columns as f64 } /// The number of pixels per row. - pub fn pixels_per_row(&self) -> f64 { + pub(crate) fn pixels_per_row(&self) -> f64 { self.height as f64 / self.rows as f64 } } @@ -83,14 +83,14 @@ impl From<(u16, u16)> for WindowSize { /// The cursor's position. #[derive(Debug, Clone, Default)] -pub struct CursorPosition { - pub column: u16, - pub row: u16, +pub(crate) struct CursorPosition { + pub(crate) column: u16, + pub(crate) row: u16, } impl CursorPosition { /// Get the current cursor position. - pub fn current() -> io::Result { + pub(crate) fn current() -> io::Result { let (column, row) = position()?; Ok(Self { column, row }) } diff --git a/src/render/terminal.rs b/src/render/terminal.rs index be04219d..7d7a0df2 100644 --- a/src/render/terminal.rs +++ b/src/render/terminal.rs @@ -14,7 +14,7 @@ where W: io::Write, { writer: W, - pub cursor_row: u16, + pub(crate) cursor_row: u16, } impl Terminal { diff --git a/src/resource.rs b/src/resource.rs index 0600a600..b12b0a01 100644 --- a/src/resource.rs +++ b/src/resource.rs @@ -27,7 +27,7 @@ impl Resources { } /// Get the image at the given path. - pub fn image>(&mut self, path: P) -> Result { + pub(crate) fn image>(&mut self, path: P) -> Result { let path = self.base_path.join(path); if let Some(image) = self.images.get(&path) { return Ok(image.clone()); @@ -40,7 +40,7 @@ impl Resources { } /// Get the theme at the given path. - pub fn theme>(&mut self, path: P) -> Result { + pub(crate) fn theme>(&mut self, path: P) -> Result { let path = self.base_path.join(path); if let Some(theme) = self.themes.get(&path) { return Ok(theme.clone()); diff --git a/src/splash.rs b/src/splash.rs deleted file mode 100644 index ff27a387..00000000 --- a/src/splash.rs +++ /dev/null @@ -1,19 +0,0 @@ -use colored::Colorize; - -pub fn show_splashes() -> String { - let crate_version = env!("CARGO_PKG_VERSION"); - - let logo = format!( - r#" - ┌─┐┬─┐┌─┐┌─┐┌─┐┌┐┌┌┬┐┌─┐┬─┐┌┬┐ - ├─┘├┬┘├┤ └─┐├┤ │││ │ ├┤ ├┬┘│││ - ┴ ┴└─└─┘└─┘└─┘┘└┘ ┴ └─┘┴└─┴ ┴ v{} - A terminal slideshow tool - @mfontanini/presenterm -"#, - crate_version, - ) - .bold() - .purple(); - format!("{logo}") -} diff --git a/src/style.rs b/src/style.rs index 7a98f2e5..1c960fbc 100644 --- a/src/style.rs +++ b/src/style.rs @@ -9,82 +9,82 @@ use std::{ /// The style of a piece of text. #[derive(Clone, Debug, Default, PartialEq, Eq)] -pub struct TextStyle { +pub(crate) struct TextStyle { flags: u8, - pub colors: Colors, + pub(crate) colors: Colors, } impl TextStyle { /// Add bold to this style. - pub fn bold(mut self) -> Self { + pub(crate) fn bold(mut self) -> Self { self.flags |= TextFormatFlags::Bold as u8; self } /// Add italics to this style. - pub fn italics(mut self) -> Self { + pub(crate) fn italics(mut self) -> Self { self.flags |= TextFormatFlags::Italics as u8; self } /// Indicate this text is a piece of inline code. - pub fn code(mut self) -> Self { + pub(crate) fn code(mut self) -> Self { self.flags |= TextFormatFlags::Code as u8; self } /// Add strikethrough to this style. - pub fn strikethrough(mut self) -> Self { + pub(crate) fn strikethrough(mut self) -> Self { self.flags |= TextFormatFlags::Strikethrough as u8; self } /// Indicate this is a link. - pub fn link(mut self) -> Self { + pub(crate) fn link(mut self) -> Self { self.flags |= TextFormatFlags::Link as u8; self } /// Set the colors for this text style. - pub fn colors(mut self, colors: Colors) -> Self { + pub(crate) fn colors(mut self, colors: Colors) -> Self { self.colors = colors; self } /// Check whether this text style is bold. - pub fn is_bold(&self) -> bool { + pub(crate) fn is_bold(&self) -> bool { self.flags & TextFormatFlags::Bold as u8 != 0 } /// Check whether this text style has italics. - pub fn is_italics(&self) -> bool { + pub(crate) fn is_italics(&self) -> bool { self.flags & TextFormatFlags::Italics as u8 != 0 } /// Check whether this text is code. - pub fn is_code(&self) -> bool { + pub(crate) fn is_code(&self) -> bool { self.flags & TextFormatFlags::Code as u8 != 0 } /// Check whether this text style is strikethrough. - pub fn is_strikethrough(&self) -> bool { + pub(crate) fn is_strikethrough(&self) -> bool { self.flags & TextFormatFlags::Strikethrough as u8 != 0 } /// Check whether this text is a link. - pub fn is_link(&self) -> bool { + pub(crate) fn is_link(&self) -> bool { self.flags & TextFormatFlags::Link as u8 != 0 } /// Merge this style with another one. - pub fn merge(&mut self, other: &TextStyle) { + pub(crate) fn merge(&mut self, other: &TextStyle) { self.flags |= other.flags; self.colors.background = self.colors.background.or(other.colors.background); self.colors.foreground = self.colors.foreground.or(other.colors.foreground); } /// Apply this style to a piece of text. - pub fn apply>(&self, text: T) -> ::Styled { + pub(crate) fn apply>(&self, text: T) -> ::Styled { let text: String = text.into(); let mut styled = text.stylize(); if self.is_bold() { @@ -119,10 +119,10 @@ enum TextFormatFlags { } #[derive(Debug, Copy, Clone, PartialEq, Eq, SerializeDisplay, DeserializeFromStr)] -pub struct Color(crossterm::style::Color); +pub(crate) struct Color(crossterm::style::Color); impl Color { - pub fn new(r: u8, g: u8, b: u8) -> Self { + pub(crate) fn new(r: u8, g: u8, b: u8) -> Self { Self(crossterm::style::Color::Rgb { r, g, b }) } } @@ -154,12 +154,12 @@ impl From for crossterm::style::Color { /// Text colors. #[derive(Clone, Debug, Default, Deserialize, PartialEq, Eq, Serialize)] -pub struct Colors { +pub(crate) struct Colors { /// The background color. - pub background: Option, + pub(crate) background: Option, /// The foreground color. - pub foreground: Option, + pub(crate) foreground: Option, } impl From for crossterm::style::Colors { @@ -172,7 +172,7 @@ impl From for crossterm::style::Colors { #[derive(thiserror::Error, Debug)] #[error("invalid color: {0}")] -pub struct ParseColorError(#[from] FromHexError); +pub(crate) struct ParseColorError(#[from] FromHexError); #[cfg(test)] mod test { diff --git a/src/theme.rs b/src/theme.rs index e2c3707a..9fab103c 100644 --- a/src/theme.rs +++ b/src/theme.rs @@ -9,43 +9,43 @@ include!(concat!(env!("OUT_DIR"), "/themes.rs")); pub struct PresentationTheme { /// The style for a slide's title. #[serde(default)] - pub slide_title: SlideTitleStyle, + pub(crate) slide_title: SlideTitleStyle, /// The style for a block of code. #[serde(default)] - pub code: CodeBlockStyle, + pub(crate) code: CodeBlockStyle, /// The style for the execution output of a piece of code. #[serde(default)] - pub execution_output: ExecutionOutputBlockStyle, + pub(crate) execution_output: ExecutionOutputBlockStyle, /// The style for inline code. #[serde(default)] - pub inline_code: InlineCodeStyle, + pub(crate) inline_code: InlineCodeStyle, /// The style for a table. #[serde(default)] - pub table: Option, + pub(crate) table: Option, /// The style for a block quote. #[serde(default)] - pub block_quote: BlockQuoteStyle, + pub(crate) block_quote: BlockQuoteStyle, /// The default style. #[serde(rename = "default", default)] - pub default_style: DefaultStyle, + pub(crate) default_style: DefaultStyle, //// The style of all headings. #[serde(default)] - pub headings: HeadingStyles, + pub(crate) headings: HeadingStyles, /// The style of the introduction slide. #[serde(default)] - pub intro_slide: IntroSlideStyle, + pub(crate) intro_slide: IntroSlideStyle, /// The style of the presentation footer. #[serde(default)] - pub footer: FooterStyle, + pub(crate) footer: FooterStyle, } impl PresentationTheme { @@ -64,7 +64,7 @@ impl PresentationTheme { } /// Construct a presentation from a path. - pub fn from_path>(path: P) -> Result { + pub(crate) fn from_path>(path: P) -> Result { let contents = fs::read_to_string(path)?; let theme = serde_yaml::from_str(&contents)?; Ok(theme) @@ -73,7 +73,7 @@ impl PresentationTheme { /// Get the alignment for an element. /// /// This will fall back to the default alignment. - pub fn alignment(&self, element: &ElementType) -> Alignment { + pub(crate) fn alignment(&self, element: &ElementType) -> Alignment { use ElementType::*; let alignment = match element { @@ -98,130 +98,130 @@ impl PresentationTheme { /// The style of a slide title. #[derive(Clone, Debug, Default, Deserialize, Serialize)] -pub struct SlideTitleStyle { +pub(crate) struct SlideTitleStyle { /// The alignment. #[serde(flatten, default)] - pub alignment: Option, + pub(crate) alignment: Option, /// Whether to use a separator line. #[serde(default)] - pub separator: bool, + pub(crate) separator: bool, /// The padding that should be added before the text. #[serde(default)] - pub padding_top: Option, + pub(crate) padding_top: Option, /// The padding that should be added after the text. #[serde(default)] - pub padding_bottom: Option, + pub(crate) padding_bottom: Option, /// The colors to be used. #[serde(default)] - pub colors: Colors, + pub(crate) colors: Colors, } /// The style for all headings. #[derive(Clone, Debug, Default, Deserialize, Serialize)] -pub struct HeadingStyles { +pub(crate) struct HeadingStyles { /// H1 style. #[serde(default)] - pub h1: HeadingStyle, + pub(crate) h1: HeadingStyle, /// H2 style. #[serde(default)] - pub h2: HeadingStyle, + pub(crate) h2: HeadingStyle, /// H3 style. #[serde(default)] - pub h3: HeadingStyle, + pub(crate) h3: HeadingStyle, /// H4 style. #[serde(default)] - pub h4: HeadingStyle, + pub(crate) h4: HeadingStyle, /// H5 style. #[serde(default)] - pub h5: HeadingStyle, + pub(crate) h5: HeadingStyle, /// H6 style. #[serde(default)] - pub h6: HeadingStyle, + pub(crate) h6: HeadingStyle, } /// The style for a heading. #[derive(Clone, Debug, Default, Deserialize, Serialize)] -pub struct HeadingStyle { +pub(crate) struct HeadingStyle { /// The alignment. #[serde(flatten, default)] - pub alignment: Option, + pub(crate) alignment: Option, /// The prefix to be added to this heading. /// /// This allows adding text like "->" to every heading. #[serde(default)] - pub prefix: Option, + pub(crate) prefix: Option, /// The colors to be used. #[serde(default)] - pub colors: Colors, + pub(crate) colors: Colors, } /// The style of a block quote. #[derive(Clone, Debug, Default, Deserialize, Serialize)] -pub struct BlockQuoteStyle { +pub(crate) struct BlockQuoteStyle { /// The alignment. #[serde(flatten, default)] - pub alignment: Option, + pub(crate) alignment: Option, /// The prefix to be added to this block quote. /// /// This allows adding something like a vertical bar before the text. #[serde(default)] - pub prefix: Option, + pub(crate) prefix: Option, /// The colors to be used. #[serde(default)] - pub colors: Colors, + pub(crate) colors: Colors, } /// The style for the presentation introduction slide. #[derive(Clone, Debug, Default, Deserialize, Serialize)] -pub struct IntroSlideStyle { +pub(crate) struct IntroSlideStyle { /// The style of the title line. #[serde(default)] - pub title: BasicStyle, + pub(crate) title: BasicStyle, /// The style of the subtitle line. #[serde(default)] - pub subtitle: BasicStyle, + pub(crate) subtitle: BasicStyle, /// The style of the author line. #[serde(default)] - pub author: AuthorStyle, + pub(crate) author: AuthorStyle, } /// A simple style. #[derive(Clone, Debug, Default, Deserialize, Serialize)] -pub struct DefaultStyle { +pub(crate) struct DefaultStyle { /// The margin on the left/right of the screen. #[serde(default, with = "serde_yaml::with::singleton_map")] - pub margin: Option, + pub(crate) margin: Option, /// The colors to be used. #[serde(default)] - pub colors: Colors, + pub(crate) colors: Colors, } /// A simple style. #[derive(Clone, Debug, Default, Deserialize, Serialize)] -pub struct BasicStyle { +pub(crate) struct BasicStyle { /// The alignment. #[serde(flatten, default)] - pub alignment: Option, + pub(crate) alignment: Option, /// The colors to be used. #[serde(default)] - pub colors: Colors, + pub(crate) colors: Colors, } /// Text alignment. @@ -229,7 +229,7 @@ pub struct BasicStyle { /// This allows anchoring presentation elements to the left, center, or right of the screen. #[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] #[serde(tag = "alignment", rename_all = "snake_case")] -pub enum Alignment { +pub(crate) enum Alignment { /// Left alignment. Left { /// The margin before any text. @@ -264,24 +264,24 @@ impl Default for Alignment { /// The style for the author line in the presentation intro slide. #[derive(Clone, Debug, Default, Deserialize, Serialize)] -pub struct AuthorStyle { +pub(crate) struct AuthorStyle { /// The alignment. #[serde(flatten, default)] - pub alignment: Option, + pub(crate) alignment: Option, /// The colors to be used. #[serde(default)] - pub colors: Colors, + pub(crate) colors: Colors, /// The positioning of the author's name. #[serde(default)] - pub positioning: AuthorPositioning, + pub(crate) positioning: AuthorPositioning, } /// The style of the footer that's shown in every slide. #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(tag = "style", rename_all = "snake_case")] -pub enum FooterStyle { +pub(crate) enum FooterStyle { /// Use a template to generate the footer. Template { /// The template for the text to be put on the left. @@ -325,52 +325,52 @@ impl Default for FooterStyle { /// The style for a piece of code. #[derive(Clone, Debug, Default, Deserialize, Serialize)] -pub struct CodeBlockStyle { +pub(crate) struct CodeBlockStyle { /// The alignment. #[serde(flatten)] - pub alignment: Option, + pub(crate) alignment: Option, /// The padding. #[serde(default)] - pub padding: PaddingRect, + pub(crate) padding: PaddingRect, /// The syntect theme name to use. #[serde(default)] - pub theme_name: Option, + pub(crate) theme_name: Option, } /// The style for the output of a code execution block. #[derive(Clone, Debug, Default, Deserialize, Serialize)] -pub struct ExecutionOutputBlockStyle { +pub(crate) struct ExecutionOutputBlockStyle { /// The colors to be used. #[serde(default)] - pub colors: Colors, + pub(crate) colors: Colors, } /// The style for inline code. #[derive(Clone, Debug, Default, Deserialize, Serialize)] -pub struct InlineCodeStyle { +pub(crate) struct InlineCodeStyle { /// The colors to be used. #[serde(default)] - pub colors: Colors, + pub(crate) colors: Colors, } /// Vertical/horizontal padding. #[derive(Clone, Debug, Default, Deserialize, Serialize)] -pub struct PaddingRect { +pub(crate) struct PaddingRect { /// The number of columns to use as horizontal padding. #[serde(default)] - pub horizontal: Option, + pub(crate) horizontal: Option, /// The number of rows to use as vertical padding. #[serde(default)] - pub vertical: Option, + pub(crate) vertical: Option, } /// A margin. #[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] #[serde(rename_all = "snake_case")] -pub enum Margin { +pub(crate) enum Margin { /// A fixed number of characters. Fixed(u16), @@ -379,7 +379,7 @@ pub enum Margin { } impl Margin { - pub fn as_characters(&self, screen_size: u16) -> u16 { + pub(crate) fn as_characters(&self, screen_size: u16) -> u16 { match *self { Self::Fixed(value) => value, Self::Percent(percent) => { @@ -399,7 +399,7 @@ impl Default for Margin { /// An element type. #[derive(Clone, Deserialize, Debug, PartialEq, Eq, PartialOrd, Ord, Serialize)] #[serde(rename_all = "snake_case")] -pub enum ElementType { +pub(crate) enum ElementType { SlideTitle, Heading1, Heading2, @@ -420,7 +420,7 @@ pub enum ElementType { /// Where to position the author's name in the intro slide. #[derive(Clone, Debug, Default, Deserialize, Serialize)] #[serde(rename_all = "snake_case")] -pub enum AuthorPositioning { +pub(crate) enum AuthorPositioning { /// Right below the title. BelowTitle,