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 5ba34d4f97 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.
This commit is contained in:
Christian Duerr 2018-07-28 23:10:13 +00:00 committed by GitHub
parent 0ca5c7a695
commit c4a0f9c4cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 488 additions and 211 deletions

View File

@ -16,7 +16,7 @@ env:
- CLIPPY=""
install:
- if [ -n "$CLIPPY" ]; then cargo install -f clippy; fi
- if [ -n "$CLIPPY" ]; then rustup component add clippy-preview; fi
matrix:
fast_finish: true
@ -31,3 +31,4 @@ matrix:
script:
- if [ -n "$CLIPPY" ]; then cargo clippy --all-features --all-targets; fi
- if [ -z "$CLIPPY" ]; then cargo test; fi
- if [ -z "$CLIPPY" ]; then cargo test -p font; fi

426
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -5,6 +5,8 @@ authors = ["Joe Wilm <joe@jwilm.com>"]
license = "Apache-2.0"
build = "build.rs"
description = "GPU-accelerated terminal emulator"
readme = "README.md"
homepage = "https://github.com/jwilm/alacritty"
[[bin]]
doc = false
@ -43,6 +45,7 @@ x11-dl = "2"
[target.'cfg(target_os = "macos")'.dependencies]
objc = "0.2.2"
dirs = "1.0.2"
[features]
default = []
@ -56,3 +59,23 @@ gl_generator = "0.9"
[profile.release]
debug = 1
[package.metadata.deb]
maintainer = "Joe Wilm <joe@jwilm.com>"
license-file = ["LICENSE-APACHE", "3"]
extended-description = """\
Alacritty is the fastest terminal emulator in existence. Using the GPU for \
rendering enables optimizations that simply aren't possible in other emulators. \
Alacritty currently supports FreeBSD, Linux, macOS, and OpenBSD. Windows \
support is planned before the 1.0 release. """
depends = "$auto, cmake, libfreetype6-dev, libfontconfig1-dev, xclip"
section = "rust"
priority = "optional"
assets = [
["target/release/alacritty", "usr/local/bin/", "755"],
["alacritty.desktop", "usr/share/applications/", "644"],
["alacritty-completions.bash", "usr/share/bash-completion/completions/alacritty", "644"],
["alacritty-completions.fish", "usr/share/fish/completions/alacritty", "644"],
["alacritty-completions.zsh", "usr/share/zsh/functions/Completion/alacritty", "644"],
["alacritty.info", "usr/share/terminfo/a/alacritty", "644"],
]

View File

@ -49,6 +49,17 @@ cd alacritty-git
makepkg -isr
```
### Debian/Ubuntu
Using `cargo deb`, you can create and install a deb file.
```sh
git clone https://github.com/jwilm/alacritty.git
cd alacritty
cargo install cargo-deb
cargo deb --install
```
### openSUSE Tumbleweed Linux
```sh
@ -86,11 +97,14 @@ xbps-install alacritty
rustup update stable
```
#### Ubuntu
#### Debian/Ubuntu
On Ubuntu, you need a few extra libraries to build Alacritty. Here's an `apt`
command that should install all of them. If something is still found to be
missing, please open an issue.
You can build alacritty using `cargo deb` and use your system's package manager
to maintain the application using the instructions [above](#debianubuntu).
If you'd still like to build a local version manually, you need a few extra
libraries to build Alacritty. Here's an apt command that should install all of
them. If something is still found to be missing, please open an issue.
```sh
apt-get install cmake libfreetype6-dev libfontconfig1-dev xclip
@ -244,6 +258,7 @@ cargo build --release
If all goes well, this should place a binary at `target/release/alacritty`.
##### Desktop Entry
Many linux distributions support desktop entries for adding applications to

View File

@ -15,7 +15,6 @@ _alacritty()
# If `--command` or `-e` is used, stop completing
for i in "${!COMP_WORDS[@]}"; do
echo "${COMP_WORDS[i]}" >> ./testfile
if [[ "${COMP_WORDS[i]}" == "--command" ]] \
|| [[ "${COMP_WORDS[i]}" == "-e" ]] \
&& [[ "${#COMP_WORDS[@]}" -gt "$(($i + 2))" ]]

