From 2e103ee6b3703e120025d43f04fe9a6d7ae92b5e Mon Sep 17 00:00:00 2001 From: Oliver looney Date: Sun, 10 Dec 2023 16:39:34 +0000 Subject: able to set terminal title to hardcoded value --- src/pager.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/pager.rs b/src/pager.rs index 5b707779..bdd5eb7f 100644 --- a/src/pager.rs +++ b/src/pager.rs @@ -1,5 +1,6 @@ use shell_words::ParseError; -use std::env; +use std::{env, io}; +use std::io::Write; /// If we use a pager, this enum tells us from where we were told to use it. #[derive(Debug, PartialEq)] @@ -36,6 +37,16 @@ pub(crate) enum PagerKind { Unknown, } +fn set_terminal_title(title: &str) { + print!("\x1b]2;{}\x07", title); + io::stdout().flush().unwrap(); +} + +fn restore_terminal_title() { + print!("\x1b]2;\x07"); + io::stdout().flush().unwrap(); +} + impl PagerKind { fn from_bin(bin: &str) -> PagerKind { use std::path::Path; @@ -102,6 +113,7 @@ pub(crate) fn get_pager(config_pager: Option<&str>) -> Result, Par }; let parts = shell_words::split(cmd)?; + set_terminal_title("test"); match parts.split_first() { Some((bin, args)) => { let kind = PagerKind::from_bin(bin); -- cgit v1.2.3 From 4863d428dd7004b471960fdf1c6b30417d94383d Mon Sep 17 00:00:00 2001 From: Oliver looney Date: Sun, 10 Dec 2023 16:44:47 +0000 Subject: title is being reset on quit, so no need to restore terminal title --- src/pager.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/pager.rs b/src/pager.rs index bdd5eb7f..052cdbff 100644 --- a/src/pager.rs +++ b/src/pager.rs @@ -42,11 +42,6 @@ fn set_terminal_title(title: &str) { io::stdout().flush().unwrap(); } -fn restore_terminal_title() { - print!("\x1b]2;\x07"); - io::stdout().flush().unwrap(); -} - impl PagerKind { fn from_bin(bin: &str) -> PagerKind { use std::path::Path; -- cgit v1.2.3 From b9b554248daba2134d4355ebc5cd4373ad265abe Mon Sep 17 00:00:00 2001 From: Oliver looney Date: Sun, 10 Dec 2023 17:17:19 +0000 Subject: successfully setting the terminal title to bat's input's names --- src/bin/bat/main.rs | 10 ++++++++++ src/controller.rs | 1 + src/input.rs | 4 ++-- src/pager.rs | 9 +-------- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/bin/bat/main.rs b/src/bin/bat/main.rs index 43e9d288..6e5b71be 100644 --- a/src/bin/bat/main.rs +++ b/src/bin/bat/main.rs @@ -227,9 +227,19 @@ pub fn list_themes(cfg: &Config, config_dir: &Path, cache_dir: &Path) -> Result< Ok(()) } +fn set_terminal_title_to_inputs_names(inputs: &Vec) { + let mut input_names = "bat: ".to_string(); + for input in inputs.iter() { + input_names = input_names + &input.description.name.to_string() + ", " + } + print!("\x1b]2;{}\x07", input_names); + io::stdout().flush().unwrap(); +} + fn run_controller(inputs: Vec, config: &Config, cache_dir: &Path) -> Result { let assets = assets_from_cache_or_binary(config.use_custom_assets, cache_dir)?; let controller = Controller::new(config, &assets); + set_terminal_title_to_inputs_names(&inputs); controller.run(inputs, None) } diff --git a/src/controller.rs b/src/controller.rs index f378cbc6..6333ebb1 100644 --- a/src/controller.rs +++ b/src/controller.rs @@ -88,6 +88,7 @@ impl<'b> Controller<'b> { clircle::Identifier::stdout() }; + let mut writer = match output_buffer { Some(buf) => OutputHandle::FmtWrite(buf), None => OutputHandle::IoWrite(output_type.handle()?), diff --git a/src/input.rs b/src/input.rs index ccab98bf..724c5e15 100644 --- a/src/input.rs +++ b/src/input.rs @@ -13,7 +13,7 @@ use crate::error::*; /// This tells bat how to refer to the input. #[derive(Clone)] pub struct InputDescription { - pub(crate) name: String, + pub name: String, /// The input title. /// This replaces the name if provided. @@ -94,7 +94,7 @@ pub(crate) struct InputMetadata { pub struct Input<'a> { pub(crate) kind: InputKind<'a>, pub(crate) metadata: InputMetadata, - pub(crate) description: InputDescription, + pub description: InputDescription, } pub(crate) enum OpenedInputKind { diff --git a/src/pager.rs b/src/pager.rs index 052cdbff..d627e903 100644 --- a/src/pager.rs +++ b/src/pager.rs @@ -1,6 +1,5 @@ use shell_words::ParseError; -use std::{env, io}; -use std::io::Write; +use std::{env}; /// If we use a pager, this enum tells us from where we were told to use it. #[derive(Debug, PartialEq)] @@ -37,11 +36,6 @@ pub(crate) enum PagerKind { Unknown, } -fn set_terminal_title(title: &str) { - print!("\x1b]2;{}\x07", title); - io::stdout().flush().unwrap(); -} - impl PagerKind { fn from_bin(bin: &str) -> PagerKind { use std::path::Path; @@ -108,7 +102,6 @@ pub(crate) fn get_pager(config_pager: Option<&str>) -> Result, Par }; let parts = shell_words::split(cmd)?; - set_terminal_title("test"); match parts.split_first() { Some((bin, args)) => { let kind = PagerKind::from_bin(bin); -- cgit v1.2.3 From 069318b139eaf88c3fdc0819e42953fb63cc7592 Mon Sep 17 00:00:00 2001 From: Oliver looney Date: Sun, 10 Dec 2023 17:20:42 +0000 Subject: fixed formatting of terminal title --- src/bin/bat/main.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/bin/bat/main.rs b/src/bin/bat/main.rs index 6e5b71be..fb6abd11 100644 --- a/src/bin/bat/main.rs +++ b/src/bin/bat/main.rs @@ -229,8 +229,11 @@ pub fn list_themes(cfg: &Config, config_dir: &Path, cache_dir: &Path) -> Result< fn set_terminal_title_to_inputs_names(inputs: &Vec) { let mut input_names = "bat: ".to_string(); - for input in inputs.iter() { - input_names = input_names + &input.description.name.to_string() + ", " + for (index, input) in inputs.iter().enumerate() { + input_names += &input.description.name.to_string(); + if index < inputs.len() - 1 { + input_names += ", "; + } } print!("\x1b]2;{}\x07", input_names); io::stdout().flush().unwrap(); -- cgit v1.2.3 From 6ad800e43a18c5e4274ec63cc022c014506f6397 Mon Sep 17 00:00:00 2001 From: Oliver looney Date: Sun, 10 Dec 2023 17:24:49 +0000 Subject: tidied commits --- src/controller.rs | 1 - src/pager.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/controller.rs b/src/controller.rs index 6333ebb1..f378cbc6 100644 --- a/src/controller.rs +++ b/src/controller.rs @@ -88,7 +88,6 @@ impl<'b> Controller<'b> { clircle::Identifier::stdout() }; - let mut writer = match output_buffer { Some(buf) => OutputHandle::FmtWrite(buf), None => OutputHandle::IoWrite(output_type.handle()?), diff --git a/src/pager.rs b/src/pager.rs index d627e903..5b707779 100644 --- a/src/pager.rs +++ b/src/pager.rs @@ -1,5 +1,5 @@ use shell_words::ParseError; -use std::{env}; +use std::env; /// If we use a pager, this enum tells us from where we were told to use it. #[derive(Debug, PartialEq)] -- cgit v1.2.3 From fd84e4f49fdb363e245eceb96a50080a589eb993 Mon Sep 17 00:00:00 2001 From: Oliver looney Date: Mon, 11 Dec 2023 19:09:48 +0000 Subject: fixed all but two failing tests. Last two tests are erroring because of IO circle detected error --- tests/integration_tests.rs | 180 ++++++++++++++++++++++----------------------- 1 file changed, 90 insertions(+), 90 deletions(-) diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index be70fdca..96540cc6 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -48,7 +48,7 @@ fn basic() { .arg("test.txt") .assert() .success() - .stdout("hello world\n") + .stdout("\u{1b}]2;bat: test.txt\x07hello world\n") .stderr(""); } @@ -58,7 +58,7 @@ fn stdin() { .write_stdin("foo\nbar\n") .assert() .success() - .stdout("foo\nbar\n"); + .stdout("\u{1b}]2;bat: STDIN\x07foo\nbar\n"); } #[test] @@ -68,7 +68,7 @@ fn concatenate() { .arg("test.txt") .assert() .success() - .stdout("hello world\nhello world\n"); + .stdout("\u{1b}]2;bat: test.txt, test.txt\x07hello world\nhello world\n"); } #[test] @@ -80,7 +80,7 @@ fn concatenate_stdin() { .write_stdin("stdin\n") .assert() .success() - .stdout("hello world\nstdin\nhello world\n"); + .stdout("\u{1b}]2;bat: test.txt, STDIN, test.txt\x07hello world\nstdin\nhello world\n"); } #[test] @@ -90,7 +90,7 @@ fn concatenate_empty_first() { .arg("test.txt") .assert() .success() - .stdout("hello world\n"); + .stdout("\u{1b}]2;bat: empty.txt, test.txt\x07hello world\n"); } #[test] @@ -100,7 +100,7 @@ fn concatenate_empty_last() { .arg("empty.txt") .assert() .success() - .stdout("hello world\n"); + .stdout("\u{1b}]2;bat: test.txt, empty.txt\x07hello world\n"); } #[test] @@ -110,7 +110,7 @@ fn concatenate_empty_both() { .arg("empty.txt") .assert() .success() - .stdout(""); + .stdout("\u{1b}]2;bat: empty.txt, empty.txt\x07"); } #[test] @@ -121,7 +121,7 @@ fn concatenate_empty_between() { .arg("test.txt") .assert() .success() - .stdout("hello world\nhello world\n"); + .stdout("\u{1b}]2;bat: test.txt, empty.txt, test.txt\x07hello world\nhello world\n"); } #[test] @@ -132,7 +132,7 @@ fn concatenate_empty_first_and_last() { .arg("empty.txt") .assert() .success() - .stdout("hello world\n"); + .stdout("\u{1b}]2;bat: empty.txt, test.txt, empty.txt\x07hello world\n"); } #[test] @@ -142,7 +142,7 @@ fn concatenate_single_line() { .arg("single-line.txt") .assert() .success() - .stdout("Single LineSingle Line"); + .stdout("\u{1b}]2;bat: single-line.txt, single-line.txt\x07Single LineSingle Line"); } #[test] @@ -153,7 +153,7 @@ fn concatenate_single_line_empty() { .arg("single-line.txt") .assert() .success() - .stdout("Single LineSingle Line"); + .stdout("\u{1b}]2;bat: single-line.txt, empty.txt, single-line.txt\x07Single LineSingle Line"); } #[test] @@ -164,7 +164,7 @@ fn line_numbers() { .arg("--decorations=always") .assert() .success() - .stdout(" 1 line 1\n 2 line 2\n 3 line 3\n 4 line 4\n"); + .stdout("\u{1b}]2;bat: multiline.txt\x07 1 line 1\n 2 line 2\n 3 line 3\n 4 line 4\n"); } #[test] @@ -174,7 +174,7 @@ fn line_range_2_3() { .arg("--line-range=2:3") .assert() .success() - .stdout("line 2\nline 3\n"); + .stdout("\u{1b}]2;bat: multiline.txt\x07line 2\nline 3\n"); } #[test] @@ -184,7 +184,7 @@ fn line_range_first_two() { .arg("--line-range=:2") .assert() .success() - .stdout("line 1\nline 2\n"); + .stdout("\u{1b}]2;bat: multiline.txt\x07line 1\nline 2\n"); } #[test] @@ -194,7 +194,7 @@ fn line_range_last_3() { .arg("--line-range=2:") .assert() .success() - .stdout("line 2\nline 3\nline 4\n"); + .stdout("\u{1b}]2;bat: multiline.txt\x07line 2\nline 3\nline 4\n"); } #[test] @@ -205,7 +205,7 @@ fn line_range_multiple() { .arg("--line-range=4:4") .assert() .success() - .stdout("line 1\nline 2\nline 4\n"); + .stdout("\u{1b}]2;bat: multiline.txt\x07line 1\nline 2\nline 4\n"); } #[test] @@ -354,7 +354,7 @@ fn tabs_numbers() { .assert() .success() .stdout( - " 1 1 2 3 4 + "\u{1b}]2;bat: tabs.txt\x07 1 1 2 3 4 2 1 ? 3 22 ? 4 333 ? @@ -377,7 +377,7 @@ fn tabs_passthrough_wrapped() { .assert() .success() .stdout( - " 1 2 3 4 + "\u{1b}]2;bat: tabs.txt\x07 1 2 3 4 1 ? 22 ? 333 ? @@ -400,7 +400,7 @@ fn tabs_4_wrapped() { .assert() .success() .stdout( - " 1 2 3 4 + "\u{1b}]2;bat: tabs.txt\x07 1 2 3 4 1 ? 22 ? 333 ? @@ -423,7 +423,7 @@ fn tabs_8_wrapped() { .assert() .success() .stdout( - " 1 2 3 4 + "\u{1b}]2;bat: tabs.txt\x07 1 2 3 4 1 ? 22 ? 333 ? @@ -446,7 +446,7 @@ fn tabs_passthrough() { .assert() .success() .stdout( - " 1 2 3 4 + "\u{1b}]2;bat: tabs.txt\x07 1 2 3 4 1 ? 22 ? 333 ? @@ -469,7 +469,7 @@ fn tabs_4() { .assert() .success() .stdout( - " 1 2 3 4 + "\u{1b}]2;bat: tabs.txt\x07 1 2 3 4 1 ? 22 ? 333 ? @@ -492,7 +492,7 @@ fn tabs_8() { .assert() .success() .stdout( - " 1 2 3 4 + "\u{1b}]2;bat: tabs.txt\x07 1 2 3 4 1 ? 22 ? 333 ? @@ -516,7 +516,7 @@ fn tabs_4_env_overrides_config() { .assert() .success() .stdout( - " 1 2 3 4 + "\u{1b}]2;bat: tabs.txt\x07 1 2 3 4 1 ? 22 ? 333 ? @@ -541,7 +541,7 @@ fn tabs_4_arg_overrides_env() { .assert() .success() .stdout( - " 1 2 3 4 + "\u{1b}]2;bat: tabs.txt\x07 1 2 3 4 1 ? 22 ? 333 ? @@ -565,7 +565,7 @@ fn tabs_4_arg_overrides_env_noconfig() { .assert() .success() .stdout( - " 1 2 3 4 + "\u{1b}]2;bat: tabs.txt\x07 1 2 3 4 1 ? 22 ? 333 ? @@ -594,7 +594,7 @@ fn do_not_exit_directory() { .arg("sub_directory") .arg("test.txt") .assert() - .stdout("hello world\n") + .stdout("\u{1b}]2;bat: sub_directory, test.txt\x07hello world\n") .failure(); } @@ -653,7 +653,7 @@ fn pager_disable() { .arg("test.txt") .assert() .success() - .stdout(predicate::eq("hello world\n").normalize()); + .stdout(predicate::eq("\u{1b}]2;bat: test.txt\x07hello world\n").normalize()); } #[test] @@ -734,7 +734,7 @@ fn env_var_pager_value_bat() { .arg("test.txt") .assert() .success() - .stdout(predicate::eq("hello world\n").normalize()); + .stdout(predicate::eq("\u{1b}]2;bat: test.txt\x07hello world\n").normalize()); } #[test] @@ -772,7 +772,7 @@ fn pager_most_from_pager_env_var() { .arg("test.txt") .assert() .success() - .stdout(predicate::eq("hello world\n").normalize()); + .stdout(predicate::eq("\u{1b}]2;bat: test.txt\x07hello world\n").normalize()); }); } @@ -818,7 +818,7 @@ fn pager_most_with_arg() { .arg("test.txt") .assert() .success() - .stdout(predicate::eq("hello world\n").normalize()); + .stdout(predicate::eq("\u{1b}]2;bat: test.txt\x07hello world\n").normalize()); }); } @@ -833,7 +833,7 @@ fn pager_more() { .arg("test.txt") .assert() .success() - .stdout(predicate::eq("hello world\n").normalize()); + .stdout(predicate::eq("\u{1b}]2;bat: test.txt\x07hello world\n").normalize()); }); } @@ -845,7 +845,7 @@ fn alias_pager_disable() { .arg("test.txt") .assert() .success() - .stdout(predicate::eq("hello world\n").normalize()); + .stdout(predicate::eq("\u{1b}]2;bat: test.txt\x07hello world\n").normalize()); } #[test] @@ -872,7 +872,7 @@ fn disable_pager_if_disable_paging_flag_comes_after_paging() { .arg("test.txt") .assert() .success() - .stdout(predicate::eq("hello world\n").normalize()); + .stdout(predicate::eq("\u{1b}]2;bat: test.txt\x07hello world\n").normalize()); } #[test] @@ -884,7 +884,7 @@ fn disable_pager_if_pp_flag_comes_after_paging() { .arg("test.txt") .assert() .success() - .stdout(predicate::eq("hello world\n").normalize()); + .stdout(predicate::eq("\u{1b}]2;bat: test.txt\x07hello world\n").normalize()); } #[test] @@ -896,7 +896,7 @@ fn enable_pager_if_disable_paging_flag_comes_before_paging() { .arg("test.txt") .assert() .success() - .stdout(predicate::eq("pager-output\n").normalize()); + .stdout(predicate::eq("\u{1b}]2;bat: test.txt\x07pager-output\n").normalize()); } #[test] @@ -908,7 +908,7 @@ fn enable_pager_if_pp_flag_comes_before_paging() { .arg("test.txt") .assert() .success() - .stdout(predicate::eq("pager-output\n").normalize()); + .stdout(predicate::eq("\u{1b}]2;bat: test.txt\x07pager-output\n").normalize()); } #[test] @@ -1111,7 +1111,7 @@ fn utf16() { .arg("test_UTF-16LE.txt") .assert() .success() - .stdout("hello world\n"); + .stdout("\u{1b}]2;bat: test_UTF-16LE.txt\x07hello world\n"); } // Regression test for https://github.com/sharkdp/bat/issues/1922 @@ -1124,7 +1124,7 @@ fn bom_not_stripped_in_loop_through_mode() { .arg("test_BOM.txt") .assert() .success() - .stdout("\u{feff}hello world\n"); + .stdout("\u{1b}]2;bat: test_BOM.txt\x07\u{feff}hello world\n"); } // Regression test for https://github.com/sharkdp/bat/issues/1922 @@ -1153,7 +1153,7 @@ fn bom_stripped_when_no_color_and_not_loop_through() { .assert() .success() .stdout( - "\ + "\u{1b}]2;bat: test_BOM.txt\x07\ ─────┬────────────────────────────────────────────────────────────────────────── │ File: test_BOM.txt ─────┼────────────────────────────────────────────────────────────────────────── @@ -1169,7 +1169,7 @@ fn can_print_file_named_cache() { .arg("cache") .assert() .success() - .stdout("test\n") + .stdout("\u{1b}]2;bat: cache\x07test\n") .stderr(""); } @@ -1180,7 +1180,7 @@ fn can_print_file_named_cache_with_additional_argument() { .arg("test.txt") .assert() .success() - .stdout("test\nhello world\n") + .stdout("\u{1b}]2;bat: cache, test.txt\x07test\nhello world\n") .stderr(""); } @@ -1190,7 +1190,7 @@ fn can_print_file_starting_with_cache() { .arg("cache.c") .assert() .success() - .stdout("test\n") + .stdout("\u{1b}]2;bat: cache.c\x07test\n") .stderr(""); } @@ -1220,7 +1220,7 @@ fn unicode_wrap() { .assert() .success() .stdout( - " 1 ビタミンA ビタミンD ビタミンE ビ + "\u{1b}]2;bat: unicode-wrap.txt\x07 1 ビタミンA ビタミンD ビタミンE ビ タミンK ビタミンB1 ビタミンB2 ナ イアシン パントテン酸 ビタミンB6 ビタミンB12 葉酸 ビオチン ビタ @@ -1264,7 +1264,7 @@ fn snip() { .assert() .success() .stdout( - " 1 line 1 + "\u{1b}]2;bat: multiline.txt\x07 1 line 1 2 line 2 ...─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ 8< ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ 4 line 4 @@ -1281,7 +1281,7 @@ fn empty_file_leads_to_empty_output_with_grid_enabled() { .arg("--terminal-width=80") .assert() .success() - .stdout(""); + .stdout("\u{1b}]2;bat: empty.txt\x07"); } #[test] @@ -1293,7 +1293,7 @@ fn empty_file_leads_to_empty_output_with_rule_enabled() { .arg("--terminal-width=80") .assert() .success() - .stdout(""); + .stdout("\u{1b}]2;bat: empty.txt\x07"); } #[test] @@ -1306,7 +1306,7 @@ fn header_basic() { .arg("--file-name=foo") .assert() .success() - .stdout("File: foo\n") + .stdout("\u{1b}]2;bat: foo\x07File: foo\n") .stderr(""); } @@ -1320,7 +1320,7 @@ fn header_full_basic() { .arg("--file-name=foo") .assert() .success() - .stdout("File: foo\nSize: 12 B\n") + .stdout("\u{1b}]2;bat: foo\x07File: foo\nSize: 12 B\n") .stderr(""); } @@ -1334,7 +1334,7 @@ fn header_env_basic() { .arg("--file-name=foo") .assert() .success() - .stdout("File: foo\nSize: 12 B\n") + .stdout("\u{1b}]2;bat: foo\x07File: foo\nSize: 12 B\n") .stderr(""); } @@ -1349,7 +1349,7 @@ fn header_arg_overrides_env() { .arg("--file-name=foo") .assert() .success() - .stdout("File: foo\n") + .stdout("\u{1b}]2;bat: foo\x07File: foo\n") .stderr(""); } @@ -1363,7 +1363,7 @@ fn header_binary() { .arg("--file-name=foo") .assert() .success() - .stdout("File: foo \n") + .stdout("\u{1b}]2;bat: foo\x07File: foo \n") .stderr(""); } @@ -1377,7 +1377,7 @@ fn header_full_binary() { .arg("--file-name=foo") .assert() .success() - .stdout("File: foo \nSize: 4 B\n") + .stdout("\u{1b}]2;bat: foo\x07File: foo \nSize: 4 B\n") .stderr(""); } @@ -1395,7 +1395,7 @@ fn header_default() { .assert() .success() .stdout( - "\ + "\u{1b}]2;bat: single-line.txt\x07\ ───────┬──────────────────────────────────────────────────────────────────────── │ File: single-line.txt ───────┼──────────────────────────────────────────────────────────────────────── @@ -1419,7 +1419,7 @@ fn header_default_is_default() { .assert() .success() .stdout( - "\ + "\u{1b}]2;bat: single-line.txt\x07\ ───────┬──────────────────────────────────────────────────────────────────────── │ File: single-line.txt ───────┼──────────────────────────────────────────────────────────────────────── @@ -1441,7 +1441,7 @@ fn filename_stdin() { .arg("--file-name=foo") .assert() .success() - .stdout("File: foo\n") + .stdout("\u{1b}]2;bat: foo\x07File: foo\n") .stderr(""); } @@ -1455,7 +1455,7 @@ fn filename_stdin_binary() { .arg("--file-name=foo") .assert() .success() - .stdout("File: foo \n") + .stdout("\u{1b}]2;bat: foo\x07File: foo \n") .stderr(""); } @@ -1471,7 +1471,7 @@ fn filename_multiple_ok() { .arg("--file-name=bar") .assert() .success() - .stdout("File: foo\n\nFile: bar\n") + .stdout("\u{1b}]2;bat: foo, bar\x07File: foo\n\nFile: bar\n") .stderr(""); } @@ -1496,7 +1496,7 @@ fn header_padding() { .arg("test.txt") .arg("single-line.txt") .assert() - .stdout("File: test.txt\nhello world\n\nFile: single-line.txt\nSingle Line\n") + .stdout("\u{1b}]2;bat: test.txt, single-line.txt\x07File: test.txt\nhello world\n\nFile: single-line.txt\nSingle Line\n") .stderr(""); } @@ -1508,7 +1508,7 @@ fn header_full_padding() { .arg("test.txt") .arg("single-line.txt") .assert() - .stdout("File: test.txt\nSize: 12 B\nhello world\n\nFile: single-line.txt\nSize: 11 B\nSingle Line\n") + .stdout("\u{1b}]2;bat: test.txt, single-line.txt\x07File: test.txt\nSize: 12 B\nhello world\n\nFile: single-line.txt\nSize: 11 B\nSingle Line\n") .stderr(""); } @@ -1522,7 +1522,7 @@ fn header_padding_rule() { .arg("single-line.txt") .assert() .stdout( - "File: test.txt + "\u{1b}]2;bat: test.txt, single-line.txt\x07File: test.txt hello world ──────────────────────────────────────────────────────────────────────────────── File: single-line.txt @@ -1542,7 +1542,7 @@ fn header_full_padding_rule() { .arg("single-line.txt") .assert() .stdout( - "File: test.txt + "\u{1b}]2;bat: test.txt, single-line.txt\x07File: test.txt Size: 12 B hello world ──────────────────────────────────────────────────────────────────────────────── @@ -1564,7 +1564,7 @@ fn grid_overrides_rule() { .arg("single-line.txt") .assert() .stdout( - "\ + "\u{1b}]2;bat: test.txt, single-line.txt\x07\ ──────────────────────────────────────────────────────────────────────────────── hello world ──────────────────────────────────────────────────────────────────────────────── @@ -1669,7 +1669,7 @@ fn show_all_mode() { .arg("--show-all") .arg("nonprintable.txt") .assert() - .stdout("hello·world␊\n├──┤␍␀␇␈␛") + .stdout("\u{1b}]2;bat: nonprintable.txt\x07hello·world␊\n├──┤␍␀␇␈␛") .stderr(""); } @@ -1683,7 +1683,7 @@ fn show_all_extends_tab_markers_to_next_tabstop() { .assert() .success() .stdout( - "├──┤1├─┤2├─┤3├─┤4␊ + "\u{1b}]2;bat: tabs.txt\x07├──┤1├─┤2├─┤3├─┤4␊ 1├─┤?␊ 22├┤?␊ 333↹?␊ @@ -1706,7 +1706,7 @@ fn show_all_extends_tab_markers_to_next_tabstop_width_8() { .assert() .success() .stdout( - "├──────┤1├─────┤2├─────┤3├─────┤4␊ + "\u{1b}]2;bat: tabs.txt\x07├──────┤1├─────┤2├─────┤3├─────┤4␊ 1├─────┤?␊ 22├────┤?␊ 333├───┤?␊ @@ -1726,7 +1726,7 @@ fn show_all_with_caret_notation() { .arg("--nonprintable-notation=caret") .arg("nonprintable.txt") .assert() - .stdout("hello·world^J\n├──┤^M^@^G^H^[") + .stdout("\u{1b}]2;bat: nonprintable.txt\x07hello·world^J\n├──┤^M^@^G^H^[") .stderr(""); bat() @@ -1734,7 +1734,7 @@ fn show_all_with_caret_notation() { .arg("--nonprintable-notation=caret") .arg("control_characters.txt") .assert() - .stdout("^@^A^B^C^D^E^F^G^H├─┤^J\n^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\\^]^^^_^?") + .stdout("\u{1b}]2;bat: control_characters.txt\x07^@^A^B^C^D^E^F^G^H├─┤^J\n^K^L^M^N^O^P^Q^R^S^T^U^V^W^X^Y^Z^[^\\^]^^^_^?") .stderr(""); } @@ -1745,7 +1745,7 @@ fn show_all_with_unicode() { .arg("--nonprintable-notation=unicode") .arg("control_characters.txt") .assert() - .stdout("␀␁␂␃␄␅␆␇␈├─┤␊\n␋␌␍␎␏␐␑␒␓␔␕␖␗␘␙␚␛␜␝␞␟␡") + .stdout("\u{1b}]2;bat: control_characters.txt\x07␀␁␂␃␄␅␆␇␈├─┤␊\n␋␌␍␎␏␐␑␒␓␔␕␖␗␘␙␚␛␜␝␞␟␡") .stderr(""); } @@ -1758,7 +1758,7 @@ fn no_paging_arg() { .arg("single-line.txt") .assert() .success() - .stdout("Single Line"); + .stdout("\u{1b}]2;bat: single-line.txt\x07Single Line"); } #[test] @@ -1770,7 +1770,7 @@ fn no_paging_short_arg() { .arg("single-line.txt") .assert() .success() - .stdout("Single Line"); + .stdout("\u{1b}]2;bat: single-line.txt\x07Single Line"); } #[test] @@ -1782,7 +1782,7 @@ fn no_pager_arg() { .arg("single-line.txt") .assert() .success() - .stdout("Single Line"); + .stdout("\u{1b}]2;bat: single-line.txt\x07Single Line"); } #[test] @@ -1795,7 +1795,7 @@ fn plain_mode_does_not_add_nonexisting_newline() { .arg("single-line.txt") .assert() .success() - .stdout("Single Line"); + .stdout("\u{1b}]2;bat: single-line.txt\x07Single Line"); } // Regression test for https://github.com/sharkdp/bat/issues/299 @@ -1813,7 +1813,7 @@ fn grid_for_file_without_newline() { .assert() .success() .stdout( - "\ + "\u{1b}]2;bat: single-line.txt\x07\ ───────┬──────────────────────────────────────────────────────────────────────── │ File: single-line.txt │ Size: 11 B @@ -1840,7 +1840,7 @@ fn ansi_highlight_underline() { .write_stdin("Ansi Underscore Test\nAnother Line") .assert() .success() - .stdout("\x1B[4mAnsi Underscore Test\n\x1B[24mAnother Line") + .stdout("\u{1b}]2;bat: STDIN\x07\x1B[4mAnsi Underscore Test\n\x1B[24mAnother Line") .stderr(""); } @@ -1859,7 +1859,7 @@ fn ansi_passthrough_emit() { .write_stdin("\x1B[33mColor\nColor \x1B[m\nPlain\n") .assert() .success() - .stdout("\x1B[33m\x1B[33mColor\n\x1B[33mColor \x1B[m\nPlain\n") + .stdout("\u{1b}]2;bat: STDIN\x07\x1B[33m\x1B[33mColor\n\x1B[33mColor \x1B[m\nPlain\n") .stderr(""); } } @@ -1874,7 +1874,7 @@ fn ignored_suffix_arg() { .arg("test.json~") .assert() .success() - .stdout("\u{1b}[38;5;231m{\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;208mtest\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;231m:\u{1b}[0m\u{1b}[38;5;231m \u{1b}[0m\u{1b}[38;5;186m\"\u{1b}[0m\u{1b}[38;5;186mvalue\u{1b}[0m\u{1b}[38;5;186m\"\u{1b}[0m\u{1b}[38;5;231m}\u{1b}[0m") + .stdout("\u{1b}]2;bat: test.json~\x07\u{1b}[38;5;231m{\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;208mtest\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;231m:\u{1b}[0m\u{1b}[38;5;231m \u{1b}[0m\u{1b}[38;5;186m\"\u{1b}[0m\u{1b}[38;5;186mvalue\u{1b}[0m\u{1b}[38;5;186m\"\u{1b}[0m\u{1b}[38;5;231m}\u{1b}[0m") .stderr(""); bat() @@ -1886,7 +1886,7 @@ fn ignored_suffix_arg() { .arg("test.json.suffix") .assert() .success() - .stdout("\u{1b}[38;5;231m{\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;208mtest\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;231m:\u{1b}[0m\u{1b}[38;5;231m \u{1b}[0m\u{1b}[38;5;186m\"\u{1b}[0m\u{1b}[38;5;186mvalue\u{1b}[0m\u{1b}[38;5;186m\"\u{1b}[0m\u{1b}[38;5;231m}\u{1b}[0m") + .stdout("\u{1b}]2;bat: test.json.suffix\x07\u{1b}[38;5;231m{\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;208mtest\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;231m:\u{1b}[0m\u{1b}[38;5;231m \u{1b}[0m\u{1b}[38;5;186m\"\u{1b}[0m\u{1b}[38;5;186mvalue\u{1b}[0m\u{1b}[38;5;186m\"\u{1b}[0m\u{1b}[38;5;231m}\u{1b}[0m") .stderr(""); bat() @@ -1897,16 +1897,16 @@ fn ignored_suffix_arg() { .arg("test.json.suffix") .assert() .success() - .stdout("\u{1b}[38;5;231m{\"test\": \"value\"}\u{1b}[0m") + .stdout("\u{1b}]2;bat: test.json.suffix\x07\u{1b}[38;5;231m{\"test\": \"value\"}\u{1b}[0m") .stderr(""); } fn wrapping_test(wrap_flag: &str, expect_wrap: bool) { let expected = match expect_wrap { true => - "abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcde\nfghigklmnopqrstuvxyz\n", + "\u{1b}]2;bat: long-single-line.txt\x07abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcde\nfghigklmnopqrstuvxyz\n", false => - "abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyz\n", + "\u{1b}]2;bat: long-single-line.txt\x07abcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyzabcdefghigklmnopqrstuvxyz\n", }; bat() @@ -1957,7 +1957,7 @@ fn theme_arg_overrides_env() { .write_stdin("Ansi Underscore Test\nAnother Line") .assert() .success() - .stdout("\x1B[4mAnsi Underscore Test\n\x1B[24mAnother Line") + .stdout("\u{1b}]2;bat: STDIN\x07\x1B[4mAnsi Underscore Test\n\x1B[24mAnother Line") .stderr(""); } @@ -1977,7 +1977,7 @@ fn theme_arg_overrides_env_withconfig() { .write_stdin("Ansi Underscore Test\nAnother Line") .assert() .success() - .stdout("\x1B[4mAnsi Underscore Test\n\x1B[24mAnother Line") + .stdout("\u{1b}]2;bat: STDIN\x07\x1B[4mAnsi Underscore Test\n\x1B[24mAnother Line") .stderr(""); } @@ -1996,13 +1996,13 @@ fn theme_env_overrides_config() { .write_stdin("Ansi Underscore Test\nAnother Line") .assert() .success() - .stdout("\x1B[4mAnsi Underscore Test\n\x1B[24mAnother Line") + .stdout("\u{1b}]2;bat: STDIN\x07\x1B[4mAnsi Underscore Test\n\x1B[24mAnother Line") .stderr(""); } #[test] fn highlighting_is_skipped_on_long_lines() { - let expected = "\u{1b}[38;5;231m{\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;208mapi\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;231m:\u{1b}[0m\n".to_owned() + + let expected = "\u{1b}]2;bat: longline.json\x07\u{1b}[38;5;231m{\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;208mapi\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;231m:\u{1b}[0m\n".to_owned() + "\u{1b}" + r#"[38;5;231m {"ANGLE_instanced_arrays":{"__compat":{"mdn_url":"https://developer.mozilla.org/docs/Web/API/ANGLE_instanced_arrays","spec_url":"https://www.khronos.org/registry/webgl/extensions/ANGLE_instanced_arrays/","support":{"chrome":{"version_added":"32"},"chrome_android":{"version_added":"32"},"edge":{"version_added":"12"},"firefox":{"version_added":"47"},"firefox_android":{"version_added":true},"ie":{"version_added":"11"},"opera":{"version_added":"19"},"opera_android":{"version_added":"19"},"safari":{"version_added":"8"},"safari_ios":{"version_added":"8"},"samsunginternet_android":{"version_added":"2.0"},"webview_android":{"version_added":"4.4"}},"status":{"experimental":false,"standard_track":true,"deprecated":false}},"drawArraysInstancedANGLE":{"__compat":{"mdn_url":"https://developer.mozilla.org/docs/Web/API/ANGLE_instanced_arrays/drawArraysInstancedANGLE","spec_url":"https://www.khronos.org/registry/webgl/extensions/ANGLE_instanced_arrays/","support":{"chrome":{"version_added":"32"},"chrome_android":{"version_added":"32"},"edge":{"version_added":"12"},"firefox":{"version_added":"47"},"firefox_android":{"version_added":true},"ie":{"version_added":"11"},"opera":{"version_added":"19"},"opera_android":{"version_added":"19"},"safari":{"version_added":"8"},"safari_ios":{"version_added":"8"},"samsunginternet_android":{"version_added":"2.0"},"webview_android":{"version_added":"4.4"}},"status":{"experimental":false,"standard_track":true,"deprecated":false}}},"drawElementsInstancedANGLE":{"__compat":{"mdn_url":"https://developer.mozilla.org/docs/Web/API/ANGLE_instanced_arrays/drawElementsInstancedANGLE","spec_url":"https://www.khronos.org/registry/webgl/extensions/ANGLE_instanced_arrays/","support":{"chrome":{"version_added":"32"},"chrome_android":{"version_added":"32"},"edge":{"version_added":"12"},"firefox":{"version_added":"47"},"firefox_android":{"version_added":true},"ie":{"version_added":"11"},"opera":{"version_added":"19"},"opera_android":{"version_added":"19"},"safari":{"version_added":"8"},"safari_ios":{"version_added":"8"},"samsunginternet_android":{"version_added":"2.0"},"webview_android":{"version_added":"4.4"}},"status":{"experimental":false,"standard_track":true,"deprecated":false}}},"vertexAttribDivisorANGLE":{"__compat":{"mdn_url":"https://developer.mozilla.org/docs/Web/API/ANGLE_instanced_arrays/vertexAttribDivisorANGLE","spec_url":"https://www.khronos.org/registry/webgl/extensions/ANGLE_instanced_arrays/","support":{"chrome":{"version_added":"32"},"chrome_android":{"version_added":"32"},"edge":{"version_added":"12"},"firefox":{"version_added":"47"},"firefox_android":{"version_added":true},"ie":{"version_added":"11"},"opera":{"version_added":"19"},"opera_android":{"version_added":"19"},"safari":{"version_added":"8"},"safari_ios":{"version_added":"8"},"samsunginternet_android":{"version_added":"2.0"},"webview_android":{"version_added":"4.4"}},"status":{"experimental":false,"standard_track":true,"deprecated":false}}}},"AbortController":{"__compat":{"mdn_url":"https://developer.mozilla.org/docs/Web/API/AbortController","spec_url":"https://dom.spec.whatwg.org/#interface-abortcontroller","support":{"chrome":{"version_added":"66"},"chrome_android":{"version_added":"66"},"edge":{"version_added":"16"},"firefox":{"version_added":"57"},"firefox_android":{"version_added":"57"},"ie":{"version_added":false},"nodejs":{"version_added":"15.0.0"},"opera":{"version_added":"53"},"opera_android":{"version_added":"47"},"safari":[{"version_added":"12.1"},{"version_added":"11.1","partial_implementation":true,"notes":"Even though window.AbortController is defined, it doesn't really abort fetch requests. See bug 174980."}],"safari_ios":[{"version_added":"12.2"},{"version_added":"11.3","partial_implementation":true,"notes":"Even though window.AbortController is defined, it doesn't really abort fetch requests. See bug 174980."}],"samsunginternet_android":{"version_added":"9.0"},"webview_android":{"version_added":"66"}},"status":{"experimental":true,"standard_track":true,"deprecated":false}},"AbortController":{"__compat":{"mdn_url":"https://developer.mozilla.org/docs/Web/API/AbortController/AbortController","spec_url":"https://dom.spec.whatwg.org/#ref-for-dom-abortcontroller-abortcontroller①","description":"AbortController() constructor","support":{"chrome":{"version_added":"66"},"chrome_android":{"version_added":"66"},"edge":{"version_added":"16"},"firefox":{"version_added":"57"},"firefox_android":{"version_added":"57"},"ie":{"version_added":false},"nodejs":{"version_added":"15.0.0"},"opera":{"version_added":"53"},"opera_android":{"version_added":"47"},"safari":[{"version_added":"12.1"},{"version_added":"11.1","partial_implementation":true,"notes":"Even though window.AbortController is defined, it doesn't really abort fetch requests. See bug 174980."}],"safari_ios":[{"version_added":"12.2"},{"version_added":"11.3","partial_implementation":true,"notes":"Even though window.AbortController is defined, it doesn't really abort fetch requests. See bug 174980."}],"samsunginternet_android":{"version_added":"9.0"},"webview_android":{"version_added":"66"}},"status":{"experimental":true,"standard_track":true,"deprecated":false}}},"abort":{"__compat":{"mdn_url":"https://developer.mozilla.org/docs/Web/API/AbortController/abort","spec_url":"https://dom.spec.whatwg.org/#ref-for-dom-abortcontroller-abortcontroller①","support":{"chrome":{"version_added":"66"},"chrome_android":{"version_added":"66"},"edge":{"version_added":"16"},"firefox":{"version_added":"57"},"firefox_android":{"version_added":"57"},"ie":{"version_added":false},"nodejs":{"version_added":"15.0.0"},"opera":{"version_added":"53"},"opera_android":{"version_added":"47"},"safari":[{"version_added":"12.1"},{"version_added":"11.1","partial_implementation":true,"notes":"Even though window.AbortController is defined, it doesn't really abort fetch requests. See bug 174980."}],"safari_ios":[{"version_added":"12.2"},{"version_added":"11.3","partial_implementation":true,"notes":"Even though window.AbortController is defined, it doesn't really abort fetch requests. See bug 174980."}],"samsunginternet_android":{"version_added":"9.0"},"webview_android":{"version_added":"66"}},"status":{"experimental":true,"standard_track":true,"deprecated":false}}},"signal":{"__compat":{"mdn_url":"https://developer.mozilla.org/docs/Web/API/AbortController/signal","spec_url":"https://dom.spec.whatwg.org/#ref-for-dom-abortcontroller-signal②","support":{"chrome":{"version_added":"66"},"chrome_android":{"version_added":"66"},"edge":{"version_added":"16"},"firefox":{"version_added":"57"},"firefox_android":{"version_added":"57"},"ie":{"version_added":false},"nodejs":{"version_added":"15.0.0"},"opera":{"version_added":"53"},"opera_android":{"version_added":"47"},"safari":[{"version_added":"12.1"},{"version_added":"11.1","partial_implementation":true,"notes":"Even though window.AbortController is defined, it doesn't really abort fetch requests. See bug 174980."}],"safari_ios":[{"version_added":"12.2"},{"version_added":"11.3","partial_implementation":true,"notes":"Even though window.AbortController is defined, it doesn't really abort fetch requests. See bug 174980."}],"samsunginternet_android":{"version_added":"9.0"},"webview_android":{"version_added":"66"}},"status":{"experimental":true,"standard_track":true,"deprecated":false}}}},"AbortPaymentEvent":{"__compat":{"mdn_url":"https://developer.mozilla.org/docs/Web/API/AbortPaymentEvent","support":{"chrome":{"version_added":"70"},"chrome_android":{"version_added":"70"},"edge":{"version_added":"79"},"firefox":{"version_added":false},"firefox_android":{"version_added":false},"ie":{"version_added":false},"opera":{"version_added":"57"},"opera_android":{"version_added":"49"},"safari":{"version_added":false},"safari_ios":{"version_added":false},"samsunginternet_android":{"version_added":"10.0"},"webview_android":{"version_added":false}},"status":{"experimental":true,"standard_track":false,"deprecated":false}},"AbortPaymentEvent":{"__compat":{"description":"AbortPaymentEvent() constructor","mdn_url":"https://developer.mozilla.org/docs/Web/API/AbortPaymentEvent/AbortPaymentEvent","support":{"chrome":{"version_added":"70"},"chrome_android":{"version_added":"70"},"edge":{"version_added":"79"},"firefox":{"version_added":false},"firefox_android":{"version_added":false},"ie":{"version_added":false},"opera":{"version_added":"57"},"opera_android":{"version_added":"49"},"safari":{"version_added":false},"safari_ios":{"version_added":false},"samsunginternet_android":{"version_added":"10.0"},"webview_android":{"version_added":false}},"status":{"experimental":true,"standard_track":false,"deprecated":false}}},"respondWith":{"__compat":{"mdn_url":"https://developer.mozilla.org/docs/Web/API/AbortPaymentEvent/respondWith","support":{"chrome":{"version_added":"70"},"chrome_android":{"version_added":"70"},"edge":{"version_added":"79"},"firefox":{"version_added":false},"firefox_android":{"version_added":false},"ie":{"version_added":false},"opera":{"version_added":"57"},"opera_android":{"version_added":"49"},"safari":{"version_added":false},"safari_ios":{"version_added":false},"samsunginternet_android":{"version_added":"10.0"},"webview_android":{"version_added":false}},"status":{"experimental":true,"standard_track":false,"deprecated":false}}}},"AbortSignal":{"__compat":{"mdn_url":"https://developer.mozilla.org/docs/Web/API/AbortSignal","spec_url":"https://dom.spec.whatwg.org/#interface-AbortSignal","support":{"chrome":{"version_added":"66"},"chrome_android":{"version_added":"66"},"edge":{"version_added":"16"},"firefox":{"version_added":"57"},"firefox_android":{"version_added":"57"},"ie":{"version_added":false},"nodejs":{"version_added":"15.0.0"},"opera":{"version_added":"53"},"opera_android":{"version_added":"47"},"safari":{"version_added":"11.1"},"safari_ios":{"version_added":"11.3"},"samsunginternet_android":{"version_added":"9.0"},"webview_android":{"version_added":"66"}},"status":{"experimental":false,"standard_track":true,"deprecated":false}},"abort":{"__compat":{"mdn_url":"https://developer.mozilla.org/docs/Web/API/AbortSignal/abort","spec_url":"https://dom.spec.whatwg.org/#ref-for-dom-abortsignal-abort①","support":{"chrome":{"version_added":false},"chrome_android":{"version_added":false},"edge":{"version_added":false},"firefox":{"version_added":"88"},"firefox_android":{"version_added":"88"},"ie":{"version_added":false},"nodejs":{"version_added":false},"opera":{"version_added":false},"opera_android":{"version_added":false},"safari":{"version_added":false},"safari_ios":{"version_added":false},"samsunginternet_android":{"version_added":false},"webview_android":{"version_added":false}},"status":{"experimental":false,"standard_track":true,"deprecated":false}}},"abort_event":{"__compat":{"description":"abort event","mdn_url":"https://developer.mozilla.org/docs/Web/API/AbortSignal/abort_event","spec_url":"https://dom.spec.whatwg.org/#eventdef-abortsignal-abort","support":{"chrome":{"version_added":"66"},"chrome_android":{"version_added":"66"},"edge":{"version_added":"16"},"firefox":{"version_added":"57"},"firefox_android":{"version_added":"57"},"ie":{"version_added":false},"nodejs":{"version_added":"15.0.0"},"opera":{"version_added":"53"},"opera_android":{"version_added":"47"},"safari":{"version_added":"11.1"},"safari_ios":{"version_added":"11.3"},"samsunginternet_android":{"version_added":"9.0"},"webview_android":{"version_added":"66"}},"status":{"experimental":false,"standard_track":true,"deprecated":false}}},"aborted":{"__compat":{"mdn_url":"https://developer.mozilla.org/docs/Web/API/AbortSignal/aborted","spec_url":"https://dom.spec.whatwg.org/#ref-for-dom-abortsignal-aborted①","support":{"chrome":{"version_added":"66"},"chrome_android":{"version_added":"66"},"edge":{"version_added":"16"},"firefox":{"version_added":"57"},"firefox_android":{"version_added":"57"},"ie":{"version_added":false},"nodejs":{"version_added":"15.0.0"},"opera":{"version_added":"53"},"opera_android":{"version_added":"47"},"safari":{"version_added":"11.1"},"safari_ios":{"version_added":"11.3"},"samsunginternet_android":{"version_added":"9.0"},"webview_android":{"version_added":"66"}},"status":{"experimental":false,"standard_track":true,"deprecated":false}}},"onabort":{"__compat":{"mdn_url":"https://developer.mozilla.org/docs/Web/API/AbortSignal/onabort","spec_url":"https://dom.spec.whatwg.org/#abortsignal-onabort","support":{"chrome":{"version_added":"66"},"chrome_android":{"version_added":"66"},"edge":{"version_added":"16"},"firefox":{"version_added":"57"},"firefox_android":{"version_added":"57"},"ie":{"version_added":false},"nodejs":{"version_added":"15.0.0"},"opera":{"version_added":"53"},"opera_android":{"version_added":"47"},"safari":{"version_added":"11.1"},"safari_ios":{"version_added":"11.3"},"samsunginternet_android":{"version_added":"9.0"},"webview_android":{"version_added":"66"}},"status":{"experimental":false,"standard_track":true,"deprecated":false}}}},"AbsoluteOrientationSensor":{"__compat":{"mdn_url":"https://developer.mozilla.org/docs/Web/API/AbsoluteOrientationSensor","spec_url":"https://w3c.github.io/orientation-sensor/#absoluteorientationsensor-interface","support":{"chrome":{"version_added":"67"},"chrome_android":{"version_added":"67"},"edge":{"version_added":"79"},"firefox":{"version_added":false},"firefox_android":{"version_added":false},"ie":{"version_added":false},"opera":{"version_added":"54"},"opera_android":{"version_added":"48"},"safari":{"version_added":false},"safari_ios":{"version_added":false},"samsunginternet_android":{"version_added":"9.0"},"webview_android":{"version_added":"67"}},"status":{"experimental":false,"standard_track":true,"deprecated":false}},"AbsoluteOrientationSensor":{"__compat":{"mdn_url":"https://developer.mozilla.org/docs/Web/API/AbsoluteOrientationSensor/AbsoluteOrientationSensor","spec_url":"https://w3c.github.io/orientation-sensor/#dom-absoluteorientationsensor-absoluteorientationsensor","description":"AbsoluteOrientationSensor() constructor","support":{"chrome":{"version_added":"67"},"chrome_android":{"version_added":"67"},"edge":{"version_added":"79"},"firefox":{"version_added":false},"firefox_android":{"version_added":false},"ie":{"version_added":false},"opera":{"version_added":"54"},"opera_android":{"version_added":"48"},"safari":{"version_added":false},"safari_ios":{"version_added":false},"samsunginternet_android":{"version_added":"9.0"},"webview_android":{"version_added":"67"}},"status":{"experimental":false,"standard_track":true,"deprecated":false}}}},"AbstractRange":{"__compat":{"mdn_url":"https://developer.mozilla.org/docs/Web/API/AbstractRange","spec_url":"https://dom.spec.whatwg.org/#interface-abstractrange","support":{"chrome":{"version_added":"90"},"chrome_android":{"version_added":"90"},"edge":[{"version_added":"90"},{"version_added":"18","version_removed":"79"}],"firefox":{"version_added":"69"},"firefox_android":{"version_added":false},"ie":{"version_added":false},"opera":{"version_added":false},"opera_android":{"version_added":false},"safari":{"version_added":"14.1"},"safari_ios":{"version_added":"14.5"},"samsunginternet_android":{"version_added":false},"webview_android":{"version_added":"90"}},"status":{"experimental":false,"standard_track":true,"deprecated":false}},"collapsed":{"__compat":{"mdn_url":"https://developer.mozilla.org/docs/Web/API/AbstractRange/collapsed","spec_url":"https://dom.spec.whatwg.org/#ref-for-dom-range-collapsed①","support":{"chrome":{"version_added":"90"},"chrome_android":{"version_added":"90"},"edge":[{"version_added":"90"},{"version_added":"18","version_removed":"79"}],"firefox":{"version_added":"69"},"firefox_android":{"version_added":false},"ie":{"version_added":false},"opera":{"version_added":false},"opera_android":"# + "\u{1b}[0m\n\u{1b}[38;5;231m \u{1b}[0m\u{1b}[38;5;231m{\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;208mversion_added\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;231m:\u{1b}[0m\u{1b}[38;5;141mfalse\u{1b}[0m\u{1b}[38;5;231m}\u{1b}[0m\n"; @@ -2036,7 +2036,7 @@ fn all_global_git_config_locations_syntax_mapping_work() { .arg("git/.config/git/config") .assert() .success() - .stdout(expected) + .stdout("\u{1b}]2;bat: git/.config/git/config\x07".to_owned() + expected) .stderr(""); bat() @@ -2048,7 +2048,7 @@ fn all_global_git_config_locations_syntax_mapping_work() { .arg("git/.config/git/config") .assert() .success() - .stdout(expected) + .stdout("\u{1b}]2;bat: git/.config/git/config\x07".to_owned() + expected) .stderr(""); bat() @@ -2060,7 +2060,7 @@ fn all_global_git_config_locations_syntax_mapping_work() { .arg("git/.gitconfig") .assert() .success() - .stdout(expected) + .stdout("\u{1b}]2;bat: git/.gitconfig\x07".to_owned() + expected) .stderr(""); } @@ -2076,7 +2076,7 @@ fn map_syntax_and_ignored_suffix_work_together() { .arg("test.demo.suffix") .assert() .success() - .stdout("\u{1b}[38;5;231m{\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;208mtest\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;231m:\u{1b}[0m\u{1b}[38;5;231m \u{1b}[0m\u{1b}[38;5;186m\"\u{1b}[0m\u{1b}[38;5;186mvalue\u{1b}[0m\u{1b}[38;5;186m\"\u{1b}[0m\u{1b}[38;5;231m}\u{1b}[0m") + .stdout("\u{1b}]2;bat: test.demo.suffix\x07\u{1b}[38;5;231m{\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;208mtest\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;231m:\u{1b}[0m\u{1b}[38;5;231m \u{1b}[0m\u{1b}[38;5;186m\"\u{1b}[0m\u{1b}[38;5;186mvalue\u{1b}[0m\u{1b}[38;5;186m\"\u{1b}[0m\u{1b}[38;5;231m}\u{1b}[0m") .stderr(""); bat() @@ -2090,7 +2090,7 @@ fn map_syntax_and_ignored_suffix_work_together() { .arg("test.demo.foo.suffix") .assert() .success() - .stdout("\u{1b}[38;5;231m{\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;208mtest\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;231m:\u{1b}[0m\u{1b}[38;5;231m \u{1b}[0m\u{1b}[38;5;186m\"\u{1b}[0m\u{1b}[38;5;186mvalue\u{1b}[0m\u{1b}[38;5;186m\"\u{1b}[0m\u{1b}[38;5;231m}\u{1b}[0m") + .stdout("\u{1b}]2;bat: test.demo.foo.suffix\x07\u{1b}[38;5;231m{\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;208mtest\u{1b}[0m\u{1b}[38;5;208m\"\u{1b}[0m\u{1b}[38;5;231m:\u{1b}[0m\u{1b}[38;5;231m \u{1b}[0m\u{1b}[38;5;186m\"\u{1b}[0m\u{1b}[38;5;186mvalue\u{1b}[0m\u{1b}[38;5;186m\"\u{1b}[0m\u{1b}[38;5;231m}\u{1b}[0m") .stderr(""); } -- cgit v1.2.3 From 12b74dfb4ec0575664482c714e55e28d3493415d Mon Sep 17 00:00:00 2001 From: Oliver looney Date: Mon, 18 Dec 2023 16:59:12 +0000 Subject: terminal title is only set when pager is being used --- src/bin/bat/main.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/bin/bat/main.rs b/src/bin/bat/main.rs index fb6abd11..97ea48f8 100644 --- a/src/bin/bat/main.rs +++ b/src/bin/bat/main.rs @@ -242,7 +242,9 @@ fn set_terminal_title_to_inputs_names(inputs: &Vec) { fn run_controller(inputs: Vec, config: &Config, cache_dir: &Path) -> Result { let assets = assets_from_cache_or_binary(config.use_custom_assets, cache_dir)?; let controller = Controller::new(config, &assets); - set_terminal_title_to_inputs_names(&inputs); + if config.paging_mode != PagingMode::Never { + set_terminal_title_to_inputs_names(&inputs); + } controller.run(inputs, None) } -- cgit v1.2.3 From 907af9e35f6c8e117533161c1a6a62d45dea6f38 Mon Sep 17 00:00:00 2001 From: Oliver looney Date: Mon, 18 Dec 2023 17:27:51 +0000 Subject: updated tests since terminal title is set conditionally --- tests/integration_tests.rs | 166 ++++++++++++++++++++++----------------------- 1 file changed, 83 insertions(+), 83 deletions(-) diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 96540cc6..43a75d8b 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -48,7 +48,7 @@ fn basic() { .arg("test.txt") .assert() .success() - .stdout("\u{1b}]2;bat: test.txt\x07hello world\n") + .stdout("hello world\n") .stderr(""); } @@ -58,7 +58,7 @@ fn stdin() { .write_stdin("foo\nbar\n") .assert() .success() - .stdout("\u{1b}]2;bat: STDIN\x07foo\nbar\n"); + .stdout("foo\nbar\n"); } #[test] @@ -68,7 +68,7 @@ fn concatenate() { .arg("test.txt") .assert() .success() - .stdout("\u{1b}]2;bat: test.txt, test.txt\x07hello world\nhello world\n"); + .stdout("hello world\nhello world\n"); } #[test] @@ -80,7 +80,7 @@ fn concatenate_stdin() { .write_stdin("stdin\n") .assert() .success() - .stdout("\u{1b}]2;bat: test.txt, STDIN, test.txt\x07hello world\nstdin\nhello world\n"); + .stdout("hello world\nstdin\nhello world\n"); } #[test] @@ -90,7 +90,7 @@ fn concatenate_empty_first() { .arg("test.txt") .assert() .success() - .stdout("\u{1b}]2;bat: empty.txt, test.txt\x07hello world\n"); + .stdout("hello world\n"); } #[test] @@ -100,7 +100,7 @@ fn concatenate_empty_last() { .arg("empty.txt") .assert() .success() - .stdout("\u{1b}]2;bat: test.txt, empty.txt\x07hello world\n"); + .stdout("hello world\n"); } #[test] @@ -110,7 +110,7 @@ fn concatenate_empty_both() { .arg("empty.txt") .assert() .success() - .stdout("\u{1b}]2;bat: empty.txt, empty.txt\x07"); + .stdout(""); } #[test] @@ -121,7 +121,7 @@ fn concatenate_empty_between() { .arg("test.txt") .assert() .success() - .stdout("\u{1b}]2;bat: test.txt, empty.txt, test.txt\x07hello world\nhello world\n"); + .stdout("hello world\nhello world\n"); } #[test] @@ -132,7 +132,7 @@ fn concatenate_empty_first_and_last() { .arg("empty.txt") .assert() .success() - .stdout("\u{1b}]2;bat: empty.txt, test.txt, empty.txt\x07hello world\n"); + .stdout("hello world\n"); } #[test] @@ -142,7 +142,7 @@ fn concatenate_single_line() { .arg("single-line.txt") .assert() .success() - .stdout("\u{1b}]2;bat: single-line.txt, single-line.txt\x07Single LineSingle Line"); + .stdout("Single LineSingle Line"); } #[test] @@ -153,7 +153,7 @@ fn concatenate_single_line_empty() { .arg("single-line.txt") .assert() .success() - .stdout("\u{1b}]2;bat: single-line.txt, empty.txt, single-line.txt\x07Single LineSingle Line"); + .stdout("Single LineSingle Line"); } #[test] @@ -164,7 +164,7 @@ fn line_numbers() { .arg("--decorations=always") .assert() .success() - .stdout("\u{1b}]2;bat: multiline.txt\x07 1 line 1\n 2 line 2\n 3 line 3\n 4 line 4\n"); + .stdout(" 1 line 1\n 2 line 2\n 3 line 3\n 4 line 4\n"); } #[test] @@ -174,7 +174,7 @@ fn line_range_2_3() { .arg("--line-range=2:3") .assert() .success() - .stdout("\u{1b}]2;bat: multiline.txt\x07line 2\nline 3\n"); + .stdout("line 2\nline 3\n"); } #[test] @@ -184,7 +184,7 @@ fn line_range_first_two() { .arg("--line-range=:2") .assert() .success() - .stdout("\u{1b}]2;bat: multiline.txt\x07line 1\nline 2\n"); + .stdout("line 1\nline 2\n"); } #[test] @@ -194,7 +194,7 @@ fn line_range_last_3() { .arg("--line-range=2:") .assert() .success() - .stdout("\u{1b}]2;bat: multiline.txt\x07line 2\nline 3\nline 4\n"); + .stdout("line 2\nline 3\nline 4\n"); } #[test] @@ -205,7 +205,7 @@ fn line_range_multiple() { .arg("--line-range=4:4") .assert() .success() - .stdout("\u{1b}]2;bat: multiline.txt\x07line 1\nline 2\nline 4\n"); + .stdout("line 1\nline 2\nline 4\n"); } #[test] @@ -354,7 +354,7 @@ fn tabs_numbers() { .assert() .success() .stdout( - "\u{1b}]2;bat: tabs.txt\x07 1 1 2 3 4 + " 1 1 2 3 4 2 1 ? 3 22 ? 4 333 ? @@ -377,7 +377,7 @@ fn tabs_passthrough_wrapped() { .assert() .success() .stdout( - "\u{1b}]2;bat: tabs.txt\x07 1 2 3 4 + " 1 2 3 4 1 ? 22 ? 333 ? @@ -400,7 +400,7 @@ fn tabs_4_wrapped() { .assert() .success() .stdout( - "\u{1b}]2;bat: tabs.txt\x07 1 2 3 4 + " 1 2 3 4 1 ? 22 ? 333 ? @@ -423,7 +423,7 @@ fn tabs_8_wrapped() { .assert() .success() .stdout( - "\u{1b}]2;bat: tabs.txt\x07 1 2 3 4 + " 1 2 3 4 1 ? 22 ? 333 ? @@ -446,7 +446,7 @@ fn tabs_passthrough() { .assert() .success() .stdout( - "\u{1b}]2;bat: tabs.txt\x07 1 2 3 4 + " 1 2 3 4 1 ? 22 ? 333 ? @@ -469,7 +469,7 @@ fn tabs_4() { .assert() .success() .stdout( - "\u{1b}]2;bat: tabs.txt\x07 1 2 3 4 + " 1 2 3 4 1 ? 22 ? 333 ? @@ -492,7 +492,7 @@ fn tabs_8() { .assert() .success() .stdout( - "\u{1b}]2;bat: tabs.txt\x07 1 2 3 4 + " 1 2 3 4 1 ? 22 ? 333 ? @@ -516,7 +516,7 @@ fn tabs_4_env_overrides_config() { .assert() .success() .stdout( - "\u{1b}]2;bat: tabs.txt\x07 1 2 3 4 + " 1 2 3 4 1 ? 22 ? 333 ? @@ -541,7 +541,7 @@ fn tabs_4_arg_overrides_env() { .assert() .success() .stdout( - "\u{1b}]2;bat: tabs.txt\x07 1 2 3 4 + " 1 2 3 4 1 ? 22 ? 333 ? @@ -565,7 +565,7 @@ fn tabs_4_arg_overrides_env_noconfig() { .assert() .success() .stdout( - "\u{1b}]2;bat: tabs.txt\x07 1 2 3 4 + " 1 2 3 4 1 ? 22 ? 333 ? @@ -594,7 +594,7 @@ fn do_not_exit_directory() { .arg("sub_directory") .arg("test.txt") .assert() - .stdout("\u{1b}]2;bat: sub_directory, test.txt\x07hello world\n") + .stdout("hello world\n") .failure(); } @@ -845,7 +845,7 @@ fn alias_pager_disable() { .arg("test.txt") .assert() .success() - .stdout(predicate::eq("\u{1b}]2;bat: test.txt\x07hello world\n").normalize()); + .stdout(predicate::eq("hello world\n").normalize()); } #[test] @@ -872,7 +872,7 @@ fn disable_pager_if_disable_paging_flag_comes_after_paging() { .arg("test.txt") .assert() .success() - .stdout(predicate::eq("\u{1b}]2;bat: test.txt\x07hello world\n").normalize()); + .stdout(predicate::eq("hello world\n").normalize()); } #[test] @@ -884,7 +884,7 @@ fn disable_pager_if_pp_flag_comes_after_paging() { .arg("test.txt") .assert() .success() - .stdout(predicate::eq("\u{1b}]2;bat: test.txt\x07hello world\n").normalize()); + .stdout(predicate::eq("hello world\n").normalize()); } #[test] @@ -1111,7 +1111,7 @@ fn utf16() { .arg("test_UTF-16LE.txt") .assert() .success() - .stdout("\u{1b}]2;bat: test_UTF-16LE.txt\x07hello world\n"); + .stdout("hello world\n"); } // Regression test for https://github.com/sharkdp/bat/issues/1922 @@ -1124,7 +1124,7 @@ fn bom_not_stripped_in_loop_through_mode() { .arg("test_BOM.txt") .assert() .success() - .stdout("\u{1b}]2;bat: test_BOM.txt\x07\u{feff}hello world\n"); + .stdout("\u{feff}hello world\n"); } // Regression test for https://github.com/sharkdp/bat/issues/1922 @@ -1153,7 +1153,7 @@ fn bom_stripped_when_no_color_and_not_loop_through() { .assert() .success() .stdout( - "\u{1b}]2;bat: test_BOM.txt\x07\ + "\ ─────┬────────────────────────────────────────────────────────────────────────── │ File: test_BOM.txt ─────┼────────────────────────────────────────────────────────────────────────── @@ -1169,7 +1169,7 @@ fn can_print_file_named_cache() { .arg("cache") .assert() .success() - .stdout("\u{1b}]2;bat: cache\x07test\n") + .stdout("test\n") .stderr(""); } @@ -1180,7 +1180,7 @@ fn can_print_file_named_cache_with_additional_argument() { .arg("test.txt") .assert() .success() - .stdout("\u{1b}]2;bat