2016-06-30 03:56:12 +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.
|
|
|
|
//
|
2016-05-25 03:55:51 +00:00
|
|
|
//! Alacritty - The GPU Enhanced Terminal
|
2018-07-21 17:17:41 +00:00
|
|
|
#![cfg_attr(feature = "cargo-clippy", deny(clippy, if_not_else, enum_glob_use, wrong_pub_self_convention))]
|
2018-01-06 01:42:55 +00:00
|
|
|
#![cfg_attr(feature = "nightly", feature(core_intrinsics))]
|
|
|
|
#![cfg_attr(all(test, feature = "bench"), feature(test))]
|
2016-10-14 23:38:15 +00:00
|
|
|
|
2018-10-16 17:02:52 +00:00
|
|
|
// With the default subsystem, 'console', windows creates an additional console
|
|
|
|
// window for the program.
|
|
|
|
// This is silently ignored on non-windows systems.
|
|
|
|
// See https://msdn.microsoft.com/en-us/library/4cc7ya5b.aspx for more details.
|
2018-10-18 02:58:58 +00:00
|
|
|
#![windows_subsystem = "windows"]
|
2018-10-16 17:02:52 +00:00
|
|
|
|
2016-11-20 00:16:20 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate alacritty;
|
2016-06-06 23:54:15 +00:00
|
|
|
|
2017-01-13 07:15:06 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate log;
|
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
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
extern crate dirs;
|
2017-01-13 07:15:06 +00:00
|
|
|
|
2016-12-11 06:44:13 +00:00
|
|
|
use std::error::Error;
|
2016-12-12 06:02:03 +00:00
|
|
|
use std::sync::Arc;
|
2018-10-18 02:58:58 +00:00
|
|
|
|
2018-01-08 04:46:11 +00:00
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
use std::env;
|
2018-10-18 02:58:58 +00:00
|
|
|
|
2018-10-16 17:02:52 +00:00
|
|
|
#[cfg(not(windows))]
|
|
|
|
use std::os::unix::io::AsRawFd;
|
2016-06-28 02:46:24 +00:00
|
|
|
|
2018-10-18 02:58:58 +00:00
|
|
|
#[cfg(windows)]
|
|
|
|
extern crate winapi;
|
|
|
|
#[cfg(windows)]
|
2018-10-27 04:47:01 +00:00
|
|
|
use winapi::um::wincon::{AttachConsole, FreeConsole, ATTACH_PARENT_PROCESS};
|
2018-10-18 02:58:58 +00:00
|
|
|
|
2016-12-11 06:44:13 +00:00
|
|
|
use alacritty::cli;
|
2016-11-20 00:16:20 +00:00
|
|
|
use alacritty::config::{self, Config};
|
2016-12-11 07:32:12 +00:00
|
|
|
use alacritty::display::Display;
|
2016-11-20 00:16:20 +00:00
|
|
|
use alacritty::event;
|
2017-05-20 04:35:43 +00:00
|
|
|
use alacritty::event_loop::{self, EventLoop, Msg};
|
2017-12-13 17:52:36 +00:00
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
use alacritty::locale;
|
2017-01-13 07:15:06 +00:00
|
|
|
use alacritty::logging;
|
2016-11-20 00:16:20 +00:00
|
|
|
use alacritty::sync::FairMutex;
|
2018-10-16 17:02:52 +00:00
|
|
|
use alacritty::term::Term;
|
2016-12-11 06:44:13 +00:00
|
|
|
use alacritty::tty::{self, process_should_exit};
|
2017-01-02 03:09:27 +00:00
|
|
|
use alacritty::util::fmt::Red;
|
2016-06-30 03:14:37 +00:00
|
|
|
|
2016-06-10 03:39:40 +00:00
|
|
|
fn main() {
|
2018-10-18 02:58:58 +00:00
|
|
|
// When linked with the windows subsystem windows won't automatically attach
|
|
|
|
// to the console of the parent process, so we do it explicitly. This fails
|
|
|
|
// silently if the parent has no console.
|
|
|
|
#[cfg(windows)]
|
2018-10-27 04:47:01 +00:00
|
|
|
unsafe { AttachConsole(ATTACH_PARENT_PROCESS); }
|
2018-10-18 02:58:58 +00:00
|
|
|
|
2017-05-29 00:42:36 +00:00
|
|
|
// Load command line options and config
|
2016-12-05 00:27:20 +00:00
|
|
|
let options = cli::Options::load();
|
2018-07-21 17:17:41 +00:00
|
|
|
let config = load_config(&options).update_dynamic_title(&options);
|
2016-11-20 00:16:20 +00:00
|
|
|
|
2018-01-08 04:46:11 +00:00
|
|
|
// Switch to home directory
|
|
|
|
#[cfg(target_os = "macos")]
|
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
|
|
|
env::set_current_dir(dirs::home_dir().unwrap()).unwrap();
|
2018-01-08 04:46:11 +00:00
|
|
|
// Set locale
|
2017-12-13 17:52:36 +00:00
|
|
|
#[cfg(target_os = "macos")]
|
|
|
|
locale::set_locale_environment();
|
|
|
|
|
2016-12-10 19:27:53 +00:00
|
|
|
// Run alacritty
|
2017-11-29 23:38:29 +00:00
|
|
|
if let Err(err) = run(config, &options) {
|
2017-01-01 03:49:51 +00:00
|
|
|
die!("Alacritty encountered an unrecoverable error:\n\n\t{}\n", Red(err));
|
2016-12-11 06:44:13 +00:00
|
|
|
}
|
|
|
|
|
2017-01-13 07:15:06 +00:00
|
|
|
info!("Goodbye.");
|
2016-12-10 19:27:53 +00:00
|
|
|
}
|
|
|
|
|
2017-05-29 00:42:36 +00:00
|
|
|
/// Load configuration
|
|
|
|
///
|
|
|
|
/// If a configuration file is given as a command line argument we don't
|
|
|
|
/// generate a default file. If an empty configuration file is given, i.e.
|
2018-10-16 17:02:52 +00:00
|
|
|
/// /dev/null, we load the compiled-in defaults.)
|
2017-05-29 00:42:36 +00:00
|
|
|
fn load_config(options: &cli::Options) -> Config {
|
|
|
|
let config_path = options.config_path()
|
2018-01-06 01:42:55 +00:00
|
|
|
.or_else(Config::installed_config)
|
2017-05-29 00:42:36 +00:00
|
|
|
.unwrap_or_else(|| {
|
|
|
|
Config::write_defaults()
|
|
|
|
.unwrap_or_else(|err| die!("Write defaults config failure: {}", err))
|
|
|
|
});
|
|
|
|
|
|
|
|
Config::load_from(&*config_path).unwrap_or_else(|err| {
|
2018-01-06 00:50:12 +00:00
|
|
|
eprintln!("Error: {}; Loading default config", err);
|
|
|
|
Config::default()
|
2017-05-29 00:42:36 +00:00
|
|
|
})
|
|
|
|
}
|
2017-01-01 03:49:51 +00:00
|
|
|
|
2016-12-10 19:27:53 +00:00
|
|
|
/// Run Alacritty
|
|
|
|
///
|
2016-12-11 07:32:12 +00:00
|
|
|
/// Creates a window, the terminal state, pty, I/O event loop, input processor,
|
|
|
|
/// config change monitor, and runs the main display loop.
|
2017-11-29 23:38:29 +00:00
|
|
|
fn run(mut config: Config, options: &cli::Options) -> Result<(), Box<Error>> {
|
2017-01-23 16:45:40 +00:00
|
|
|
// Initialize the logger first as to capture output from other subsystems
|
2017-11-29 23:38:29 +00:00
|
|
|
logging::initialize(options)?;
|
2017-01-23 16:45:40 +00:00
|
|
|
|
2017-01-13 07:15:06 +00:00
|
|
|
info!("Welcome to Alacritty.");
|
2018-05-11 18:22:36 +00:00
|
|
|
if let Some(config_path) = config.path() {
|
2017-09-11 18:12:25 +00:00
|
|
|
info!("Configuration loaded from {}", config_path.display());
|
2018-05-11 18:22:36 +00:00
|
|
|
};
|
2017-01-13 07:15:06 +00:00
|
|
|
|
2018-11-11 12:55:28 +00:00
|
|
|
// Set environment variables
|
|
|
|
tty::setup_env(&config);
|
|
|
|
|
2016-12-11 06:44:13 +00:00
|
|
|
// Create a display.
|
|
|
|
//
|
|
|
|
// The display manages a window and can draw the terminal
|
2017-11-29 23:38:29 +00:00
|
|
|
let mut display = Display::new(&config, options)?;
|
2016-12-11 06:44:13 +00:00
|
|
|
|
2017-01-13 07:15:06 +00:00
|
|
|
info!(
|
2016-12-30 01:39:30 +00:00
|
|
|
"PTY Dimensions: {:?} x {:?}",
|
|
|
|
display.size().lines(),
|
|
|
|
display.size().cols()
|
|
|
|
);
|
|
|
|
|
2016-12-11 06:44:13 +00:00
|
|
|
// Create the terminal
|
|
|
|
//
|
|
|
|
// This object contains all of the state about what's being displayed. It's
|
|
|
|
// wrapped in a clonable mutex since both the I/O loop and display need to
|
|
|
|
// access it.
|
2017-01-09 03:18:39 +00:00
|
|
|
let terminal = Term::new(&config, display.size().to_owned());
|
2016-12-30 02:38:22 +00:00
|
|
|
let terminal = Arc::new(FairMutex::new(terminal));
|
2016-12-11 06:44:13 +00:00
|
|
|
|
2017-05-28 03:08:28 +00:00
|
|
|
// Find the window ID for setting $WINDOWID
|
|
|
|
let window_id = display.get_window_id();
|
|
|
|
|
2016-12-11 06:44:13 +00:00
|
|
|
// Create the pty
|
|
|
|
//
|
|
|
|
// The pty forks a process to run the shell on the slave side of the
|
|
|
|
// pseudoterminal. A file descriptor for the master side is retained for
|
|
|
|
// reading/writing to the shell.
|
2018-10-16 17:02:52 +00:00
|
|
|
let pty = tty::new(&config, options, &display.size(), window_id);
|
|
|
|
|
|
|
|
// Get a reference to something that we can resize
|
|
|
|
//
|
|
|
|
// This exists because rust doesn't know the interface is thread-safe
|
|
|
|
// and we need to be able to resize the PTY from the main thread while the IO
|
|
|
|
// thread owns the EventedRW object.
|
|
|
|
#[cfg(windows)]
|
|
|
|
let resize_handle = unsafe { &mut *pty.winpty.get() };
|
|
|
|
#[cfg(not(windows))]
|
2018-10-27 18:54:28 +00:00
|
|
|
let resize_handle = &mut pty.fd.as_raw_fd();
|
2016-11-12 01:40:12 +00:00
|
|
|
|
2016-12-11 06:44:13 +00:00
|
|
|
// Create the pseudoterminal I/O loop
|
|
|
|
//
|
|
|
|
// pty I/O is ran on another thread as to not occupy cycles used by the
|
|
|
|
// renderer and input processing. Note that access to the terminal state is
|
|
|
|
// synchronized since the I/O loop updates the state, and the display
|
|
|
|
// consumes it periodically.
|
2016-09-24 23:11:50 +00:00
|
|
|
let event_loop = EventLoop::new(
|
2017-09-28 00:29:44 +00:00
|
|
|
Arc::clone(&terminal),
|
2016-12-11 06:44:13 +00:00
|
|
|
display.notifier(),
|
2018-10-16 17:02:52 +00:00
|
|
|
pty,
|
2016-12-05 00:27:20 +00:00
|
|
|
options.ref_test,
|
2016-09-18 18:17:44 +00:00
|
|
|
);
|
2016-09-01 17:24:20 +00:00
|
|
|
|
2016-12-11 07:32:12 +00:00
|
|
|
// The event loop channel allows write requests from the event processor
|
|
|
|
// to be sent to the loop and ultimately written to the pty.
|
2016-09-24 23:11:50 +00:00
|
|
|
let loop_tx = event_loop.channel();
|
|
|
|
|
2016-09-01 17:24:20 +00:00
|
|
|
// Event processor
|
2016-12-12 06:02:03 +00:00
|
|
|
//
|
|
|
|
// Need the Rc<RefCell<_>> here since a ref is shared in the resize callback
|
2016-12-12 17:31:48 +00:00
|
|
|
let mut processor = event::Processor::new(
|
2017-05-20 04:35:43 +00:00
|
|
|
event_loop::Notifier(event_loop.channel()),
|
2016-12-11 07:32:12 +00:00
|
|
|
display.resize_channel(),
|
2017-11-29 23:38:29 +00:00
|
|
|
options,
|
2016-11-20 00:16:20 +00:00
|
|
|
&config,
|
2016-12-05 00:27:20 +00:00
|
|
|
options.ref_test,
|
2016-12-29 20:30:30 +00:00
|
|
|
display.size().to_owned(),
|
2016-12-12 17:31:48 +00:00
|
|
|
);
|
2016-09-01 17:24:20 +00:00
|
|
|
|
2016-12-11 07:32:12 +00:00
|
|
|
// Create a config monitor when config was loaded from path
|
|
|
|
//
|
|
|
|
// The monitor watches the config file for changes and reloads it. Pending
|
|
|
|
// config changes are processed in the main loop.
|
2017-08-29 16:32:08 +00:00
|
|
|
let config_monitor = match (options.live_config_reload, config.live_config_reload()) {
|
|
|
|
// Start monitor if CLI flag says yes
|
|
|
|
(Some(true), _) |
|
|
|
|
// Or if no CLI flag was passed and the config says yes
|
|
|
|
(None, true) => config.path()
|
|
|
|
.map(|path| config::Monitor::new(path, display.notifier())),
|
|
|
|
// Otherwise, don't start the monitor
|
|
|
|
_ => None,
|
|
|
|
};
|
2016-10-27 17:05:04 +00:00
|
|
|
|
2016-12-11 07:32:12 +00:00
|
|
|
// Kick off the I/O thread
|
2018-10-16 17:02:52 +00:00
|
|
|
let _io_thread = event_loop.spawn(None);
|
|
|
|
|
|
|
|
info!("Initialisation complete");
|
2016-10-27 17:05:04 +00:00
|
|
|
|
2016-12-11 07:32:12 +00:00
|
|
|
// Main display loop
|
2016-09-01 17:24:20 +00:00
|
|
|
loop {
|
2016-12-11 07:32:12 +00:00
|
|
|
// Process input and window events
|
2018-09-23 16:21:47 +00:00
|
|
|
let mut terminal_lock = processor.process_events(&terminal, display.window());
|
2016-09-01 17:24:20 +00:00
|
|
|
|
2016-12-04 23:48:12 +00:00
|
|
|
// Handle config reloads
|
2018-05-11 18:22:36 +00:00
|
|
|
if let Some(new_config) = config_monitor
|
|
|
|
.as_ref()
|
2016-12-11 07:32:12 +00:00
|
|
|
.and_then(|monitor| monitor.pending_config())
|
2018-05-11 18:22:36 +00:00
|
|
|
{
|
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
|
|
|
config = new_config.update_dynamic_title(options);
|
2018-05-11 18:22:36 +00:00
|
|
|
display.update_config(&config);
|
|
|
|
processor.update_config(&config);
|
2018-09-23 16:21:47 +00:00
|
|
|
terminal_lock.update_config(&config);
|
|
|
|
terminal_lock.dirty = true;
|
2018-05-11 18:22:36 +00:00
|
|
|
}
|
2016-10-27 17:05:04 +00:00
|
|
|
|
2016-09-01 17:24:20 +00:00
|
|
|
// Maybe draw the terminal
|
2018-09-23 16:21:47 +00:00
|
|
|
if terminal_lock.needs_draw() {
|
2017-07-25 00:54:06 +00:00
|
|
|
// Try to update the position of the input method editor
|
2018-11-10 16:08:48 +00:00
|
|
|
#[cfg(not(windows))]
|
2018-09-23 16:21:47 +00:00
|
|
|
display.update_ime_position(&terminal_lock);
|
2018-10-27 18:54:28 +00:00
|
|
|
|
2016-12-12 17:31:48 +00:00
|
|
|
// Handle pending resize events
|
|
|
|
//
|
|
|
|
// The second argument is a list of types that want to be notified
|
|
|
|
// of display size changes.
|
2018-10-16 17:02:52 +00:00
|
|
|
display.handle_resize(&mut terminal_lock, &config, &mut [resize_handle, &mut processor]);
|
|
|
|
|
2018-09-23 16:21:47 +00:00
|
|
|
drop(terminal_lock);
|
2016-12-12 17:31:48 +00:00
|
|
|
|
|
|
|
// Draw the current state of the terminal
|
2018-09-23 16:21:47 +00:00
|
|
|
display.draw(&terminal, &config);
|
2016-09-01 17:24:20 +00:00
|
|
|
}
|
2016-08-30 02:23:04 +00:00
|
|
|
|
2016-12-04 23:48:12 +00:00
|
|
|
// Begin shutdown if the flag was raised.
|
2016-09-01 17:24:20 +00:00
|
|
|
if process_should_exit() {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2016-09-01 04:16:17 +00:00
|
|
|
|
2018-10-16 17:02:52 +00:00
|
|
|
loop_tx
|
|
|
|
.send(Msg::Shutdown)
|
|
|
|
.expect("Error sending shutdown to event loop");
|
2017-05-20 04:35:43 +00:00
|
|
|
|
2016-12-11 07:32:12 +00:00
|
|
|
// FIXME patch notify library to have a shutdown method
|
2016-10-27 17:05:04 +00:00
|
|
|
// config_reloader.join().ok();
|
|
|
|
|
2018-10-27 04:47:01 +00:00
|
|
|
// Without explicitly detaching the console cmd won't redraw it's prompt
|
|
|
|
#[cfg(windows)]
|
|
|
|
unsafe { FreeConsole(); }
|
|
|
|
|
2016-12-11 06:44:13 +00:00
|
|
|
Ok(())
|
2016-08-30 02:23:04 +00:00
|
|
|
}
|