View File

@ -141,6 +141,15 @@ colors:
background: '0x000000'
foreground: '0xeaeaea'
# (Optional) Bright and Dim foreground colors
#
# The dimmed foreground color is calculated automatically if it is not present.
# If the bright foreground color is not set, or `draw_bold_text_with_bright_colors`
# is `false`, the normal foreground color will be used.
#
# dim_foreground: '0x9a9a9a'
# bright_foreground: '0xffffff'
# Colors the cursor will use if `custom_cursor_colors` is true
cursor:
text: '0x000000'
@ -250,6 +259,9 @@ hide_cursor_when_typing: false
# - Beam
cursor_style: Block
# Whether the cursor should be a hollow block on window focus loss
unfocused_hollow_cursor: true
# Live config reload (changes require restart)
live_config_reload: true

View File

@ -119,6 +119,15 @@ colors:
background: '0x000000'
foreground: '0xeaeaea'
# (Optional) Bright and Dim foreground colors
#
# The dimmed foreground color is calculated automatically if it is not present.
# If the bright foreground color is not set, or `draw_bold_text_with_bright_colors`
# is `false`, the normal foreground color will be used.
#
# dim_foreground: '0x9a9a9a'
# bright_foreground: '0xffffff'
# Colors the cursor will use if `custom_cursor_colors` is true
cursor:
text: '0x000000'
@ -229,6 +238,9 @@ hide_cursor_when_typing: false
# - Beam
cursor_style: Block
# Whether the cursor should be a hollow block on window focus loss
unfocused_hollow_cursor: true
# Live config reload (changes require restart)
live_config_reload: true
@ -293,6 +305,7 @@ key_bindings:
- { key: C, mods: Command, action: Copy }
- { key: Paste, action: Paste }
- { key: Copy, action: Copy }
- { key: H, mods: Command, action: Hide }
- { key: Q, mods: Command, action: Quit }
- { key: W, mods: Command, action: Quit }
- { key: Home, chars: "\x1bOH", mode: AppCursor }
@ -393,3 +406,4 @@ key_bindings:
- { key: F10, mods: Command, chars: "\x1b[21;3~" }
- { key: F11, mods: Command, chars: "\x1b[23;3~" }
- { key: F12, mods: Command, chars: "\x1b[24;3~" }
- { key: NumpadEnter, chars: "\n" }

View File

@ -631,7 +631,7 @@ mod tests {
};
print!("{}", c);
}
print!("\n");
println!();
}
}
}

View File

@ -326,7 +326,7 @@ mod tests {
print!("embeddedbitmap={:?}; ", font.embeddedbitmap());
print!("lcdfilter={:?}; ", font.lcdfilter());
print!("hintstyle={:?}", font.hintstyle());
println!("");
println!();
}
#[test]
@ -346,7 +346,7 @@ mod tests {
print!("style={:?}; ", font.style());
print!("rgba={:?}", font.rgba());
print!("rgba={:?}", font.rgba());
println!("");
println!();
}
}
@ -367,7 +367,7 @@ mod tests {
print!("family={:?}; ", font.family());
print!("style={:?}; ", font.style());
print!("rgba={:?}", font.rgba());
println!("");
println!();
}
}
}

View File

