Ejemplo n.º 1
0
def colors_as_escape_codes(o: KittyOptions) -> str:
    ans = set_default_colors(fg=o.foreground,
                             bg=o.background,
                             cursor=o.cursor,
                             select_bg=o.selection_background,
                             select_fg=o.selection_foreground)
    cmds = []
    for i in range(256):
        col = color_as_sharp(color_from_int(o.color_table[i]))
        cmds.append(f'{i};{col}')
    return ans + '\033]4;' + ';'.join(cmds) + '\033\\'
Ejemplo n.º 2
0
 def response_from_kitty(self, boss: Boss, window: Optional[Window], payload_get: PayloadGetType) -> ResponseType:
     from kitty.fast_data_types import get_options
     opts = get_options()
     ans = {k: getattr(opts, k) for k in opts if isinstance(getattr(opts, k), Color)}
     if not payload_get('configured'):
         windows = self.windows_for_match_payload(boss, window, payload_get)
         if windows and windows[0]:
             for k, v in windows[0].current_colors.items():
                 if v is None:
                     ans.pop(k, None)
                 else:
                     ans[k] = color_from_int(v)
     all_keys = natsort_ints(ans)
     maxlen = max(map(len, all_keys))
     return '\n'.join(('{:%ds} {}' % maxlen).format(key, color_as_sharp(ans[key])) for key in all_keys)
Ejemplo n.º 3
0
 def response_from_kitty(self, boss: Boss, window: Optional[Window],
                         payload_get: PayloadGetType) -> ResponseType:
     ans = {
         k: getattr(boss.opts, k)
         for k in boss.opts if isinstance(getattr(boss.opts, k), Color)
     }
     if not payload_get('configured'):
         windows = self.windows_for_match_payload(boss, window, payload_get)
         ans.update({
             k: color_from_int(v)
             for k, v in windows[0].current_colors.items()
         })
     all_keys = natsort_ints(ans)
     maxlen = max(map(len, all_keys))
     return '\n'.join(
         ('{:%ds} {}' % maxlen).format(key, color_as_sharp(ans[key]))
         for key in all_keys)
Ejemplo n.º 4
0
 def set_colors_to_current_theme(self) -> bool:
     if not self.themes_list and self.colors_set_once:
         return False
     self.colors_set_once = True
     if self.themes_list:
         o = self.themes_list.current_theme.kitty_opts
     else:
         o = create_default_opts()
     self.cmd.set_default_colors(
         fg=o.foreground, bg=o.background, cursor=o.cursor, select_bg=o.selection_background, select_fg=o.selection_foreground
     )
     self.current_opts = o
     cmds = []
     for i in range(256):
         col = color_as_sharp(color_from_int(o.color_table[i]))
         cmds.append(f'{i};{col}')
     self.print(end='\033]4;' + ';'.join(cmds) + '\033\\')
     return True