mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-27 10:41:58 +02:00
Also get the current fg/bg colors to render text with
This commit is contained in:
@@ -175,6 +175,41 @@ class DpiY(Query):
|
||||
return f'{cf["logical_dpi_y"]:g}'
|
||||
|
||||
|
||||
@query
|
||||
class Foreground(Query):
|
||||
name: str = 'foreground'
|
||||
help_text: str = 'The current foreground color as a 24-bit # color code'
|
||||
|
||||
@staticmethod
|
||||
def get_result(opts: Options, window_id: int, os_window_id: int) -> str:
|
||||
from kitty.fast_data_types import Color, get_boss
|
||||
boss = get_boss()
|
||||
w = boss.window_id_map.get(window_id)
|
||||
if w is None:
|
||||
return opts.foreground.as_sharp
|
||||
col = w.screen.color_profile.default_fg
|
||||
r, g, b = col >> 16, (col >> 8) & 0xff, col & 0xff
|
||||
return Color(r, g, b).as_sharp
|
||||
|
||||
|
||||
@query
|
||||
class Background(Query):
|
||||
name: str = 'background'
|
||||
help_text: str = 'The current background color as a 24-bit # color code'
|
||||
|
||||
@staticmethod
|
||||
def get_result(opts: Options, window_id: int, os_window_id: int) -> str:
|
||||
from kitty.fast_data_types import Color, get_boss
|
||||
boss = get_boss()
|
||||
w = boss.window_id_map.get(window_id)
|
||||
if w is None:
|
||||
return opts.background.as_sharp
|
||||
col = w.screen.color_profile.default_bg
|
||||
r, g, b = col >> 16, (col >> 8) & 0xff, col & 0xff
|
||||
return Color(r, g, b).as_sharp
|
||||
|
||||
|
||||
|
||||
@query
|
||||
class ClipboardControl(Query):
|
||||
name: str = 'clipboard_control'
|
||||
|
||||
Reference in New Issue
Block a user