2019-05-10 11:36:16 +00:00
|
|
|
// Copyright 2016 Joe Wilm, The Alacritty Project Contributors
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2017-01-15 01:53:48 +00:00
|
|
|
use std::borrow::Cow;
|
2019-03-30 16:48:36 +00:00
|
|
|
use std::collections::HashMap;
|
2019-07-06 19:34:56 +00:00
|
|
|
use std::fmt::Display;
|
2019-07-07 14:51:11 +00:00
|
|
|
use std::path::PathBuf;
|
2017-07-20 17:50:50 +00:00
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
use serde::{Deserialize, Deserializer};
|
2019-07-06 19:34:56 +00:00
|
|
|
use serde_yaml::Value;
|
2017-02-24 16:23:07 +00:00
|
|
|
|
2019-01-17 09:17:26 +00:00
|
|
|
mod bindings;
|
2019-05-10 11:36:16 +00:00
|
|
|
mod colors;
|
|
|
|
mod debug;
|
|
|
|
mod font;
|
|
|
|
mod monitor;
|
|
|
|
mod mouse;
|
|
|
|
mod scrolling;
|
|
|
|
#[cfg(test)]
|
|
|
|
mod test;
|
|
|
|
mod visual_bell;
|
|
|
|
mod window;
|
2018-09-18 15:54:40 +00:00
|
|
|
|
2019-07-10 21:24:04 +00:00
|
|
|
use crate::ansi::{Color, CursorStyle, NamedColor};
|
2019-05-10 11:36:16 +00:00
|
|
|
use crate::input::{Binding, KeyBinding, MouseBinding};
|
|
|
|
|
|
|
|
pub use crate::config::bindings::Key;
|
|
|
|
pub use crate::config::colors::Colors;
|
|
|
|
pub use crate::config::debug::Debug;
|
|
|
|
pub use crate::config::font::{Font, FontDescription};
|
|
|
|
pub use crate::config::monitor::Monitor;
|
|
|
|
pub use crate::config::mouse::{ClickHandler, Mouse};
|
|
|
|
pub use crate::config::scrolling::Scrolling;
|
|
|
|
pub use crate::config::visual_bell::{VisualBellAnimation, VisualBellConfig};
|
|
|
|
pub use crate::config::window::{Decorations, Dimensions, StartupMode, WindowConfig};
|
2019-07-10 21:24:04 +00:00
|
|
|
use crate::term::color::Rgb;
|
2019-05-10 11:36:16 +00:00
|
|
|
|
2019-06-18 21:23:03 +00:00
|
|
|
pub static DEFAULT_ALACRITTY_CONFIG: &str =
|
2019-04-28 13:24:58 +00:00
|
|
|
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/../alacritty.yml"));
|
2019-05-10 11:36:16 +00:00
|
|
|
const MAX_SCROLLBACK_LINES: u32 = 100_000;
|
2017-12-20 19:12:32 +00:00
|
|
|
|
2016-06-30 16:04:06 +00:00
|
|
|
/// Top-level config type
|
2019-01-17 09:17:26 +00:00
|
|
|
#[derive(Debug, PartialEq, Deserialize)]
|
2016-06-30 16:04:06 +00:00
|
|
|
pub struct Config {
|
2017-12-22 20:47:14 +00:00
|
|
|
/// Pixel padding
|
2018-01-06 00:50:12 +00:00
|
|
|
#[serde(default, deserialize_with = "failure_default")]
|
2019-05-10 11:36:16 +00:00
|
|
|
pub padding: Option<Delta<u8>>,
|
2017-12-22 20:47:14 +00:00
|
|
|
|
2017-02-14 02:22:59 +00:00
|
|
|
/// TERM env variable
|
2018-01-06 00:50:12 +00:00
|
|
|
#[serde(default, deserialize_with = "failure_default")]
|
2019-05-10 11:36:16 +00:00
|
|
|
pub env: HashMap<String, String>,
|
2017-02-14 02:22:59 +00:00
|
|
|
|
2016-06-30 16:04:06 +00:00
|
|
|
/// Font configuration
|
2018-01-06 00:50:12 +00:00
|
|
|
#[serde(default, deserialize_with = "failure_default")]
|
2019-05-10 11:36:16 +00:00
|
|
|
pub font: Font,
|
2016-10-15 22:56:27 +00:00
|
|
|
|
2017-10-30 15:03:58 +00:00
|
|
|
/// Should draw bold text with brighter colors instead of bold font
|
2019-05-10 11:36:16 +00:00
|
|
|
#[serde(default, deserialize_with = "failure_default")]
|
|
|
|
draw_bold_text_with_bright_colors: DefaultTrueBool,
|
2016-10-28 16:19:48 +00:00
|
|
|
|
2018-01-06 00:50:12 +00:00
|
|
|
#[serde(default, deserialize_with = "failure_default")]
|
2019-05-10 11:36:16 +00:00
|
|
|
pub colors: Colors,
|
2016-11-15 17:38:50 +00:00
|
|
|
|
2017-08-20 16:55:45 +00:00
|
|
|
/// Background opacity from 0.0 to 1.0
|
2018-01-06 00:50:12 +00:00
|
|
|
#[serde(default, deserialize_with = "failure_default")]
|
2017-08-20 16:55:45 +00:00
|
|
|
background_opacity: Alpha,
|
|
|
|
|
2017-12-20 19:12:32 +00:00
|
|
|
/// Window configuration
|
2018-01-06 00:50:12 +00:00
|
|
|
#[serde(default, deserialize_with = "failure_default")]
|
2019-05-10 11:36:16 +00:00
|
|
|
pub window: WindowConfig,
|
2017-12-17 07:23:49 +00:00
|
|
|
|
2016-11-15 17:38:50 +00:00
|
|
|
/// Keybindings
|
2019-03-30 16:48:36 +00:00
|
|
|
#[serde(default = "default_key_bindings", deserialize_with = "deserialize_key_bindings")]
|
2019-05-10 11:36:16 +00:00
|
|
|
pub key_bindings: Vec<KeyBinding>,
|
2016-11-15 17:38:50 +00:00
|
|
|
|
|
|
|
/// Bindings for the mouse
|
2019-03-30 16:48:36 +00:00
|
|
|
#[serde(default = "default_mouse_bindings", deserialize_with = "deserialize_mouse_bindings")]
|
2019-05-10 11:36:16 +00:00
|
|
|
pub mouse_bindings: Vec<MouseBinding>,
|
2016-12-05 19:18:02 +00:00
|
|
|
|
2018-01-06 00:50:12 +00:00
|
|
|
#[serde(default, deserialize_with = "failure_default")]
|
2019-05-10 11:36:16 +00:00
|
|
|
pub selection: Selection,
|
2017-01-15 01:53:48 +00:00
|
|
|
|
2018-01-06 00:50:12 +00:00
|
|
|
#[serde(default, deserialize_with = "failure_default")]
|
2019-05-10 11:36:16 +00:00
|
|
|
pub mouse: Mouse,
|
2017-01-15 01:53:48 +00:00
|
|
|
|
2017-01-07 17:07:06 +00:00
|
|
|
/// Path to a shell program to run on startup
|
2019-07-06 19:34:56 +00:00
|
|
|
#[serde(default, deserialize_with = "from_string_or_deserialize")]
|
2019-05-10 11:36:16 +00:00
|
|
|
pub shell: Option<Shell<'static>>,
|
2017-01-07 02:06:45 +00:00
|
|
|
|
2016-12-05 19:18:02 +00:00
|
|
|
/// Path where config was loaded from
|
2018-01-06 00:50:12 +00:00
|
|
|
#[serde(default, deserialize_with = "failure_default")]
|
2019-05-10 11:36:16 +00:00
|
|
|
pub config_path: Option<PathBuf>,
|
2017-02-03 23:34:52 +00:00
|
|
|
|
|
|
|
/// Visual bell configuration
|
2018-01-06 00:50:12 +00:00
|
|
|
#[serde(default, deserialize_with = "failure_default")]
|
2019-05-10 11:36:16 +00:00
|
|
|
pub visual_bell: VisualBellConfig,
|
2017-02-22 19:52:37 +00:00
|
|
|
|
2017-12-24 18:24:28 +00:00
|
|
|
/// Use dynamic title
|
2018-11-01 17:23:49 +00:00
|
|
|
#[serde(default, deserialize_with = "failure_default")]
|
2019-05-10 11:36:16 +00:00
|
|
|
dynamic_title: DefaultTrueBool,
|
2017-05-06 15:45:23 +00:00
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
/// Live config reload
|
|
|
|
#[serde(default, deserialize_with = "failure_default")]
|
|
|
|
live_config_reload: DefaultTrueBool,
|
2016-10-28 16:19:48 +00:00
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
/// Number of spaces in one tab
|
|
|
|
#[serde(default, deserialize_with = "failure_default")]
|
|
|
|
tabspaces: Tabspaces,
|
2016-06-30 16:04:06 +00:00
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
/// How much scrolling history to keep
|
|
|
|
#[serde(default, deserialize_with = "failure_default")]
|
|
|
|
pub scrolling: Scrolling,
|
2017-02-05 10:01:26 +00:00
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
/// Cursor configuration
|
|
|
|
#[serde(default, deserialize_with = "failure_default")]
|
|
|
|
pub cursor: Cursor,
|
2017-12-20 19:12:32 +00:00
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
/// Enable experimental conpty backend instead of using winpty.
|
|
|
|
/// Will only take effect on Windows 10 Oct 2018 and later.
|
|
|
|
#[cfg(windows)]
|
|
|
|
#[serde(default, deserialize_with = "failure_default")]
|
|
|
|
pub enable_experimental_conpty_backend: bool,
|
2017-02-03 23:34:52 +00:00
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
/// Send escape sequences using the alt key.
|
|
|
|
#[serde(default, deserialize_with = "failure_default")]
|
|
|
|
alt_send_esc: DefaultTrueBool,
|
2016-06-30 16:04:06 +00:00
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
/// Shell startup directory
|
2019-07-06 19:34:56 +00:00
|
|
|
#[serde(default, deserialize_with = "option_explicit_none")]
|
|
|
|
working_directory: Option<PathBuf>,
|
2017-01-10 13:58:54 +00:00
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
/// Debug options
|
|
|
|
#[serde(default, deserialize_with = "failure_default")]
|
|
|
|
pub debug: Debug,
|
2019-01-17 09:17:26 +00:00
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
// TODO: DEPRECATED
|
|
|
|
#[serde(default, deserialize_with = "failure_default")]
|
|
|
|
pub render_timer: Option<bool>,
|
2016-12-05 19:18:02 +00:00
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
// TODO: DEPRECATED
|
|
|
|
#[serde(default, deserialize_with = "failure_default")]
|
|
|
|
pub persistent_logging: Option<bool>,
|
|
|
|
}
|
2017-01-07 02:06:45 +00:00
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
impl Default for Config {
|
|
|
|
fn default() -> Self {
|
|
|
|
serde_yaml::from_str(DEFAULT_ALACRITTY_CONFIG).expect("default config is invalid")
|
2017-02-14 02:22:59 +00:00
|
|
|
}
|
2019-05-10 11:36:16 +00:00
|
|
|
}
|
2017-02-14 02:22:59 +00:00
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
impl Config {
|
|
|
|
pub fn tabspaces(&self) -> usize {
|
|
|
|
self.tabspaces.0
|
2017-02-22 19:52:37 +00:00
|
|
|
}
|
|
|
|
|
2017-12-03 21:38:42 +00:00
|
|
|
#[inline]
|
2019-05-10 11:36:16 +00:00
|
|
|
pub fn draw_bold_text_with_bright_colors(&self) -> bool {
|
|
|
|
self.draw_bold_text_with_bright_colors.0
|
2017-12-03 21:38:42 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
/// Should show render timer
|
Merge master into scrollback
* Allow disabling DPI scaling
This makes it possible to disable DPI scaling completely, instead the
the display pixel ration will always be fixed to 1.0.
By default nothing has changed and DPI is still enabled, this just seems
like a better way than running `WINIT_HIDPI_FACTOR=1.0 alacritty` every
time the user wants to start alacritty.
It would be possible to allow specifying any DPR, however I've decided
against this since I'd assume it's a very rare usecase. It's also still
possible to make use of `WINIT_HIDPI_FACTOR` to do this on X11.
Currently this is not updated at runtime using the live config update,
there is not really much of a technical limitation why this woudn't be
possible, however a solution for that issue should be first added in
jwilm/alacritty#1346, once a system is established for changing DPI at
runtime, porting that functionality to this PR should be simple.
* Add working --class and --title CLI parameters
* Reduce Increase-/DecreaseFontSize step to 0.5
Until now the Increase-/DecreaseFontSize keybinds hand a step size of 1.0. Since the font size however is multiplied by two to allow more granular font size control, this lead to the bindings skipping one font size (incrementing/decrementing by +-2).
To fix this the step size of the Increase-/DecreaseFontSize bindings has been reduced to the minimum step size that exists with the current font configuration (0.5). This should allow users to increment and decrement the font size by a single point instead of two.
This also adds a few tests to make sure the methods for increasing/decreasing/resetting font size work properly.
* Add Copy/Cut/Paste keys
This just adds support for the Copy/Cut/Paste keys and sets up
Copy/Paste as alternative defaults for Ctrl+Shift+C/V.
* Move to cargo clippy
Using clippy as a library has been deprecated, instead the `cargo
clippy` command should be used instead. To comply with this change
clippy has been removed from the `Cargo.toml` and is now installed with
cargo when building in CI.
This has also lead to a few new clippy issues to show up, this includes
everything in the `font` subdirectory. This has been fixed and `font`
should now be covered by clippy CI too.
This also upgrades all dependencies, as a result this fixes #1341 and
this fixes #1344.
* Override dynamic_title when --title is specified
* Change green implementation to use the macro
* Ignore mouse input if window is unfocused
* Make compilation of binary a phony target
* Add opensuse zypper install method to readme
* Fix clippy issues
* Update manpage to document all CLI options
The introduction of `--class` has added a flag to the CLI without adding
it to the manpage. This has been fixed by updating the manpage.
This also adds the default values of `--class` and `--title` to the CLI
options.
* Remove unnecessary clippy lint annotations
We moved to "cargo clippy" in 5ba34d4f9766a55a06ed5e3e44cc384af1b09f65 and
removing the clippy lint annotations in `src/lib.rs` does not cause any additional warnings.
This also changes `cargo clippy` to use the flags required for checking integration tests.
* Enable clippy in font/copypasta crates
Enabled clippy in the sub-crates font and copypasta. All issues
that were discovered by this change have also been fixed.
* Remove outdated comment about NixOS
* Replace debug asserts with static_assertions
To check that transmutes will work correctly without having to rely on
error-prone runtime checking, the `static_assertions` crate has been
introduced. This allows comparing the size of types at compile time,
preventing potentially silent breakage.
This fixes #1417.
* Add `cargo deb` build instructions
Updated the `Cargo.toml` file and added a `package.metadata.deb`
subsection to define how to build a debian "deb" install file using
`cargo deb`. This will allow debian/ubuntu users to install `alacritty`
using their system's package manager. It also will make it easier to
provide pre-built binaries for those systems.
Also fixed a stray debug line in the bash autocomplete script that was
writting to a tempfile.
* Add config for unfocused window cursor change
* Add support for cursor shape escape sequence
* Add bright foreground color option
It was requested in jwilm/alacritty#825 that it should be possible to
add an optional bright foreground color.
This is now added to the primary colors structure and allows the user to
set a foreground color for bold normal text. This has no effect unless
the draw_bold_text_with_bright_colors option is also enabled.
If the color is not specified, the bright foreground color will fall
back to the normal foreground color.
This fixes #825.
* Fix clone URL in deb install instructions
* Fix 'cargo-deb' desktop file name
* Remove redundant dependency from deb build
* Switch from deprecated `std::env::home_dir` to `dirs::home_dir`
* Allow specifying modifiers for mouse bindings
* Send newline with NumpadEnter
* Add support for LCD-V pixel mode
* Add binding action for hiding the window
* Switch to rustup clippy component
* Add optional dim foreground color
Add optional color for the dim foreground (`\e[2m;`)
Defaults to 2/3 of the foreground color. (same as other colors).
If a bright color is dimmed, it's displayed as the normal color. The
exception for this is when the bright foreground is dimmed when no
bright foreground color is set. In that case it's treated as a normal
foreground color and dimmed to DimForeground.
To minimize the surprise for the user, the bright and dim colors have
been completely removed from the default configuration file.
Some documentation has also been added to make it clear to users what
these options can be used for.
This fixes #1448.
* Fix clippy lints and run font tests on travis
This fixes some existing clippy issues and runs the `font` tests through travis.
Testing of copypasta crate was omitted due to problens when running on headless travis-ci environment (x11 clipboard would fail).
* Ignore errors when logger can't write to output
The (e)print macro will panic when there is no output available to
write to, however in our scenario where we only log user errors to
stderr, the better choice would be to ignore when writing to stdout or
stderr is not possible.
This changes the (e)print macro to make use of `write` and ignore
any potential errors.
Since (e)println rely on (e)print, this also solves potential failuers
when calling (e)println.
With this change implemented, all of logging, (e)println and (e)print
should never fail even if the stdout/stderr is not available.
2018-07-28 23:10:13 +00:00
|
|
|
#[inline]
|
2019-05-10 11:36:16 +00:00
|
|
|
pub fn render_timer(&self) -> bool {
|
|
|
|
self.render_timer.unwrap_or(self.debug.render_timer)
|
Merge master into scrollback
* Allow disabling DPI scaling
This makes it possible to disable DPI scaling completely, instead the
the display pixel ration will always be fixed to 1.0.
By default nothing has changed and DPI is still enabled, this just seems
like a better way than running `WINIT_HIDPI_FACTOR=1.0 alacritty` every
time the user wants to start alacritty.
It would be possible to allow specifying any DPR, however I've decided
against this since I'd assume it's a very rare usecase. It's also still
possible to make use of `WINIT_HIDPI_FACTOR` to do this on X11.
Currently this is not updated at runtime using the live config update,
there is not really much of a technical limitation why this woudn't be
possible, however a solution for that issue should be first added in
jwilm/alacritty#1346, once a system is established for changing DPI at
runtime, porting that functionality to this PR should be simple.
* Add working --class and --title CLI parameters
* Reduce Increase-/DecreaseFontSize step to 0.5
Until now the Increase-/DecreaseFontSize keybinds hand a step size of 1.0. Since the font size however is multiplied by two to allow more granular font size control, this lead to the bindings skipping one font size (incrementing/decrementing by +-2).
To fix this the step size of the Increase-/DecreaseFontSize bindings has been reduced to the minimum step size that exists with the current font configuration (0.5). This should allow users to increment and decrement the font size by a single point instead of two.
This also adds a few tests to make sure the methods for increasing/decreasing/resetting font size work properly.
* Add Copy/Cut/Paste keys
This just adds support for the Copy/Cut/Paste keys and sets up
Copy/Paste as alternative defaults for Ctrl+Shift+C/V.
* Move to cargo clippy
Using clippy as a library has been deprecated, instead the `cargo
clippy` command should be used instead. To comply with this change
clippy has been removed from the `Cargo.toml` and is now installed with
cargo when building in CI.
This has also lead to a few new clippy issues to show up, this includes
everything in the `font` subdirectory. This has been fixed and `font`
should now be covered by clippy CI too.
This also upgrades all dependencies, as a result this fixes #1341 and
this fixes #1344.
* Override dynamic_title when --title is specified
* Change green implementation to use the macro
* Ignore mouse input if window is unfocused
* Make compilation of binary a phony target
* Add opensuse zypper install method to readme
* Fix clippy issues
* Update manpage to document all CLI options
The introduction of `--class` has added a flag to the CLI without adding
it to the manpage. This has been fixed by updating the manpage.
This also adds the default values of `--class` and `--title` to the CLI
options.
* Remove unnecessary clippy lint annotations
We moved to "cargo clippy" in 5ba34d4f9766a55a06ed5e3e44cc384af1b09f65 and
removing the clippy lint annotations in `src/lib.rs` does not cause any additional warnings.
This also changes `cargo clippy` to use the flags required for checking integration tests.
* Enable clippy in font/copypasta crates
Enabled clippy in the sub-crates font and copypasta. All issues
that were discovered by this change have also been fixed.
* Remove outdated comment about NixOS
* Replace debug asserts with static_assertions
To check that transmutes will work correctly without having to rely on
error-prone runtime checking, the `static_assertions` crate has been
introduced. This allows comparing the size of types at compile time,
preventing potentially silent breakage.
This fixes #1417.
* Add `cargo deb` build instructions
Updated the `Cargo.toml` file and added a `package.metadata.deb`
subsection to define how to build a debian "deb" install file using
`cargo deb`. This will allow debian/ubuntu users to install `alacritty`
using their system's package manager. It also will make it easier to
provide pre-built binaries for those systems.
Also fixed a stray debug line in the bash autocomplete script that was
writting to a tempfile.
* Add config for unfocused window cursor change
* Add support for cursor shape escape sequence
* Add bright foreground color option
It was requested in jwilm/alacritty#825 that it should be possible to
add an optional bright foreground color.
This is now added to the primary colors structure and allows the user to
set a foreground color for bold normal text. This has no effect unless
the draw_bold_text_with_bright_colors option is also enabled.
If the color is not specified, the bright foreground color will fall
back to the normal foreground color.
This fixes #825.
* Fix clone URL in deb install instructions
* Fix 'cargo-deb' desktop file name
* Remove redundant dependency from deb build
* Switch from deprecated `std::env::home_dir` to `dirs::home_dir`
* Allow specifying modifiers for mouse bindings
* Send newline with NumpadEnter
* Add support for LCD-V pixel mode
* Add binding action for hiding the window
* Switch to rustup clippy component
* Add optional dim foreground color
Add optional color for the dim foreground (`\e[2m;`)
Defaults to 2/3 of the foreground color. (same as other colors).
If a bright color is dimmed, it's displayed as the normal color. The
exception for this is when the bright foreground is dimmed when no
bright foreground color is set. In that case it's treated as a normal
foreground color and dimmed to DimForeground.
To minimize the surprise for the user, the bright and dim colors have
been completely removed from the default configuration file.
Some documentation has also been added to make it clear to users what
these options can be used for.
This fixes #1448.
* Fix clippy lints and run font tests on travis
This fixes some existing clippy issues and runs the `font` tests through travis.
Testing of copypasta crate was omitted due to problens when running on headless travis-ci environment (x11 clipboard would fail).
* Ignore errors when logger can't write to output
The (e)print macro will panic when there is no output available to
write to, however in our scenario where we only log user errors to
stderr, the better choice would be to ignore when writing to stdout or
stderr is not possible.
This changes the (e)print macro to make use of `write` and ignore
any potential errors.
Since (e)println rely on (e)print, this also solves potential failuers
when calling (e)println.
With this change implemented, all of logging, (e)println and (e)print
should never fail even if the stdout/stderr is not available.
2018-07-28 23:10:13 +00:00
|
|
|
}
|
|
|
|
|
2017-08-29 16:32:08 +00:00
|
|
|
/// Live config reload
|
|
|
|
#[inline]
|
|
|
|
pub fn live_config_reload(&self) -> bool {
|
2019-05-10 11:36:16 +00:00
|
|
|
self.live_config_reload.0
|
2017-12-24 18:24:28 +00:00
|
|
|
}
|
|
|
|
|
2018-03-09 18:45:40 +00:00
|
|
|
#[inline]
|
2019-05-10 11:36:16 +00:00
|
|
|
pub fn set_live_config_reload(&mut self, live_config_reload: bool) {
|
|
|
|
self.live_config_reload.0 = live_config_reload;
|
2018-03-09 18:45:40 +00:00
|
|
|
}
|
|
|
|
|
2018-11-01 17:23:49 +00:00
|
|
|
#[inline]
|
2019-05-10 11:36:16 +00:00
|
|
|
pub fn dynamic_title(&self) -> bool {
|
|
|
|
self.dynamic_title.0
|
2018-11-01 17:23:49 +00:00
|
|
|
}
|
|
|
|
|
2019-07-10 21:24:04 +00:00
|
|
|
/// Cursor foreground color
|
|
|
|
#[inline]
|
|
|
|
pub fn cursor_text_color(&self) -> Option<Rgb> {
|
|
|
|
self.colors.cursor.text
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Cursor background color
|
|
|
|
#[inline]
|
|
|
|
pub fn cursor_cursor_color(&self) -> Option<Color> {
|
|
|
|
self.colors.cursor.cursor.map(|_| Color::Named(NamedColor::Cursor))
|
|
|
|
}
|
|
|
|
|
2018-12-28 16:01:58 +00:00
|
|
|
#[inline]
|
2019-05-10 11:36:16 +00:00
|
|
|
pub fn set_dynamic_title(&mut self, dynamic_title: bool) {
|
|
|
|
self.dynamic_title.0 = dynamic_title;
|
2018-12-28 16:01:58 +00:00
|
|
|
}
|
|
|
|
|
2019-01-17 20:42:12 +00:00
|
|
|
/// Send escape sequences using the alt key
|
|
|
|
#[inline]
|
|
|
|
pub fn alt_send_esc(&self) -> bool {
|
2019-05-10 11:36:16 +00:00
|
|
|
self.alt_send_esc.0
|
2018-04-14 15:21:48 +00:00
|
|
|
}
|
|
|
|
|
Display errors and warnings
To make sure that all error and information reporting to the user is
unified, all instances of `print!`, `eprint!`, `println!` and
`eprintln!` have been removed and replaced by logging.
When `RUST_LOG` is not specified, the default Alacritty logger now also
prints to both the stderr and a log file. The log file is only created
when a message is written to it and its name is printed to stdout the
first time it is used.
Whenever a warning or an error has been written to the log file/stderr,
a message is now displayed in Alacritty which points to the log file
where the full error is documented.
The message is cleared whenever the screen is cleared using either the
`clear` command or the `Ctrl+L` key binding.
To make sure that log files created by root don't prevent normal users
from interacting with them, the Alacritty log file is `/tmp/Alacritty-$PID.log`.
Since it's still possible that the log file can't be created, the UI
error/warning message now informs the user if the message was only
written to stderr. The reason why it couldn't be created is then printed
to stderr.
To make sure the deletion of the log file at runtime doesn't create any
issues, the file is re-created if a write is attempted without the file
being present.
To help with debugging Alacritty issues, a timestamp and the error
level are printed in all log messages.
All log messages now follow this format:
[YYYY-MM-DD HH:MM] [LEVEL] Message
Since it's not unusual to spawn a lot of different terminal emulators
without restarting, Alacritty can create a ton of different log files.
To combat this problem, logfiles are removed by default after
Alacritty has been closed. If the user wants to persist the log of a
single session, the `--persistent_logging` option can be used. For
persisting all log files, the `persistent_logging` option can be set in
the configuration file
2018-11-17 14:39:13 +00:00
|
|
|
/// Keep the log file after quitting Alacritty
|
|
|
|
#[inline]
|
|
|
|
pub fn persistent_logging(&self) -> bool {
|
2019-05-10 11:36:16 +00:00
|
|
|
self.persistent_logging.unwrap_or(self.debug.persistent_logging)
|
2017-12-22 20:47:14 +00:00
|
|
|
}
|
2017-02-05 10:01:26 +00:00
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
#[inline]
|
|
|
|
pub fn background_opacity(&self) -> f32 {
|
|
|
|
self.background_opacity.0
|
2017-02-05 10:01:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2019-05-10 11:36:16 +00:00
|
|
|
pub fn working_directory(&self) -> &Option<PathBuf> {
|
2019-07-06 19:34:56 +00:00
|
|
|
&self.working_directory
|
2017-02-05 10:01:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[inline]
|
2019-05-10 11:36:16 +00:00
|
|
|
pub fn set_working_directory(&mut self, working_directory: Option<PathBuf>) {
|
2019-07-06 19:34:56 +00:00
|
|
|
self.working_directory = working_directory;
|
2016-08-12 18:38:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
fn default_key_bindings() -> Vec<KeyBinding> {
|
|
|
|
bindings::default_key_bindings()
|
2018-11-10 16:08:48 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
fn default_mouse_bindings() -> Vec<MouseBinding> {
|
|
|
|
bindings::default_mouse_bindings()
|
2017-01-03 02:52:41 +00:00
|
|
|
}
|
2016-08-12 18:38:41 +00:00
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
fn deserialize_key_bindings<'a, D>(deserializer: D) -> Result<Vec<KeyBinding>, D::Error>
|
|
|
|
where
|
|
|
|
D: Deserializer<'a>,
|
|
|
|
{
|
|
|
|
deserialize_bindings(deserializer, bindings::default_key_bindings())
|
2016-06-30 16:04:06 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
fn deserialize_mouse_bindings<'a, D>(deserializer: D) -> Result<Vec<MouseBinding>, D::Error>
|
|
|
|
where
|
|
|
|
D: Deserializer<'a>,
|
|
|
|
{
|
|
|
|
deserialize_bindings(deserializer, bindings::default_mouse_bindings())
|
2019-01-17 09:17:26 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
fn deserialize_bindings<'a, D, T>(
|
|
|
|
deserializer: D,
|
|
|
|
mut default: Vec<Binding<T>>,
|
|
|
|
) -> Result<Vec<Binding<T>>, D::Error>
|
2019-01-17 09:17:26 +00:00
|
|
|
where
|
2019-05-10 11:36:16 +00:00
|
|
|
D: Deserializer<'a>,
|
|
|
|
T: Copy + Eq + std::hash::Hash + std::fmt::Debug,
|
|
|
|
Binding<T>: Deserialize<'a>,
|
2019-01-17 09:17:26 +00:00
|
|
|
{
|
2019-05-10 11:36:16 +00:00
|
|
|
let mut bindings: Vec<Binding<T>> = failure_default(deserializer)?;
|
|
|
|
|
|
|
|
for binding in bindings.iter() {
|
|
|
|
default.retain(|b| !b.triggers_match(binding));
|
|
|
|
}
|
|
|
|
|
|
|
|
bindings.extend(default);
|
|
|
|
|
|
|
|
Ok(bindings)
|
2019-01-17 09:17:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[serde(default)]
|
2019-05-10 11:36:16 +00:00
|
|
|
#[derive(Deserialize, Default, Clone, Debug, PartialEq, Eq)]
|
|
|
|
pub struct Selection {
|
2019-01-17 09:17:26 +00:00
|
|
|
#[serde(deserialize_with = "failure_default")]
|
2019-05-10 11:36:16 +00:00
|
|
|
semantic_escape_chars: EscapeChars,
|
2019-01-17 09:17:26 +00:00
|
|
|
#[serde(deserialize_with = "failure_default")]
|
2019-05-10 11:36:16 +00:00
|
|
|
pub save_to_clipboard: bool,
|
2019-01-17 09:17:26 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
impl Selection {
|
|
|
|
pub fn semantic_escape_chars(&self) -> &str {
|
|
|
|
&self.semantic_escape_chars.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Deserialize, Clone, Debug, PartialEq, Eq)]
|
|
|
|
struct EscapeChars(String);
|
|
|
|
|
|
|
|
impl Default for EscapeChars {
|
|
|
|
fn default() -> Self {
|
|
|
|
EscapeChars(String::from(",│`|:\"' ()[]{}<>"))
|
2016-06-30 16:04:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-17 09:17:26 +00:00
|
|
|
#[serde(default)]
|
2019-05-10 11:36:16 +00:00
|
|
|
#[derive(Copy, Clone, Debug, Deserialize, PartialEq, Eq)]
|
|
|
|
pub struct Cursor {
|
2019-01-17 09:17:26 +00:00
|
|
|
#[serde(deserialize_with = "failure_default")]
|
2019-05-10 11:36:16 +00:00
|
|
|
pub style: CursorStyle,
|
2019-01-17 09:17:26 +00:00
|
|
|
#[serde(deserialize_with = "failure_default")]
|
2019-05-10 11:36:16 +00:00
|
|
|
unfocused_hollow: DefaultTrueBool,
|
2019-01-17 09:17:26 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
impl Default for Cursor {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self { style: Default::default(), unfocused_hollow: Default::default() }
|
2019-01-17 09:17:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
impl Cursor {
|
|
|
|
pub fn unfocused_hollow(self) -> bool {
|
|
|
|
self.unfocused_hollow.0
|
|
|
|
}
|
2016-12-11 07:32:12 +00:00
|
|
|
}
|
2016-10-27 17:05:04 +00:00
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
#[derive(Debug, Deserialize, PartialEq, Eq)]
|
|
|
|
pub struct Shell<'a> {
|
|
|
|
pub program: Cow<'a, str>,
|
2016-12-11 07:32:12 +00:00
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
#[serde(default, deserialize_with = "failure_default")]
|
|
|
|
pub args: Vec<String>,
|
2016-10-27 17:05:04 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
impl<'a> Shell<'a> {
|
|
|
|
pub fn new<S>(program: S) -> Shell<'a>
|
|
|
|
where
|
|
|
|
S: Into<Cow<'a, str>>,
|
|
|
|
{
|
|
|
|
Shell { program: program.into(), args: Vec::new() }
|
2016-12-11 07:32:12 +00:00
|
|
|
}
|
2019-02-07 22:36:45 +00:00
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
pub fn new_with_args<S>(program: S, args: Vec<String>) -> Shell<'a>
|
2019-03-30 16:48:36 +00:00
|
|
|
where
|
2019-05-10 11:36:16 +00:00
|
|
|
S: Into<Cow<'a, str>>,
|
2016-12-05 19:18:02 +00:00
|
|
|
{
|
2019-05-10 11:36:16 +00:00
|
|
|
Shell { program: program.into(), args }
|
2016-10-27 17:05:04 +00:00
|
|
|
}
|
|
|
|
}
|
2016-11-15 17:38:50 +00:00
|
|
|
|
2019-07-06 19:34:56 +00:00
|
|
|
impl FromString for Option<Shell<'_>> {
|
|
|
|
fn from(input: String) -> Self {
|
|
|
|
Some(Shell::new(input))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
/// A delta for a point in a 2 dimensional plane
|
|
|
|
#[serde(default, bound(deserialize = "T: Deserialize<'de> + Default"))]
|
|
|
|
#[derive(Clone, Copy, Debug, Default, Deserialize, PartialEq, Eq)]
|
|
|
|
pub struct Delta<T: Default + PartialEq + Eq> {
|
|
|
|
/// Horizontal change
|
|
|
|
#[serde(deserialize_with = "failure_default")]
|
|
|
|
pub x: T,
|
|
|
|
/// Vertical change
|
|
|
|
#[serde(deserialize_with = "failure_default")]
|
|
|
|
pub y: T,
|
2016-11-15 17:38:50 +00:00
|
|
|
}
|
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
/// Wrapper around f32 that represents an alpha value between 0.0 and 1.0
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
|
|
|
pub struct Alpha(f32);
|
|
|
|
|
|
|
|
impl Alpha {
|
|
|
|
pub fn new(value: f32) -> Self {
|
|
|
|
Alpha(if value < 0.0 {
|
|
|
|
0.0
|
|
|
|
} else if value > 1.0 {
|
|
|
|
1.0
|
|
|
|
} else {
|
|
|
|
value
|
|
|
|
})
|
2016-11-15 17:38:50 +00:00
|
|
|
}
|
|
|
|
}
|
2019-01-17 09:17:26 +00:00
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
impl Default for Alpha {
|
|
|
|
fn default() -> Self {
|
|
|
|
Alpha(1.0)
|
2019-01-17 09:17:26 +00:00
|
|
|
}
|
2019-05-10 11:36:16 +00:00
|
|
|
}
|
2019-01-17 09:17:26 +00:00
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
impl<'a> Deserialize<'a> for Alpha {
|
|
|
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
|
|
|
where
|
|
|
|
D: Deserializer<'a>,
|
|
|
|
{
|
|
|
|
Ok(Alpha::new(f32::deserialize(deserializer)?))
|
2019-01-17 09:17:26 +00:00
|
|
|
}
|
2019-05-10 11:36:16 +00:00
|
|
|
}
|
2019-01-17 09:17:26 +00:00
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
#[derive(Deserialize, Debug, PartialEq, Eq)]
|
|
|
|
struct Tabspaces(usize);
|
|
|
|
|
|
|
|
impl Default for Tabspaces {
|
|
|
|
fn default() -> Self {
|
|
|
|
Tabspaces(8)
|
2019-01-17 09:17:26 +00:00
|
|
|
}
|
2019-05-10 11:36:16 +00:00
|
|
|
}
|
2019-01-17 09:17:26 +00:00
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
#[derive(Deserialize, Copy, Clone, Debug, PartialEq, Eq)]
|
|
|
|
struct DefaultTrueBool(bool);
|
2019-01-17 09:17:26 +00:00
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
impl Default for DefaultTrueBool {
|
|
|
|
fn default() -> Self {
|
|
|
|
DefaultTrueBool(true)
|
|
|
|
}
|
|
|
|
}
|
2019-01-17 09:17:26 +00:00
|
|
|
|
2019-07-06 19:34:56 +00:00
|
|
|
fn fallback_default<T, E>(err: E) -> T
|
2019-07-07 14:51:11 +00:00
|
|
|
where
|
|
|
|
T: Default,
|
|
|
|
E: Display,
|
2019-07-06 19:34:56 +00:00
|
|
|
{
|
|
|
|
error!("Problem with config: {}; using default value", err);
|
|
|
|
T::default()
|
|
|
|
}
|
|
|
|
|
2019-05-10 11:36:16 +00:00
|
|
|
pub fn failure_default<'a, D, T>(deserializer: D) -> Result<T, D::Error>
|
|
|
|
where
|
|
|
|
D: Deserializer<'a>,
|
|
|
|
T: Deserialize<'a> + Default,
|
|
|
|
{
|
2019-07-06 19:34:56 +00:00
|
|
|
Ok(T::deserialize(Value::deserialize(deserializer)?).unwrap_or_else(fallback_default))
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn option_explicit_none<'de, T, D>(deserializer: D) -> Result<Option<T>, D::Error>
|
2019-07-07 14:51:11 +00:00
|
|
|
where
|
|
|
|
D: Deserializer<'de>,
|
|
|
|
T: Deserialize<'de> + Default,
|
2019-07-06 19:34:56 +00:00
|
|
|
{
|
|
|
|
Ok(match Value::deserialize(deserializer)? {
|
|
|
|
Value::String(ref value) if value.to_lowercase() == "none" => None,
|
2019-07-07 14:51:11 +00:00
|
|
|
value => Some(T::deserialize(value).unwrap_or_else(fallback_default)),
|
2019-07-06 19:34:56 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn from_string_or_deserialize<'de, T, D>(deserializer: D) -> Result<T, D::Error>
|
2019-07-07 14:51:11 +00:00
|
|
|
where
|
|
|
|
D: Deserializer<'de>,
|
|
|
|
T: Deserialize<'de> + FromString + Default,
|
2019-07-06 19:34:56 +00:00
|
|
|
{
|
|
|
|
Ok(match Value::deserialize(deserializer)? {
|
|
|
|
Value::String(value) => T::from(value),
|
2019-07-07 14:51:11 +00:00
|
|
|
value => T::deserialize(value).unwrap_or_else(fallback_default),
|
2019-07-06 19:34:56 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// Used over From<String>, to allow implementation for foreign types
|
|
|
|
pub trait FromString {
|
|
|
|
fn from(input: String) -> Self;
|
2019-01-17 09:17:26 +00:00
|
|
|
}
|