Merge branch 'less-contrast-for-powerline-alt-separator' of https://github.com/chipaca/kitty
This commit is contained in:
commit
bfe1952705
@ -71,6 +71,8 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
|
||||
executing any command specified on the command line via the users' shell
|
||||
just as ssh does (:iss:`3638`)
|
||||
|
||||
- Tab bar: Use a lower contrast color for tab separators (:pull:`3666`)
|
||||
|
||||
|
||||
0.20.3 [2021-05-06]
|
||||
----------------------
|
||||
|
||||
10
kitty/rgb.py
generated
10
kitty/rgb.py
generated
@ -12,6 +12,16 @@ class Color(NamedTuple):
|
||||
green: int
|
||||
blue: int
|
||||
|
||||
def luminance(self) -> float:
|
||||
return 0.299 * self.red + 0.587 * self.green + 0.114 * self.blue
|
||||
|
||||
def contrast(self, other: 'Color') -> float:
|
||||
a = self.luminance()
|
||||
b = other.luminance()
|
||||
if a < b:
|
||||
a, b = b, a
|
||||
return (a + 0.05) / (b + 0.05)
|
||||
|
||||
|
||||
def alpha_blend_channel(top_color: int, bottom_color: int, alpha: float) -> int:
|
||||
return int(alpha * top_color + (1 - alpha) * bottom_color)
|
||||
|
||||
@ -234,7 +234,16 @@ def draw_tab_with_powerline(draw_data: DrawData, screen: Screen, tab: TabBarData
|
||||
screen.cursor.bg = inactive_bg
|
||||
screen.draw(separator_symbol)
|
||||
else:
|
||||
prev_fg = screen.cursor.fg
|
||||
if tab_bg == tab_fg:
|
||||
screen.cursor.fg = default_bg
|
||||
elif tab_bg != default_bg:
|
||||
c1 = draw_data.inactive_bg.contrast(draw_data.default_bg)
|
||||
c2 = draw_data.inactive_bg.contrast(draw_data.inactive_fg)
|
||||
if c1 < c2:
|
||||
screen.cursor.fg = default_bg
|
||||
screen.draw(f' {separator_alt_symbol}')
|
||||
screen.cursor.fg = prev_fg
|
||||
|
||||
end = screen.cursor.x
|
||||
if end < screen.columns:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user