Update cursorless reference, help terms and docs (#599)

This commit is contained in:
Will Sommers 2022-09-07 11:08:37 -04:00 committed by GitHub
parent 3c41868de3
commit 898f51f2e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 101 additions and 71 deletions

View File

@ -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"),
},
]
}

View File

@ -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")

View File

@ -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()

View File

@ -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",
]

View File

@ -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).