WIP context menu added; upgraded ace-linters; integrated auto session register
This commit is contained in:
@@ -114,7 +114,6 @@ const chooseFolder = () => {
|
|||||||
console.debug("Canceled folder selection...");
|
console.debug("Canceled folder selection...");
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
console.log(response)
|
|
||||||
|
|
||||||
return response.filePaths[0];
|
return response.filePaths[0];
|
||||||
});
|
});
|
||||||
|
@@ -54,7 +54,7 @@
|
|||||||
"ace-builds": "1.43.0",
|
"ace-builds": "1.43.0",
|
||||||
"ace-diff": "3.0.3",
|
"ace-diff": "3.0.3",
|
||||||
"ace-layout": "1.5.0",
|
"ace-layout": "1.5.0",
|
||||||
"ace-linters": "1.7.1",
|
"ace-linters": "1.8.1",
|
||||||
"bootstrap": "5.3.6",
|
"bootstrap": "5.3.6",
|
||||||
"bootstrap-icons": "1.12.1",
|
"bootstrap-icons": "1.12.1",
|
||||||
"chokidar": "4.0.3",
|
"chokidar": "4.0.3",
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
"java": {
|
"java": {
|
||||||
|
"home": "/usr/lib/jvm/java-17-openjdk",
|
||||||
"autobuild": {
|
"autobuild": {
|
||||||
"enabled": false
|
"enabled": false
|
||||||
},
|
},
|
||||||
@@ -44,8 +45,8 @@
|
|||||||
},
|
},
|
||||||
"runtimes": [
|
"runtimes": [
|
||||||
{
|
{
|
||||||
"name": "JavaSE-17",
|
"name": "JavaJDK-17",
|
||||||
"path": "/usr/lib/jvm/default-runtime",
|
"path": "/usr/lib/jvm/java-17-openjdk",
|
||||||
"javadoc": "https://docs.oracle.com/en/java/javase/17/docs/api/",
|
"javadoc": "https://docs.oracle.com/en/java/javase/17/docs/api/",
|
||||||
"default": true
|
"default": true
|
||||||
}
|
}
|
||||||
@@ -59,7 +60,6 @@
|
|||||||
"{user.home}/.config/jdtls/m2/repository/**/*-javadoc.jar",
|
"{user.home}/.config/jdtls/m2/repository/**/*-javadoc.jar",
|
||||||
"lib/**/*-javadoc.jar"
|
"lib/**/*-javadoc.jar"
|
||||||
],
|
],
|
||||||
"silentNotification": true,
|
|
||||||
"project": {
|
"project": {
|
||||||
"encoding": "ignore",
|
"encoding": "ignore",
|
||||||
"outputPath": "bin",
|
"outputPath": "bin",
|
||||||
@@ -133,6 +133,7 @@
|
|||||||
"downloadSources": true,
|
"downloadSources": true,
|
||||||
"updateSnapshots": true
|
"updateSnapshots": true
|
||||||
},
|
},
|
||||||
|
"silentNotification": false,
|
||||||
"signatureHelp": {
|
"signatureHelp": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"description": {
|
"description": {
|
||||||
@@ -141,6 +142,15 @@
|
|||||||
},
|
},
|
||||||
"implementationsCodeLens": {
|
"implementationsCodeLens": {
|
||||||
"enabled": true
|
"enabled": true
|
||||||
|
},
|
||||||
|
"referencesCodeLens": {
|
||||||
|
"enabled": true
|
||||||
|
},
|
||||||
|
"progressReports": {
|
||||||
|
"enabled": false
|
||||||
|
},
|
||||||
|
"saveActions": {
|
||||||
|
"organizeImports": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
5
src/app/common/constants/button.map.ts
Normal file
5
src/app/common/constants/button.map.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
export abstract class ButtonMap {
|
||||||
|
static LEFT: number = 0;
|
||||||
|
static MIDDLE: number = 1;
|
||||||
|
static RIGHT: number = 2;
|
||||||
|
}
|
@@ -35,10 +35,7 @@ export class LspManagerService {
|
|||||||
|
|
||||||
this.languageProviders[mode]?.registerEditor(
|
this.languageProviders[mode]?.registerEditor(
|
||||||
editor,
|
editor,
|
||||||
{
|
editor.session.lspConfig
|
||||||
filePath: editor.session["id"],
|
|
||||||
joinWorkspaceURI: true
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,8 +94,13 @@ export class LspManagerService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.languageProviders[mode] = AceLanguageClient.for(servers);
|
this.languageProviders[mode] = AceLanguageClient.for(
|
||||||
// this.languageProviders[mode].requireFilePath = true;
|
servers,
|
||||||
|
{
|
||||||
|
manualSessionControl: true
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
this.languageProviders[mode].changeWorkspaceFolder(this.workspaceFolder);
|
this.languageProviders[mode].changeWorkspaceFolder(this.workspaceFolder);
|
||||||
return this.languageProviders[mode];
|
return this.languageProviders[mode];
|
||||||
}
|
}
|
||||||
@@ -108,11 +110,15 @@ export class LspManagerService {
|
|||||||
return LanguageProvider.create(worker);
|
return LanguageProvider.create(worker);
|
||||||
}
|
}
|
||||||
|
|
||||||
public setSessionFilePath(session: any, filePath: string = "") {
|
public registerSession(editor: any) {
|
||||||
if ( !session || !filePath ) return;
|
let mode = this.getMode(editor.session);
|
||||||
let mode = this.getMode(session);
|
|
||||||
if ( !this.languageProviders[mode] ) return;
|
if ( !this.languageProviders[mode] ) return;
|
||||||
this.languageProviders[mode].setSessionFilePath(session, filePath);
|
|
||||||
|
this.languageProviders[mode].registerSession(
|
||||||
|
editor.session,
|
||||||
|
editor,
|
||||||
|
editor.session.lspConfig
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getMode(session: any): string {
|
public getMode(session: any): string {
|
||||||
|
@@ -111,6 +111,10 @@ export class FilesService {
|
|||||||
file.session["id"] = path;
|
file.session["id"] = path;
|
||||||
file.session.setUndoManager( new UndoManager() );
|
file.session.setUndoManager( new UndoManager() );
|
||||||
file.session.setMode( getModeForPath( file.path ).mode );
|
file.session.setMode( getModeForPath( file.path ).mode );
|
||||||
|
file.session["lspConfig"] = {
|
||||||
|
filePath: path,
|
||||||
|
joinWorkspaceURI: false
|
||||||
|
}
|
||||||
|
|
||||||
this.files.set(file.path, file);
|
this.files.set(file.path, file);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@@ -46,6 +46,9 @@ export class CodeViewBase {
|
|||||||
public debounceId: number = -1;
|
public debounceId: number = -1;
|
||||||
public debounceWait: number = 800;
|
public debounceWait: number = 800;
|
||||||
|
|
||||||
|
@ViewChild('contextMenu') contextMenu!: ElementRef;
|
||||||
|
public showContextMenu: boolean = false;
|
||||||
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
}
|
}
|
||||||
|
@@ -26,3 +26,23 @@
|
|||||||
border-width: thin;
|
border-width: thin;
|
||||||
border-color: rgba(124, 124, 124, 1);
|
border-color: rgba(124, 124, 124, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.contextMenu {
|
||||||
|
display: inline-table;
|
||||||
|
z-index: 500;
|
||||||
|
position: absolute;
|
||||||
|
min-width: 2em;
|
||||||
|
padding: 0.2em;
|
||||||
|
top: 0em;
|
||||||
|
right: 0em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contextMenu li:hover {
|
||||||
|
background-color: rgba(0, 124, 0, 0.64);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contextMenu li {
|
||||||
|
padding: 0em 0.2em;
|
||||||
|
}
|
||||||
|
@@ -1,2 +1,15 @@
|
|||||||
<div class="editor" #editor >
|
<div class="editor" #editor >
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<ul #contextMenu
|
||||||
|
class="contextMenu"
|
||||||
|
[hidden]="!showContextMenu"
|
||||||
|
(blur)="hideContextMenu"
|
||||||
|
(click)="contextMenuClicked($event)"
|
||||||
|
>
|
||||||
|
<li command="cutText">Cut</li>
|
||||||
|
<li command="copyText">Copy</li>
|
||||||
|
<li command="pasteText">Paste</li>
|
||||||
|
<hr/>
|
||||||
|
<li command="prettyJSON">Prettify JSON</li>
|
||||||
|
</ul>
|
@@ -25,6 +25,7 @@ import { CodeViewBase } from './view.base';
|
|||||||
import { NewtonFile } from '../../common/types/file.type';
|
import { NewtonFile } from '../../common/types/file.type';
|
||||||
import { EditorType } from '../../common/types/editor.type';
|
import { EditorType } from '../../common/types/editor.type';
|
||||||
import { ServiceMessage } from '../../common/types/service-message.type';
|
import { ServiceMessage } from '../../common/types/service-message.type';
|
||||||
|
import { ButtonMap } from '../../common/constants/button.map';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -159,10 +160,30 @@ export class CodeViewComponent extends CodeViewBase {
|
|||||||
this.updateInfoBar();
|
this.updateInfoBar();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.editor.on("click", () => {
|
this.editor.on("click", (event) => {
|
||||||
this.updateInfoBar();
|
this.updateInfoBar();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.editor.addEventListener("mousedown", (event) => {
|
||||||
|
if (ButtonMap.LEFT === event.domEvent.button) {
|
||||||
|
this.showContextMenu = false;
|
||||||
|
} else if (ButtonMap.RIGHT === event.domEvent.button) {
|
||||||
|
let menuElm = this.contextMenu.nativeElement;
|
||||||
|
let pageX = event.domEvent.pageX;
|
||||||
|
let pageY = event.domEvent.pageY;
|
||||||
|
|
||||||
|
const origin = {
|
||||||
|
left: pageX + 5,
|
||||||
|
top: pageY - 5
|
||||||
|
};
|
||||||
|
|
||||||
|
menuElm.style.left = `${origin.left}px`;
|
||||||
|
menuElm.style.top = `${origin.top}px`;
|
||||||
|
this.showContextMenu = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this.editor.on("input", () => {
|
this.editor.on("input", () => {
|
||||||
this.updateInfoBar();
|
this.updateInfoBar();
|
||||||
});
|
});
|
||||||
@@ -219,6 +240,28 @@ export class CodeViewComponent extends CodeViewBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public prettyJSON() {
|
||||||
|
let data = JSON.parse(this.editor.session.getValue());
|
||||||
|
this.editor.session.setValue(
|
||||||
|
JSON.stringify(data, null, 4)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public hideContextMenu() {
|
||||||
|
this.showContextMenu = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public contextMenuClicked(event: any) {
|
||||||
|
this.showContextMenu = false;
|
||||||
|
|
||||||
|
const command = event.target.getAttribute("command");
|
||||||
|
const args = event.target.getAttribute("args");
|
||||||
|
|
||||||
|
if (!command) return;
|
||||||
|
|
||||||
|
this[command]( (args) ? args : null );
|
||||||
|
}
|
||||||
|
|
||||||
public assignSession(file: NewtonFile) {
|
public assignSession(file: NewtonFile) {
|
||||||
if (!file) return;
|
if (!file) return;
|
||||||
|
|
||||||
@@ -231,6 +274,11 @@ export class CodeViewComponent extends CodeViewBase {
|
|||||||
|
|
||||||
this.activeFile = file;
|
this.activeFile = file;
|
||||||
let session = this.aceApi.createEditSession(file.session.getValue());
|
let session = this.aceApi.createEditSession(file.session.getValue());
|
||||||
|
session["$config"] = {
|
||||||
|
"lsp": {
|
||||||
|
"filePath": file.path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
session.setMode( file.session.getMode()["$id"] );
|
session.setMode( file.session.getMode()["$id"] );
|
||||||
this.editor.setSession(session);
|
this.editor.setSession(session);
|
||||||
|
@@ -101,12 +101,6 @@ export class LspManagerComponent {
|
|||||||
|
|
||||||
public registerEditorToLanguageClient() {
|
public registerEditorToLanguageClient() {
|
||||||
this.lspManagerService.registerEditorToLSPClient(this.editor);
|
this.lspManagerService.registerEditorToLSPClient(this.editor);
|
||||||
/*
|
|
||||||
this.lspManagerService.setSessionFilePath(
|
|
||||||
this.editor.session,
|
|
||||||
this.activeFile.path
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -148,13 +142,7 @@ export class LspManagerComponent {
|
|||||||
this.editor.setSession(message.rawData.editor.getSession())
|
this.editor.setSession(message.rawData.editor.getSession())
|
||||||
this.activeFile = message.rawData.activeFile;
|
this.activeFile = message.rawData.activeFile;
|
||||||
|
|
||||||
/*
|
this.lspManagerService.registerSession(this.editor);
|
||||||
this.lspManagerService.setSessionFilePath(
|
|
||||||
this.editor.session,
|
|
||||||
this.activeFile.path
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private closeFile(message: ServiceMessage) {
|
private closeFile(message: ServiceMessage) {
|
||||||
|
@@ -42,6 +42,7 @@
|
|||||||
margin-left: 2em;
|
margin-left: 2em;
|
||||||
margin-right: 2em;
|
margin-right: 2em;
|
||||||
font-size: 4em;
|
font-size: 4em;
|
||||||
|
align-self: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.close-button {
|
.close-button {
|
||||||
|
@@ -10,6 +10,10 @@ body {
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ul, li {
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* IDs */
|
/* IDs */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user