Draw full text selection
This commit is contained in:
parent
2e3b689c16
commit
0adfdabffa
18
codetab.ts
18
codetab.ts
@ -373,22 +373,18 @@ const drawCodeField = (code: string, x: number, y: number, w: number, h: number)
|
|||||||
scrollY,
|
scrollY,
|
||||||
anchor,
|
anchor,
|
||||||
focus,
|
focus,
|
||||||
|
focusX,
|
||||||
|
focusY,
|
||||||
} = state;
|
} = state;
|
||||||
const {
|
|
||||||
x: focusX,
|
|
||||||
y: focusY,
|
|
||||||
} = indexToGrid(code, focus);
|
|
||||||
const {
|
|
||||||
x: anchorX,
|
|
||||||
y: anchorY,
|
|
||||||
} = indexToGrid(code, anchor);
|
|
||||||
fillRect(x, y, w, h, COLOR.DARKBLUE);
|
fillRect(x, y, w, h, COLOR.DARKBLUE);
|
||||||
if (anchor === focus) {
|
if (anchor === focus) {
|
||||||
fillRect(x+focusX*fontWidth-scrollX, y+focusY*(fontHeight+1)-scrollY, fontWidth+1, fontHeight+1, COLOR.YELLOW);
|
fillRect(x+focusX*fontWidth-scrollX, y+focusY*(fontHeight+1)-scrollY, fontWidth+1, fontHeight+1, COLOR.YELLOW);
|
||||||
} else {
|
} else {
|
||||||
// TODO: Draw this selection better
|
for (let i = Math.min(anchor, focus); i < Math.max(anchor, focus); i++) {
|
||||||
fillRect(x+anchorX*fontWidth-scrollX, y+anchorY*(fontHeight+1)-scrollY, fontWidth+1, fontHeight+1, COLOR.WHITE);
|
const {x: selX, y: selY} = indexToGrid(code, i);
|
||||||
fillRect(x+focusX*fontWidth-scrollX, y+focusY*(fontHeight+1)-scrollY, fontWidth+1, fontHeight+1, COLOR.YELLOW);
|
fillRect(x+selX*fontWidth-scrollX, y+selY*(fontHeight+1)-scrollY, fontWidth+1, fontHeight+1, COLOR.WHITE);
|
||||||
|
}
|
||||||
|
// fillRect(x+focusX*fontWidth-scrollX, y+focusY*(fontHeight+1)-scrollY, fontWidth+1, fontHeight+1, COLOR.YELLOW);
|
||||||
}
|
}
|
||||||
const builtins = Object.keys(getContext());
|
const builtins = Object.keys(getContext());
|
||||||
const tokens = [...tokenize(code)];
|
const tokens = [...tokenize(code)];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user