From 308a17b6c97ff3052b91eb08bea06a055e95f8b3 Mon Sep 17 00:00:00 2001 From: Alysa Date: Tue, 23 Jul 2024 10:52:59 -0700 Subject: [PATCH] highlight range --- static/application.js | 2 +- static/index.html | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/static/application.js b/static/application.js index a8af5be..d951f92 100644 --- a/static/application.js +++ b/static/application.js @@ -49,7 +49,7 @@ haste_document.prototype.load = function(key, callback, lang) { highlighted = "" + highlighted + ""; } - highlighted = "" + highlighted + ""; + highlighted = "" + highlighted + ""; high.value += highlighted + "\n"; } // scroll to position in document after ensuring components h"ve had time to render diff --git a/static/index.html b/static/index.html index 6bfea97..59988bb 100644 --- a/static/index.html +++ b/static/index.html @@ -67,9 +67,22 @@ handlePop({ target: window }); }); - function handleLineClick(lineId) { - /* TODO */ - window.location.hash = "#L" + (lineId + 1); + function handleLineClick(event, lineId) { + var lineNumber = lineId + 1; + if (event.shiftKey && app.selectedLines.startLine != undefined && lineNumber != app.selectedLines.startLine) { + if (lineNumber > app.selectedLines.startLine) { + app.selectedLines.endLine = lineNumber; + } else { + app.selectedLines.endLine = this.app.selectedLines.startLine; + app.selectedLines.startLine = lineNumber; + } + window.location.hash = "#L" + (app.selectedLines.startLine) + "-L" + (app.selectedLines.endLine); + } else { + // no shift range to consider + app.selectedLines.startLine = lineNumber; + app.selectedLines.endLine = lineNumber; + window.location.hash = "#L" + (lineNumber); + } }