Skip to content

Commit

Permalink
Add modifiers, more special marks to cheatsheet (cursorless-dev#885)
Browse files Browse the repository at this point in the history
* add bounds,inside,row,up,down to cheatsheet

* use correct ids

* PR comment

Co-authored-by: Pokey Rule <[email protected]>

* PR comment

Co-authored-by: Pokey Rule <[email protected]>

* PR comment

Co-authored-by: Pokey Rule <[email protected]>

* # -> number

* include line_direction special marks in cheatsheet

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* add modifiers section to cheatsheet

* Better special mark descriptions

* Modifiers descriptions

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* modifier description fix up

* update spoken form defaults

* Various improvements

* Revert accidental change

Co-authored-by: Pokey Rule <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 4, 2022
1 parent 547e11d commit 6c54a17
Show file tree
Hide file tree
Showing 6 changed files with 312 additions and 21 deletions.
11 changes: 11 additions & 0 deletions cursorless-nx/libs/cheatsheet/src/lib/cheatsheetLegend.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ const cheatsheetLegend: CheatsheetLegend = [
definition: 'Formatter (eg "camel", "snake"). Say "format help" for a list',
id: 'formatter',
},
{
term: 'M',
definition: 'Cursorless modifier',
link: 'https://www.cursorless.org/docs/#modifiers',
id: 'modifier',
},
{
term: 'P',
definition: 'Paired delimiter',
Expand All @@ -30,6 +36,11 @@ const cheatsheetLegend: CheatsheetLegend = [
link: 'https://www.cursorless.org/docs/#targets',
id: 'target',
},
{
term: 'number',
definition: 'Number',
id: 'number',
},
];

export default cheatsheetLegend;
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,90 @@
}
]
},
{
"name": "Modifiers",
"id": "modifiers",
"items": [
{
"id": "excludeInterior",
"type": "modifier",
"variations": [
{
"spokenForm": "bounds",
"description": "Bounding paired delimiters"
}
]
},
{
"id": "toRawSelection",
"type": "modifier",
"variations": [
{
"spokenForm": "just",
"description": "No inference"
}
]
},
{
"id": "leading",
"type": "modifier",
"variations": [
{
"spokenForm": "leading",
"description": "Leading delimiter range"
}
]
},
{
"id": "trailing",
"type": "modifier",
"variations": [
{
"spokenForm": "trailing",
"description": "Trailing delimiter range"
}
]
},
{
"id": "interiorOnly",
"type": "modifier",
"variations": [
{
"spokenForm": "inside",
"description": "Interior only"
}
]
},
{
"id": "extendThroughStartOf",
"type": "modifier",
"variations": [
{
"spokenForm": "head",
"description": "Extend through start of line"
},
{
"spokenForm": "head <M>",
"description": "Extend through start of <M>"
}
]
},
{
"id": "extendThroughEndOf",
"type": "modifier",
"variations": [
{
"spokenForm": "tail",
"description": "Extend through end of line"
},
{
"spokenForm": "tail <M>",
"description": "Extend through end of <M>"
}
]
}
]
},
{
"name": "Paired delimiters",
"id": "pairedDelimiters",
Expand Down Expand Up @@ -1073,6 +1157,46 @@
"description": "Nothing"
}
]
},
{
"id": "unknownSymbol",
"type": "mark",
"variations": [
{
"spokenForm": "special",
"description": "Unknown symbol"
}
]
},
{
"id": "lineNumberModulo100",
"type": "mark",
"variations": [
{
"spokenForm": "row <number>",
"description": "Line number modulo 100"
}
]
},
{
"id": "lineNumberRelativeUp",
"type": "mark",
"variations": [
{
"spokenForm": "up <number>",
"description": "Line number up from cursor"
}
]
},
{
"id": "lineNumberRelativeDown",
"type": "mark",
"variations": [
{
"spokenForm": "down <number>",
"description": "Line number down from cursor"
}
]
}
]
},
Expand Down Expand Up @@ -1136,9 +1260,23 @@
}
]
},
{
"id": "rangeExclusive",
"type": "compoundTargetConnective",
"variations": [
{
"spokenForm": "<T1> between <T2>",
"description": "between T1 and T2"
},
{
"spokenForm": "between <T>",
"description": "between S and T"
}
]
},
{
"id": "rangeInclusive",
"type": "action",
"type": "compoundTargetConnective",
"variations": [
{
"spokenForm": "<T1> past <T2>",
Expand All @@ -1149,6 +1287,34 @@
"description": "S through T"
}
]
},
{
"id": "rangeExcludingEnd",
"type": "compoundTargetConnective",
"variations": [
{
"spokenForm": "<T1> until <T2>",
"description": "T1 until start of T2"
},
{
"spokenForm": "until <T>",
"description": "S until start of T"
}
]
},
{
"id": "verticalRange",
"type": "compoundTargetConnective",
"variations": [
{
"spokenForm": "<T1> slice <T2>",
"description": "T1 vertically through T2"
},
{
"spokenForm": "slice <T>",
"description": "S vertically through T"
}
]
}
]
},
Expand Down
9 changes: 8 additions & 1 deletion cursorless-talon/src/cheatsheet_html/cheat_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
from .get_list import get_list, get_lists
from .sections.actions import get_actions
from .sections.compound_targets import get_compound_targets
from .sections.modifiers import get_modifiers
from .sections.scopes import get_scopes
from .sections.special_marks import get_special_marks

