Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: "Save As" on Ctrl+S (or CMD+S on mac) #19

Open
ComputerDruid opened this issue Apr 15, 2024 · 2 comments
Open

Feature Request: "Save As" on Ctrl+S (or CMD+S on mac) #19

ComputerDruid opened this issue Apr 15, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@ComputerDruid
Copy link
Contributor

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.

@Emilgardis
Copy link
Contributor

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();

@Ryex
Copy link
Owner

Ryex commented Apr 16, 2024

Yep, that would do it. only caveat is it would only activate when the editor has focus.

@Ryex Ryex added the enhancement New feature or request label Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants