mirror of
https://github.com/vale981/tridactyl
synced 2025-03-04 17:11:40 -05:00
Clean logs and move code around
This commit is contained in:
parent
c3c12df8cb
commit
3d5576bb73
4 changed files with 28 additions and 24 deletions
|
@ -166,7 +166,7 @@ export function focus() {
|
|||
commandline_state.clInput.focus()
|
||||
commandline_state.clInput.removeEventListener("blur", noblur)
|
||||
commandline_state.clInput.addEventListener("blur", noblur)
|
||||
logger.debug("Called focus()")
|
||||
logger.debug("commandline_frame focus()")
|
||||
Messaging.messageOwnTab("buffered_page_keys", "").then((bufferedPageKeys : string[]) => {
|
||||
let clInputStillFocused = window.document.activeElement === commandline_state.clInput;
|
||||
logger.debug("buffered_page_keys response received", bufferedPageKeys,
|
||||
|
@ -213,7 +213,7 @@ commandline_state.clInput.addEventListener(
|
|||
"keydown",
|
||||
function (keyevent: KeyboardEvent) {
|
||||
if (!keyevent.isTrusted) return
|
||||
logger.debug("Called clInput keydown event listener", keyevent)
|
||||
logger.debug("commandline_frame clInput keydown event listener", keyevent)
|
||||
commandline_state.keyEvents.push(minimalKeyFromKeyboardEvent(keyevent))
|
||||
const response = keyParser(commandline_state.keyEvents)
|
||||
if (response.isMatch) {
|
||||
|
@ -288,6 +288,11 @@ export function refresh_completions(exstr) {
|
|||
|
||||
/** @hidden **/
|
||||
let onInputPromise: Promise<any> = Promise.resolve()
|
||||
/** @hidden **/
|
||||
commandline_state.clInput.addEventListener("input", () => {
|
||||
logger.debug("commandline_frame clInput input event listener")
|
||||
clInputValueChanged();
|
||||
})
|
||||
|
||||
function clInputValueChanged() {
|
||||
const exstr = commandline_state.clInput.value
|
||||
|
@ -310,12 +315,6 @@ function clInputValueChanged() {
|
|||
}, 100)
|
||||
}
|
||||
|
||||
/** @hidden **/
|
||||
commandline_state.clInput.addEventListener("input", () => {
|
||||
logger.debug("Called clInput input event listener")
|
||||
clInputValueChanged();
|
||||
})
|
||||
|
||||
/** @hidden **/
|
||||
let cmdline_history_current = ""
|
||||
|
||||
|
@ -373,7 +372,7 @@ export function fillcmdline(
|
|||
trailspace = true,
|
||||
ffocus = true,
|
||||
) {
|
||||
logger.debug("Called commandline_frame fillcmdline, trailspace = " + trailspace + " ffocus = " + ffocus)
|
||||
logger.debug("commandline_frame fillcmdline(newcommand = " + newcommand + " trailspace = " + trailspace + " ffocus = " + ffocus + ")")
|
||||
if (trailspace) commandline_state.clInput.value = newcommand + " "
|
||||
else commandline_state.clInput.value = newcommand
|
||||
commandline_state.initialClInputValue = commandline_state.clInput.value
|
||||
|
|
|
@ -63,7 +63,7 @@ export function show(hidehover = false) {
|
|||
*
|
||||
* Inspired by VVimpulation: https://github.com/amedama41/vvimpulation/commit/53065d015d1e9a892496619b51be83771f57b3d5
|
||||
*/
|
||||
logger.debug("Called show()")
|
||||
logger.debug("commandline_content show()")
|
||||
if (hidehover) {
|
||||
const a = window.document.createElement("A")
|
||||
;(a as any).href = ""
|
||||
|
@ -96,6 +96,9 @@ export function hide() {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Discuss removal of this method?
|
||||
*/
|
||||
export function focus() {
|
||||
try {
|
||||
// I don't think this is necessary because clInput is going to be focused.
|
||||
|
|
|
@ -100,6 +100,17 @@ class KeyCanceller {
|
|||
|
||||
export const canceller = new KeyCanceller()
|
||||
|
||||
let mustBufferPageKeysForClInput = false
|
||||
let bufferedPageKeys: string[] = []
|
||||
Messaging.addListener("buffered_page_keys", (message, sender, sendResponse) => {
|
||||
logger.debug("buffered_page_keys request received, responding with", bufferedPageKeys)
|
||||
sendResponse(Promise.resolve(bufferedPageKeys))
|
||||
// At this point, clInput is focused and the page cannot get any more keyboard events
|
||||
// until it is refocused.
|
||||
mustBufferPageKeysForClInput = false
|
||||
bufferedPageKeys = []
|
||||
})
|
||||
|
||||
/** Accepts keyevents, resolves them to maps, maps to exstrs, executes exstrs */
|
||||
function* ParserController() {
|
||||
const parsers: {
|
||||
|
@ -193,7 +204,7 @@ function* ParserController() {
|
|||
if (response.exstr) {
|
||||
exstr = response.exstr
|
||||
if (exstr.startsWith("fillcmdline ")) { // Ugh. That's ugly. I needed a way to know if this command is going to open the cmdline.
|
||||
logger.debug("Setting mustBufferPageKeysForClInput to true")
|
||||
logger.debug("Starting buffering of page keys")
|
||||
mustBufferPageKeysForClInput = true
|
||||
bufferedPageKeys = []
|
||||
}
|
||||
|
@ -217,27 +228,19 @@ function* ParserController() {
|
|||
}
|
||||
}
|
||||
}
|
||||
Messaging.addListener("buffered_page_keys", (message, sender, sendResponse) => {
|
||||
logger.debug("buffered_page_keys request received, responding with", bufferedPageKeys)
|
||||
// At this point, clInput is focused and the page will not get any more keyboard events.
|
||||
sendResponse(Promise.resolve(bufferedPageKeys))
|
||||
mustBufferPageKeysForClInput = false
|
||||
bufferedPageKeys = []
|
||||
})
|
||||
let mustBufferPageKeysForClInput = false
|
||||
let bufferedPageKeys: string[] = []
|
||||
|
||||
export const generator = ParserController() // var rather than let stops weirdness in repl.
|
||||
generator.next()
|
||||
|
||||
/** Feed keys to the ParserController */
|
||||
export function acceptKey(keyevent: KeyboardEvent) {
|
||||
logger.debug("mustBufferPageKeysForClInput = " + mustBufferPageKeysForClInput)
|
||||
logger.debug("controller_content mustBufferPageKeysForClInput = " + mustBufferPageKeysForClInput)
|
||||
if (mustBufferPageKeysForClInput) {
|
||||
let isCharacterKey = keyevent.key.length == 1
|
||||
&& !keyevent.metaKey && !keyevent.ctrlKey && !keyevent.altKey && !keyevent.metaKey;
|
||||
if (isCharacterKey) {
|
||||
bufferedPageKeys.push(keyevent.key);
|
||||
logger.debug("Buffering page keys for clInput", bufferedPageKeys)
|
||||
logger.debug("Buffering page keys", bufferedPageKeys)
|
||||
}
|
||||
keyevent.preventDefault()
|
||||
keyevent.stopImmediatePropagation()
|
||||
|
|
|
@ -3861,12 +3861,11 @@ export function sleep(time_ms: number) {
|
|||
/** @hidden */
|
||||
//#content
|
||||
export function showcmdline(focus = true) {
|
||||
logger.debug("Called showcmdline")
|
||||
logger.debug("excmds showcmdline()")
|
||||
const hidehover = true
|
||||
CommandLineContent.show(hidehover)
|
||||
let done = Promise.resolve()
|
||||
if (focus) {
|
||||
CommandLineContent.focus()
|
||||
done = Messaging.messageOwnTab("commandline_frame", "focus")
|
||||
}
|
||||
return done
|
||||
|
|
Loading…
Add table
Reference in a new issue