mod = Module()

Expand Down Expand Up @@ -44,6 +46,11 @@ def cursorless_cheat_sheet_get_json():
"id": "scopes",
"items": get_scopes(),
},
{
"name": "Modifiers",
"id": "modifiers",
"items": get_modifiers(),
},
{
"name": "Paired delimiters",
"id": "pairedDelimiters",
Expand All @@ -59,7 +66,7 @@ def cursorless_cheat_sheet_get_json():
{
"name": "Special marks",
"id": "specialMarks",
"items": get_lists(["special_mark", "unknown_symbol"], "mark"),
"items": get_special_marks(),
},
{
"name": "Positions",
Expand Down
56 changes: 37 additions & 19 deletions cursorless-talon/src/cheatsheet_html/sections/compound_targets.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
from ..get_list import get_raw_list

FORMATTERS = {
"rangeExclusive": lambda start, end: f"between {start} and {end}",
"rangeInclusive": lambda start, end: f"{start} through {end}",
"rangeExcludingStart": lambda start, end: f"end of {start} through {end}",
"rangeExcludingEnd": lambda start, end: f"{start} until start of {end}",
"verticalRange": lambda start, end: f"{start} vertically through {end}",
}


def get_compound_targets():
include_both_term = next(
spoken_form
for spoken_form, value in get_raw_list("range_connective").items()
if value == "rangeInclusive"
)
list_connective_term = next(
spoken_form
for spoken_form, value in get_raw_list("list_connective").items()
if value == "listConnective"
)
vertical_range_term = next(
spoken_form
for spoken_form, value in get_raw_list("range_type").items()
if value == "verticalRange"
)

return [
{
Expand All @@ -24,18 +32,28 @@ def get_compound_targets():
},
],
},
{
"id": "rangeInclusive",
"type": "action",
"variations": [
{
"spokenForm": f"<T1> {include_both_term} <T2>",
"description": "T1 through T2",
},
{
"spokenForm": f"{include_both_term} <T>",
"description": "S through T",
},
],
},
*[
get_entry(spoken_form, id)
for spoken_form, id in get_raw_list("range_connective").items()
],
get_entry(vertical_range_term, "verticalRange"),
]


def get_entry(spoken_form, id):
formatter = FORMATTERS[id]

return {
"id": id,
"type": "compoundTargetConnective",
"variations": [
{
"spokenForm": f"<T1> {spoken_form} <T2>",
"description": formatter("T1", "T2"),
},
{
"spokenForm": f"{spoken_form} <T>",
"description": formatter("S", "T"),
},
],
}
69 changes: 69 additions & 0 deletions cursorless-talon/src/cheatsheet_html/sections/modifiers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
from ..get_list import get_raw_list, make_dict_readable

MODIFIER_LIST_NAMES = [
"simple_modifier",
"interior_modifier",
"head_tail_modifier",
]


def get_modifiers():
all_modifiers = {}
for name in MODIFIER_LIST_NAMES:
all_modifiers.update(get_raw_list(name))

complex_modifier_ids = [
"extendThroughStartOf",
"extendThroughEndOf",
]
simple_modifiers = {
key: value
for key, value in all_modifiers.items()
if value not in complex_modifier_ids
}
complex_modifiers = {
value: key
for key, value in all_modifiers.items()
if value in complex_modifier_ids
}

return [
*make_dict_readable(
"modifier",
simple_modifiers,
{
"excludeInterior": "Bounding paired delimiters",
"toRawSelection": "No inference",
"leading": "Leading delimiter range",
"trailing": "Trailing delimiter range",
},
),
{
"id": "extendThroughStartOf",
"type": "modifier",
"variations": [
{
"spokenForm": complex_modifiers["extendThroughStartOf"],
"description": "Extend through start of line",
},
{
"spokenForm": f"{complex_modifiers['extendThroughStartOf']} <M>",
"description": "Extend through start of <M>",
},
],
},
{
"id": "extendThroughEndOf",
"type": "modifier",
"variations": [
{
"spokenForm": complex_modifiers["extendThroughEndOf"],
"description": "Extend through end of line",
},
{
"spokenForm": f"{complex_modifiers['extendThroughEndOf']} <M>",
"description": "Extend through end of <M>",
},
],
},
]
Loading

0 comments on commit 6c54a17

Please sign in to comment.