@ -348,14 +348,14 @@ impl FreeTypeRasterizer {
let glyph = face.ft_face.glyph();
glyph.render_glyph(face.render_mode)?;
let (pixel_width, buf) = Self::normalize_buffer(&glyph.bitmap())?;
let (pixel_height, pixel_width, buf) = Self::normalize_buffer(&glyph.bitmap())?;
Ok(RasterizedGlyph {
c: glyph_key.c,
top: glyph.bitmap_top(),
left: glyph.bitmap_left(),
width: pixel_width,
height: glyph.bitmap().rows(),
height: pixel_height,
buf,
})
}
@ -427,7 +427,7 @@ impl FreeTypeRasterizer {
/// Given a FreeType `Bitmap`, returns packed buffer with 1 byte per LCD channel.
///
/// The i32 value in the return type is the number of pixels per row.
fn normalize_buffer(bitmap: &freetype::bitmap::Bitmap) -> freetype::FtResult<(i32, Vec<u8>)> {
fn normalize_buffer(bitmap: &freetype::bitmap::Bitmap) -> freetype::FtResult<(i32, i32, Vec<u8>)> {
use freetype::bitmap::PixelMode;
let buf = bitmap.buffer();
@ -440,7 +440,18 @@ impl FreeTypeRasterizer {
let stop = start + bitmap.width() as usize;
packed.extend_from_slice(&buf[start..stop]);
}
Ok((bitmap.width() / 3, packed))
Ok((bitmap.rows(), bitmap.width() / 3, packed))
},
PixelMode::LcdV => {
for i in 0..bitmap.rows()/3 {
for j in 0..bitmap.width() {
for k in 0..3 {
let offset = ((i as usize) * 3 + k) * pitch + (j as usize);
packed.push(buf[offset]);
}
}
}
Ok((bitmap.rows() / 3, bitmap.width(), packed))
},
// Mono data is stored in a packed format using 1 bit per pixel.
PixelMode::Mono => {
@ -471,7 +482,7 @@ impl FreeTypeRasterizer {
byte += 1;
}
}
Ok((bitmap.width(), packed))
Ok((bitmap.rows(), bitmap.width(), packed))
},
// Gray data is stored as a value between 0 and 255 using 1 byte per pixel.
PixelMode::Gray => {
@ -484,7 +495,7 @@ impl FreeTypeRasterizer {
packed.push(*byte);
}
}
Ok((bitmap.width(), packed))
Ok((bitmap.rows(), bitmap.width(), packed))
},
mode => panic!("unhandled pixel mode: {:?}", mode)
}

View File

