Skip to content

Commit

Permalink
hat-shapes (#69)
Browse files Browse the repository at this point in the history
* Add support for hat shapes

This reverts commit b8b8ffb.

* Change "star" back to "splat"

* Add shapes back to cheatsheet

* Rename bird to fox
  • Loading branch information
pokey authored Sep 1, 2021
1 parent 079915b commit 8235039
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/cheat_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
21 changes: 18 additions & 3 deletions src/marks/mark.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}] <user.any_alphanumeric_key>")
@mod.capture(
rule="[{user.cursorless_hat_color}] [{user.cursorless_hat_shape}] <user.any_alphanumeric_key>"
)
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,
}
}
Expand Down Expand Up @@ -92,6 +105,8 @@ def on_ready():
"hat_styles",
{
"hat_color": hat_colors,
# TODO: Re-add to settings csv
# "hat_shape": hat_shapes,
},
)

Expand Down

0 comments on commit 8235039

Please sign in to comment.