initial push
This commit is contained in:
28
src/app/common/configs/editor.config.ts
Normal file
28
src/app/common/configs/editor.config.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { Keybindings } from './keybindings.config';
|
||||
|
||||
export const EditorSettings: any = {
|
||||
// BASE_PATH: 'https:cdnjs.cloudflare.com/ajax/libs/ace/1.40.1/',
|
||||
BASE_PATH: 'ace',
|
||||
KEYBINDINGS: Keybindings,
|
||||
CONFIG: {
|
||||
behavioursEnabled: true,
|
||||
fontSize: "12px",
|
||||
theme: "ace/theme/one_dark",
|
||||
printMarginColumn: 80,
|
||||
enableBasicAutocompletion: true,
|
||||
enableLiveAutocompletion: true,
|
||||
enableSnippets: true,
|
||||
highlightActiveLine: true,
|
||||
enableMultiselect: true,
|
||||
tabSize: 4,
|
||||
useSoftTabs: true,
|
||||
tooltipFollowsMouse: true,
|
||||
wrapBehavioursEnabled: false,
|
||||
scrollPastEnd: 0.5,
|
||||
mergeUndoDeltas: false,
|
||||
showGutter: true,
|
||||
customScrollbar: true,
|
||||
navigateWithinSoftTabs: true,
|
||||
scrollSpeed: 5
|
||||
}
|
||||
};
|
142
src/app/common/configs/keybinding-newton.js
Normal file
142
src/app/common/configs/keybinding-newton.js
Normal file
@@ -0,0 +1,142 @@
|
||||
const editorCommands = [
|
||||
{
|
||||
name: "showSettingsMenu",
|
||||
bindKey: {win: "Ctrl-Shift-m", mac: "Ctrl-Shift-m"},
|
||||
exec: function(editor) {
|
||||
ace.config.loadModule("ace/ext/settings_menu", function(module) {
|
||||
module.init(editor);
|
||||
editor.showSettingsMenu();
|
||||
})
|
||||
}
|
||||
}, {
|
||||
name: "showKeyboardShortcuts",
|
||||
bindKey: {win: "ctrl-shift-h", mac: "command-shift-h"},
|
||||
exec: function(editor) {
|
||||
ace.config.loadModule("ace/ext/keybinding_menu", function(module) {
|
||||
module.init(editor);
|
||||
editor.showKeyboardShortcuts();
|
||||
})
|
||||
}
|
||||
}, {
|
||||
name: "openCommandPalette2",
|
||||
bindKey: {linux: "Command-Shift-/|F1", win: "Ctrl-Shift-/|F1"},
|
||||
exec: function(editor) {
|
||||
editor.execCommand("openCommandPalette");
|
||||
}
|
||||
}, {
|
||||
name: "showLSPManager",
|
||||
bindKey: {win: "ctrl-m", mac: "command-m"},
|
||||
exec: function(editor) {
|
||||
$('#lsp-modal').modal("toggle");
|
||||
}
|
||||
}, {
|
||||
name: "search",
|
||||
bindKey: {win: "ctrl-f", mac: "ctrl-f"},
|
||||
exec: function(editor) {
|
||||
blockHigherNewtonEvePropigation = true;
|
||||
searchReplace.toggleShow();
|
||||
},
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "openFile",
|
||||
bindKey: {win: "ctrl-o", mac: "ctrl-o"},
|
||||
exec: function(editor) {
|
||||
fpath = aceSessions[currentSession]["fpath"]
|
||||
sendMessage("open_file", "", "", fpath, "");
|
||||
},
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "saveSession",
|
||||
bindKey: {win: "ctrl-s", mac: "ctrl-s"},
|
||||
exec: function(editor) {
|
||||
saveSession(currentSession);
|
||||
},
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "newSession",
|
||||
bindKey: {win: "ctrl-t", mac: "ctrl-t"},
|
||||
exec: function(editor) {
|
||||
newSession();
|
||||
},
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "closeSession",
|
||||
bindKey: {win: "ctrl-w", mac: "ctrl-w"},
|
||||
exec: function(editor) {
|
||||
closeSession(currentSession);
|
||||
},
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "toggleLineHighlight",
|
||||
bindKey: {win: "ctrl-h", mac: "ctrl-h"},
|
||||
exec: function(editor) {
|
||||
toggleLineHighlight();
|
||||
},
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "gotoDefinition",
|
||||
bindKey: {win: "ctrl-g", mac: "ctrl-g"},
|
||||
exec: function(editor) {
|
||||
console.log("Goto stub...");
|
||||
// lspProvider.$messageController.postMessage(Message(), callback);
|
||||
},
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "movelinesUp",
|
||||
bindKey: {win: "ctrl-up", mac: "ctrl-up"},
|
||||
exec: function(editor) {
|
||||
editor.execCommand("movelinesup");
|
||||
},
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "movelinesDown",
|
||||
bindKey: {win: "ctrl-down", mac: "ctrl-down"},
|
||||
exec: function(editor) {
|
||||
editor.execCommand("movelinesdown");
|
||||
},
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "tgglTopMainMenubar",
|
||||
bindKey: {win: "ctrl-0", mac: "ctrl-0"},
|
||||
exec: function(editor) {
|
||||
sendMessage("tggl_top_main_menubar", "", "", "", "");
|
||||
},
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "zoomIn",
|
||||
bindKey: {win: "ctrl-=", mac: "ctrl-="},
|
||||
exec: function(editor) {
|
||||
zoomIn();
|
||||
},
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "zoomOut",
|
||||
bindKey: {win: "ctrl--", mac: "ctrl--"},
|
||||
exec: function(editor) {
|
||||
zoomOut();
|
||||
},
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "scrollUp",
|
||||
bindKey: {win: "alt-up", mac: "alt-up"},
|
||||
exec: function(editor) {
|
||||
editor.execCommand("scrollup");
|
||||
},
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "scrollDown",
|
||||
bindKey: {win: "alt-down", mac: "alt-down"},
|
||||
exec: function(editor) {
|
||||
editor.execCommand("scrolldown");
|
||||
},
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "launhLSP",
|
||||
bindKey: {win: "ctrl-l", mac: "ctrl-l"},
|
||||
exec: function(editor) {
|
||||
loadLSPManager();
|
||||
},
|
||||
readOnly: true
|
||||
}
|
||||
|
||||
];
|
146
src/app/common/configs/keybindings.config.ts
Normal file
146
src/app/common/configs/keybindings.config.ts
Normal file
@@ -0,0 +1,146 @@
|
||||
export const Keybindings: Array<any> = [
|
||||
// export const Keybindings: any = [
|
||||
// {
|
||||
// name: "showSettingsMenu",
|
||||
// bindKey: {win: "Ctrl-Shift-m", mac: "Ctrl-Shift-m"},
|
||||
// exec: () => {
|
||||
// ace.config.loadModule("ace/ext/settings_menu", function(module) {
|
||||
// module.init(editor);
|
||||
// editor.showSettingsMenu();
|
||||
// })
|
||||
// }
|
||||
// }, {
|
||||
// name: "showKeyboardShortcuts",
|
||||
// bindKey: {win: "ctrl-shift-h", mac: "command-shift-h"},
|
||||
// exec: () => {
|
||||
// ace.config.loadModule("ace/ext/keybinding_menu", function(module) {
|
||||
// module.init(editor);
|
||||
// editor.showKeyboardShortcuts();
|
||||
// })
|
||||
// }
|
||||
// }, {
|
||||
// name: "openCommandPalette2",
|
||||
// bindKey: {linux: "Command-Shift-/|F1", win: "Ctrl-Shift-/|F1"},
|
||||
// exec: () => {
|
||||
// editor.execCommand("openCommandPalette");
|
||||
// }
|
||||
// }, {
|
||||
// name: "showLSPManager",
|
||||
// bindKey: {win: "ctrl-m", mac: "command-m"},
|
||||
// exec: () => {
|
||||
// $('//lsp-modal').modal("toggle");
|
||||
// }
|
||||
// }, {
|
||||
{
|
||||
name: "search",
|
||||
bindKey: {win: "ctrl-f", mac: "ctrl-f"},
|
||||
exec: () => {
|
||||
// blockHigherNewtonEvePropigation = true;
|
||||
// searchReplace.toggleShow();
|
||||
console.log("Search");
|
||||
},
|
||||
readOnly: true
|
||||
}
|
||||
// }, {
|
||||
// name: "openFile",
|
||||
// bindKey: {win: "ctrl-o", mac: "ctrl-o"},
|
||||
// exec: () => {
|
||||
// fpath = aceSessions[currentSession]["fpath"]
|
||||
// sendMessage("open_file", "", "", fpath, "");
|
||||
// },
|
||||
// readOnly: true
|
||||
// }, {
|
||||
// name: "saveSession",
|
||||
// bindKey: {win: "ctrl-s", mac: "ctrl-s"},
|
||||
// exec: () => {
|
||||
// saveSession(currentSession);
|
||||
// },
|
||||
// readOnly: true
|
||||
// }, {
|
||||
// name: "newSession",
|
||||
// bindKey: {win: "ctrl-t", mac: "ctrl-t"},
|
||||
// exec: () => {
|
||||
// newSession();
|
||||
// },
|
||||
// readOnly: true
|
||||
// }, {
|
||||
// name: "closeSession",
|
||||
// bindKey: {win: "ctrl-w", mac: "ctrl-w"},
|
||||
// exec: () => {
|
||||
// closeSession(currentSession);
|
||||
// },
|
||||
// readOnly: true
|
||||
// }, {
|
||||
// name: "toggleLineHighlight",
|
||||
// bindKey: {win: "ctrl-h", mac: "ctrl-h"},
|
||||
// exec: () => {
|
||||
// toggleLineHighlight();
|
||||
// },
|
||||
// readOnly: true
|
||||
// }, {
|
||||
// name: "gotoDefinition",
|
||||
// bindKey: {win: "ctrl-g", mac: "ctrl-g"},
|
||||
// exec: () => {
|
||||
// console.log("Goto stub...");
|
||||
// lspProvider.$messageController.postMessage(Message(), callback);
|
||||
// },
|
||||
// readOnly: true
|
||||
// }, {
|
||||
// name: "movelinesUp",
|
||||
// bindKey: {win: "ctrl-up", mac: "ctrl-up"},
|
||||
// exec: () => {
|
||||
// editor.execCommand("movelinesup");
|
||||
// },
|
||||
// readOnly: true
|
||||
// }, {
|
||||
// name: "movelinesDown",
|
||||
// bindKey: {win: "ctrl-down", mac: "ctrl-down"},
|
||||
// exec: () => {
|
||||
// editor.execCommand("movelinesdown");
|
||||
// },
|
||||
// readOnly: true
|
||||
// }, {
|
||||
// name: "tgglTopMainMenubar",
|
||||
// bindKey: {win: "ctrl-0", mac: "ctrl-0"},
|
||||
// exec: () => {
|
||||
// sendMessage("tggl_top_main_menubar", "", "", "", "");
|
||||
// },
|
||||
// readOnly: true
|
||||
// }, {
|
||||
// name: "zoomIn",
|
||||
// bindKey: {win: "ctrl-=", mac: "ctrl-="},
|
||||
// exec: () => {
|
||||
// zoomIn();
|
||||
// },
|
||||
// readOnly: true
|
||||
// }, {
|
||||
// name: "zoomOut",
|
||||
// bindKey: {win: "ctrl--", mac: "ctrl--"},
|
||||
// exec: () => {
|
||||
// zoomOut();
|
||||
// },
|
||||
// readOnly: true
|
||||
// }, {
|
||||
// name: "scrollUp",
|
||||
// bindKey: {win: "alt-up", mac: "alt-up"},
|
||||
// exec: () => {
|
||||
// editor.execCommand("scrollup");
|
||||
// },
|
||||
// readOnly: true
|
||||
// }, {
|
||||
// name: "scrollDown",
|
||||
// bindKey: {win: "alt-down", mac: "alt-down"},
|
||||
// exec: () => {
|
||||
// editor.execCommand("scrolldown");
|
||||
// },
|
||||
// readOnly: true
|
||||
// }, {
|
||||
// name: "launhLSP",
|
||||
// bindKey: {win: "ctrl-l", mac: "ctrl-l"},
|
||||
// exec: () => {
|
||||
// loadLSPManager();
|
||||
// },
|
||||
// readOnly: true
|
||||
// }
|
||||
|
||||
];
|
46
src/app/common/directives/dnd.directive.ts
Normal file
46
src/app/common/directives/dnd.directive.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import {
|
||||
Directive,
|
||||
Output,
|
||||
Input,
|
||||
EventEmitter,
|
||||
HostBinding,
|
||||
HostListener
|
||||
} from '@angular/core';
|
||||
|
||||
import { NewtonFile } from '../types/file.type';
|
||||
|
||||
|
||||
@Directive({
|
||||
selector: '[dropzone]'
|
||||
})
|
||||
export class DndDirective {
|
||||
@HostBinding('class.fileover') fileOver!: boolean;
|
||||
@Output() fileDropped = new EventEmitter<any>();
|
||||
|
||||
@HostListener('dragover', ['$event']) onDragOver(evt: any) {
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
|
||||
this.fileOver = true;
|
||||
}
|
||||
|
||||
@HostListener('dragleave', ['$event']) public onDragLeave(evt: any) {
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
|
||||
this.fileOver = false;
|
||||
}
|
||||
|
||||
@HostListener('drop', ['$event']) public ondrop(evt: any) {
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
|
||||
this.fileOver = false;
|
||||
let files: Array<NewtonFile> = evt.dataTransfer.files;
|
||||
|
||||
if (files.length == 0) return;
|
||||
|
||||
this.fileDropped.emit(files);
|
||||
}
|
||||
|
||||
}
|
22
src/app/common/services/editor/editors.service.ts
Normal file
22
src/app/common/services/editor/editors.service.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { BehaviorSubject, ReplaySubject, Observable } from 'rxjs';
|
||||
|
||||
import { ServiceMessage } from '../../types/service-message.type';
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class EditorsService {
|
||||
private dataSubject: ReplaySubject<ServiceMessage> = new ReplaySubject<ServiceMessage>(1);
|
||||
|
||||
constructor() {}
|
||||
|
||||
setData(data: ServiceMessage): void {
|
||||
this.dataSubject.next(data);
|
||||
}
|
||||
|
||||
getData$(): Observable<ServiceMessage> {
|
||||
return this.dataSubject.asObservable();
|
||||
}
|
||||
}
|
22
src/app/common/services/editor/tabs/tabs.service.ts
Normal file
22
src/app/common/services/editor/tabs/tabs.service.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { BehaviorSubject, ReplaySubject, Observable } from 'rxjs';
|
||||
|
||||
import { ServiceMessage } from '../../../types/service-message.type';
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class TabsService {
|
||||
private dataSubject: ReplaySubject<ServiceMessage> = new ReplaySubject<ServiceMessage>(1);
|
||||
|
||||
constructor() {}
|
||||
|
||||
setData(data: ServiceMessage): void {
|
||||
this.dataSubject.next(data);
|
||||
}
|
||||
|
||||
getData$(): Observable<ServiceMessage> {
|
||||
return this.dataSubject.asObservable();
|
||||
}
|
||||
}
|
9
src/app/common/types/file.type.ts
Normal file
9
src/app/common/types/file.type.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { EditSession } from 'ace-builds';
|
||||
|
||||
|
||||
export interface NewtonFile extends File {
|
||||
fname: string,
|
||||
path: string,
|
||||
hash: string,
|
||||
session: EditSession
|
||||
}
|
5
src/app/common/types/service-message.type.ts
Normal file
5
src/app/common/types/service-message.type.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export class ServiceMessage {
|
||||
action: string = "none";
|
||||
message: string = "";
|
||||
uuid!: string;
|
||||
}
|
Reference in New Issue
Block a user