mirror of
https://github.com/vale981/tridactyl
synced 2025-03-06 01:51:40 -05:00
Fix #2050: add WIP visual mode
We need to make merging of nmaps happen at runtime before we merge this, or we'll break the binds of people who are just selecting text to help them read.
This commit is contained in:
parent
d8c94c5a27
commit
fec145606b
4 changed files with 17 additions and 0 deletions
|
@ -355,6 +355,15 @@ config.getAsync("leavegithubalone").then(v => {
|
|||
}
|
||||
})
|
||||
|
||||
document.addEventListener("selectionchange", () => {
|
||||
const selection = document.getSelection()
|
||||
if (selection.anchorOffset == selection.focusOffset) {
|
||||
contentState.mode = "normal"
|
||||
} else {
|
||||
contentState.mode = "visual"
|
||||
}
|
||||
})
|
||||
|
||||
// Listen for statistics from each content script and send them to the
|
||||
// background for collection. Attach the observer to the window object
|
||||
// since there's apparently a bug that causes performance observers to
|
||||
|
|
|
@ -101,6 +101,7 @@ function* ParserController() {
|
|||
ignore: keys => generic.parser("ignoremaps", keys),
|
||||
hint: hinting.parser,
|
||||
gobble: gobblemode.parser,
|
||||
visual: keys => generic.parser("vmaps", keys),
|
||||
}
|
||||
|
||||
while (true) {
|
||||
|
|
|
@ -8,6 +8,7 @@ export type ModeName =
|
|||
| "ignore"
|
||||
| "gobble"
|
||||
| "input"
|
||||
| "visual"
|
||||
|
||||
export class PrevInput {
|
||||
inputId: string
|
||||
|
|
|
@ -302,6 +302,12 @@ export class default_config {
|
|||
"open https://www.youtube.com/watch?v=M3iOROuTuMA",
|
||||
}
|
||||
|
||||
vmaps = mergeDeep(this.nmaps, { // we really want a real-time merge as this means that user normal binds will no longer work while text is selected
|
||||
"<Escape>": "composite js document.getSelection().empty(); mode normal; hidecmdline",
|
||||
"<C-[>": "composite js document.getSelection().empty(); mode normal ; hidecmdline",
|
||||
"y": "composite js document.getSelection().toString() | yank",
|
||||
})
|
||||
|
||||
hintmaps = {
|
||||
"<Backspace>": "hint.popKey",
|
||||
"<Escape>": "hint.reset",
|
||||
|
|
Loading…
Add table
Reference in a new issue