@ -558,11 +558,16 @@ pub enum NamedColor {
DimCyan,
/// Dim white
DimWhite,
/// The bright foreground color
BrightForeground,
/// Dim foreground
DimForeground,
}
impl NamedColor {
pub fn to_bright(self) -> Self {
match self {
NamedColor::Foreground => NamedColor::BrightForeground,
NamedColor::Black => NamedColor::BrightBlack,
NamedColor::Red => NamedColor::BrightRed,
NamedColor::Green => NamedColor::BrightGreen,
@ -571,6 +576,7 @@ impl NamedColor {
NamedColor::Magenta => NamedColor::BrightMagenta,
NamedColor::Cyan => NamedColor::BrightCyan,
NamedColor::White => NamedColor::BrightWhite,
NamedColor::DimForeground => NamedColor::Foreground,
NamedColor::DimBlack => NamedColor::Black,
NamedColor::DimRed => NamedColor::Red,
NamedColor::DimGreen => NamedColor::Green,
@ -593,6 +599,7 @@ impl NamedColor {
NamedColor::Magenta => NamedColor::DimMagenta,
NamedColor::Cyan => NamedColor::DimCyan,
NamedColor::White => NamedColor::DimWhite,
NamedColor::Foreground => NamedColor::DimForeground,
NamedColor::BrightBlack => NamedColor::Black,
NamedColor::BrightRed => NamedColor::Red,
NamedColor::BrightGreen => NamedColor::Green,
@ -601,6 +608,7 @@ impl NamedColor {
NamedColor::BrightMagenta => NamedColor::Magenta,
NamedColor::BrightCyan => NamedColor::Cyan,
NamedColor::BrightWhite => NamedColor::White,
NamedColor::BrightForeground => NamedColor::Foreground,
val => val
}
}
@ -814,6 +822,21 @@ impl<'a, H, W> vte::Perform for Performer<'a, H, W>
unhandled(params);
}
// Set cursor style
b"50" => {
if params.len() >= 2 && params[1].len() >= 13 && params[1][0..12] == *b"CursorShape=" {
let style = match params[1][12] as char {
'0' => CursorStyle::Block,
'1' => CursorStyle::Beam,
'2' => CursorStyle::Underline,
_ => return unhandled(params),
};
self.handler.set_cursor_style(Some(style));
return;
}
unhandled(params);
}
// Set clipboard
b"52" => {
if params.len() < 3 {

View File

@ -373,6 +373,10 @@ pub struct Config {
#[serde(default, deserialize_with = "failure_default")]
cursor_style: CursorStyle,
/// Use hollow block cursor when unfocused
#[serde(default="true_bool", deserialize_with = "default_true_bool")]
unfocused_hollow_cursor: bool,
/// Live config reload
#[serde(default="true_bool", deserialize_with = "default_true_bool")]
live_config_reload: bool,
@ -593,7 +597,8 @@ impl<'a> de::Deserialize<'a> for ActionWrapper {
fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("Paste, Copy, PasteSelection, IncreaseFontSize, DecreaseFontSize, \
ResetFontSize, ScrollPageUp, ScrollPageDown, ScrollToTop, ScrollToBottom or Quit")
ResetFontSize, ScrollPageUp, ScrollPageDown, ScrollToTop, \
ScrollToBottom, Hide, or Quit")
}
fn visit_str<E>(self, value: &str) -> ::std::result::Result<ActionWrapper, E>
@ -610,6 +615,7 @@ impl<'a> de::Deserialize<'a> for ActionWrapper {
"ScrollPageDown" => Action::ScrollPageDown,
"ScrollToTop" => Action::ScrollToTop,
"ScrollToBottom" => Action::ScrollToBottom,
"Hide" => Action::Hide,
"Quit" => Action::Quit,
_ => return Err(E::invalid_value(Unexpected::Str(value), &self)),
}))
@ -1070,6 +1076,26 @@ pub struct PrimaryColors {
pub background: Rgb,
#[serde(deserialize_with = "rgb_from_hex")]
pub foreground: Rgb,
#[serde(default, deserialize_with = "deserialize_optional_color")]
pub bright_foreground: Option<Rgb>,
#[serde(default, deserialize_with = "deserialize_optional_color")]
pub dim_foreground: Option<Rgb>,
}
fn deserialize_optional_color<'a, D>(deserializer: D) -> ::std::result::Result<Option<Rgb>, D::Error>
where D: de::Deserializer<'a>
{
match Option::deserialize(deserializer) {
Ok(Some(color)) => {
let color: serde_yaml::Value = color;
Ok(Some(rgb_from_hex(color).unwrap()))
},
Ok(None) => Ok(None),
Err(err) => {
eprintln!("problem with config: {}; Using standard foreground color", err);
Ok(None)
},
}
}
impl Default for PrimaryColors {
@ -1077,6 +1103,8 @@ impl Default for PrimaryColors {
PrimaryColors {
background: Rgb { r: 0, g: 0, b: 0 },
foreground: Rgb { r: 0xea, g: 0xea, b: 0xea },
bright_foreground: None,
dim_foreground: None,
}
}
}
@ -1415,6 +1443,12 @@ impl Config {
self.cursor_style
}
/// Use hollow block cursor when unfocused
#[inline]
pub fn unfocused_hollow_cursor(&self) -> bool {
self.unfocused_hollow_cursor
}
/// Live config reload
#[inline]
pub fn live_config_reload(&self) -> bool {

View File

@ -39,6 +39,7 @@ pub struct ActionContext<'a, N: 'a> {
pub received_count: &'a mut usize,
pub suppress_chars: &'a mut bool,
pub last_modifiers: &'a mut ModifiersState,
pub window_changes: &'a mut WindowChanges,
}
impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> {
@ -138,6 +139,33 @@ impl<'a, N: Notify + 'a> input::ActionContext for ActionContext<'a, N> {
fn last_modifiers(&mut self) -> &mut ModifiersState {
&mut self.last_modifiers
}
#[inline]
fn hide_window(&mut self) {
self.window_changes.hide = true;
}
}
/// The ActionContext can't really have direct access to the Window
/// with the current design. Event handlers that want to change the
/// window must set these flags instead. The processor will trigger
/// the actual changes.
pub struct WindowChanges {
pub hide: bool,
}
impl WindowChanges {
fn clear(&mut self) {
self.hide = false;
}
}
impl Default for WindowChanges {
fn default() -> WindowChanges {
WindowChanges {
hide: false,
}
}
}
pub enum ClickState {
@ -204,6 +232,7 @@ pub struct Processor<N> {
suppress_chars: bool,
last_modifiers: ModifiersState,
pending_events: Vec<Event>,
window_changes: WindowChanges,
}
/// Notify that the terminal was resized
@ -246,6 +275,7 @@ impl<N: Notify> Processor<N> {
suppress_chars: false,
last_modifiers: Default::default(),
pending_events: Vec::with_capacity(4),
window_changes: Default::default(),
}
}
@ -398,6 +428,7 @@ impl<N: Notify> Processor<N> {
received_count: &mut self.received_count,
suppress_chars: &mut self.suppress_chars,
last_modifiers: &mut self.last_modifiers,
window_changes: &mut self.window_changes,
};
processor = input::Processor {
@ -442,6 +473,11 @@ impl<N: Notify> Processor<N> {
window.is_focused = window_is_focused;
}
if self.window_changes.hide {
window.hide();
}
self.window_changes.clear();
self.wait_for_event = !terminal.dirty;
terminal

View File

@ -69,6 +69,7 @@ pub trait ActionContext {
fn change_font_size(&mut self, delta: f32);
fn reset_font_size(&mut self);
fn scroll(&mut self, scroll: Scroll);
fn hide_window(&mut self);
}
/// Describes a state and action to take in that state
@ -185,6 +186,9 @@ pub enum Action {
/// Run given command
Command(String, Vec<String>),
/// Hides the Alacritty window
Hide,
/// Quits Alacritty.
Quit,
}
@ -240,6 +244,9 @@ impl Action {
},
}
},
Action::Hide => {
ctx.hide_window();
},
Action::Quit => {
// FIXME should do a more graceful shutdown
::std::process::exit(0);
@ -570,7 +577,7 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> {
return;
}
self.process_mouse_bindings(ModifiersState::default(), button);
self.process_mouse_bindings(modifiers, button);
}
/// Process key input
@ -665,7 +672,7 @@ mod tests {
use glutin::{VirtualKeyCode, Event, WindowEvent, ElementState, MouseButton, ModifiersState};
use term::{SizeInfo, Term, TermMode};
use event::{Mouse, ClickState};
use event::{Mouse, ClickState, WindowChanges};
use config::{self, Config, ClickHandler};
use index::{Point, Side};
use selection::Selection;
@ -691,6 +698,7 @@ mod tests {
pub received_count: usize,
pub suppress_chars: bool,
pub last_modifiers: ModifiersState,
pub window_changes: &'a mut WindowChanges,
}
impl <'a>super::ActionContext for ActionContext<'a> {
@ -748,6 +756,8 @@ mod tests {
}
fn reset_font_size(&mut self) {
}
fn hide_window(&mut self) {
}
}
macro_rules! test_clickstate {
@ -786,6 +796,7 @@ mod tests {
received_count: 0,
suppress_chars: false,
last_modifiers: ModifiersState::default(),
window_changes: &mut WindowChanges::default(),
};
let mut processor = Processor {

View File

@ -47,7 +47,7 @@ impl<T: Send + io::Write> log::Log for Logger<T> {
fn log(&self, record: &log::Record) {
if self.enabled(record.metadata()) && record.target().starts_with("alacritty") {
if let Ok(ref mut writer) = self.output.lock() {
writer.write_all(format!("{}\n", record.args()).as_ref()).expect("Error while logging!");
let _ = writer.write_all(format!("{}\n", record.args()).as_ref());
}
}
}

View File

@ -29,3 +29,19 @@ macro_rules! maybe {
}
}
}
#[macro_export]
macro_rules! print {
($($arg:tt)*) => {{
use std::io::Write;
let _ = write!(::std::io::stdout(), $($arg)*);
}};
}
#[macro_export]
macro_rules! eprint {
($($arg:tt)*) => {{
use std::io::Write;
let _ = write!(::std::io::stderr(), $($arg)*);
}};
}

View File

@ -22,6 +22,8 @@ extern crate alacritty;
#[macro_use]
extern crate log;
#[cfg(target_os = "macos")]
extern crate dirs;
use std::error::Error;
use std::sync::Arc;
@ -48,7 +50,7 @@ fn main() {
// Switch to home directory
#[cfg(target_os = "macos")]
env::set_current_dir(env::home_dir().unwrap()).unwrap();
env::set_current_dir(dirs::home_dir().unwrap()).unwrap();
// Set locale
#[cfg(target_os = "macos")]
locale::set_locale_environment();
@ -178,7 +180,7 @@ fn run(mut config: Config, options: &cli::Options) -> Result<(), Box<Error>> {
.as_ref()
.and_then(|monitor| monitor.pending_config())
{
config = new_config.update_dynamic_title(&options);
config = new_config.update_dynamic_title(options);
display.update_config(&config);
processor.update_config(&config);
terminal.update_config(&config);

View File

@ -4,7 +4,7 @@ use std::fmt;
use {Rgb, ansi};
use config::Colors;
pub const COUNT: usize = 268;
pub const COUNT: usize = 270;
/// List of indexed colors
///
@ -13,6 +13,7 @@ pub const COUNT: usize = 268;
/// the configured foreground color, item 257 is the configured background
/// color, item 258 is the cursor foreground color, item 259 is the cursor
/// background color. Following that are 8 positions for dim colors.
/// Item 268 is the bright foreground color, 269 the dim foreground.
#[derive(Copy, Clone)]
pub struct List([Rgb; COUNT]);
@ -50,6 +51,10 @@ impl List {
self[ansi::NamedColor::BrightMagenta] = colors.bright.magenta;
self[ansi::NamedColor::BrightCyan] = colors.bright.cyan;
self[ansi::NamedColor::BrightWhite] = colors.bright.white;
self[ansi::NamedColor::BrightForeground] = colors
.primary
.bright_foreground
.unwrap_or(colors.primary.foreground);
// Foreground and background
self[ansi::NamedColor::Foreground] = colors.primary.foreground;
@ -60,6 +65,10 @@ impl List {
self[ansi::NamedColor::Cursor] = colors.cursor.cursor;
// Dims
self[ansi::NamedColor::DimForeground] = colors
.primary
.dim_foreground
.unwrap_or(colors.primary.foreground * 0.66);
match colors.dim {
Some(ref dim) => {
trace!("Using config-provided dim colors");

View File

@ -320,11 +320,18 @@ impl<'a> RenderableCellsIter<'a> {
Color::Spec(rgb) => rgb,
Color::Named(ansi) => {
match (self.config.draw_bold_text_with_bright_colors(), cell.flags & Flags::DIM_BOLD) {
// If no bright foreground is set, treat it like the BOLD flag doesn't exist
(_, self::cell::Flags::DIM_BOLD)
if ansi == NamedColor::Foreground
&& self.config.colors().primary.bright_foreground.is_none() =>
{
self.colors[NamedColor::DimForeground]
}
// Draw bold text in bright colors *and* contains bold flag.
(true, self::cell::Flags::DIM_BOLD) |
(true, self::cell::Flags::BOLD) => self.colors[ansi.to_bright()],
(true, self::cell::Flags::BOLD) => self.colors[ansi.to_bright()],
// Cell is marked as dim and not bold
(_, self::cell::Flags::DIM) => self.colors[ansi.to_dim()],
(_, self::cell::Flags::DIM) |
(false, self::cell::Flags::DIM_BOLD) => self.colors[ansi.to_dim()],
// None of the above, keep original color.
_ => self.colors[ansi]
}
@ -412,6 +419,7 @@ impl<'a> Iterator for RenderableCellsIter<'a> {
if cell.is_empty() && !selected {
continue;
}
(cell, selected)
};
@ -1071,7 +1079,7 @@ impl Term {
.map(|span| {
span.to_locations()
});
let cursor = if window_focused {
let cursor = if window_focused || !config.unfocused_hollow_cursor() {
self.cursor_style.unwrap_or(self.default_cursor_style)
} else {
CursorStyle::HollowBlock

View File

@ -379,6 +379,11 @@ impl Window {
pub fn get_window_id(&self) -> Option<usize> {
None
}
/// Hide the window
pub fn hide(&self) {
self.window.hide();
}
}
pub trait OsExtensions {