Skip to content

Commit

Permalink
make some commands easier to use
Browse files Browse the repository at this point in the history
  • Loading branch information
gdh1995 committed Dec 23, 2023
1 parent aa0bdc7 commit 657fb53
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
15 changes: 11 additions & 4 deletions background/all_commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,17 +245,24 @@ set_bgC_([
} satisfies {
[key in Exclude<keyof BgCmdOptions[C.dispatchEventCmd], keyof EventInit | `$${string}`>]: 1
}
for (const [key, val] of Object.entries!(dict)) {
if (key && key[0] !== "$" && !skipped.hasOwnProperty(key)) {
destDict[(dict === opts2 && key.startsWith("o.") ? key.slice(2) : key) as keyof EventInit] = val as any
dict === opts2 && delete (opts2)[key as keyof EventInit]
for (const key of dict === opts2 ? "alt ctrl meta shift super".split(" ") as ("super" | "superKey")[] : []) {
if (key in opts2 && !((key + "Key") in opts2)) {
opts2[(key + "Key") as "superKey"] = opts2[key as "super" as unknown as "superKey"]
delete opts2[key as "superKey"]
}
}
if (opts2.superKey) {
Build.OS & kBOS.MAC && (Build.OS === kBOS.MAC as number || !os_)
? destDict.metaKey = true : destDict.ctrlKey = true
delete opts2.superKey
}
for (const [key, val] of Object.entries!(dict)) {
if (key && (dict !== opts2 || key[0] !== "$") && !skipped.hasOwnProperty(key)) {
destDict[(dict === opts2 ? key.startsWith("o.") ? key.slice(2) : key
: key.startsWith("$") ? key.slice(1) : key) as keyof EventInit] = val as any
dict === opts2 && delete (opts2)[key as keyof EventInit]
}
}
let nonWordArr: RegExpExecArray | null = null
if (key && (typeof key === "object" || typeof key === "string")) {
typeof key === "string" && (nonWordArr = (<RegExpOne> /[^\w]/).exec(key.slice(1)))
Expand Down
1 change: 1 addition & 0 deletions content/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ set_contentCommands_([
return cur
}
}))
cur === 0 && (offset += a1.length, start += offset, end += offset)
editable === insert_Lock_() && rawOffset != null && inputSelRange(editable, start, end)
} else if (cmd === "select") {
const activeEl = findAnElement_(options, i > firstCmd ? 1 : count)[0]
Expand Down
3 changes: 2 additions & 1 deletion content/hud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export { box as hud_box, text as hud_text, opacity_ as hud_opacity, timer as hud
export const hudTip = (tid: kTip | HintMode, duration?: 0 | 0.0001 | 1 | 2, args?: Array<string | number> | string
, embed?: 1): void => {
hudShow(tid, args, embed)
text && (timer = timeout_(hudHide, ((duration || 1.5) * 1000) | 0))
text && (timer = timeout_(hudHide
, ((duration || (tid === kTip.copiedIs && (find_box || visual_mode_name) ? 0.5 : 1.5)) * 1000) | 0))
}
export const hudShow = (tid: kTip | HintMode, args?: Array<string | number> | string
, embed?: boolean | BOOL | TimerType.fake | void): void => {
Expand Down

0 comments on commit 657fb53

Please sign in to comment.