optimize hex mode
This commit is contained in:
parent
92eb71eaed
commit
7e2ed2af55
|
@ -456,7 +456,7 @@ amdRequire(["vs/editor/editor.main"], function () {
|
||||||
editor.addAction({
|
editor.addAction({
|
||||||
id: "highlight-toggle",
|
id: "highlight-toggle",
|
||||||
label: "Highlight Toggle",
|
label: "Highlight Toggle",
|
||||||
keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_E],
|
keybindings: [monaco.KeyMod.CtrlCmd + monaco.KeyCode.KEY_E],
|
||||||
precondition: null,
|
precondition: null,
|
||||||
keybindingContext: null,
|
keybindingContext: null,
|
||||||
contextMenuGroupId: "9_cutcopypaste",
|
contextMenuGroupId: "9_cutcopypaste",
|
||||||
|
@ -518,7 +518,7 @@ amdRequire(["vs/editor/editor.main"], function () {
|
||||||
return newRange;
|
return newRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectLineRange(model, range) {
|
function showCursors(model, range) {
|
||||||
let cordRange = getCordinateRange(model, range);
|
let cordRange = getCordinateRange(model, range);
|
||||||
if (undefined === cordRange) return;
|
if (undefined === cordRange) return;
|
||||||
|
|
||||||
|
@ -537,12 +537,14 @@ amdRequire(["vs/editor/editor.main"], function () {
|
||||||
range: range,
|
range: range,
|
||||||
options: {
|
options: {
|
||||||
className: "hex-select",
|
className: "hex-select",
|
||||||
|
zIndex: 999,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
range: cordRange,
|
range: cordRange,
|
||||||
options: {
|
options: {
|
||||||
className: "hex-select",
|
className: "hex-select",
|
||||||
|
zIndex: 999,
|
||||||
overviewRuler: {
|
overviewRuler: {
|
||||||
color: "#f06292",
|
color: "#f06292",
|
||||||
position: 4, // 2: center, 4: right, 1: left, 7: full
|
position: 4, // 2: center, 4: right, 1: left, 7: full
|
||||||
|
@ -553,6 +555,44 @@ amdRequire(["vs/editor/editor.main"], function () {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function selectLineRange(model, range, decoration) {
|
||||||
|
let cordRange = getCordinateRange(model, range);
|
||||||
|
if (undefined === cordRange) return;
|
||||||
|
|
||||||
|
// first remove old decos
|
||||||
|
let decos = model.getLineDecorations(range.startLineNumber);
|
||||||
|
for (let deco of decos) {
|
||||||
|
if (
|
||||||
|
deco.options.className !== null &&
|
||||||
|
deco.options.className.indexOf("hl-") !== -1
|
||||||
|
) {
|
||||||
|
model.deltaDecorations([deco.id], []);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
model.deltaDecorations(
|
||||||
|
[],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
range: range,
|
||||||
|
options: {
|
||||||
|
className: decoration.style,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
range: cordRange,
|
||||||
|
options: {
|
||||||
|
className: decoration.style,
|
||||||
|
overviewRuler: {
|
||||||
|
color: decoration.color,
|
||||||
|
position: 4, // 2: center, 4: right, 1: left, 7: full
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function extracLineRange(range, line) {
|
function extracLineRange(range, line) {
|
||||||
let lineRange = new monaco.Range(line, 1, line, 1);
|
let lineRange = new monaco.Range(line, 1, line, 1);
|
||||||
|
|
||||||
|
@ -597,20 +637,22 @@ amdRequire(["vs/editor/editor.main"], function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
editor.onMouseUp(() => {
|
editor.onMouseUp(() => {
|
||||||
return;
|
|
||||||
|
|
||||||
let model = editor.getModel();
|
let model = editor.getModel();
|
||||||
let range = editor.getSelection();
|
let range = editor.getSelection();
|
||||||
console.log("In: " + range);
|
console.log("In: " + range);
|
||||||
|
|
||||||
// processHexLine(model, range);
|
if (range.isEmpty() === true) {
|
||||||
|
showCursors(model, range);
|
||||||
|
} else {
|
||||||
|
let deco = decoGet();
|
||||||
for (
|
for (
|
||||||
let line = range.startLineNumber;
|
let line = range.startLineNumber;
|
||||||
line <= range.endLineNumber;
|
line <= range.endLineNumber;
|
||||||
line++
|
line++
|
||||||
) {
|
) {
|
||||||
let lineRange = extracLineRange(range, line);
|
let lineRange = extracLineRange(range, line);
|
||||||
selectLineRange(model, lineRange);
|
selectLineRange(model, lineRange, deco);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -307,5 +307,5 @@ input {
|
||||||
}
|
}
|
||||||
|
|
||||||
.hex-select {
|
.hex-select {
|
||||||
border: 1px solid #f06292;
|
border-left: 2px solid #e91e63;;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue