Skip to content

Update cursorless reference, help terms and docs #599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Sep 7, 2022
140 changes: 77 additions & 63 deletions cursorless-talon/src/cheatsheet_html/cheat_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
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
Expand All @@ -12,12 +12,29 @@
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"'
)
Comment on lines +28 to +30
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like better UX than Talon just refusing to hear them when they say "cursorless cheatsheet" in the wrong place


def cursorless_open_instructions():
"""Open web page with cursorless instructions"""
webbrowser.open(instructions_url)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no reason not to support this everywhere. This way if user first installs Cursorless and says "cursorless help", they'll get the docs no matter what



@ctx.action_class("user")
class Actions:
def cursorless_cheat_sheet_show_html():
"""Show new cursorless html cheat sheet"""
Expand All @@ -26,71 +43,68 @@ def cursorless_cheat_sheet_show_html():
"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():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to local function rather than action, per discussion today

"""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"),
},
]
}
7 changes: 1 addition & 6 deletions cursorless-talon/src/cursorless.talon
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@ app: vscode
<user.cursorless_wrapper> {user.cursorless_wrap_action} <user.cursorless_target>:
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")
3 changes: 3 additions & 0 deletions cursorless-talon/src/cursorless_global.talon
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{user.cursorless_homophone} (reference | ref | cheatsheet | cheat sheet): user.cursorless_cheat_sheet_show_html()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make all these active globally, though the cheatsheet just shows a helpful message, per above

{user.cursorless_homophone} (instructions | docks | help) | help {user.cursorless_homophone}:
user.cursorless_open_instructions()
18 changes: 18 additions & 0 deletions cursorless-talon/src/terms.py
Original file line number Diff line number Diff line change
@@ -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",
]
4 changes: 2 additions & 2 deletions docs/user/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down