Merge branch 'kovidgoyal-master' of https://github.com/jimbob3806/kitty
This commit is contained in:
commit
761a941d43
@ -494,6 +494,7 @@ class Theme:
|
|||||||
is_dark: bool = False
|
is_dark: bool = False
|
||||||
blurb: str = ''
|
blurb: str = ''
|
||||||
num_settings: int = 0
|
num_settings: int = 0
|
||||||
|
is_user_defined: bool = False
|
||||||
|
|
||||||
def apply_dict(self, d: Dict[str, Any]) -> None:
|
def apply_dict(self, d: Dict[str, Any]) -> None:
|
||||||
self.name = str(d['name'])
|
self.name = str(d['name'])
|
||||||
@ -501,7 +502,7 @@ class Theme:
|
|||||||
a = d.get(x)
|
a = d.get(x)
|
||||||
if isinstance(a, str):
|
if isinstance(a, str):
|
||||||
setattr(self, x, a)
|
setattr(self, x, a)
|
||||||
for x in ('is_dark', 'num_settings'):
|
for x in ('is_dark', 'num_settings', 'is_user_defined'):
|
||||||
a = d.get(x)
|
a = d.get(x)
|
||||||
if isinstance(a, int):
|
if isinstance(a, int):
|
||||||
setattr(self, x, a)
|
setattr(self, x, a)
|
||||||
@ -594,6 +595,7 @@ class Themes:
|
|||||||
d = parse_theme(name, raw)
|
d = parse_theme(name, raw)
|
||||||
except (Exception, SystemExit):
|
except (Exception, SystemExit):
|
||||||
continue
|
continue
|
||||||
|
d['is_user_defined'] = True
|
||||||
t = Theme(raw.__str__)
|
t = Theme(raw.__str__)
|
||||||
t.apply_dict(d)
|
t.apply_dict(d)
|
||||||
if t.name:
|
if t.name:
|
||||||
|
|||||||
@ -69,6 +69,10 @@ def create_recent_filter(names: Iterable[str]) -> Callable[[Theme], bool]:
|
|||||||
return recent_filter
|
return recent_filter
|
||||||
|
|
||||||
|
|
||||||
|
def user_filter(q: Theme) -> bool:
|
||||||
|
return q.is_user_defined
|
||||||
|
|
||||||
|
|
||||||
def mark_shortcut(text: str, acc: str) -> str:
|
def mark_shortcut(text: str, acc: str) -> str:
|
||||||
acc_idx = text.lower().index(acc.lower())
|
acc_idx = text.lower().index(acc.lower())
|
||||||
return text[:acc_idx] + styled(text[acc_idx], underline='straight', bold=True, fg_intense=True) + text[acc_idx+1:]
|
return text[:acc_idx] + styled(text[acc_idx], underline='straight', bold=True, fg_intense=True) + text[acc_idx+1:]
|
||||||
@ -153,12 +157,13 @@ class ThemesHandler(Handler):
|
|||||||
self.report_traceback_on_exit: Optional[str] = None
|
self.report_traceback_on_exit: Optional[str] = None
|
||||||
self.filter_map: Dict[str, Callable[[Theme], bool]] = {
|
self.filter_map: Dict[str, Callable[[Theme], bool]] = {
|
||||||
'dark': dark_filter, 'light': light_filter, 'all': all_filter,
|
'dark': dark_filter, 'light': light_filter, 'all': all_filter,
|
||||||
'recent': create_recent_filter(self.cached_values.get('recent', ()))
|
'recent': create_recent_filter(self.cached_values.get('recent', ())),
|
||||||
|
'user': user_filter
|
||||||
}
|
}
|
||||||
self.themes_list = ThemesList()
|
self.themes_list = ThemesList()
|
||||||
self.colors_set_once = False
|
self.colors_set_once = False
|
||||||
self.line_edit = LineEdit()
|
self.line_edit = LineEdit()
|
||||||
self.tabs = tuple('all dark light recent'.split())
|
self.tabs = tuple('all dark light recent user'.split())
|
||||||
self.quit_on_next_key_release = -1
|
self.quit_on_next_key_release = -1
|
||||||
|
|
||||||
def update_recent(self) -> None:
|
def update_recent(self) -> None:
|
||||||
@ -389,7 +394,7 @@ class ThemesHandler(Handler):
|
|||||||
if key_event.matches('esc') or key_event.matches_text('q'):
|
if key_event.matches('esc') or key_event.matches_text('q'):
|
||||||
self.quit_on_next_key_release = 0
|
self.quit_on_next_key_release = 0
|
||||||
return
|
return
|
||||||
for cat in 'all dark light recent'.split():
|
for cat in self.tabs:
|
||||||
if key_event.matches_text(cat[0]) or key_event.matches(f'alt+{cat[0]}'):
|
if key_event.matches_text(cat[0]) or key_event.matches(f'alt+{cat[0]}'):
|
||||||
if cat != self.current_category:
|
if cat != self.current_category:
|
||||||
self.current_category = cat
|
self.current_category = cat
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user