diff --git a/src/app/common/configs/keybindings.config.ts b/src/app/common/configs/keybindings.config.ts index 913604d..8d19f51 100644 --- a/src/app/common/configs/keybindings.config.ts +++ b/src/app/common/configs/keybindings.config.ts @@ -1,7 +1,7 @@ export const Keybindings: Array<{}> = [ { name: "quit", - bindKey: {win: "Ctrl-q", mac: "Ctrl-q"}, + bindKey: {win: "ctrl-q", mac: "ctrl-q"}, readOnly: false }, { name: "toggleFullScreen", @@ -9,7 +9,7 @@ export const Keybindings: Array<{}> = [ readOnly: false }, { name: "showSettingsMenu", - bindKey: {win: "Ctrl-Shift-m", mac: "Ctrl-Shift-m"}, + bindKey: {win: "ctrl-shift-m", mac: "ctrl-shift-m"}, readOnly: false }, { name: "showKeyboardShortcuts", @@ -17,13 +17,17 @@ export const Keybindings: Array<{}> = [ readOnly: false }, { name: "openCommandPalette2", - bindKey: {linux: "Command-shift-/|F1", win: "ctrl-shift-/|F1"}, + bindKey: {linux: "command-shift-/|F1", win: "ctrl-shift-/|F1"}, readOnly: false }, { name: "showFilesModal", - bindKey: {win: "ctrl-b", mac: "ctrl-b"}, + bindKey: {win: "ctrl-shift-b", mac: "ctrl-shift-b"}, service: "filesModalService", readOnly: false + }, { + name: "showFilesList", + bindKey: {win: "ctrl-b", mac: "ctrl-b"}, + readOnly: false }, { name: "showLSPModal", bindKey: {win: "ctrl-shift-l", mac: "ctrl-shift-l"}, diff --git a/src/app/common/services/editor/files.service.ts b/src/app/common/services/editor/files.service.ts index eaece12..6af6630 100644 --- a/src/app/common/services/editor/files.service.ts +++ b/src/app/common/services/editor/files.service.ts @@ -31,6 +31,14 @@ export class FilesService { return this.files.get(path); } + public getAllPaths(): string[] { + return [...this.files.keys()]; + } + + public getAllFiles(): NewtonFile[] { + return [...this.files.values()]; + } + public delete(file: NewtonFile) { file.session.destroy(); window.fs.closeFile(file.path); diff --git a/src/app/editor/newton-editor/newton-editor.base.ts b/src/app/editor/newton-editor/newton-editor.base.ts index 205dce9..e488c95 100644 --- a/src/app/editor/newton-editor/newton-editor.base.ts +++ b/src/app/editor/newton-editor/newton-editor.base.ts @@ -97,6 +97,55 @@ export class NewtonEditorBase { console.log(this.editor.session.getMode()["$id"]); } + public showFilesList() { + let paths = this.filesService.getAllPaths(); + let stubPaths = []; + + for (let i = 0; i < paths.length; i++) { + let fpath = paths[i]; + if (fpath.length > 67) { + fpath = "..." + fpath.slice(fpath.length - 67, fpath.length); + } + stubPaths.push(fpath); + } + + this.editor.prompt("", + { + name: "Files:", + placeholder: "Search...", + getCompletions: (search) => { + let query = search.getValue(); + let result = []; + + if (!query) return stubPaths; + + for (let i = 0; i < stubPaths.length; i++) { + if (stubPaths[i].includes(query)) { + result.push(stubPaths[i]); + } + } + + return result; + }, + onAccept: (data) => { + let fpath = data.value; + let path = ""; + + for (let i = 0; i < stubPaths.length; i++) { + if (stubPaths[i] === fpath) { + path = paths[i]; + } + } + + if (!path) return; + + this.activeFile = this.filesService.get(path); + this.editor.setSession(this.activeFile.session); + } + }); + + } + public destroySession() { this.editor.session.destroy(); } diff --git a/src/app/editor/newton-editor/newton-editor.component.ts b/src/app/editor/newton-editor/newton-editor.component.ts index 91ec540..0b1d113 100644 --- a/src/app/editor/newton-editor/newton-editor.component.ts +++ b/src/app/editor/newton-editor/newton-editor.component.ts @@ -5,6 +5,7 @@ import * as ace from "ace-builds/src-noconflict/ace"; import "ace-builds/src-noconflict/ext-settings_menu"; import "ace-builds/src-noconflict/ext-keybinding_menu"; import "ace-builds/src-noconflict/ext-command_bar"; +import "ace-builds/src-noconflict/ext-prompt"; import "ace-builds/src-noconflict/ext-language_tools"; import "ace-builds/src-noconflict/theme-one_dark"; import "ace-builds/src-noconflict/theme-dracula";