Automatically type code during presentations
Initialize Presentation Buddy to create the required .presentation-buddy\instructions.json
file with some demo instructions.
You can do this using the Command Palette (Ctrl+Shift+P) and selecting the Presentation Buddy: Init
command.
Once Presentation Buddy is initialized and you have updated the instructions you can start Presentation Buddy using the Command Palette (Ctrl+Shift+P) and selecting the Presentation Buddy: Start
command.
This extension contributes the following settings:
presentation-buddy.delay
: Delay (in ms) between keys entered. Defaults to 100ms.
Note: Any instruction will accept a "skip": true
settings causing it to be ignored
Type some text at the current cursor position of the currently open file. The text setting can either be a string or an array of strings. In the case of an array of strings each string is entered on a new line.
This takes an optional numerical delay
setting in ms which can be used to override the default delay between keys. This can be useful if you want to speed up or slow down the typing speed for a specific instruction.
Example:
{
"type": "typeText",
"text": [
"// Some comment",
"const lineTwo = true;"
]
}
Type some text at the current cursor position of the currently open file. The text is read from the file indicated by the path. The path is relative to the .presentation-buddy
folder.
This takes an optional numerical delay
setting which can be used to override the default delay between keys. This can be useful if you want to slow down the typing speed for a specific instruction.
Example:
{
"type": "typeTextFromFile",
"path": "./text-source.js"
}
Opens the file specified in the editor. Note that the file needs to exist.
See also: CreateFile
Example:
{
"type": "openFile",
"path": "src/my-file.js"
}
Go to a specific position in the currently open file. The positions are 1 based so they match up with what Visual Studio Code displays. Both the line and column default to 1 if not specified.
Example:
{
"type": "goto",
"line": 75,
"column": 21
}
Select from the current position to a specific position in the currently open file. The positions are 1 based so they match up with what Visual Studio Code displays. Both the line and column default to 1 if not specified.
Example:
{
"type": "select",
"line": 75,
"column": 21
}
Executes one of the standard Visual Studio Code commands. The command should be one of the standard Visual Studio Code command names. See the Keyboard shortcuts for the known commands. When the command requires additional parameters an args array or primitive types can be passed along. Add an optional repeat
settings if a command needs to be execured multiple times.
Note: Not all commands might work as expected so your mileage may vary.
Examples:
{
"type": "command",
"command": "workbench.action.files.save"
},
{
"type": "command",
"command": "editor.action.smartSelect.expand",
"repeat": 2
},
{
"type": "command",
"command": "editor.action.clipboardPasteAction"
}
Creates the file specified and opens it in the editor.
Note: If the file specified already exists it is replaced with an empty file.
Example:
{
"type": "createFile",
"path": "src/my-file.js"
}
Pauses playback for a pecified period. A delay can be passed as either a number representing the number of milliseconds to wait or and the "manual"
. In the case of "manual"
playback will only resume when the Presentation Buddy: Continue
command is executed. If the save
option is set to true all dirty editor files in the workbench will be saved first.
Examples:
{
"type": "wait",
"delay": 10000
},
{
"type": "wait",
"delay": "manual",
"save": true
}
See .presentation-buddy\instructions.json
[
{
"type": "createFile",
"path": "src/calculator.js"
},
{
"type": "typeText",
"text": [
"// This code is typed by Presentation Buddy",
"",
"class Calculator {",
" add(x, y) {",
" return x + y;",
" }",
"}"
],
"delay": 200
},
{
"type": "goto",
"line": 4,
"column": 1
},
{
"type": "command",
"command": "workbench.action.files.save"
},
{
"type": "command",
"command": "workbench.action.closeActiveEditor"
},
{
"type": "createFile",
"path": "src/demo.js"
},
{
"type": "typeText",
"text": [
"// This code is typed by Presentation Buddy",
"",
"const Calculator = require('./calculator');",
"",
"const calc = new Calculator();",
"const sum = calc.add(1, 2)",
"console.log(`The sum of 1 + 2 = ${sum}`);"
]
},
{
"type": "openFile",
"path": "src/calculator.js"
},
{
"type": "command",
"command": "cursorBottom"
},
{
"type": "typeText",
"text": ["", "module.exports = Calculator;"]
}
]
This is still in the experimental preview stage. Use at your own risk.
- ToDo