WIP: show possible matches in mode indicator

This commit is contained in:
Oliver Blanthorn 2019-05-29 16:32:59 +01:00
parent cef4c3f5d2
commit 9ba2471ce0
No known key found for this signature in database
GPG key ID: 2BB8C36BB504BFF3
2 changed files with 13 additions and 4 deletions

View file

@ -11,6 +11,7 @@ const logger = new Logger("controller")
function PrintableKey(k) {
let result = k.key
console.log(k)
if (
result === "Control" ||
result === "Meta" ||
@ -156,10 +157,17 @@ function* ParserController() {
exstr = response.exstr
break
} else {
keyEvents = response.keys
keyEvents = response.potMatches
console.log([...keyEvents.keys()])
// show current keyEvents as a suffix of the contentState
contentState.suffix = keyEvents
.map(x => PrintableKey(x))
contentState.suffix = [...keyEvents.keys()]
.map(y => {
console.log(y)
; (y as any).map(x => {
console.log(x)
PrintableKey(x.key)
}).join(" ")
})
.join("")
logger.debug("suffix: ", contentState.suffix)
}

View file

@ -112,6 +112,7 @@ export interface ParserResponse {
exstr?: any
isMatch: boolean
numericPrefix?: number
potMatches?: KeyMap
}
export function parse(keyseq: KeyEventLike[], map: KeyMap): ParserResponse {
@ -156,7 +157,7 @@ export function parse(keyseq: KeyEventLike[], map: KeyMap): ParserResponse {
// command, numericPrefix is a numeric prefix of that. We want to
// preserve that whole thing, so concat them back together before
// returning.
return { keys: numericPrefix.concat(keyseq), isMatch: keyseq.length > 0 }
return { keys: numericPrefix.concat(keyseq), isMatch: keyseq.length > 0, potMatches: possibleMappings }
}
/** True if seq1 is a prefix or equal to seq2 */