From 082db122f62cb9aa3bf52c4a127518bd5b5ad2d1 Mon Sep 17 00:00:00 2001 From: Admiral Potato Date: Sat, 4 Jul 2020 03:51:25 -0600 Subject: [PATCH 1/6] Remove deprecated/invalid JetBrains IDE configs --- .gitignore | 6 +- .idea/misc.xml | 6 - .idea/modules.xml | 8 - .idea/typescript-compiler.xml | 9 - .idea/vcs.xml | 8 - .idea/webide.iml | 12 -- .idea/workspace.xml | 394 ---------------------------------- 7 files changed, 5 insertions(+), 438 deletions(-) delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/typescript-compiler.xml delete mode 100644 .idea/vcs.xml delete mode 100644 .idea/webide.iml delete mode 100644 .idea/workspace.xml diff --git a/.gitignore b/.gitignore index a48b0737..73d2a922 100644 --- a/.gitignore +++ b/.gitignore @@ -254,4 +254,8 @@ lib/_npm/ *.pyc .serve_files_secret \.DS_Store -playground/*.js* \ No newline at end of file +playground/*.js* + +# Exclude JetBrains IDE files +*.iml +.idea diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 28a804d8..00000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 2eaf920f..00000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/typescript-compiler.xml b/.idea/typescript-compiler.xml deleted file mode 100644 index 9b1ae4e6..00000000 --- a/.idea/typescript-compiler.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index a8418f64..00000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/webide.iml b/.idea/webide.iml deleted file mode 100644 index 24643cc3..00000000 --- a/.idea/webide.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index e32fb2b2..00000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,394 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - toggle - - - - - - - - - - - - - false - - false - false - - - true - DEFINITION_ORDER - - - - - - - - - - - - - - - Vue - - - - - VueDuplicateTag - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - project - - - true - - - - DIRECTORY - - false - - - - - - - - - 1492290653407 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 8578958f816662bff79ebf736f9deb141bc3b9d8 Mon Sep 17 00:00:00 2001 From: Admiral Potato Date: Sat, 4 Jul 2020 05:12:56 -0600 Subject: [PATCH 2/6] Fix: Arrow keys in HexEditor update InfoPanel --- src/v1/app.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/v1/app.ts b/src/v1/app.ts index 8fbdff78..b82e131a 100644 --- a/src/v1/app.ts +++ b/src/v1/app.ts @@ -215,7 +215,7 @@ class AppController { this.refreshSelectionInput(); if (this.ui.parsedDataTreeHandler && hasSelection && !this.selectedInTree) { - var intervals = this.ui.parsedDataTreeHandler.intervalHandler.searchRange(this.ui.hexViewer.mouseDownOffset || start); + var intervals = this.ui.parsedDataTreeHandler.intervalHandler.searchRange(this.ui.hexViewer.selectionStart || start); if (intervals.items.length > 0) { //console.log("selected node", intervals[0].id); this.blockRecursive = true; From 076e69c14d417ab1125ee300533f1119d3fdaeab Mon Sep 17 00:00:00 2001 From: Admiral Potato Date: Sat, 4 Jul 2020 06:18:36 -0600 Subject: [PATCH 3/6] Shift + Arrow keys in HexEditor now select range --- src/HexViewer.ts | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/src/HexViewer.ts b/src/HexViewer.ts index 1160b01c..309df575 100644 --- a/src/HexViewer.ts +++ b/src/HexViewer.ts @@ -100,11 +100,11 @@ export class HexViewer { private content: JQuery; private contentOuter: JQuery; - public mouseDownOffset: number; private canDeselect: boolean; - public selectionStart: number = -1; public selectionEnd: number = -1; + public selectionDragStart: number; + public selectionDragEnd: number = 0; public onSelectionChanged: (() => void); private isRecursive: boolean; @@ -125,15 +125,17 @@ export class HexViewer { if ("dataOffset" in cell) { if (e.type === "mousedown") { this.canDeselect = this.selectionStart === cell.dataOffset && this.selectionEnd === cell.dataOffset; - this.mouseDownOffset = cell.dataOffset; + this.selectionDragStart = cell.dataOffset; + this.selectionDragEnd = cell.dataOffset; this.content.on("mousemove", evt => this.cellMouseAction(evt)); this.setSelection(cell.dataOffset, cell.dataOffset); } else if (e.type === "mousemove") { - this.setSelection(this.mouseDownOffset, cell.dataOffset); + this.selectionDragEnd = cell.dataOffset; + this.setSelection(this.selectionDragStart, cell.dataOffset); this.canDeselect = false; } - else if (e.type === "mouseup" && this.canDeselect && this.mouseDownOffset === cell.dataOffset) + else if (e.type === "mouseup" && this.canDeselect && this.selectionDragStart === cell.dataOffset) this.deselect(); this.contentOuter.focus(); @@ -177,12 +179,29 @@ export class HexViewer { e.key === "ArrowRight" ? 1 : e.key === "ArrowLeft" ? -1 : null; if (selDiff === null) return; - - var newSel = this.selectionStart + selDiff; + var newSel = this.selectionDragEnd + selDiff; if (newSel < 0) newSel = 0; else if (newSel >= this.dataProvider.length) newSel = this.dataProvider.length - 1; - - this.setSelection(newSel); + if (!e.shiftKey) { + this.selectionDragStart = newSel; + this.setSelection(newSel); + } else { + var smaller = Math.min( + this.selectionDragStart, + newSel + ); + var larger = Math.max( + this.selectionDragStart, + newSel + ); + this.setSelection( + smaller, + smaller < this.selectionDragStart + ? larger - 1 + : larger + ); + } + this.selectionDragEnd = newSel; return false; }); } From 79a30577e8dac208b4dfac92575a9ce3f9f42a96 Mon Sep 17 00:00:00 2001 From: Admiral Potato Date: Sat, 4 Jul 2020 06:35:32 -0600 Subject: [PATCH 4/6] Shift + Click in HexEditor now selects range --- src/HexViewer.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/HexViewer.ts b/src/HexViewer.ts index 309df575..2380a0c7 100644 --- a/src/HexViewer.ts +++ b/src/HexViewer.ts @@ -125,10 +125,12 @@ export class HexViewer { if ("dataOffset" in cell) { if (e.type === "mousedown") { this.canDeselect = this.selectionStart === cell.dataOffset && this.selectionEnd === cell.dataOffset; - this.selectionDragStart = cell.dataOffset; + this.selectionDragStart = e.shiftKey + ? this.selectionDragStart + : cell.dataOffset; this.selectionDragEnd = cell.dataOffset; this.content.on("mousemove", evt => this.cellMouseAction(evt)); - this.setSelection(cell.dataOffset, cell.dataOffset); + this.setSelection(this.selectionDragStart, this.selectionDragEnd); } else if (e.type === "mousemove") { this.selectionDragEnd = cell.dataOffset; @@ -196,9 +198,7 @@ export class HexViewer { ); this.setSelection( smaller, - smaller < this.selectionDragStart - ? larger - 1 - : larger + larger ); } this.selectionDragEnd = newSel; From 3fe576232e085518bac4365949461a1a3101efbc Mon Sep 17 00:00:00 2001 From: Admiral Potato Date: Mon, 6 Jul 2020 00:05:20 -0600 Subject: [PATCH 5/6] Improve HexEditor Shift logic, Add cursor display --- css/HexViewer.css | 1 + src/HexViewer.ts | 100 +++++++++++++++++++++++++++++----------------- src/v1/app.ts | 14 +++++-- 3 files changed, 75 insertions(+), 40 deletions(-) diff --git a/css/HexViewer.css b/css/HexViewer.css index 3a67e60e..06fddb6a 100644 --- a/css/HexViewer.css +++ b/css/HexViewer.css @@ -12,6 +12,7 @@ .hexViewer .header .hex .c8 { margin-left: 17px } .hexViewer .selected { background:#0076e0; color:white } +.hexViewer .cursor { background: #00ccff; } .hexViewer .asciicell { padding: 2px 0 } .hexViewer .hexRow { height:21px; } diff --git a/src/HexViewer.ts b/src/HexViewer.ts index 2380a0c7..e9f7de25 100644 --- a/src/HexViewer.ts +++ b/src/HexViewer.ts @@ -103,8 +103,7 @@ export class HexViewer { private canDeselect: boolean; public selectionStart: number = -1; public selectionEnd: number = -1; - public selectionDragStart: number; - public selectionDragEnd: number = 0; + public selectionCursor: number = -1; public onSelectionChanged: (() => void); private isRecursive: boolean; @@ -125,19 +124,18 @@ export class HexViewer { if ("dataOffset" in cell) { if (e.type === "mousedown") { this.canDeselect = this.selectionStart === cell.dataOffset && this.selectionEnd === cell.dataOffset; - this.selectionDragStart = e.shiftKey - ? this.selectionDragStart - : cell.dataOffset; - this.selectionDragEnd = cell.dataOffset; this.content.on("mousemove", evt => this.cellMouseAction(evt)); - this.setSelection(this.selectionDragStart, this.selectionDragEnd); + if (e.shiftKey) { + this.shiftCursor(cell.dataOffset); + } else { + this.setCursor(cell.dataOffset); + } } else if (e.type === "mousemove") { - this.selectionDragEnd = cell.dataOffset; - this.setSelection(this.selectionDragStart, cell.dataOffset); + this.shiftCursor(cell.dataOffset); this.canDeselect = false; } - else if (e.type === "mouseup" && this.canDeselect && this.selectionDragStart === cell.dataOffset) + else if (e.type === "mouseup" && this.canDeselect && this.selectionStart === cell.dataOffset) this.deselect(); this.contentOuter.focus(); @@ -181,27 +179,12 @@ export class HexViewer { e.key === "ArrowRight" ? 1 : e.key === "ArrowLeft" ? -1 : null; if (selDiff === null) return; - var newSel = this.selectionDragEnd + selDiff; - if (newSel < 0) newSel = 0; - else if (newSel >= this.dataProvider.length) newSel = this.dataProvider.length - 1; - if (!e.shiftKey) { - this.selectionDragStart = newSel; - this.setSelection(newSel); + var newSel = this.selectionCursor + selDiff; + if (e.shiftKey) { + this.shiftCursor(newSel); } else { - var smaller = Math.min( - this.selectionDragStart, - newSel - ); - var larger = Math.max( - this.selectionDragStart, - newSel - ); - this.setSelection( - smaller, - larger - ); + this.setCursor(newSel); } - this.selectionDragEnd = newSel; return false; }); } @@ -275,8 +258,10 @@ export class HexViewer { hexCell.cell.dataOffset = asciiCell.dataOffset = dataOffset; var isSelected = this.selectionStart <= dataOffset && dataOffset <= this.selectionEnd; - $(hexCell.cell).toggleClass("selected", isSelected); - $(asciiCell).toggleClass("selected", isSelected); + var isCursor = dataOffset === this.selectionCursor; + var targets = [hexCell.cell, asciiCell]; + $(targets).toggleClass("selected", isSelected); + $(targets).toggleClass("cursor", isCursor); var skipInt = 0; for (var level = 0; level < this.maxLevel; level++) { @@ -284,8 +269,16 @@ export class HexViewer { var intIn = int && int.start <= dataOffset && dataOffset <= int.end; var intStart = intIn && int.start === dataOffset; var intEnd = intIn && int.end === dataOffset; - hexCell.levels[level].className = `l${this.maxLevel - 1 - level} ${((intBaseIdx + intIdx) % 2 === 0) ? "even" : "odd"}` + - (intIn ? ` m${level}` : "") + (intStart ? " start" : "") + (intEnd ? " end" : "") + (isSelected ? " selected" : ""); + var classes = [ + `l${this.maxLevel - 1 - level}`, + `${((intBaseIdx + intIdx) % 2 === 0) ? "even" : "odd"}`, + ]; + if(intIn) classes.push(`m${level}`); + if(intStart) classes.push("start"); + if(intEnd) classes.push("end"); + if(isSelected) classes.push("selected"); + if(isCursor) classes.push("cursor"); + hexCell.levels[level].className = classes.join(" "); if (intEnd) skipInt++; @@ -310,16 +303,49 @@ export class HexViewer { } public deselect() { - this.setSelection(-1, -1); + this.setCursor(-1); + } + + public setCursor (cursor: number) { + this.selectionCursor = cursor; + this.setSelection( + this.selectionCursor + ); } - public setSelection(start: number, end?: number) { + public shiftCursor (cursor: number) { + var start = this.selectionStart; + var end = this.selectionEnd; + if (this.selectionCursor === end) { + end = cursor; + } else if (this.selectionCursor === start) { + start = cursor; + } + this.selectionCursor = cursor; + this.setSelection( + Math.max(0, start), + end + ); + } + + public setSelection(start: number, end?: number, cursor?: number) { if (this.isRecursive) return; end = end || start; var oldStart = this.selectionStart, oldEnd = this.selectionEnd; - this.selectionStart = start < end ? start : end; - this.selectionEnd = Math.min(start < end ? end : start, this.dataProvider.length - 1); + this.selectionStart = Math.min(start, end); + this.selectionEnd = Math.min( + Math.max(start, end), + this.dataProvider.length - 1 + ); + + // is cursor out of bounds because called externally? + if ( + this.selectionCursor < this.selectionStart + || this.selectionCursor > this.selectionEnd + ) cursor = this.selectionEnd; + if (cursor) this.selectionCursor = cursor; + if (this.selectionStart !== oldStart || this.selectionEnd !== oldEnd) { this.isRecursive = true; try { diff --git a/src/v1/app.ts b/src/v1/app.ts index b82e131a..661f1c24 100644 --- a/src/v1/app.ts +++ b/src/v1/app.ts @@ -207,7 +207,11 @@ class AppController { onHexViewerSelectionChanged() { //console.log("setSelection", ui.hexViewer.selectionStart, ui.hexViewer.selectionEnd); - localStorage.setItem("selection", JSON.stringify({ start: this.ui.hexViewer.selectionStart, end: this.ui.hexViewer.selectionEnd })); + localStorage.setItem("selection", JSON.stringify({ + start: this.ui.hexViewer.selectionStart, + end: this.ui.hexViewer.selectionEnd, + cursor: this.ui.hexViewer.selectionCursor + })); var start = this.ui.hexViewer.selectionStart; var hasSelection = start !== -1; @@ -215,7 +219,7 @@ class AppController { this.refreshSelectionInput(); if (this.ui.parsedDataTreeHandler && hasSelection && !this.selectedInTree) { - var intervals = this.ui.parsedDataTreeHandler.intervalHandler.searchRange(this.ui.hexViewer.selectionStart || start); + var intervals = this.ui.parsedDataTreeHandler.intervalHandler.searchRange(this.ui.hexViewer.selectionCursor || start); if (intervals.items.length > 0) { //console.log("selected node", intervals[0].id); this.blockRecursive = true; @@ -281,7 +285,11 @@ $(() => { app.inputReady.then(() => { var storedSelection = JSON.parse(localStorage.getItem("selection")); if (storedSelection) - app.ui.hexViewer.setSelection(storedSelection.start, storedSelection.end); + app.ui.hexViewer.setSelection( + storedSelection.start, + storedSelection.end, + storedSelection.cursor + ); }); var editDelay = new Delayed(500); From c01f94238fddf6145c7f640e5d5be2b452d72737 Mon Sep 17 00:00:00 2001 From: Petr Pucil Date: Sat, 20 Nov 2021 22:06:32 +0100 Subject: [PATCH 6/6] HexViewer: fix formatting, remove unneded string interpolation --- src/HexViewer.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/HexViewer.ts b/src/HexViewer.ts index e9f7de25..269ef897 100644 --- a/src/HexViewer.ts +++ b/src/HexViewer.ts @@ -271,13 +271,13 @@ export class HexViewer { var intEnd = intIn && int.end === dataOffset; var classes = [ `l${this.maxLevel - 1 - level}`, - `${((intBaseIdx + intIdx) % 2 === 0) ? "even" : "odd"}`, + (intBaseIdx + intIdx) % 2 === 0 ? "even" : "odd", ]; - if(intIn) classes.push(`m${level}`); - if(intStart) classes.push("start"); - if(intEnd) classes.push("end"); - if(isSelected) classes.push("selected"); - if(isCursor) classes.push("cursor"); + if (intIn) classes.push(`m${level}`); + if (intStart) classes.push("start"); + if (intEnd) classes.push("end"); + if (isSelected) classes.push("selected"); + if (isCursor) classes.push("cursor"); hexCell.levels[level].className = classes.join(" "); if (intEnd) @@ -367,4 +367,4 @@ export class HexViewer { } } } -} \ No newline at end of file +}