From 82350393220468e1992ec7adde969bf8de83f7e0 Mon Sep 17 00:00:00 2001 From: Pokey Rule Date: Wed, 1 Sep 2021 18:49:36 +0100 Subject: [PATCH] hat-shapes (#69) * Add support for hat shapes This reverts commit b8b8ffbbaf3006be3724fea9ce5a9ccafaecefa7. * Change "star" back to "splat" * Add shapes back to cheatsheet * Rename bird to fox --- src/cheat_sheet.py | 4 ++++ src/marks/mark.py | 21 ++++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/cheat_sheet.py b/src/cheat_sheet.py index abbf98a6..0817f5ef 100644 --- a/src/cheat_sheet.py +++ b/src/cheat_sheet.py @@ -207,6 +207,10 @@ def draw(self, canvas): self.draw_header(canvas, "Colors") self.draw_items(canvas, get_list("hat_color")) + self.next_row() + self.draw_header(canvas, "Shapes") + self.draw_items(canvas, get_list("hat_shape")) + self.next_row() self.draw_header(canvas, "Examples") self.draw_items( diff --git a/src/marks/mark.py b/src/marks/mark.py index b7d059dc..e040a61d 100644 --- a/src/marks/mark.py +++ b/src/marks/mark.py @@ -8,6 +8,7 @@ mod.list("cursorless_hat_color", desc="Supported hat colors for cursorless") +mod.list("cursorless_hat_shape", desc="Supported hat shapes for cursorless") # NOTE: Please do not change these dicts. Use the CSVs for customization. # See https://github.com/pokey/cursorless-talon/blob/master/docs/customization.md @@ -19,16 +20,28 @@ "plum": "purple", } +# TODO: Re-add to settings csv +hat_shapes = { + "splat": "star", + "fox": "chevron", +} +ctx.lists[get_cursorless_list_name("hat_shape")] = hat_shapes + -@mod.capture(rule="[{user.cursorless_hat_color}] ") +@mod.capture( + rule="[{user.cursorless_hat_color}] [{user.cursorless_hat_shape}] " +) def cursorless_decorated_symbol(m) -> str: """A decorated symbol""" hat_color = getattr(m, "cursorless_hat_color", "default") - + try: + hat_style_name = f"{hat_color}-{m.cursorless_hat_shape}" + except AttributeError: + hat_style_name = hat_color return { "mark": { "type": "decoratedSymbol", - "symbolColor": hat_color, + "symbolColor": hat_style_name, "character": m.any_alphanumeric_key, } } @@ -92,6 +105,8 @@ def on_ready(): "hat_styles", { "hat_color": hat_colors, + # TODO: Re-add to settings csv + # "hat_shape": hat_shapes, }, )