From 898f51f2e8c8a6d8894fbbd620ebee9a2136cc65 Mon Sep 17 00:00:00 2001 From: Will Sommers Date: Wed, 7 Sep 2022 11:08:37 -0400 Subject: [PATCH] Update cursorless reference, help terms and docs (#599) --- .../src/cheatsheet_html/cheat_sheet.py | 140 ++++++++++-------- cursorless-talon/src/cursorless.talon | 7 +- cursorless-talon/src/cursorless_global.talon | 3 + cursorless-talon/src/terms.py | 18 +++ docs/user/README.md | 4 +- 5 files changed, 101 insertions(+), 71 deletions(-) create mode 100644 cursorless-talon/src/cursorless_global.talon create mode 100644 cursorless-talon/src/terms.py diff --git a/cursorless-talon/src/cheatsheet_html/cheat_sheet.py b/cursorless-talon/src/cheatsheet_html/cheat_sheet.py index e9da00ceb..913023c2a 100644 --- a/cursorless-talon/src/cheatsheet_html/cheat_sheet.py +++ b/cursorless-talon/src/cheatsheet_html/cheat_sheet.py @@ -2,7 +2,7 @@ import tempfile import webbrowser from pathlib import Path -from talon import Module, actions +from talon import Context, Module, actions, app from .get_list import get_list, get_lists from .sections.actions import get_actions @@ -12,12 +12,29 @@ from .sections.scopes import get_scopes from .sections.special_marks import get_special_marks mod = Module() +ctx = Context() +ctx.matches = r""" +app: vscode +""" cheatsheet_out_dir = Path(tempfile.mkdtemp()) instructions_url = "https://www.cursorless.org/docs/" @mod.action_class +class Actions: + def cursorless_cheat_sheet_show_html(): + """Show new cursorless html cheat sheet""" + app.notify( + 'Please first focus an app that supports cursorless, eg say "focus code"' + ) + + def cursorless_open_instructions(): + """Open web page with cursorless instructions""" + webbrowser.open(instructions_url) + + +@ctx.action_class("user") class Actions: def cursorless_cheat_sheet_show_html(): """Show new cursorless html cheat sheet""" @@ -26,71 +43,68 @@ class Actions: "cursorless.showCheatsheet", { "version": 0, - "spokenFormInfo": actions.user.cursorless_cheat_sheet_get_json(), + "spokenFormInfo": cursorless_cheat_sheet_get_json(), "outputPath": str(cheatsheet_out_path), }, ) webbrowser.open(cheatsheet_out_path.as_uri()) - def cursorless_cheat_sheet_get_json(): - """Get cursorless cheat sheet json""" - return { - "sections": [ - { - "name": "Actions", - "id": "actions", - "items": get_actions(), - }, - { - "name": "Scopes", - "id": "scopes", - "items": get_scopes(), - }, - { - "name": "Modifiers", - "id": "modifiers", - "items": get_modifiers(), - }, - { - "name": "Paired delimiters", - "id": "pairedDelimiters", - "items": get_lists( - [ - "wrapper_only_paired_delimiter", - "wrapper_selectable_paired_delimiter", - "selectable_only_paired_delimiter", - ], - "pairedDelimiter", - ), - }, - { - "name": "Special marks", - "id": "specialMarks", - "items": get_special_marks(), - }, - { - "name": "Positions", - "id": "positions", - "items": get_list("position", "position"), - }, - { - "name": "Compound targets", - "id": "compoundTargets", - "items": get_compound_targets(), - }, - { - "name": "Colors", - "id": "colors", - "items": get_list("hat_color", "hatColor"), - }, - { - "name": "Shapes", - "id": "shapes", - "items": get_list("hat_shape", "hatShape"), - }, - ] - } - def cursorless_open_instructions(): - """Open web page with cursorless instructions""" - webbrowser.open(instructions_url) +def cursorless_cheat_sheet_get_json(): + """Get cursorless cheat sheet json""" + return { + "sections": [ + { + "name": "Actions", + "id": "actions", + "items": get_actions(), + }, + { + "name": "Scopes", + "id": "scopes", + "items": get_scopes(), + }, + { + "name": "Modifiers", + "id": "modifiers", + "items": get_modifiers(), + }, + { + "name": "Paired delimiters", + "id": "pairedDelimiters", + "items": get_lists( + [ + "wrapper_only_paired_delimiter", + "wrapper_selectable_paired_delimiter", + "selectable_only_paired_delimiter", + ], + "pairedDelimiter", + ), + }, + { + "name": "Special marks", + "id": "specialMarks", + "items": get_special_marks(), + }, + { + "name": "Positions", + "id": "positions", + "items": get_list("position", "position"), + }, + { + "name": "Compound targets", + "id": "compoundTargets", + "items": get_compound_targets(), + }, + { + "name": "Colors", + "id": "colors", + "items": get_list("hat_color", "hatColor"), + }, + { + "name": "Shapes", + "id": "shapes", + "items": get_list("hat_shape", "hatShape"), + }, + ] + } diff --git a/cursorless-talon/src/cursorless.talon b/cursorless-talon/src/cursorless.talon index cc0397262..bfbb8fdeb 100644 --- a/cursorless-talon/src/cursorless.talon +++ b/cursorless-talon/src/cursorless.talon @@ -19,12 +19,7 @@ app: vscode {user.cursorless_wrap_action} : user.cursorless_wrap(cursorless_wrap_action, cursorless_target, cursorless_wrapper) -cursorless help: user.cursorless_cheat_sheet_toggle() -cursorless instructions: user.cursorless_open_instructions() -cursorless docks: user.cursorless_open_instructions() -cursorless reference: user.cursorless_cheat_sheet_show_html() -cursorless cheat sheet: user.cursorless_cheat_sheet_show_html() -cursorless settings: +{user.cursorless_homophone} settings: user.vscode("workbench.action.openGlobalSettings") sleep(250ms) insert("cursorless") diff --git a/cursorless-talon/src/cursorless_global.talon b/cursorless-talon/src/cursorless_global.talon new file mode 100644 index 000000000..e0953ed91 --- /dev/null +++ b/cursorless-talon/src/cursorless_global.talon @@ -0,0 +1,3 @@ +{user.cursorless_homophone} (reference | ref | cheatsheet | cheat sheet): user.cursorless_cheat_sheet_show_html() +{user.cursorless_homophone} (instructions | docks | help) | help {user.cursorless_homophone}: + user.cursorless_open_instructions() diff --git a/cursorless-talon/src/terms.py b/cursorless-talon/src/terms.py new file mode 100644 index 000000000..688d305a2 --- /dev/null +++ b/cursorless-talon/src/terms.py @@ -0,0 +1,18 @@ +""" +Stores terms that are used in many different places +""" +from talon import Context, Module + +mod = Module() +ctx = Context() + +mod.list( + "cursorless_homophone", + "Various alternative pronunciations of 'cursorless' to improve accuracy", +) + +ctx.lists["user.cursorless_homophone"] = [ + "cursorless", + "cursor less", + "cursor list", +] diff --git a/docs/user/README.md b/docs/user/README.md index bcd69a397..e93fc4376 100644 --- a/docs/user/README.md +++ b/docs/user/README.md @@ -8,9 +8,9 @@ Welcome to Cursorless! You may find it helpful to start with the [tutorial video This guide assumes you've already [installed Cursorless](installation.md). -Once you understand the concepts, you can pull up a cheatsheet for reference using the command `"cursorless help"`. +Once you understand the concepts, you can pull up a cheatsheet for reference using either `"cursorless reference"` or `"cursorless cheatsheet"` commands within VSCode. -You can get back to these docs by saying `"cursorless instructions"`. +You can get back to these docs by saying `"cursorless docs"`, `"cursorless help"` within VSCode. Note: If you'd like to customize any of the spoken forms, please see [Customization](customization.md).