diff options
author | Jake Merdich <jake@merdich.com> | 2017-06-23 10:01:53 -0700 |
---|---|---|
committer | Joe Wilm <jwilm@users.noreply.github.com> | 2017-06-23 11:27:15 -0700 |
commit | b4a839aee9784a2d281be1bec87ac6f2ae4a79f0 (patch) | |
tree | 19a72d9a8a80c472a5cc4bf431e769695b01a02c /src/lib.rs | |
parent | 0091d3cb99e69ffc946ab6bbf40530ff8694b246 (diff) | |
download | alacritty-b4a839aee9784a2d281be1bec87ac6f2ae4a79f0.tar.gz alacritty-b4a839aee9784a2d281be1bec87ac6f2ae4a79f0.zip |
Add dim color support
Add support for the VTE 'dim' flag, with additional support for
custom-themed dim colors. If no color is specified in the config, it
will default to 2/3 the previous (not a spec, but the value other
terminals seem to use).
The actual dimming behavior brings bright colors to normal and regular
colors to the new dim ones. Custom RGB values are not changed, nor are
non-named indexed colors.
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -71,6 +71,8 @@ pub mod tty; pub mod util; pub mod window; +use std::ops::Mul; + pub use grid::Grid; pub use term::Term; @@ -81,6 +83,24 @@ pub struct Rgb { pub b: u8, } +// a multiply function for Rgb, as the default dim is just *2/3 +impl Mul<f32> for Rgb { + type Output = Rgb; + + fn mul(self, rhs: f32) -> Rgb { + let result = Rgb { + r: (self.r as f32 * rhs).max(0.0).min(255.0) as u8, + g: (self.g as f32 * rhs).max(0.0).min(255.0) as u8, + b: (self.b as f32 * rhs).max(0.0).min(255.0) as u8 + }; + + trace!("Scaling RGB by {} from {:?} to {:?}", rhs, self, result); + + result + } +} + + #[cfg_attr(feature = "clippy", allow(too_many_arguments))] #[cfg_attr(feature = "clippy", allow(doc_markdown))] pub mod gl { |