mirror of
https://github.com/vale981/tridactyl
synced 2025-03-06 01:51:40 -05:00
Un-regress hinting and finding
Turned out this was simple - I'd forgotten to switch the controller to use the content versions of hinting and finding, so the controller was using the background versions which were messaging-based proxies for the content versions that weren't running any more. Calling the content versions directly fixed hinting immediately.
This commit is contained in:
parent
90fa242e84
commit
fc08fa4471
7 changed files with 24 additions and 113 deletions
|
@ -10,7 +10,6 @@ import * as commandline_background from "./commandline_background"
|
|||
import * as convert from "./convert"
|
||||
import * as config from "./config"
|
||||
import * as dom from "./dom"
|
||||
import * as hinting_background from "./hinting_background"
|
||||
import * as download_background from "./download_background"
|
||||
import * as itertools from "./itertools"
|
||||
import * as keyseq from "./keyseq"
|
||||
|
@ -27,7 +26,6 @@ import { AutoContain } from "./lib/autocontainers"
|
|||
convert,
|
||||
config,
|
||||
dom,
|
||||
hinting_background,
|
||||
download_background,
|
||||
itertools,
|
||||
native,
|
||||
|
|
|
@ -6,8 +6,8 @@ import Logger from "./logging"
|
|||
import * as messaging from "./messaging"
|
||||
|
||||
import { parser as exmode_parser } from "./parsers/exmode"
|
||||
import { parser as hintmode_parser } from "./hinting_background"
|
||||
import { parser as findmode_parser } from "./finding_background"
|
||||
import * as hinting from "./hinting"
|
||||
import * as finding from "./finding"
|
||||
import * as gobblemode from "./parsers/gobblemode"
|
||||
import * as generic from "./parsers/genericmode"
|
||||
|
||||
|
@ -21,8 +21,8 @@ function* ParserController() {
|
|||
insert: keys => generic.parser("imaps", keys),
|
||||
input: keys => generic.parser("inputmaps", keys),
|
||||
ignore: keys => generic.parser("ignoremaps", keys),
|
||||
hint: hintmode_parser,
|
||||
find: findmode_parser,
|
||||
hint: hinting.parser,
|
||||
find: finding.parser,
|
||||
gobble: gobblemode.parser,
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,6 @@ function* ParserController() {
|
|||
} else if (currentMode === "input" && !textEditable) {
|
||||
contentState.mode = "normal"
|
||||
}
|
||||
logger.debug(keyevent_safe, contentState.mode)
|
||||
|
||||
// Accumulate key events. The parser will cut this
|
||||
// down whenever it's not a valid prefix of a known
|
||||
|
@ -69,7 +68,7 @@ function* ParserController() {
|
|||
|
||||
let response = undefined
|
||||
response = (parsers[contentState.mode] as any)(keyEvents)
|
||||
logger.debug(keyEvents, response)
|
||||
logger.debug(currentMode, contentState.mode, keyEvents, response)
|
||||
|
||||
if (response.isMatch) {
|
||||
keyevent_raw.preventDefault()
|
||||
|
|
|
@ -149,14 +149,9 @@ function pushKey(ke) {
|
|||
}
|
||||
}
|
||||
|
||||
import { addListener, attributeCaller } from "./messaging"
|
||||
addListener(
|
||||
"finding_content",
|
||||
attributeCaller({
|
||||
pushKey,
|
||||
mode,
|
||||
reset,
|
||||
findPage,
|
||||
navigate,
|
||||
}),
|
||||
)
|
||||
export function parser(keys: KeyboardEvent[]) {
|
||||
for (const { key } of keys) {
|
||||
pushKey(key)
|
||||
}
|
||||
return { keys: [], ex_str: "" }
|
||||
}
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
import { messageActiveTab } from "./messaging"
|
||||
|
||||
async function pushKey(key) {
|
||||
return await messageActiveTab("finding_content", "pushKey", [key])
|
||||
}
|
||||
|
||||
export async function findPage(direction) {
|
||||
return await messageActiveTab("finding_content", "findPage", [direction])
|
||||
}
|
||||
|
||||
export async function findPageNavigate(n: number) {
|
||||
return await messageActiveTab("finding_content", "navigate", [n])
|
||||
}
|
||||
|
||||
async function reset(args = { leavemarks: "false" }) {
|
||||
return await messageActiveTab("finding_content", "reset", [args])
|
||||
}
|
||||
|
||||
import { MsgSafeKeyboardEvent } from "./msgsafe"
|
||||
|
||||
/** At some point, this might be turned into a real keyseq parser
|
||||
|
||||
reset and selectFocusedfinds are OK candidates for map targets in the
|
||||
future. pushKey less so, I think.
|
||||
|
||||
*/
|
||||
export function parser(keys: MsgSafeKeyboardEvent[]) {
|
||||
const key = keys[0].key
|
||||
// if (key === 'Escape') {
|
||||
// reset()
|
||||
// } else if (key === 'Enter') {
|
||||
// reset({leavemarks: "true"})
|
||||
// } else {
|
||||
pushKey(keys[0])
|
||||
// }
|
||||
return { keys: [], ex_str: "" }
|
||||
}
|
|
@ -450,8 +450,6 @@ function filterHintsVimperator(fstr, reflow = false) {
|
|||
}
|
||||
|
||||
/** Remove all hints, reset STATE.
|
||||
* If abort is true, we're resetting because the user pressed escape.
|
||||
* If it is false, we're resetting because the user selected a hint.
|
||||
**/
|
||||
function reset() {
|
||||
if (modeState) {
|
||||
|
@ -545,12 +543,15 @@ function selectFocusedHint(delay = false) {
|
|||
else focused.select()
|
||||
}
|
||||
|
||||
import { addListener, attributeCaller } from "./messaging"
|
||||
addListener(
|
||||
"hinting_content",
|
||||
attributeCaller({
|
||||
pushKey,
|
||||
selectFocusedHint,
|
||||
reset,
|
||||
}),
|
||||
)
|
||||
export function parser(keys: KeyboardEvent[]) {
|
||||
for (const { key } of keys) {
|
||||
if (key === "Escape") {
|
||||
reset()
|
||||
} else if (["Enter", " "].includes(key)) {
|
||||
selectFocusedHint()
|
||||
} else {
|
||||
pushKey(keys[0])
|
||||
}
|
||||
}
|
||||
return { keys: [], ex_str: "" }
|
||||
}
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
import { messageActiveTab } from "./messaging"
|
||||
|
||||
async function pushKey(key) {
|
||||
return await messageActiveTab("hinting_content", "pushKey", [key])
|
||||
}
|
||||
|
||||
async function selectFocusedHint() {
|
||||
return await messageActiveTab("hinting_content", "selectFocusedHint")
|
||||
}
|
||||
|
||||
/* abort = true means that we're resetting because the user pressed escape */
|
||||
async function reset(abort = false) {
|
||||
return await messageActiveTab("hinting_content", "reset", [abort])
|
||||
}
|
||||
|
||||
/** Type for "hint save" actions:
|
||||
* - "link": elements that point to another resource (eg
|
||||
* links to pages/files) - the link target is saved
|
||||
* - "img": image elements
|
||||
*/
|
||||
export type HintSaveType = "link" | "img"
|
||||
|
||||
import { MsgSafeKeyboardEvent } from "./msgsafe"
|
||||
|
||||
/** At some point, this might be turned into a real keyseq parser
|
||||
|
||||
reset and selectFocusedHints are OK candidates for map targets in the
|
||||
future. pushKey less so, I think.
|
||||
|
||||
*/
|
||||
export function parser(keys: MsgSafeKeyboardEvent[]) {
|
||||
const key = keys[0].key
|
||||
if (key === "Escape") {
|
||||
reset(true)
|
||||
} else if (["Enter", " "].includes(key)) {
|
||||
selectFocusedHint()
|
||||
} else {
|
||||
pushKey(keys[0])
|
||||
}
|
||||
return { keys: [], ex_str: "" }
|
||||
}
|
|
@ -6,8 +6,6 @@ export type TabMessageType =
|
|||
| "excmd_content"
|
||||
| "commandline_content"
|
||||
| "commandline_frame"
|
||||
| "hinting_content"
|
||||
| "finding_content"
|
||||
export type NonTabMessageType =
|
||||
| "commandline_background"
|
||||
| "controller_background"
|
||||
|
@ -82,9 +80,7 @@ export async function messageTab(tabId, type: TabMessageType, command, args?) {
|
|||
command,
|
||||
args,
|
||||
}
|
||||
return browserBg.tabs.sendMessage(tabId, message).catch((e) => {
|
||||
logger.error(e, tabId, message)
|
||||
})
|
||||
return browserBg.tabs.sendMessage(tabId, message)
|
||||
}
|
||||
|
||||
export async function messageAllTabs(
|
||||
|
|
Loading…
Add table
Reference in a new issue