From 1dae8cc71fdc26cd95087bee95aeab351dabdc46 Mon Sep 17 00:00:00 2001 From: RabsRincon Date: Wed, 27 Mar 2019 21:21:03 +0100 Subject: [PATCH] Further work towards a better code linking colours --- static/colour.js | 34 ++++++++++++++++----------------- static/panes/compiler.js | 4 ++-- static/panes/editor.js | 4 ++-- static/panes/ir-view.js | 14 +++++++------- static/themes/default-theme.css | 4 ++++ 5 files changed, 32 insertions(+), 28 deletions(-) diff --git a/static/colour.js b/static/colour.js index 2733413e7..bed22cb16 100644 --- a/static/colour.js +++ b/static/colour.js @@ -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"; diff --git a/static/panes/compiler.js b/static/panes/compiler.js index 7db1fa482..bc35c58e9 100644 --- a/static/panes/compiler.js +++ b/static/panes/compiler.js @@ -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 } }; }); diff --git a/static/panes/editor.js b/static/panes/editor.js index ecc651e61..69329dabb 100644 --- a/static/panes/editor.js +++ b/static/panes/editor.js @@ -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' } }]; diff --git a/static/panes/ir-view.js b/static/panes/ir-view.js index b1c8df354..859e04096 100644 --- a/static/panes/ir-view.js +++ b/static/panes/ir-view.js @@ -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:""}]); + } else if (compiler.supportsIrView) { + this.showIrResults([{text: ""}]); } // 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 } }; }); diff --git a/static/themes/default-theme.css b/static/themes/default-theme.css index e92091b15..f43547145 100644 --- a/static/themes/default-theme.css +++ b/static/themes/default-theme.css @@ -77,6 +77,10 @@ a.navbar-brand img.logo.normal { background: lightblue; } +.linked-code-decoration-line { + background: lightblue !important; +} + .font-option { background: white; }