Skip to content
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

Cursorless tutorial ced #2131

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
466fe64
Initial tutorial work
pokey Dec 7, 2023
617ea7c
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Dec 7, 2023
ef66688
Update spoken forms
pokey Dec 7, 2023
ae958d3
Upgrade commands
pokey Dec 7, 2023
1b4cae3
Fix extension tests
pokey Dec 7, 2023
bb303aa
whoops
pokey Dec 7, 2023
6ecaf87
Merge branch 'main' into cursorless-tutorial
pokey Dec 12, 2023
016e4d8
basic communication between talon and the extension for the tutorial
Dec 13, 2023
f761306
initial way to populate a window even if not really the right way
Dec 13, 2023
d4b8aa6
use the injected ide
Dec 19, 2023
9673f52
remove dependencies unneeded now
Dec 19, 2023
8b95e02
moved tutorial to a class
Dec 20, 2023
b0e2f8c
Merge remote-tracking branch 'upstream/main' into cursorless-tutorial…
Dec 21, 2023
25be0ca
start parsing things from the extension side
Jan 2, 2024
a7c7fa2
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Jan 2, 2024
203bdd2
refactor and parse literalStep
Jan 4, 2024
1bbfe44
finished converting all the spoken forms
Jan 4, 2024
f3a3bf3
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Jan 4, 2024
1436353
document functions and use a tutorial directory
Jan 5, 2024
43734e7
initial working version of the tutorial
Jan 5, 2024
171abdd
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Jan 5, 2024
cd5bfc6
tweaks
pokey Jan 17, 2024
e022e69
change function
pokey Jan 17, 2024
e0f3c02
more cleanup
pokey Jan 17, 2024
142ec58
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Jan 17, 2024
7ed3aac
fix
pokey Jan 17, 2024
a5ed0ff
More cleanup
pokey Jan 17, 2024
f789d24
More cleanup
pokey Jan 17, 2024
f607f16
Tweak imports
pokey Jan 17, 2024
01fc505
More tweaks# Please enter the commit message for your changes. Lines …
pokey Jan 17, 2024
af491e9
More cleanup
pokey Jan 17, 2024
06025d4
more tweaks
pokey Jan 17, 2024
55b596d
Remove comment
pokey Jan 17, 2024
6e101de
Bugfixes
pokey Jan 17, 2024
0e1cf6b
More fixes
pokey Jan 17, 2024
179098b
Merge branch 'main' into pr/saidelike/2131
pokey Feb 23, 2024
46be1bd
run meta-updater
pokey Feb 23, 2024
20bd5ed
Initial cursorless-vscode-tutorial scaffolding
pokey Feb 23, 2024
ea0481c
cursorless-vscode-tutorial => cursorless-vscode-tutorial-webview
pokey Feb 23, 2024
47fd057
more tutorial hacking
pokey Feb 28, 2024
69bd66b
Tweak package.json
pokey Mar 10, 2024
e9d8dbe
Update adding-a-new-package.md (#2247)
pokey Feb 23, 2024
5cbc8e1
bump pnpm => 8.15.3 (#2248)
pokey Feb 24, 2024
6dc5a2d
Update adding-a-new-package.md (#2249)
pokey Feb 24, 2024
5cd2c12
{grand, every} rephrasings for clarity and consistency (#2250)
jmegner Feb 25, 2024
ed7ae67
Update adding-a-new-package.md (#2255)
pokey Feb 27, 2024
401cb10
Get actual js from our webview package
pokey Mar 10, 2024
d5dddff
Initial React scaffolding
pokey Mar 10, 2024
ff3f0cd
Fix tsconfig
pokey Mar 10, 2024
419d830
more cleanup
pokey Mar 10, 2024
571a979
fix:meta
pokey Mar 10, 2024
2f1d786
more cleanup
pokey Mar 10, 2024
dce7d96
Merge branch 'main' into pr/saidelike/2131
pokey Mar 15, 2024
db75743
Add tailwind
pokey Mar 15, 2024
4d63d67
Let VscodeTutorial own tutorial state
pokey Mar 15, 2024
04c5653
Clean up some TutorialImpl stuff
pokey Mar 15, 2024
b59cccb
More PR feedback
pokey Mar 15, 2024
ac51e1f
Initial step content and step init code connected to webview
pokey Mar 15, 2024
26a2cd9
tweaks
pokey Mar 16, 2024
1f07077
tweaks
pokey Mar 26, 2024
0dbbfcd
some more tweaks
pokey Mar 27, 2024
32ab372
Merge branch 'main' into pr/saidelike/2131
pokey Mar 27, 2024
c9f56b3
more tweaks
pokey Mar 28, 2024
e8a66f8
Merge branch 'main' into pr/saidelike/2131
pokey Mar 28, 2024
ad8a152
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] Mar 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 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": "compile: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
6 changes: 6 additions & 0 deletions cursorless-talon/src/cursorless.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ def private_cursorless_show_command_statistics():
actions.user.private_cursorless_run_rpc_command_no_wait(
"cursorless.analyzeCommandHistory"
)

def private_cursorless_start_tutorial():
"""Start Cursorless tutorial"""
actions.user.private_cursorless_run_rpc_command_no_wait(
"cursorless.tutorial.start", "unit-2-basic-coding"
)
3 changes: 3 additions & 0 deletions cursorless-talon/src/cursorless.talon
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,6 @@ bar {user.cursorless_homophone}:

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

{user.cursorless_homophone} tutorial:
user.private_cursorless_start_tutorial()
9 changes: 9 additions & 0 deletions data/playground/tutorial/extra-cloning-a-talon-list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from talon import Context, Module

mod = Module()
ctx = Context()

mod.list("cursorless_walkthrough_list", desc="My tutorial list")
ctx.list["user.cursorless_walkthrough_list"] = {
"spoken form": "whatever",
}
11 changes: 11 additions & 0 deletions data/playground/tutorial/unit-1-basics.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
==================================================
========== ==========
========== Welcome to Cursorless! ==========
========== ==========
========== Let's start using marks ==========
========== ==========
========== so we can navigate around ==========
========== ==========
========== without lifting a finger! ==========
========== ==========
==================================================
13 changes: 13 additions & 0 deletions data/playground/tutorial/unit-2-basic-coding.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def print_color(color, invert=False):
if invert:
print(invert_color(color))
else:
print(color)


def invert_color(color):
if color == "black":
return "white"


print_color("black")
2 changes: 2 additions & 0 deletions packages/common/src/cursorlessCommandIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const cursorlessCommandIds = [
"cursorless.toggleDecorations",
"cursorless.showScopeVisualizer",
"cursorless.hideScopeVisualizer",
"cursorless.tutorial.start",
"cursorless.analyzeCommandHistory",
] as const satisfies readonly `cursorless.${string}`[];

Expand Down Expand Up @@ -81,6 +82,7 @@ export const cursorlessCommandDescriptions: Record<
"Analyze collected command history",
),

["cursorless.tutorial.start"]: new HiddenCommand("Start a tutorial"),
["cursorless.command"]: new HiddenCommand("The core cursorless command"),
["cursorless.showQuickPick"]: new HiddenCommand(
"Pop up a quick pick of all cursorless commands",
Expand Down
2 changes: 2 additions & 0 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ export * from "./types/HatTokenMap";
export * from "./types/ScopeProvider";
export * from "./types/SpokenForm";
export * from "./types/commandHistory";
export * from "./types/tutorial.types";
export * from "./util/textFormatters";
export * from "./util/serializedMarksToTokenHats";
export * from "./types/snippet.types";
export * from "./testUtil/fromPlainObject";
export * from "./testUtil/spyToPlainObject";
Expand Down
16 changes: 16 additions & 0 deletions packages/common/src/types/tutorial.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
export type TutorialId = "introduction";

interface PickingTutorialState {
type: "pickingTutorial";
}

export interface ActiveTutorialState {
type: "doingTutorial";
title: string;
tutorialId: TutorialId;
stepNumber: number;
stepContent: string;
stepCount: number;
}

export type TutorialState = PickingTutorialState | ActiveTutorialState;
36 changes: 36 additions & 0 deletions packages/common/src/util/serializedMarksToTokenHats.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { plainObjectToRange } from "../testUtil/fromPlainObject";
import { splitKey } from "./splitKey";
import { SerializedMarks } from "./toPlainObject";
import { TextEditor } from "../types/TextEditor";
import { TokenHat } from "../types/HatTokenMap";

export function serializedMarksToTokenHats(
marks: SerializedMarks | undefined,
editor: TextEditor,
): TokenHat[] {
if (marks == null) {
return [];
}

return Object.entries(marks).map(([key, token]) => {
const { hatStyle, character } = splitKey(key);
const range = plainObjectToRange(token);

return {
hatStyle,
grapheme: character,
token: {
editor,
range,
offsets: {
start: editor.document.offsetAt(range.start),
end: editor.document.offsetAt(range.end),
},
text: editor.document.getText(range),
},

// NB: We don't care about the hat range for this test
hatRange: range,
};
});
}
2 changes: 2 additions & 0 deletions packages/cursorless-engine/src/api/CursorlessEngineApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
import type { CommandRunner } from "../CommandRunner";
import type { Snippets } from "../core/Snippets";
import type { StoredTargetMap } from "../core/StoredTargets";
import { Tutorial } from "./Tutorial";

export interface CursorlessEngine {
commandApi: CommandApi;
Expand All @@ -17,6 +18,7 @@ export interface CursorlessEngine {
storedTargets: StoredTargetMap;
hatTokenMap: HatTokenMap;
snippets: Snippets;
tutorial: Tutorial;
injectIde: (ide: IDE | undefined) => void;
runIntegrationTests: () => Promise<void>;
addCommandRunnerDecorator: (
Expand Down
55 changes: 55 additions & 0 deletions packages/cursorless-engine/src/api/Tutorial.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { TutorialId } from "@cursorless/common";

export interface TutorialContent {
/**
* The title of the tutorial
*/
title: string;

/**
* The steps of the current tutorial
*/
steps: Array<TutorialStep>;
}

export interface RawTutorialContent {
/**
* The title of the tutorial
*/
title: string;

/**
* The steps of the current tutorial
*/
steps: string[];
}

export interface TutorialStep {
/**
* The text content of the current step
*/
content: string;

/**
* The path to the yaml file that should be used to setup the current step (if
* any). The path is relative to the tutorial directory for the given tutorial.
*/
fixturePath?: string;
}

export interface TutorialSetupStepArg {
/**
* The id of the current tutorial
*/
tutorialId: string;

/**
* The yaml file for the current step
*/
fixturePath: string;
}

export interface Tutorial {
getContent(id: TutorialId): Promise<TutorialContent>;
setupStep(arg: TutorialSetupStepArg): Promise<void>;
}
2 changes: 1 addition & 1 deletion packages/cursorless-engine/src/core/IndividualHatMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class IndividualHatMap implements ReadOnlyHatMap {
}

/**
* Overwrites the hat assignemnt for this hat token map.
* Overwrites the hat assignment for this hat token map.
*
* @param tokenHats The new hat assignments
*/
Expand Down
Loading
Loading