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,
|
||||
anchor,
|
||||
focus,
|
||||
focusX,
|
||||
focusY,
|
||||
} = state;
|
||||
const {
|
||||
x: focusX,
|
||||
y: focusY,
|
||||
} = indexToGrid(code, focus);
|
||||
const {
|
||||
x: anchorX,
|
||||
y: anchorY,
|
||||
} = indexToGrid(code, anchor);
|
||||
fillRect(x, y, w, h, COLOR.DARKBLUE);
|
||||
if (anchor === focus) {
|
||||
fillRect(x+focusX*fontWidth-scrollX, y+focusY*(fontHeight+1)-scrollY, fontWidth+1, fontHeight+1, COLOR.YELLOW);
|
||||
} else {
|
||||
// TODO: Draw this selection better
|
||||
fillRect(x+anchorX*fontWidth-scrollX, y+anchorY*(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);
|
||||
for (let i = Math.min(anchor, focus); i < Math.max(anchor, focus); i++) {
|
||||
const {x: selX, y: selY} = indexToGrid(code, i);
|
||||
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 tokens = [...tokenize(code)];
|
||||
|
Loading…
x
Reference in New Issue
Block a user