1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-18 13:55:23 -05:00

Rewrite err_println to eprintln introduced in Rust 1.19 (#799)

This commit is contained in:
Roel 2017-10-22 17:42:40 +02:00 committed by Joe Wilm
parent 8af4a4b55b
commit a1174797b4
5 changed files with 7 additions and 28 deletions

View file

@ -41,10 +41,9 @@ env_logger = "0.4"
x11-dl = "2" x11-dl = "2"
[features] [features]
default = ["err-println"] default = []
# Enabling this feature makes shaders automatically reload when changed # Enabling this feature makes shaders automatically reload when changed
live-shader-reload = [] live-shader-reload = []
err-println = []
nightly = [] nightly = []
bench = [] bench = []

View file

@ -370,7 +370,7 @@ impl<'a> de::Deserialize<'a> for ModsWrapper {
"Shift" => res.shift = true, "Shift" => res.shift = true,
"Alt" | "Option" => res.alt = true, "Alt" | "Option" => res.alt = true,
"Control" => res.ctrl = true, "Control" => res.ctrl = true,
_ => err_println!("unknown modifier {:?}", modifier), _ => eprintln!("unknown modifier {:?}", modifier),
} }
} }
@ -467,7 +467,7 @@ impl<'a> de::Deserialize<'a> for ModeWrapper {
"~AppCursor" => res.not_mode |= mode::APP_CURSOR, "~AppCursor" => res.not_mode |= mode::APP_CURSOR,
"AppKeypad" => res.mode |= mode::APP_KEYPAD, "AppKeypad" => res.mode |= mode::APP_KEYPAD,
"~AppKeypad" => res.not_mode |= mode::APP_KEYPAD, "~AppKeypad" => res.not_mode |= mode::APP_KEYPAD,
_ => err_println!("unknown omde {:?}", modifier), _ => eprintln!("unknown omde {:?}", modifier),
} }
} }
@ -1476,7 +1476,7 @@ impl Monitor {
let _ = config_tx.send(config); let _ = config_tx.send(config);
handler.on_config_reload(); handler.on_config_reload();
}, },
Err(err) => err_println!("Ignoring invalid config: {}", err), Err(err) => eprintln!("Ignoring invalid config: {}", err),
} }
} }
} }

View file

@ -187,7 +187,7 @@ impl Action {
.and_then(|clipboard| clipboard.load_primary() ) .and_then(|clipboard| clipboard.load_primary() )
.map(|contents| { self.paste(ctx, contents) }) .map(|contents| { self.paste(ctx, contents) })
.unwrap_or_else(|err| { .unwrap_or_else(|err| {
err_println!("Error loading data from clipboard. {}", Red(err)); eprintln!("Error loading data from clipboard. {}", Red(err));
}); });
}, },
Action::PasteSelection => { Action::PasteSelection => {

View file

@ -15,31 +15,11 @@
#[macro_export] #[macro_export]
macro_rules! die { macro_rules! die {
($($arg:tt)*) => {{ ($($arg:tt)*) => {{
err_println!($($arg)*); eprintln!($($arg)*);
::std::process::exit(1); ::std::process::exit(1);
}} }}
} }
#[macro_export]
macro_rules! err_println {
($($arg:tt)*) => {{
if cfg!(feature = "err-println") {
use std::io::Write;
(writeln!(&mut ::std::io::stderr(), $($arg)*)).expect("stderr");
}
}}
}
#[macro_export]
macro_rules! err_print {
($($arg:tt)*) => {{
if cfg!(feature = "err-println") {
use std::io::Write;
(write!(&mut ::std::io::stderr(), $($arg)*)).expect("stderr");
}
}}
}
#[macro_export] #[macro_export]
macro_rules! maybe { macro_rules! maybe {
($option:expr) => { ($option:expr) => {

View file

@ -68,7 +68,7 @@ fn load_config(options: &cli::Options) -> Config {
die!("Config file not found at: {}", config_path.display()); die!("Config file not found at: {}", config_path.display());
}, },
config::Error::Empty => { config::Error::Empty => {
err_println!("Empty config; Loading defaults"); eprintln!("Empty config; Loading defaults");
Config::default() Config::default()
}, },
_ => die!("{}", err), _ => die!("{}", err),