Added files list search; keybinding cleanup
This commit is contained in:
parent
ad92bfc648
commit
9915b98700
@ -1,7 +1,7 @@
|
|||||||
export const Keybindings: Array<{}> = [
|
export const Keybindings: Array<{}> = [
|
||||||
{
|
{
|
||||||
name: "quit",
|
name: "quit",
|
||||||
bindKey: {win: "Ctrl-q", mac: "Ctrl-q"},
|
bindKey: {win: "ctrl-q", mac: "ctrl-q"},
|
||||||
readOnly: false
|
readOnly: false
|
||||||
}, {
|
}, {
|
||||||
name: "toggleFullScreen",
|
name: "toggleFullScreen",
|
||||||
@ -9,7 +9,7 @@ export const Keybindings: Array<{}> = [
|
|||||||
readOnly: false
|
readOnly: false
|
||||||
}, {
|
}, {
|
||||||
name: "showSettingsMenu",
|
name: "showSettingsMenu",
|
||||||
bindKey: {win: "Ctrl-Shift-m", mac: "Ctrl-Shift-m"},
|
bindKey: {win: "ctrl-shift-m", mac: "ctrl-shift-m"},
|
||||||
readOnly: false
|
readOnly: false
|
||||||
}, {
|
}, {
|
||||||
name: "showKeyboardShortcuts",
|
name: "showKeyboardShortcuts",
|
||||||
@ -17,13 +17,17 @@ export const Keybindings: Array<{}> = [
|
|||||||
readOnly: false
|
readOnly: false
|
||||||
}, {
|
}, {
|
||||||
name: "openCommandPalette2",
|
name: "openCommandPalette2",
|
||||||
bindKey: {linux: "Command-shift-/|F1", win: "ctrl-shift-/|F1"},
|
bindKey: {linux: "command-shift-/|F1", win: "ctrl-shift-/|F1"},
|
||||||
readOnly: false
|
readOnly: false
|
||||||
}, {
|
}, {
|
||||||
name: "showFilesModal",
|
name: "showFilesModal",
|
||||||
bindKey: {win: "ctrl-b", mac: "ctrl-b"},
|
bindKey: {win: "ctrl-shift-b", mac: "ctrl-shift-b"},
|
||||||
service: "filesModalService",
|
service: "filesModalService",
|
||||||
readOnly: false
|
readOnly: false
|
||||||
|
}, {
|
||||||
|
name: "showFilesList",
|
||||||
|
bindKey: {win: "ctrl-b", mac: "ctrl-b"},
|
||||||
|
readOnly: false
|
||||||
}, {
|
}, {
|
||||||
name: "showLSPModal",
|
name: "showLSPModal",
|
||||||
bindKey: {win: "ctrl-shift-l", mac: "ctrl-shift-l"},
|
bindKey: {win: "ctrl-shift-l", mac: "ctrl-shift-l"},
|
||||||
|
@ -31,6 +31,14 @@ export class FilesService {
|
|||||||
return this.files.get(path);
|
return this.files.get(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getAllPaths(): string[] {
|
||||||
|
return [...this.files.keys()];
|
||||||
|
}
|
||||||
|
|
||||||
|
public getAllFiles(): NewtonFile[] {
|
||||||
|
return [...this.files.values()];
|
||||||
|
}
|
||||||
|
|
||||||
public delete(file: NewtonFile) {
|
public delete(file: NewtonFile) {
|
||||||
file.session.destroy();
|
file.session.destroy();
|
||||||
window.fs.closeFile(file.path);
|
window.fs.closeFile(file.path);
|
||||||
|
@ -97,6 +97,55 @@ export class NewtonEditorBase {
|
|||||||
console.log(this.editor.session.getMode()["$id"]);
|
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() {
|
public destroySession() {
|
||||||
this.editor.session.destroy();
|
this.editor.session.destroy();
|
||||||
}
|
}
|
||||||
|
@ -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-settings_menu";
|
||||||
import "ace-builds/src-noconflict/ext-keybinding_menu";
|
import "ace-builds/src-noconflict/ext-keybinding_menu";
|
||||||
import "ace-builds/src-noconflict/ext-command_bar";
|
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/ext-language_tools";
|
||||||
import "ace-builds/src-noconflict/theme-one_dark";
|
import "ace-builds/src-noconflict/theme-one_dark";
|
||||||
import "ace-builds/src-noconflict/theme-dracula";
|
import "ace-builds/src-noconflict/theme-dracula";
|
||||||
|
Loading…
Reference in New Issue
Block a user