Skip to content

Commit

Permalink
Merge master into scrollback
Browse files Browse the repository at this point in the history
* 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
#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 5ba34d4 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 #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.
  • Loading branch information
chrisduerr committed Jul 28, 2018
1 parent 0ca5c7a commit c4a0f9c
Show file tree
Hide file tree
Showing 20 changed files with 488 additions and 211 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Expand Up @@ -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
Expand All @@ -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 changes: 242 additions & 184 deletions Cargo.lock

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions Cargo.toml
Expand Up @@ -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
Expand Down Expand Up @@ -43,6 +45,7 @@ x11-dl = "2"

[target.'cfg(target_os = "macos")'.dependencies]
objc = "0.2.2"
dirs = "1.0.2"

[features]
default = []
Expand All @@ -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"],
]
23 changes: 19 additions & 4 deletions README.md
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion alacritty-completions.bash
Expand Up @@ -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))" ]]
Expand Down
12 changes: 12 additions & 0 deletions alacritty.yml
Expand Up @@ -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'
Expand Down Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions alacritty_macos.yml
Expand Up @@ -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'
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -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" }
2 changes: 1 addition & 1 deletion font/src/darwin/mod.rs
Expand Up @@ -631,7 +631,7 @@ mod tests {
};
print!("{}", c);
}
print!("\n");
println!();
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions font/src/ft/fc/mod.rs
Expand Up @@ -326,7 +326,7 @@ mod tests {
print!("embeddedbitmap={:?}; ", font.embeddedbitmap());
print!("lcdfilter={:?}; ", font.lcdfilter());
print!("hintstyle={:?}", font.hintstyle());
println!("");
println!();
}

#[test]
Expand All @@ -346,7 +346,7 @@ mod tests {
print!("style={:?}; ", font.style());
print!("rgba={:?}", font.rgba());
print!("rgba={:?}", font.rgba());
println!("");
println!();
}
}

Expand All @@ -367,7 +367,7 @@ mod tests {
print!("family={:?}; ", font.family());
print!("style={:?}; ", font.style());
print!("rgba={:?}", font.rgba());
println!("");
println!();
}
}
}
23 changes: 17 additions & 6 deletions font/src/ft/mod.rs
Expand Up @@ -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,
})
}
Expand Down Expand Up @@ -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();
Expand All @@ -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 => {
Expand Down Expand Up @@ -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 => {
Expand All @@ -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)
}
Expand Down
23 changes: 23 additions & 0 deletions src/ansi.rs
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -601,6 +608,7 @@ impl NamedColor {
NamedColor::BrightMagenta => NamedColor::Magenta,
NamedColor::BrightCyan => NamedColor::Cyan,
NamedColor::BrightWhite => NamedColor::White,
NamedColor::BrightForeground => NamedColor::Foreground,
val => val
}
}
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit c4a0f9c

Please sign in to comment.