Open ComputerDruid opened 3 months ago
Shouldn't be harder than
diff --git a/www/src/ts/editor/index.ts b/www/src/ts/editor/index.ts
index 8c170b6..78da6cf 100644
--- a/www/src/ts/editor/index.ts
+++ b/www/src/ts/editor/index.ts
@@ -33,6 +33,7 @@ import { customElement, property, query } from "lit/decorators.js";
import { editorStyles } from "./styles";
import "./shortcuts_ui";
import { AceKeyboardShortcuts } from "./shortcuts_ui";
+import { saveFile } from "../utils";
@customElement("ace-ic10")
export class IC10Editor extends BaseElement {
@@ -365,6 +366,13 @@ export class IC10Editor extends BaseElement {
that.kbShortcuts.show();
},
},
+ {
+ name: "save",
+ bindKey: {win: "Ctrl-S", mac: "Cmd-S"},
+ exec: function(editor: Ace.Editor) {
+ saveFile(window.Editor.editorValue);
+ }
+ }
]);
this.updateEditorSettings();
Yep, that would do it. only caveat is it would only activate when the editor has focus.
When developing scripts in ic10emu, I often want to trigger save before importing into the game. Usually that's to put it in a git repository before running the optimizer on it. (Very important to save before running optimizer -- since the optimized version isn't meant to be edited, I have to save the original somewhere)
So a keyboard shortcut for save would be really handy. It doesn't seem like it would be very hard to do, either with https://stackoverflow.com/questions/4446987/overriding-controls-save-functionality-in-browser or https://stackoverflow.com/questions/31801274/is-there-an-event-for-a-keyboard-initiated-save-in-ace-editor
If no one else picks this up I'll probably eventually spend the time to do it myself, but I figured I'd open an issue instead of just leaving those links open in web browser tabs.