diff --git a/README.md b/README.md index ff4bd68..4a6532a 100644 --- a/README.md +++ b/README.md @@ -22,3 +22,19 @@ You can activate AREPL directly by using control-shift-a or command-shift-a if o see [AREPL-backend](https://github.com/Almenon/AREPL-backend) for the npm package that executes the python code AREPL is also availible as a standalone [app](https://github.com/Almenon/AREPL) + +### Settings: + +AREPL offers the following customizable settings: + +// delay in ms before executing code after typing +> "AREPL.delay": 300, + +// 70 fits in 1280 screen +> "AREPL.max_string_length": 70, + +// when restart mode is active we add this to delay to delay longer +> "AREPL.restartDelay": 300, + +// 2 shows x=1 and x=[1,2], provides option to expand deeply nested data like x=[[1]] +> "AREPL.show_to_level": 2 \ No newline at end of file diff --git a/package.json b/package.json index b38f947..072a598 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,32 @@ ], "main": "./out/src/extension", "contributes": { + "configuration": { + "type": "object", + "title": "AREPL configuration", + "properties": { + "AREPL.delay": { + "type": "number", + "default": 300, + "description": "delay in ms before executing code after typing" + }, + "AREPL.restartDelay": { + "type": "number", + "default": 300, + "description": "when restart mode is active we add this to delay to delay longer" + }, + "AREPL.show_to_level": { + "type": "number", + "default": 2, + "description": "2 shows x=1 and x=[1,2], provides option to expand deeply nested data like x=[[1]]" + }, + "AREPL.max_string_length": { + "type": "number", + "default": 70, + "description": "70 fits in 1280 screen" + } + } + }, "commands": [ { "command": "extension.evalPythonInRealTime", diff --git a/src/HTMLDocumentContentProvider.ts b/src/HTMLDocumentContentProvider.ts index 699aa78..5f23361 100644 --- a/src/HTMLDocumentContentProvider.ts +++ b/src/HTMLDocumentContentProvider.ts @@ -22,11 +22,13 @@ export default class HtmlDocumentContentProvider implements vscode.TextDocumentC errorContainer = '' userVarContainer = `
`; printContainer = `
Print Output:
`; + settings:vscode.WorkspaceConfiguration; constructor(private context: vscode.ExtensionContext) { this._onDidChange = new vscode.EventEmitter(); this.css = `` this.jsonRendererScript = `` + this.settings = vscode.workspace.getConfiguration('AREPL'); } provideTextDocumentContent(uri: vscode.Uri): string { @@ -90,8 +92,8 @@ export default class HtmlDocumentContentProvider implements vscode.TextDocumentC let jsonRendererCode = `` diff --git a/src/PreviewManager.ts b/src/PreviewManager.ts index 29da2b8..6eb4bea 100644 --- a/src/PreviewManager.ts +++ b/src/PreviewManager.ts @@ -19,14 +19,16 @@ export default class PreviewManager { this.pythonEvaluator = new PythonEvaluator() this.pythonEditor = vscode.window.activeTextEditor.document; + const settings = vscode.workspace.getConfiguration('AREPL'); + vscode.workspace.registerTextDocumentContentProvider(HtmlDocumentContentProvider.scheme, this.pythonPreviewContentProvider); ///////////////////////////////////////////////////////// // python ///////////////////////////////////////////////////////// let self:PreviewManager = this; - let debounce = 300; - let restartExtraDebounce = 300; + let debounce = settings.get('delay'); + let restartExtraDebounce = settings.get('restartDelay'); this.pythonEvaluator.startPython() this.pythonEvaluator.pyshell.childProcess.on('error', err => {