pushing some new shortcuts and fixing highlighting

This commit is contained in:
2023-12-20 11:52:20 +01:00
parent 6f886ecc10
commit 24dabca102
2 changed files with 24 additions and 8 deletions

View File

@ -131,12 +131,15 @@ export class UserAPI {
load: samples; load: samples;
public global: { [key: string]: any }; public global: { [key: string]: any };
public g;
constructor(public app: Editor) { constructor(public app: Editor) {
this.MidiConnection = new MidiConnection(this, app.settings); this.MidiConnection = new MidiConnection(this, app.settings);
this.global = {}; this.global = {};
this.g = this.global;
} }
_loadUniverseFromInterface = (universe: string) => { _loadUniverseFromInterface = (universe: string) => {
this.app.selected_universe = universe.trim(); this.app.selected_universe = universe.trim();
this.app.settings.selected_universe = universe.trim(); this.app.settings.selected_universe = universe.trim();
@ -535,6 +538,7 @@ export class UserAPI {
*/ */
this.MidiConnection.sendMidiControlChange(control, value, channel); this.MidiConnection.sendMidiControlChange(control, value, channel);
}; };
public cc = this.control_change;
public midi_panic = (): void => { public midi_panic = (): void => {
/** /**

View File

@ -733,8 +733,8 @@ const completionDatabase: CompletionDatabase = {
midi: { midi: {
name: "midi", name: "midi",
category: "midi", category: "midi",
description: "Send a MIDI message", description: "Send a MIDI message (note, velocity, channel)",
example: "midi(144, 60, 100)", example: "midi(144, 60, 1)",
}, },
control_change: { control_change: {
name: "control_change", name: "control_change",
@ -742,6 +742,12 @@ const completionDatabase: CompletionDatabase = {
description: "Send a MIDI control change message", description: "Send a MIDI control change message",
example: "control_change({control: 1, value: 60, channel: 10})", 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: { program_change: {
name: "program_change", name: "program_change",
category: "midi", category: "midi",
@ -808,11 +814,17 @@ const completionDatabase: CompletionDatabase = {
description: "Wraps (or not) of the drunk walk (boolean)", description: "Wraps (or not) of the drunk walk (boolean)",
example: "drunk_wrap(true)", example: "drunk_wrap(true)",
}, },
v: { global: {
name: "v", name: "global",
category: "variable", category: "variable",
description: "Global Variable setter or getter", 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: { delete_variable: {
name: "delete_variable", name: "delete_variable",
@ -953,12 +965,12 @@ export const inlineHoveringTips = hoverTooltip(
let completion = let completion =
completionDatabase[text.slice(start - from, end - from)] || {}; completionDatabase[text.slice(start - from, end - from)] || {};
let divContent = ` let divContent = `
<h1 class="text-orange-300 text-base pb-1">${completion.name} [<em class="text-white">${completion.category}</em>]</h1> <h1 class="text-brightwhite text-base pb-1">${completion.name} [<em class="text-white">${completion.category}</em>]</h1>
<p class="text-base pl-4">${completion.description}</p> <p class="text-base pl-4">${completion.description}</p>
<pre class="-mt-2"><code class="pl-4 text-base">${completion.example}</code></pre></div> <pre class="-mt-2"><code class="pl-4 text-base">${completion.example}</code></pre></div>
`; `;
let dom = document.createElement("div"); 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; dom.innerHTML = divContent;
return { dom }; return { dom };
}, },
@ -978,7 +990,7 @@ export const toposCompletions = (context: CompletionContext) => {
info: () => { info: () => {
let div = document.createElement("div"); let div = document.createElement("div");
div.innerHTML = ` div.innerHTML = `
<h1 class="text-orange-300 text-base pb-1">${completionDatabase[key].name} [<em class="text-white">${completionDatabase[key].category}</em>]</h1> <h1 class="text-brightwhite text-base pb-1">${completionDatabase[key].name} [<em class="text-white">${completionDatabase[key].category}</em>]</h1>
<p class="text-base pl-4">${completionDatabase[key].description}</p> <p class="text-base pl-4">${completionDatabase[key].description}</p>
<div class="overflow-hidden overflow-scroll rounded px-2 ml-4 mt-2 bg-neutral-800"><code class="text-sm">${completionDatabase[key].example}</code></div> <div class="overflow-hidden overflow-scroll rounded px-2 ml-4 mt-2 bg-neutral-800"><code class="text-sm">${completionDatabase[key].example}</code></div>
`; `;