From 48ae30999e0bda9082170ceee8e380ba977f8280 Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Sat, 12 Oct 2019 15:28:21 -0500 Subject: [PATCH 1/2] Minor reformatting of css --- static/themes/dark-theme.css | 18 +++++++++++++++++- static/themes/default-theme.css | 18 +++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/static/themes/dark-theme.css b/static/themes/dark-theme.css index 48cab824c..eae538742 100644 --- a/static/themes/dark-theme.css +++ b/static/themes/dark-theme.css @@ -8,14 +8,17 @@ background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 9'%3E%3Cpath fill='%23fff' d='M.45713 8.5429l-.44426-.44438 3.5955-3.5956L.00697.90152l.8944-.89463 3.6016 3.6015 3.6014-3.6015.88867.88867-3.6014 3.6015 3.6014 3.6015-.89449.89449-3.6015-3.6014-3.5957 3.5956z'/%3E%3C/svg%3E") !important; background-size: 9px !important; } + .lm_controls .lm_maximise { background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 9'%3E%3Cpath fill='%23fff' d='M0 4.5V0h9v9H0zM8 5V2H1v6h7z'/%3E%3C/svg%3E") !important; background-size: 9px !important; } + .lm_controls .lm_close { background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 9'%3E%3Cpath fill='%23fff' d='M.45713 8.5429l-.44426-.44438 3.5955-3.5956L.00697.90152l.8944-.89463 3.6016 3.6015 3.6014-3.6015.88867.88867-3.6014 3.6015 3.6014 3.6015-.89449.89449-3.6015-3.6014-3.5957 3.5956z'/%3E%3C/svg%3E") !important; background-size: 9px !important; } + .lm_maximised .lm_controls .lm_maximise { background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 9'%3E%3Cpath fill='%23fff' d='M1.0096 8.0019v-.99809h6.9807v1.9962H1.0096z'/%3E%3C/svg%3E") !important; background-size: 9px !important; @@ -44,7 +47,7 @@ body { } .navbar-light a.nav-link { - border: rgb(140,140,140) 1px solid; + border: rgb(140, 140, 140) 1px solid; } a.navbar-brand img.logo.inverse { @@ -116,6 +119,19 @@ a.navbar-brand img.logo.normal { background: #555657 !important; } +.rainbow-decoration { + -webkit-background-clip: text; + -webkit-text-fill-color: transparent; + background-image: -webkit-gradient(linear, left top, right bottom, + color-stop(0.00, red), + color-stop(16%, orange), + color-stop(32%, yellow), + color-stop(48%, green), + color-stop(60%, blue), + color-stop(76%, indigo), + color-stop(1.00, violet)); +} + .selectize-control.single .selectize-input { color: #f2f2f2 !important; background: #666 linear-gradient(to bottom, #555, #222) !important; diff --git a/static/themes/default-theme.css b/static/themes/default-theme.css index 0ff859d8f..8c531c6da 100644 --- a/static/themes/default-theme.css +++ b/static/themes/default-theme.css @@ -8,14 +8,17 @@ background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 9'%3E%3Cpath fill='%23000' d='M.45713 8.5429l-.44426-.44438 3.5955-3.5956L.00697.90152l.8944-.89463 3.6016 3.6015 3.6014-3.6015.88867.88867-3.6014 3.6015 3.6014 3.6015-.89449.89449-3.6015-3.6014-3.5957 3.5956z'/%3E%3C/svg%3E") !important; background-size: 9px !important; } + .lm_controls .lm_maximise { background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 9'%3E%3Cpath fill='%23000' d='M0 4.5V0h9v9H0zM8 5V2H1v6h7z'/%3E%3C/svg%3E") !important; background-size: 9px !important; } + .lm_controls .lm_close { background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 9'%3E%3Cpath fill='%23000' d='M.45713 8.5429l-.44426-.44438 3.5955-3.5956L.00697.90152l.8944-.89463 3.6016 3.6015 3.6014-3.6015.88867.88867-3.6014 3.6015 3.6014 3.6015-.89449.89449-3.6015-3.6014-3.5957 3.5956z'/%3E%3C/svg%3E") !important; background-size: 9px !important; } + .lm_maximised .lm_controls .lm_maximise { background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 9 9'%3E%3Cpath fill='%23000' d='M1.0096 8.0019v-.99809h6.9807v1.9962H1.0096z'/%3E%3C/svg%3E") !important; background-size: 9px !important; @@ -42,7 +45,7 @@ body { } .navbar-nav a.nav-link { - border: rgb(140,140,140) 1px solid; + border: rgb(140, 140, 140) 1px solid; } .float-link { @@ -94,6 +97,19 @@ a.navbar-brand img.logo.normal { background: lightblue !important; } +.rainbow-decoration { + -webkit-background-clip: text; + -webkit-text-fill-color: transparent; + background-image: -webkit-gradient(linear, left top, right bottom, + color-stop(0.00, red), + color-stop(16%, orange), + color-stop(32%, yellow), + color-stop(48%, green), + color-stop(60%, blue), + color-stop(76%, indigo), + color-stop(1.00, violet)); +} + .font-option { background: white; } From 13b54c84d40f0d7ebe117e0cc2bd7f8623abf836 Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Sat, 12 Oct 2019 15:29:45 -0500 Subject: [PATCH 2/2] Support language-specific extra decorations --- static/main.js | 16 ++++++++++++---- static/motd.js | 3 ++- static/panes/editor.js | 32 +++++++++++++++++++++++++++++++- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/static/main.js b/static/main.js index dd8857b2e..1702bf2a0 100644 --- a/static/main.js +++ b/static/main.js @@ -386,11 +386,19 @@ function start() { // Skip some steps if using embedded mode if (!options.embedded) { // Don't fetch the motd - motd.initialise(options.motdUrl, $('#motd'), subLangId, settings.enableCommunityAds, function () { - hub.layout.eventHub.emit('modifySettings', { - enableCommunityAds: false + motd.initialise(options.motdUrl, $('#motd'), subLangId, settings.enableCommunityAds, + function (data) { + var sendMotd = function () { + hub.layout.eventHub.emit('motd', data); + }; + hub.layout.eventHub.on('requestMotd', sendMotd); + sendMotd(); + }, + function () { + hub.layout.eventHub.emit('modifySettings', { + enableCommunityAds: false + }); }); - }); // Don't try to update Version tree link var release = window.compilerExplorerOptions.release; diff --git a/static/motd.js b/static/motd.js index 014452067..53f8d0257 100644 --- a/static/motd.js +++ b/static/motd.js @@ -67,10 +67,11 @@ function handleMotd(motd, motdNode, subLang, adsEnabled, onHide) { } } -function initialise(url, motdNode, defaultLanguage, adsEnabled, onHide) { +function initialise(url, motdNode, defaultLanguage, adsEnabled, onMotd, onHide) { if (!url) return; $.getJSON(url) .then(function (res) { + onMotd(res); handleMotd(res, motdNode, defaultLanguage, adsEnabled, onHide); }) .catch(function (jqXHR, textStatus, errorThrown) { diff --git a/static/panes/editor.js b/static/panes/editor.js index 41ce65bb5..a8f2fe2e7 100644 --- a/static/panes/editor.js +++ b/static/panes/editor.js @@ -73,6 +73,7 @@ function Editor(hub, state, container) { this.decorations = {}; this.prevDecorations = []; + this.extraDecorations = []; this.fadeTimeoutId = -1; @@ -174,10 +175,35 @@ function Editor(hub, state, container) { }); } +Editor.prototype.onMotd = function (motd) { + this.extraDecorations = motd.decorations; + this.updateExtraDecorations(); +}; + +Editor.prototype.updateExtraDecorations = function () { + var decorationsDirty = false; + _.each(this.extraDecorations, _.bind(function (decoration) { + if (decoration.filter && decoration.filter.indexOf(this.currentLanguage.name.toLowerCase()) < 0) return; + var match = this.editor.getModel().findNextMatch(decoration.regex, { + column: 1, + lineNumber: 1 + }, true, true, null, false); + if (match !== this.decorations[decoration.name]) { + decorationsDirty = true; + this.decorations[decoration.name] = match ? [{range: match.range, options: decoration.decoration}] : null; + } + }, this)); + if (decorationsDirty) + this.updateDecorations(); +}; + // If compilerId is undefined, every compiler will be pinged Editor.prototype.maybeEmitChange = function (force, compilerId) { var source = this.getSource(); if (!force && source === this.lastChangeEmitted) return; + + this.updateExtraDecorations(); + this.lastChangeEmitted = source; this.eventHub.emit('editorChange', this.id, this.lastChangeEmitted, this.currentLanguage.id, compilerId); }; @@ -249,6 +275,8 @@ Editor.prototype.initCallbacks = function () { this.eventHub.on('conformanceViewClose', this.onConformanceViewClose, this); this.eventHub.on('resize', this.resize, this); this.eventHub.on('newSource', this.onNewSource, this); + this.eventHub.on('motd', this.onMotd, this); + this.eventHub.emit('requestMotd'); this.editor.getModel().onDidChangeContent(_.bind(function () { this.debouncedEmitChange(); @@ -830,7 +858,9 @@ Editor.prototype.onEditorSetDecoration = function (id, lineNum, reveal) { }; Editor.prototype.updateDecorations = function () { - this.prevDecorations = this.editor.deltaDecorations(this.prevDecorations, _.flatten(_.values(this.decorations))); + this.prevDecorations = this.editor.deltaDecorations( + this.prevDecorations, + _.compact(_.flatten(_.values(this.decorations)))); }; Editor.prototype.onConformanceViewOpen = function (editorId) {