mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-12-02 10:27:32 -06:00
Further work towards a better code linking colours
This commit is contained in:
+17
-17
@@ -1,25 +1,25 @@
|
||||
// Copyright (c) 2016, Matt Godbolt
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
"use strict";
|
||||
|
||||
|
||||
@@ -1350,14 +1350,14 @@ Compiler.prototype.onPanesLinkLine = function (compilerId, lineNumber, revealLin
|
||||
}
|
||||
});
|
||||
if (revealLine && lineNums[0]) this.outputEditor.revealLineInCenter(lineNums[0]);
|
||||
var inlineClass = sender !== this.getPaneName() ? 'linked-code-decoration-inline' : '';
|
||||
var lineClass = sender !== this.getPaneName() ? 'linked-code-decoration-line' : '';
|
||||
this.decorations.linkedCode = _.map(lineNums, function (line) {
|
||||
return {
|
||||
range: new monaco.Range(line, 1, line, 1),
|
||||
options: {
|
||||
isWholeLine: true,
|
||||
linesDecorationsClassName: 'linked-code-decoration-margin',
|
||||
inlineClassName: inlineClass
|
||||
className: lineClass
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
@@ -441,7 +441,7 @@ Editor.prototype.initEditorActions = function () {
|
||||
|
||||
this.editor.addAction({
|
||||
id: 'viewasm',
|
||||
label: 'Scroll to assembly',
|
||||
label: 'Reveal linked code',
|
||||
keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.F10],
|
||||
keybindingContext: null,
|
||||
contextMenuGroupId: 'navigation',
|
||||
@@ -706,7 +706,7 @@ Editor.prototype.onEditorLinkLine = function (editorId, lineNum, reveal) {
|
||||
options: {
|
||||
isWholeLine: true,
|
||||
linesDecorationsClassName: 'linked-code-decoration-margin',
|
||||
inlineClassName: 'linked-code-decoration-inline'
|
||||
className: 'linked-code-decoration-line'
|
||||
}
|
||||
}];
|
||||
|
||||
|
||||
@@ -125,9 +125,8 @@ Ir.prototype.onCompileResponse = function (id, compiler, result) {
|
||||
if (this._compilerid !== id) return;
|
||||
if (result.hasIrOutput) {
|
||||
this.showIrResults(result.irOutput);
|
||||
}
|
||||
else if (compiler.supportsIrView) {
|
||||
this.showIrResults([{text:"<No output>"}]);
|
||||
} else if (compiler.supportsIrView) {
|
||||
this.showIrResults([{text: "<No output>"}]);
|
||||
}
|
||||
|
||||
// Why call this explicitly instead of just listening to the "colours" event?
|
||||
@@ -227,7 +226,7 @@ Ir.prototype.onMouseMove = function (e) {
|
||||
var hoverCode = this.irCode[e.target.position.lineNumber - 1];
|
||||
if (hoverCode) {
|
||||
// We check that we actually have something to show at this point!
|
||||
var sourceLine = hoverCode.source && !hoverCode.source.file ? hoverCode.source.line : -1;
|
||||
var sourceLine = hoverCode.source && !hoverCode.source.file ? hoverCode.source.line : -1;
|
||||
this.eventHub.emit('editorLinkLine', this._editorid, sourceLine, false);
|
||||
this.eventHub.emit('panesLinkLine', this._compilerid, sourceLine, false, this.getPaneName());
|
||||
}
|
||||
@@ -249,18 +248,19 @@ Ir.prototype.onPanesLinkLine = function (compilerId, lineNumber, revealLine, sen
|
||||
var lineNums = [];
|
||||
_.each(this.irCode, function (irLine, i) {
|
||||
if (irLine.source && irLine.source.file === null && irLine.source.line === lineNumber) {
|
||||
lineNums.push(i + 1);
|
||||
var line = i + 1;
|
||||
lineNums.push(line);
|
||||
}
|
||||
});
|
||||
if (revealLine && lineNums[0]) this.irEditor.revealLineInCenter(lineNums[0]);
|
||||
var inlineClass = sender !== this.getPaneName() ? 'linked-code-decoration-inline' : '';
|
||||
var lineClass = sender !== this.getPaneName() ? 'linked-code-decoration-line' : '';
|
||||
this.decorations.linkedCode = _.map(lineNums, function (line) {
|
||||
return {
|
||||
range: new monaco.Range(line, 1, line, 1),
|
||||
options: {
|
||||
isWholeLine: true,
|
||||
linesDecorationsClassName: 'linked-code-decoration-margin',
|
||||
inlineClassName: inlineClass
|
||||
className: lineClass
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
@@ -77,6 +77,10 @@ a.navbar-brand img.logo.normal {
|
||||
background: lightblue;
|
||||
}
|
||||
|
||||
.linked-code-decoration-line {
|
||||
background: lightblue !important;
|
||||
}
|
||||
|
||||
.font-option {
|
||||
background: white;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user