Skip to content

Commit

Permalink
Cursorless tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
pokey committed Jul 4, 2024
1 parent 0e7897c commit 9c50b0a
Show file tree
Hide file tree
Showing 65 changed files with 3,045 additions and 17 deletions.
22 changes: 22 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@
},
"group": "build"
},
{
"label": "Build tutorial webview",
"type": "npm",
"script": "build:dev",
"path": "packages/cursorless-vscode-tutorial-webview",
"presentation": {
"reveal": "silent"
},
"group": "build"
},
{
"label": "Build test harness",
"type": "npm",
Expand All @@ -57,6 +67,7 @@
"type": "npm",
"script": "populate-dist",
"path": "packages/cursorless-vscode",
"dependsOn": ["Build tutorial webview"],
"presentation": {
"reveal": "silent"
},
Expand Down Expand Up @@ -103,6 +114,17 @@
"dependsOn": ["Watch esbuild", "Watch typescript"],
"group": "build"
},
{
"label": "watch tutorial",
"type": "npm",
"script": "watch:tailwind",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"path": "packages/cursorless-vscode-tutorial-webview",
"group": "build"
},
{
"type": "npm",
"script": "watch:esbuild",
Expand Down
1 change: 1 addition & 0 deletions cursorless-talon/src/cheatsheet/cheat_sheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def private_cursorless_cheat_sheet_update_json():

def private_cursorless_open_instructions():
"""Open web page with cursorless instructions"""
actions.user.private_cursorless_notify_docs_opened()
webbrowser.open(instructions_url)


Expand Down
68 changes: 67 additions & 1 deletion cursorless-talon/src/cursorless.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from talon import Module, actions
from talon import Context, Module, actions

mod = Module()

Expand All @@ -7,6 +7,13 @@
"Application supporting cursorless commands",
)

global_ctx = Context()

cursorless_ctx = Context()
cursorless_ctx.matches = r"""
tag: user.cursorless
"""


@mod.action_class
class Actions:
Expand All @@ -16,8 +23,67 @@ def private_cursorless_show_settings_in_ide():
def private_cursorless_show_sidebar():
"""Show Cursorless-specific settings in ide"""

def private_cursorless_notify_docs_opened():
"""Notify the ide that the docs were opened in case the tutorial is waiting for that event"""
...

def private_cursorless_show_command_statistics():
"""Show Cursorless command statistics"""
actions.user.private_cursorless_run_rpc_command_no_wait(
"cursorless.analyzeCommandHistory"
)

def private_cursorless_start_tutorial():
"""Start the introductory Cursorless tutorial"""
actions.user.private_cursorless_run_rpc_command_no_wait(
"cursorless.tutorial.start", "unit-1-basics"
)

def private_cursorless_tutorial_next():
"""Cursorless tutorial: next"""
actions.user.private_cursorless_run_rpc_command_no_wait(
"cursorless.tutorial.next"
)

def private_cursorless_tutorial_previous():
"""Cursorless tutorial: previous"""
actions.user.private_cursorless_run_rpc_command_no_wait(
"cursorless.tutorial.previous"
)

def private_cursorless_tutorial_restart():
"""Cursorless tutorial: restart"""
actions.user.private_cursorless_run_rpc_command_no_wait(
"cursorless.tutorial.restart"
)

def private_cursorless_tutorial_resume():
"""Cursorless tutorial: resume"""
actions.user.private_cursorless_run_rpc_command_no_wait(
"cursorless.tutorial.resume"
)

def private_cursorless_tutorial_list():
"""Cursorless tutorial: list all available tutorials"""
actions.user.private_cursorless_run_rpc_command_no_wait(
"cursorless.tutorial.list"
)

def private_cursorless_tutorial_start_by_number(number: int): # pyright: ignore [reportGeneralTypeIssues]
"""Start Cursorless tutorial by number"""
actions.user.private_cursorless_run_rpc_command_no_wait(
"cursorless.tutorial.start", number - 1
)


@global_ctx.action_class("user")
class GlobalActions:
def private_cursorless_notify_docs_opened():
# Do nothing if we're not in a Cursorless context
pass


@cursorless_ctx.action_class("user")
class CursorlessActions:
def private_cursorless_notify_docs_opened():
actions.user.private_cursorless_run_rpc_command_no_wait("cursorless.docsOpened")
11 changes: 11 additions & 0 deletions cursorless-talon/src/cursorless.talon
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,14 @@ bar {user.cursorless_homophone}:

{user.cursorless_homophone} stats:
user.private_cursorless_show_command_statistics()

{user.cursorless_homophone} tutorial:
user.private_cursorless_start_tutorial()

