Skip to content

Commit

Permalink
chore: fmt with latest nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
mfontanini committed Sep 21, 2024
1 parent e927f8b commit 74205db
Show file tree
Hide file tree
Showing 22 changed files with 51 additions and 51 deletions.
2 changes: 1 addition & 1 deletion src/custom.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use crate::{
GraphicsMode,
input::user::KeyBinding,
media::{emulator::TerminalEmulator, kitty::KittyMode},
processing::code::SnippetLanguage,
GraphicsMode,
};
use clap::ValueEnum;
use schemars::JsonSchema;
Expand Down
2 changes: 1 addition & 1 deletion src/demo.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{
ImageRegistry, MarkdownParser, PresentationBuilderOptions, PresentationTheme, Resources, Themes, ThirdPartyRender,
execute::SnippetExecutor,
input::{
source::Command,
Expand All @@ -8,7 +9,6 @@ use crate::{
presentation::Presentation,
processing::builder::{BuildError, PresentationBuilder},
render::{draw::TerminalDrawer, terminal::TerminalWrite},
ImageRegistry, MarkdownParser, PresentationBuilderOptions, PresentationTheme, Resources, Themes, ThirdPartyRender,
};
use std::{io, rc::Rc};

Expand Down
6 changes: 3 additions & 3 deletions src/export.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{
MarkdownParser, PresentationTheme, Resources,
custom::KeyBindingsConfig,
execute::SnippetExecutor,
markdown::parse::ParseError,
Expand All @@ -11,10 +12,9 @@ use crate::{
render::properties::WindowSize,
third_party::ThirdPartyRender,
tools::{ExecutionError, ThirdPartyTools},
MarkdownParser, PresentationTheme, Resources,
};
use base64::{engine::general_purpose::STANDARD, Engine};
use image::{codecs::png::PngEncoder, DynamicImage, ImageEncoder, ImageError};
use base64::{Engine, engine::general_purpose::STANDARD};
use image::{DynamicImage, ImageEncoder, ImageError, codecs::png::PngEncoder};
use semver::Version;
use serde::Serialize;
use std::{
Expand Down
2 changes: 1 addition & 1 deletion src/input/user.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::source::{Command, CommandDiscriminants};
use crate::custom::KeyBindingsConfig;
use crossterm::event::{poll, read, Event, KeyCode, KeyEvent, KeyEventKind, KeyModifiers};
use crossterm::event::{Event, KeyCode, KeyEvent, KeyEventKind, KeyModifiers, poll, read};
use schemars::JsonSchema;
use serde_with::DeserializeFromStr;
use std::{fmt, io, iter, mem, str::FromStr, time::Duration};
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use clap::{error::ErrorKind, CommandFactory, Parser};
use clap::{CommandFactory, Parser, error::ErrorKind};
use comrak::Arena;
use directories::ProjectDirs;
use presenterm::{
Expand Down
3 changes: 2 additions & 1 deletion src/markdown/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ use crate::{
style::TextStyle,
};
use comrak::{
Arena, ComrakOptions,
arena_tree::Node,
format_commonmark,
nodes::{
Ast, AstNode, ListDelimType, ListType, NodeCodeBlock, NodeHeading, NodeHtmlBlock, NodeList, NodeValue,
Sourcepos,
},
parse_document, Arena, ComrakOptions,
parse_document,
};
use std::{
cell::RefCell,
Expand Down
4 changes: 2 additions & 2 deletions src/media/ascii.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use super::printer::{PrintImage, PrintImageError, PrintOptions, RegisterImageError, ResourceProperties};
use crossterm::{
QueueableCommand,
cursor::{MoveRight, MoveToColumn},
style::{Color, Stylize},
QueueableCommand,
};
use image::{imageops::FilterType, DynamicImage, GenericImageView, Pixel, Rgba};
use image::{DynamicImage, GenericImageView, Pixel, Rgba, imageops::FilterType};
use itertools::Itertools;
use std::{fs, ops::Deref};

Expand Down
2 changes: 1 addition & 1 deletion src/media/emulator.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::kitty::local_mode_supported;
use crate::{media::kitty::KittyMode, GraphicsMode};
use crate::{GraphicsMode, media::kitty::KittyMode};
use std::env;
use strum::IntoEnumIterator;

Expand Down
4 changes: 2 additions & 2 deletions src/media/iterm.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::printer::{PrintImage, PrintImageError, PrintOptions, RegisterImageError, ResourceProperties};
use base64::{engine::general_purpose::STANDARD, Engine};
use image::{codecs::png::PngEncoder, GenericImageView, ImageEncoder};
use base64::{Engine, engine::general_purpose::STANDARD};
use image::{GenericImageView, ImageEncoder, codecs::png::PngEncoder};
use std::{env, fs, path::Path};

pub(crate) struct ItermResource {
Expand Down
8 changes: 4 additions & 4 deletions src/media/kitty.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use super::printer::{PrintImage, PrintImageError, PrintOptions, RegisterImageError, ResourceProperties};
use crate::style::Color;
use base64::{engine::general_purpose::STANDARD, Engine};
use base64::{Engine, engine::general_purpose::STANDARD};
use console::{Key, Term};
use crossterm::{cursor::MoveToColumn, style::SetForegroundColor, QueueableCommand};
use image::{codecs::gif::GifDecoder, AnimationDecoder, Delay, DynamicImage, EncodableLayout, ImageReader, RgbaImage};
use crossterm::{QueueableCommand, cursor::MoveToColumn, style::SetForegroundColor};
use image::{AnimationDecoder, Delay, DynamicImage, EncodableLayout, ImageReader, RgbaImage, codecs::gif::GifDecoder};
use rand::Rng;
use std::{
fmt,
Expand All @@ -12,7 +12,7 @@ use std::{
path::{Path, PathBuf},
sync::atomic::{AtomicU32, Ordering},
};
use tempfile::{tempdir, NamedTempFile, TempDir};
use tempfile::{NamedTempFile, TempDir, tempdir};

const IMAGE_PLACEHOLDER: &str = "\u{10EEEE}";
const DIACRITICS: &[u32] = &[
Expand Down
2 changes: 1 addition & 1 deletion src/media/sixel.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::printer::{
CreatePrinterError, PrintImage, PrintImageError, PrintOptions, RegisterImageError, ResourceProperties,
};
use image::{imageops::FilterType, DynamicImage, GenericImageView};
use image::{DynamicImage, GenericImageView, imageops::FilterType};
use sixel_rs::{
encoder::{Encoder, QuickFrameBuilder},
optflags::EncodePolicy,
Expand Down
17 changes: 9 additions & 8 deletions src/processing/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1549,10 +1549,11 @@ mod test {
#[test]
fn iterate_list_starting_from_other() {
let list = ListIterator::new(
vec![
ListItem { depth: 0, contents: "0".into(), item_type: ListItemType::Unordered },
ListItem { depth: 0, contents: "1".into(), item_type: ListItemType::Unordered },
],
vec![ListItem { depth: 0, contents: "0".into(), item_type: ListItemType::Unordered }, ListItem {
depth: 0,
contents: "1".into(),
item_type: ListItemType::Unordered,
}],
3,
);
let expected_indexes = [3, 4];
Expand Down Expand Up @@ -1639,10 +1640,10 @@ mod test {

#[test]
fn implicit_slide_ends_with_front_matter() {
let elements = vec![
MarkdownElement::FrontMatter("theme:\n name: light".into()),
MarkdownElement::SetexHeading { text: "hi".into() },
];
let elements =
vec![MarkdownElement::FrontMatter("theme:\n name: light".into()), MarkdownElement::SetexHeading {
text: "hi".into(),
}];
let options = PresentationBuilderOptions { implicit_slide_ends: true, ..Default::default() };
let slides = build_presentation_with_options(elements, options).into_slides();
assert_eq!(slides.len(), 1);
Expand Down
15 changes: 9 additions & 6 deletions src/processing/code.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::padding::NumberPadder;
use crate::{
PresentationTheme,
markdown::{
elements::{Percent, PercentParseError},
text::{WeightedText, WeightedTextBlock},
Expand All @@ -11,7 +12,6 @@ use crate::{
},
style::{Color, TextStyle},
theme::{Alignment, CodeBlockStyle},
PresentationTheme,
};
use serde::Deserialize;
use serde_with::DeserializeFromStr;
Expand Down Expand Up @@ -622,8 +622,8 @@ pub(crate) struct ExternalFile {
#[cfg(test)]
mod test {
use super::*;
use rstest::rstest;
use Highlight::*;
use rstest::rstest;

fn parse_language(input: &str) -> SnippetLanguage {
let (language, _) = CodeBlockParser::parse_block_info(input).expect("parse failed");
Expand Down Expand Up @@ -725,10 +725,13 @@ mod test {
#[test]
fn highlight_line_range() {
let attributes = parse_attributes("bash { 1, 2-4,6 , all , 10 - 12 }");
assert_eq!(
attributes.highlight_groups,
&[HighlightGroup::new(vec![Single(1), Range(2..5), Single(6), All, Range(10..13)])]
);
assert_eq!(attributes.highlight_groups, &[HighlightGroup::new(vec![
Single(1),
Range(2..5),
Single(6),
All,
Range(10..13)
])]);
}

#[test]
Expand Down
5 changes: 2 additions & 3 deletions src/processing/execution.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crossterm::{
cursor,
ExecutableCommand, cursor,
terminal::{self, disable_raw_mode, enable_raw_mode},
ExecutableCommand,
};

use super::separator::{RenderSeparator, SeparatorWidth};
use crate::{
PresentationTheme,
ansi::AnsiSplitter,
execute::{ExecutionHandle, ExecutionState, ProcessStatus, SnippetExecutor},
markdown::{
Expand All @@ -17,7 +17,6 @@ use crate::{
render::{properties::WindowSize, terminal::should_hide_cursor},
style::{Colors, TextStyle},
theme::{Alignment, ExecutionStatusBlockStyle, Margin},
PresentationTheme,
};
use std::{
cell::RefCell,
Expand Down
11 changes: 4 additions & 7 deletions src/processing/footer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,10 @@ impl AsRenderOperations for FooterGenerator {
let columns_ratio = (total_columns as f64 * progress_ratio).ceil();
let bar = character.repeat(columns_ratio as usize);
let bar = Text::new(bar, TextStyle::default().colors(*colors));
vec![
RenderOperation::JumpToBottomRow { index: 0 },
RenderOperation::RenderText {
line: vec![bar].into(),
alignment: Alignment::Left { margin: Margin::Fixed(0) },
},
]
vec![RenderOperation::JumpToBottomRow { index: 0 }, RenderOperation::RenderText {
line: vec![bar].into(),
alignment: Alignment::Left { margin: Margin::Fixed(0) },
}]
}
FooterStyle::Empty => vec![],
}
Expand Down
2 changes: 1 addition & 1 deletion src/processing/modals.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{
PresentationTheme,
custom::KeyBindingsConfig,
input::user::KeyBinding,
markdown::{
Expand All @@ -13,7 +14,6 @@ use crate::{
render::properties::WindowSize,
style::{Colors, TextStyle},
theme::Margin,
PresentationTheme,
};
use std::{iter, rc::Rc};
use unicode_width::UnicodeWidthStr;
Expand Down
2 changes: 1 addition & 1 deletion src/render/highlighting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use once_cell::sync::Lazy;
use serde::Deserialize;
use std::{cell::RefCell, collections::BTreeMap, fs, path::Path, rc::Rc};
use syntect::{
LoadingError,
easy::HighlightLines,
highlighting::{Style, Theme, ThemeSet},
parsing::SyntaxSet,
LoadingError,
};

static SYNTAX_SET: Lazy<SyntaxSet> = Lazy::new(|| {
Expand Down
3 changes: 1 addition & 2 deletions src/render/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ use crate::{
style::{Color, Colors},
};
use crossterm::{
cursor,
QueueableCommand, cursor,
style::{self, StyledContent},
terminal::{self},
QueueableCommand,
};
use std::{
io::{self, Write},
Expand Down
2 changes: 1 addition & 1 deletion src/render/validate.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use super::{properties::WindowSize, terminal::TerminalWrite};
use crate::{
ImagePrinter,
presentation::Presentation,
render::{
draw::RenderError,
engine::{RenderEngine, RenderEngineOptions},
terminal::Terminal,
},
ImagePrinter,
};
use std::{io, sync::Arc};

Expand Down
4 changes: 2 additions & 2 deletions src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ use std::{
fs, io, mem,
path::{Path, PathBuf},
sync::{
atomic::{AtomicBool, Ordering},
mpsc::{channel, Receiver, Sender},
Arc,
atomic::{AtomicBool, Ordering},
mpsc::{Receiver, Sender, channel},
},
thread,
time::{Duration, SystemTime},
Expand Down
2 changes: 1 addition & 1 deletion src/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ pub enum LoadThemeError {
#[cfg(test)]
mod test {
use super::*;
use tempfile::{tempdir, TempDir};
use tempfile::{TempDir, tempdir};

fn write_theme(name: &str, theme: PresentationTheme, directory: &TempDir) {
let theme = serde_yaml::to_string(&theme).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/third_party.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{
ImageRegistry, PresentationTheme,
custom::{default_mermaid_scale, default_snippet_render_threads, default_typst_ppi},
markdown::elements::{Percent, Text, TextBlock},
media::{image::Image, printer::RegisterImageError},
Expand All @@ -11,7 +12,6 @@ use crate::{
style::{Color, Colors, TextStyle},
theme::{Alignment, MermaidStyle, TypstStyle},
tools::{ExecutionError, ThirdPartyTools},
ImageRegistry, PresentationTheme,
};
use std::{
collections::{HashMap, VecDeque},
Expand Down

0 comments on commit 74205db

Please sign in to comment.