Improve syntax highlight switching on AST and Opt

This commit is contained in:
RabsRincon
2018-03-28 22:23:06 +02:00
parent fde853c784
commit 2e219a2294
8 changed files with 35 additions and 23 deletions

View File

@@ -1,4 +1,4 @@
// Type your code here, or load an example.
int square(int num) {
return num * num;
return num * num;
}

View File

@@ -3,7 +3,7 @@
package main
func Square(x int) int {
return x * x
return x * x
}
func main() {}

View File

@@ -1,4 +1,4 @@
define i32 @square(i32) local_unnamed_addr #0 {
%2 = mul nsw i32 %0, %0
ret i32 %2
%2 = mul nsw i32 %0, %0
ret i32 %2
}

View File

@@ -10,7 +10,7 @@ implementation
function Square(const num: Integer): Integer;
begin
Square := num * num;
Square := num * num;
end;
end.

View File

@@ -1,4 +1,4 @@
// Type your code here, or load an example.
pub fn square(num: i32) -> i32 {
num * num
num * num
}

View File

@@ -37,7 +37,7 @@ function Ast(hub, container, state) {
this.astEditor = monaco.editor.create(this.domRoot.find(".monaco-placeholder")[0], {
value: "",
scrollBeyondLastLine: false,
language: 'text',
language: 'plaintext',
readOnly: true,
glyphMargin: true,
fontFamily: 'Consolas, "Liberation Mono", Courier, monospace',
@@ -94,17 +94,23 @@ Ast.prototype.resize = function () {
};
Ast.prototype.onCompileResult = function (id, compiler, result, lang) {
if (this._compilerid === id) {
if (result.hasAstOutput) {
this.showAstResults(result.astOutput);
}
else {
this.showAstResults("<No output>");
}
if (lang && lang.monaco) {
monaco.editor.setModelLanguage(this.astEditor.getModel(), lang.monaco);
}
if (this._compilerid !== id) return;
if (result.hasAstOutput) {
this.showAstResults(result.astOutput);
}
else {
this.showAstResults("<No output>");
}
if (lang && lang.monaco && this.getCurrentEditorLanguage() !== lang.monaco) {
monaco.editor.setModelLanguage(this.astEditor.getModel(), lang.monaco);
}
};
// Monaco language id of the current editor
Ast.prototype.getCurrentEditorLanguage = function () {
return this.astEditor.getModel().getModeId();
};
Ast.prototype.setTitle = function () {

View File

@@ -194,7 +194,7 @@ GccDump.prototype.onCompileResult = function (id, compiler, result) {
if (result.hasGccDumpOutput && result.gccDumpOutput.syntaxHighlight) {
monaco.editor.setModelLanguage(this.gccDumpEditor.getModel(), 'gccdump-rtl-gimple');
} else {
monaco.editor.setModelLanguage(this.gccDumpEditor.getModel(), 'text');
monaco.editor.setModelLanguage(this.gccDumpEditor.getModel(), 'plaintext');
}
if (result.hasGccDumpOutput) {

View File

@@ -43,7 +43,7 @@ function Opt(hub, container, state) {
this.optEditor = monaco.editor.create(this.domRoot.find(".monaco-placeholder")[0], {
value: this.code,
scrollBeyondLastLine: false,
language: 'text',
language: 'plaintext',
readOnly: true,
glyphMargin: true,
quickSuggestions: false,
@@ -101,12 +101,18 @@ Opt.prototype.initCallbacks = function () {
};
Opt.prototype.onCompileResult = function (id, compiler, result, lang) {
if (result.hasOptOutput && this._compilerid === id) {
if (this._compilerid !== id) return;
if (result.hasOptOutput) {
this.showOptResults(result.optOutput);
if (lang && lang.monaco) {
monaco.editor.setModelLanguage(this.optEditor.getModel(), lang.monaco);
}
}
if (lang && lang.monaco && this.getCurrentEditorLanguage() !== lang.monaco) {
monaco.editor.setModelLanguage(this.optEditor.getModel(), lang.monaco);
}
};
// Monaco language id of the current editor
Opt.prototype.getCurrentEditorLanguage = function () {
return this.optEditor.getModel().getModeId();
};
Opt.prototype.setTitle = function () {