tutorial next: user.private_cursorless_tutorial_next()
tutorial (previous | last): user.private_cursorless_tutorial_previous()
tutorial restart: user.private_cursorless_tutorial_restart()
tutorial resume: user.private_cursorless_tutorial_resume()
tutorial list: user.private_cursorless_tutorial_list()
tutorial <user.private_cursorless_number_small>:
user.private_cursorless_tutorial_start_by_number(private_cursorless_number_small)
50 changes: 50 additions & 0 deletions data/fixtures/recorded/tutorial/unit-1-basics/chuckDrum.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
languageId: plaintext
command:
version: 6
spokenForm: chuck drum
action:
name: remove
target:
type: primitive
mark: {type: decoratedSymbol, symbolColor: default, character: d}
usePrePhraseSnapshot: false
initialState:
documentContents: |-
==================================================
========== ==========
========== Welcome to Cursorless! ==========
========== ==========
========== Let's start using marks ==========
========== ==========
========== so we can navigate around ==========
========== ==========
========== without lifting a finger! ==========
========== ==========
==================================================
selections:
- anchor: {line: 2, character: 14}
active: {line: 2, character: 21}
- anchor: {line: 6, character: 15}
active: {line: 6, character: 17}
marks:
default.d:
start: {line: 6, character: 31}
end: {line: 6, character: 37}
finalState:
documentContents: |-
==================================================
========== ==========
========== Welcome to Cursorless! ==========
========== ==========
========== Let's start using marks ==========
========== ==========
========== so we can navigate ==========
========== ==========
========== without lifting a finger! ==========
========== ==========
==================================================
selections:
- anchor: {line: 2, character: 14}
active: {line: 2, character: 21}
- anchor: {line: 6, character: 15}
active: {line: 6, character: 17}
52 changes: 52 additions & 0 deletions data/fixtures/recorded/tutorial/unit-1-basics/chuckLineLook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
languageId: plaintext
command:
version: 6
spokenForm: chuck line look
action:
name: remove
target:
type: primitive
modifiers:
- type: containingScope
scopeType: {type: line}
mark: {type: decoratedSymbol, symbolColor: default, character: l}
usePrePhraseSnapshot: false
initialState:
documentContents: |-
==================================================
========== ==========
========== Welcome to Cursorless! ==========
========== ==========
========== Let's start using marks ==========
========== ==========
========== so we can navigate ==========
========== ==========
========== without lifting a finger! ==========
========== ==========
==================================================
selections:
- anchor: {line: 2, character: 14}
active: {line: 2, character: 21}
- anchor: {line: 6, character: 15}
active: {line: 6, character: 17}
marks:
default.l:
start: {line: 4, character: 13}
end: {line: 4, character: 16}
finalState:
documentContents: |-
==================================================
========== ==========
========== Welcome to Cursorless! ==========
========== ==========
========== ==========
========== so we can navigate ==========
========== ==========
========== without lifting a finger! ==========
========== ==========
==================================================
selections:
- anchor: {line: 2, character: 14}
active: {line: 2, character: 21}
- anchor: {line: 5, character: 15}
active: {line: 5, character: 17}
44 changes: 44 additions & 0 deletions data/fixtures/recorded/tutorial/unit-1-basics/clearTrap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
languageId: plaintext
command:
version: 6
spokenForm: change trap
action:
name: clearAndSetSelection
target:
type: primitive
mark: {type: decoratedSymbol, symbolColor: default, character: t}
usePrePhraseSnapshot: false
initialState:
documentContents: |-
==================================================
========== ==========
========== Welcome to Cursorless! ==========
========== ==========
========== ==========
========== so we can navigate ==========
========== ==========
========== without lifting a finger! ==========
========== ==========
==================================================
selections:
- anchor: {line: 7, character: 27}
active: {line: 7, character: 27}
marks:
default.t:
start: {line: 2, character: 22}
end: {line: 2, character: 24}
finalState:
documentContents: |-
==================================================
========== ==========
========== Welcome Cursorless! ==========
========== ==========
========== ==========
========== so we can navigate ==========
========== ==========
========== without lifting a finger! ==========
========== ==========
==================================================
selections:
- anchor: {line: 2, character: 22}
active: {line: 2, character: 22}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
languageId: plaintext
command:
version: 6
spokenForm: change whale
action:
name: clearAndSetSelection
target:
type: primitive
mark: {type: decoratedSymbol, symbolColor: default, character: w}
usePrePhraseSnapshot: false
initialState:
documentContents: |-
==================================================
========== ==========
========== Welcome Cursorless! ==========
========== ==========
========== ==========
========== so we can navigate ==========
========== ==========
========== without lifting a finger! ==========
========== ==========
==================================================
selections:
- anchor: {line: 2, character: 22}
active: {line: 2, character: 22}
marks:
default.w:
start: {line: 5, character: 15}
end: {line: 5, character: 17}
finalState:
documentContents: |-
==================================================
========== ==========
========== Welcome Cursorless! ==========
========== ==========
========== ==========
========== so can navigate ==========
========== ==========
========== without lifting a finger! ==========
========== ==========
==================================================
selections:
- anchor: {line: 5, character: 15}
active: {line: 5, character: 15}
44 changes: 44 additions & 0 deletions data/fixtures/recorded/tutorial/unit-1-basics/postLook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
languageId: plaintext
command:
version: 6
spokenForm: post look
action:
name: setSelectionAfter
target:
type: primitive
mark: {type: decoratedSymbol, symbolColor: default, character: l}
usePrePhraseSnapshot: false
initialState:
documentContents: |-
==================================================
========== ==========
========== Welcome to Cursorless! ==========
========== ==========
========== ==========
========== so we can navigate ==========
========== ==========
========== without lifting a finger! ==========
========== ==========
==================================================
selections:
- anchor: {line: 7, character: 12}
active: {line: 7, character: 12}
marks:
default.l:
start: {line: 7, character: 20}
end: {line: 7, character: 27}
finalState:
documentContents: |-
==================================================
========== ==========
========== Welcome to Cursorless! ==========
========== ==========
========== ==========
========== so we can navigate ==========
========== ==========
========== without lifting a finger! ==========
========== ==========
==================================================
selections:
- anchor: {line: 7, character: 27}
active: {line: 7, character: 27}
Loading

0 comments on commit 9c50b0a

Please sign in to comment.