mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 15:26:16 -04:00
reverse highlight
This commit is contained in:
parent
1d8c7dcb97
commit
6dbaf6a36c
1 changed files with 10 additions and 10 deletions
|
@ -100,19 +100,19 @@ class ToHex extends Operation {
|
||||||
*/
|
*/
|
||||||
highlightReverse(pos, args) {
|
highlightReverse(pos, args) {
|
||||||
const delim = Utils.charRep(args[0] || "Space"),
|
const delim = Utils.charRep(args[0] || "Space"),
|
||||||
len = delim === "\r\n" ? 1 : delim.length,
|
lineSize = args[1],
|
||||||
|
comma = args[2],
|
||||||
|
len = (delim === "\r\n" ? 1 : delim.length) + (comma ? 1 : 0),
|
||||||
width = len + 2;
|
width = len + 2;
|
||||||
|
|
||||||
// 0x and \x are added to the beginning if they are selected, so increment the positions accordingly
|
const countLF = function(p) {
|
||||||
if (delim === "0x" || delim === "\\x") {
|
// Count the number of LFs from 0 up to p
|
||||||
if (pos[0].start > 1) pos[0].start -= 2;
|
const lineLength = width * lineSize;
|
||||||
else pos[0].start = 0;
|
return (p / lineLength | 0) - (p >= lineLength && p % lineLength === 0);
|
||||||
if (pos[0].end > 1) pos[0].end -= 2;
|
};
|
||||||
else pos[0].end = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
pos[0].start = pos[0].start === 0 ? 0 : Math.round(pos[0].start / width);
|
pos[0].start = pos[0].start === 0 ? 0 : Math.round((pos[0].start - countLF(pos[0].start)) / width);
|
||||||
pos[0].end = pos[0].end === 0 ? 0 : Math.ceil(pos[0].end / width);
|
pos[0].end = pos[0].end === 0 ? 0 : Math.ceil((pos[0].end - countLF(pos[0].end)) / width);
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue