From 24dabca10245716e8f347df4084ce7eb51e74db8 Mon Sep 17 00:00:00 2001 From: Raphael Forment Date: Wed, 20 Dec 2023 11:52:20 +0100 Subject: [PATCH] pushing some new shortcuts and fixing highlighting --- src/API.ts | 4 ++++ src/documentation/inlineHelp.ts | 28 ++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/API.ts b/src/API.ts index ceb5670..e562a0e 100644 --- a/src/API.ts +++ b/src/API.ts @@ -131,12 +131,15 @@ export class UserAPI { load: samples; public global: { [key: string]: any }; + public g; constructor(public app: Editor) { this.MidiConnection = new MidiConnection(this, app.settings); this.global = {}; + this.g = this.global; } + _loadUniverseFromInterface = (universe: string) => { this.app.selected_universe = universe.trim(); this.app.settings.selected_universe = universe.trim(); @@ -535,6 +538,7 @@ export class UserAPI { */ this.MidiConnection.sendMidiControlChange(control, value, channel); }; + public cc = this.control_change; public midi_panic = (): void => { /** diff --git a/src/documentation/inlineHelp.ts b/src/documentation/inlineHelp.ts index 2c0a8bd..0daf2fb 100644 --- a/src/documentation/inlineHelp.ts +++ b/src/documentation/inlineHelp.ts @@ -733,8 +733,8 @@ const completionDatabase: CompletionDatabase = { midi: { name: "midi", category: "midi", - description: "Send a MIDI message", - example: "midi(144, 60, 100)", + description: "Send a MIDI message (note, velocity, channel)", + example: "midi(144, 60, 1)", }, control_change: { name: "control_change", @@ -742,6 +742,12 @@ const completionDatabase: CompletionDatabase = { description: "Send a MIDI control change message", example: "control_change({control: 1, value: 60, channel: 10})", }, + cc: { + name: "cc", + category: "midi", + description: "Send a MIDI control change message", + example: "cc({control: 1, value: 60, channel: 10})", + }, program_change: { name: "program_change", category: "midi", @@ -808,11 +814,17 @@ const completionDatabase: CompletionDatabase = { description: "Wraps (or not) of the drunk walk (boolean)", example: "drunk_wrap(true)", }, - v: { - name: "v", + global: { + name: "global", category: "variable", description: "Global Variable setter or getter", - example: "v('my_var', 10) // Sets global variable 'my_var' to 10", + example: "global.my_var = 10; // Sets global variable 'my_var' to 10", + }, + g: { + name: "g", + category: "variable", + description: "Global Variable setter or getter", + example: "g.my_var = 10; // Sets global variable 'my_var' to 10", }, delete_variable: { name: "delete_variable", @@ -953,12 +965,12 @@ export const inlineHoveringTips = hoverTooltip( let completion = completionDatabase[text.slice(start - from, end - from)] || {}; let divContent = ` -

${completion.name} [${completion.category}]

+

${completion.name} [${completion.category}]

${completion.description}

${completion.example}
`; let dom = document.createElement("div"); - dom.classList.add("px-4", "py-2", "bg-neutral-700", "rounded-lg"); + dom.classList.add("px-4", "py-2", "bg-background", "rounded-lg"); dom.innerHTML = divContent; return { dom }; }, @@ -978,7 +990,7 @@ export const toposCompletions = (context: CompletionContext) => { info: () => { let div = document.createElement("div"); div.innerHTML = ` -

${completionDatabase[key].name} [${completionDatabase[key].category}]

+

${completionDatabase[key].name} [${completionDatabase[key].category}]

${completionDatabase[key].description}

${completionDatabase[key].example}
`;