term: revise color cube in the default palette
This commit adjusts the default color palette to use the same color cube calculation as xterm; it isn't the ideal color cube calculation and results in slightly brighter colors. This commit also memoizes the default palette calculation so that it isn't recomputed each time a palette is created. refs: https://github.com/wez/wezterm/issues/348
This commit is contained in:
1 parent
d99b025e24
commit
dfde0c8809
3 files changed
+16
-2
No files matched your search
Generated
+1
@@ -4604,6 +4604,7 @@ dependencies = [
|
||||
"bitflags 1.2.1",
|
||||
"image",
|
||||
"k9",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"lru",
|
||||
"num-traits 0.2.14",
|
||||
|
||||
@@ -17,6 +17,7 @@ use_serde = ["termwiz/use_serde"]
|
||||
anyhow = "1.0"
|
||||
bitflags = "1.0"
|
||||
image = "0.23"
|
||||
lazy_static = "1.4"
|
||||
log = "0.4"
|
||||
lru = "0.5"
|
||||
num-traits = "0.2"
|
||||
|
||||
+14
-2
@@ -94,9 +94,19 @@ impl ColorPalette {
|
||||
}
|
||||
}
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
static ref DEFAULT_PALETTE: ColorPalette = ColorPalette::compute_default();
|
||||
}
|
||||
|
||||
impl Default for ColorPalette {
|
||||
/// Construct a default color palette
|
||||
fn default() -> ColorPalette {
|
||||
DEFAULT_PALETTE.clone()
|
||||
}
|
||||
}
|
||||
|
||||
impl ColorPalette {
|
||||
fn compute_default() -> Self {
|
||||
let mut colors = [RgbColor::default(); 256];
|
||||
|
||||
// The XTerm ansi color set
|
||||
@@ -201,8 +211,10 @@ impl Default for ColorPalette {
|
||||
|
||||
colors[0..16].copy_from_slice(&ANSI);
|
||||
|
||||
// 216 color cube
|
||||
static RAMP6: [u8; 6] = [0x00, 0x33, 0x66, 0x99, 0xCC, 0xFF];
|
||||
// 216 color cube.
|
||||
// This isn't the perfect color cube, but it matches the values used
|
||||
// by xterm, which are slightly brighter.
|
||||
static RAMP6: [u8; 6] = [0, 0x5f, 0x87, 0xaf, 0xd7, 0xff];
|
||||
for idx in 0..216 {
|
||||
let blue = RAMP6[idx % 6];
|
||||
let green = RAMP6[idx / 6 % 6];
|
||||
|
||||
Reference in new issue
Block a user