diff --git a/CHANGELOG.md b/CHANGELOG.md
index da9b9346..4cdc6827 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -51,6 +51,9 @@
- `PrettyPrinter::vcs_modification_markers` has been marked deprecated when building without the `git` feature, see #997 and #1020 (@eth-p, @sharkdp)
- Add APIs to provide `Input` descriptions with `InputDescription` (@eth-p)
- Add function to directly provide `Input`s to `PrettyPrinter` (@eth-p)
+- `Input::theme_preview_file` is no longer available. (@eth-p)
+
+Changes colored red are breaking changes.
## Packaging
diff --git a/src/assets.rs b/src/assets.rs
index b2ba8e5d..073cf564 100644
--- a/src/assets.rs
+++ b/src/assets.rs
@@ -193,11 +193,7 @@ impl HighlightingAssets {
input: &mut OpenedInput,
mapping: &SyntaxMapping,
) -> Result<&SyntaxReference> {
- if input.kind.is_theme_preview_file() {
- self.syntax_set
- .find_syntax_by_name("Rust")
- .ok_or_else(|| ErrorKind::UnknownSyntax("Rust".to_owned()).into())
- } else if let Some(language) = language {
+ if let Some(language) = language {
self.syntax_set
.find_syntax_by_token(language)
.ok_or_else(|| ErrorKind::UnknownSyntax(language.to_owned()).into())
diff --git a/src/bin/bat/main.rs b/src/bin/bat/main.rs
index 2eb612df..422fffdf 100644
--- a/src/bin/bat/main.rs
+++ b/src/bin/bat/main.rs
@@ -10,7 +10,7 @@ mod directories;
use std::collections::HashSet;
use std::ffi::OsStr;
use std::io;
-use std::io::Write;
+use std::io::{BufReader, Write};
use std::path::Path;
use std::process;
@@ -25,6 +25,7 @@ use assets::{assets_from_cache_or_binary, cache_dir, clear_assets, config_dir};
use clap::crate_version;
use directories::PROJECT_DIRS;
+use bat::input::InputDescription;
use bat::{
assets::HighlightingAssets,
config::Config,
@@ -34,6 +35,8 @@ use bat::{
style::{StyleComponent, StyleComponents},
};
+const THEME_PREVIEW_DATA: &[u8] = include_bytes!("../../../assets/theme_preview.rs");
+
fn run_cache_subcommand(matches: &clap::ArgMatches) -> Result<()> {
if matches.is_present("build") {
let source_dir = matches
@@ -118,6 +121,12 @@ pub fn list_languages(config: &Config) -> Result<()> {
Ok(())
}
+fn theme_preview_file<'a>() -> Input<'a> {
+ Input::from_reader(Box::new(BufReader::new(THEME_PREVIEW_DATA)))
+ .with_name(Some("theme.rs".as_ref()))
+ .with_description(Some(InputDescription::new("")))
+}
+
pub fn list_themes(cfg: &Config) -> Result<()> {
let assets = assets_from_cache_or_binary()?;
let mut config = cfg.clone();
@@ -137,7 +146,7 @@ pub fn list_themes(cfg: &Config) -> Result<()> {
)?;
config.theme = theme.to_string();
Controller::new(&config, &assets)
- .run(vec![Input::theme_preview_file()])
+ .run(vec![theme_preview_file()])
.ok();
writeln!(stdout)?;
}
diff --git a/src/input.rs b/src/input.rs
index 96d3055c..f3036ab8 100644
--- a/src/input.rs
+++ b/src/input.rs
@@ -6,8 +6,6 @@ use content_inspector::{self, ContentType};
use crate::error::*;
-const THEME_PREVIEW_FILE: &[u8] = include_bytes!("../assets/theme_preview.rs");
-
/// A description of an Input source.
/// This tells bat how to refer to the input.
#[derive(Clone)]
@@ -62,7 +60,6 @@ impl InputDescription {
pub(crate) enum InputKind<'a> {
OrdinaryFile(OsString),
StdIn,
- ThemePreviewFile,
CustomReader(Box),
}
@@ -73,7 +70,6 @@ impl<'a> InputKind<'a> {
InputDescription::new(path.to_string_lossy()).with_kind(Some("File"))
}
InputKind::StdIn => InputDescription::new("STDIN"),
- InputKind::ThemePreviewFile => InputDescription::new(""),
InputKind::CustomReader(_) => InputDescription::new("READER"),
}
}
@@ -93,19 +89,9 @@ pub struct Input<'a> {
pub(crate) enum OpenedInputKind {
OrdinaryFile(OsString),
StdIn,
- ThemePreviewFile,
CustomReader,
}
-impl OpenedInputKind {
- pub(crate) fn is_theme_preview_file(&self) -> bool {
- match self {
- OpenedInputKind::ThemePreviewFile => true,
- _ => false,
- }
- }
-}
-
pub(crate) struct OpenedInput<'a> {
pub(crate) kind: OpenedInputKind,
pub(crate) metadata: InputMetadata,
@@ -130,14 +116,6 @@ impl<'a> Input<'a> {
}
}
- pub fn theme_preview_file() -> Self {
- Input {
- kind: InputKind::ThemePreviewFile,
- metadata: InputMetadata::default(),
- description: None,
- }
- }
-
pub fn from_reader(reader: Box) -> Self {
Input {
kind: InputKind::CustomReader(reader),
@@ -196,12 +174,6 @@ impl<'a> Input<'a> {
InputReader::new(BufReader::new(file))
},
}),
- InputKind::ThemePreviewFile => Ok(OpenedInput {
- kind: OpenedInputKind::ThemePreviewFile,
- description,
- metadata: self.metadata,
- reader: InputReader::new(THEME_PREVIEW_FILE),
- }),
InputKind::CustomReader(reader) => Ok(OpenedInput {
description,
kind: OpenedInputKind::CustomReader,