From 6b5d1887ceb89db895f550146b32e1bd96650ba8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Rinc=C3=B3n?= Date: Tue, 14 Mar 2017 17:18:15 +0100 Subject: [PATCH 1/7] An alert is issued when the URL shortener fails, explaining that it's probably because of length limits. This is a temporary solution while Matt creates a local shortener --- static/sharing.js | 7 ++++--- static/urlshorten-google.js | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/static/sharing.js b/static/sharing.js index e801b6cce..d7e713c2a 100644 --- a/static/sharing.js +++ b/static/sharing.js @@ -118,11 +118,12 @@ define(function (require) { } }); - // Dismiss on any click that isn't either in the opening element, or inside - // the popover. + // Dismiss on any click that isn't either in the opening element, inside + // the popover or on any alert $(document).on('click.editable', function (e) { var target = $(e.target); - if (!target.is(getLink) && getLink.has(target).length === 0 && target.closest('.popover').length === 0) + if (!target.is(getLink) && getLink.has(target).length === 0 && target.closest('.popover').length === 0 + && $('#alert').has(target).length === 0) getLink.popover("hide"); }); } diff --git a/static/urlshorten-google.js b/static/urlshorten-google.js index b5a353a0b..bf780728d 100644 --- a/static/urlshorten-google.js +++ b/static/urlshorten-google.js @@ -26,6 +26,7 @@ define(function (require) { "use strict"; var options = require('options'); + var Alert = require('alert'); function googleJSClientLoaded() { gapi.client.setApiKey(options.gapiKey); @@ -51,6 +52,7 @@ define(function (require) { } done(id); }, function () { + new Alert().alert('Could not shorten your URL', 'The current url probaly exceeds the Google Url Shortener length limits.'); done(url); }); } From 7215153b632a81633d4668f4d4eea1a0a56c53b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Rinc=C3=B3n?= Date: Tue, 14 Mar 2017 18:04:31 +0100 Subject: [PATCH 2/7] Fixes tests. I tought Javascript was ok with that separation. Well, you learn something new every day --- static/sharing.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/sharing.js b/static/sharing.js index d7e713c2a..a1574c8de 100644 --- a/static/sharing.js +++ b/static/sharing.js @@ -122,8 +122,8 @@ define(function (require) { // the popover or on any alert $(document).on('click.editable', function (e) { var target = $(e.target); - if (!target.is(getLink) && getLink.has(target).length === 0 && target.closest('.popover').length === 0 - && $('#alert').has(target).length === 0) + if (!target.is(getLink) && getLink.has(target).length === 0 && target.closest('.popover').length === 0 && + $('#alert').has(target).length === 0) getLink.popover("hide"); }); } From 538cee087c62bb95718cbcd38033cec12e1f1c42 Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Tue, 14 Mar 2017 22:47:29 -0500 Subject: [PATCH 3/7] Lose the rc4-ness of clang --- etc/config/c++.amazon.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/config/c++.amazon.properties b/etc/config/c++.amazon.properties index f97ff1662..1b43143fb 100644 --- a/etc/config/c++.amazon.properties +++ b/etc/config/c++.amazon.properties @@ -97,7 +97,7 @@ compiler.clang390.name=x86-64 clang 3.9.0 compiler.clang391.exe=/opt/compiler-explorer/clang-3.9.1/bin/clang++ compiler.clang391.name=x86-64 clang 3.9.1 compiler.clang400.exe=/opt/compiler-explorer/clang-4.0.0/bin/clang++ -compiler.clang400.name=x86-64 clang 4.0.0 (rc4) +compiler.clang400.name=x86-64 clang 4.0.0 compiler.clang_trunk.exe=/opt/compiler-explorer/clang-trunk/bin/clang++ compiler.clang_trunk.name=x86-64 clang (trunk) From 7d5739c3a887e2016dd4bf5e618bbd33660cfd9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Rinc=C3=B3n?= Date: Wed, 15 Mar 2017 12:27:11 +0100 Subject: [PATCH 4/7] Fixed typo that prevented code highlighting. Sorry about that --- static/compiler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/compiler.js b/static/compiler.js index 640b93793..1cc202e97 100644 --- a/static/compiler.js +++ b/static/compiler.js @@ -123,7 +123,7 @@ define(function (require) { this.outputEditor.onMouseMove(function (e) { if (e === null || e.target === null || e.target.position === null) return; - if (self.settings.hoverShowSource === true && !self.assembly) { + if (self.settings.hoverShowSource === true && self.assembly) { var desiredLine = e.target.position.lineNumber - 1; if (!self.assembly[desiredLine]) { // We check that we actually have something to show at this point! From bd7d1fc324d472cd5981de1b29ccb3d9ff87314e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Rinc=C3=B3n?= Date: Wed, 15 Mar 2017 12:29:13 +0100 Subject: [PATCH 5/7] Fixed typo that prevented code highlighting. Sorry about that --- static/compiler.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/compiler.js b/static/compiler.js index 1cc202e97..b5b225c3d 100644 --- a/static/compiler.js +++ b/static/compiler.js @@ -125,7 +125,7 @@ define(function (require) { if (e === null || e.target === null || e.target.position === null) return; if (self.settings.hoverShowSource === true && self.assembly) { var desiredLine = e.target.position.lineNumber - 1; - if (!self.assembly[desiredLine]) { + if (self.assembly[desiredLine]) { // We check that we actually have something to show at this point! self.eventHub.emit('editorSetDecoration', self.sourceEditorId, self.assembly[desiredLine].source); } From 1c084ea6f46c829ca90dfb6eb8648bc7272470bc Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Wed, 15 Mar 2017 07:43:01 -0500 Subject: [PATCH 6/7] IntelliJ autoformat --- static/sharing.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/sharing.js b/static/sharing.js index a1574c8de..d4bda798c 100644 --- a/static/sharing.js +++ b/static/sharing.js @@ -123,7 +123,7 @@ define(function (require) { $(document).on('click.editable', function (e) { var target = $(e.target); if (!target.is(getLink) && getLink.has(target).length === 0 && target.closest('.popover').length === 0 && - $('#alert').has(target).length === 0) + $('#alert').has(target).length === 0) getLink.popover("hide"); }); } From f277a166fdaf71d697ab6c23a549318b91db7ad2 Mon Sep 17 00:00:00 2001 From: Matt Godbolt Date: Wed, 15 Mar 2017 18:12:51 -0500 Subject: [PATCH 7/7] Handle hex properly; extract function. Handle hex style. Throttle mouse moves --- static/compiler.js | 59 +++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/static/compiler.js b/static/compiler.js index b5b225c3d..bf031aaf0 100644 --- a/static/compiler.js +++ b/static/compiler.js @@ -121,36 +121,7 @@ define(function (require) { } }); - this.outputEditor.onMouseMove(function (e) { - if (e === null || e.target === null || e.target.position === null) return; - if (self.settings.hoverShowSource === true && self.assembly) { - var desiredLine = e.target.position.lineNumber - 1; - if (self.assembly[desiredLine]) { - // We check that we actually have something to show at this point! - self.eventHub.emit('editorSetDecoration', self.sourceEditorId, self.assembly[desiredLine].source); - } - } - if (e.target.element !== null && $.isNumeric(e.target.element.textContent)) { - var elementContent = e.target.element.textContent; - self.rawDecorations[0] = { - range: e.target.range, - options: { - isWholeLine: false, - hoverMessage: [ - parseInt(elementContent,16).toString(16) === elementContent.toLowerCase() ? // Is Hex? - '0x' + parseInt(elementContent).toString(16) - : - (parseInt(elementContent,10) === elementContent ? // Is Decimal - parseInt(elementContent).toString(10) - : // Else ... Show both - ('0x' + parseInt(elementContent, 16).toString() + ' (' + parseInt(elementContent, 10).toString() + ')')) - - ] - } - }; - self.decorations = self.outputEditor.deltaDecorations(self.decorations, self.rawDecorations); - } - }); + this.outputEditor.onMouseMove(_.throttle(_.bind(this.onMouseMove, this)), 250); this.fontScale = new FontScale(this.domRoot, state, this.outputEditor); this.fontScale.on('change', _.bind(function () { @@ -558,6 +529,34 @@ define(function (require) { } }; + var hexLike = /^([$]|0x)([0-9a-fA-F]+)$/; + + function getToolTip(value) { + var match = hexLike.exec(value); + if (match) return parseInt(match[2], 16).toString(); + if ($.isNumeric(value)) return '0x' + parseInt(value).toString(16); + return null; + } + + Compiler.prototype.onMouseMove = function (e) { + if (e === null || e.target === null || e.target.position === null) return; + if (this.settings.hoverShowSource === true && this.assembly) { + var desiredLine = e.target.position.lineNumber - 1; + if (this.assembly[desiredLine]) { + // We check that we actually have something to show at this point! + this.eventHub.emit('editorSetDecoration', this.sourceEditorId, this.assembly[desiredLine].source); + } + } + var numericToolTip = e.target.element ? getToolTip(e.target.element.textContent) : null; + if (numericToolTip) { + this.rawDecorations[0] = { + range: e.target.range, + options: {isWholeLine: false, hoverMessage: [numericToolTip]} + }; + this.decorations = this.outputEditor.deltaDecorations(this.decorations, this.rawDecorations); + } + }; + return { Compiler: Compiler };