Skip to content

Commit

Permalink
add vimium://sed, sed-p and sed2
Browse files Browse the repository at this point in the history
Usages:
* sed `context-keys: /^[#$]?[a-z]+$/` text (without default contexts)
* sed `rule: s/.../.../flags` text (without static rules)
* `sed-p|sed.p` context-keys|rule text (with a default context of `paste`)
* sed2 rule context-keys text (without default contexts)

It can be used on Vomnibar to do simple string replacement / preview seding
  • Loading branch information
gdh1995 committed Apr 3, 2021
1 parent d868365 commit 41e2396
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions background/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,21 @@ var BgUtils_ = {
arr = arr[0].split(a.spacesRe_);
}
break;
case "sed": case "substitute": case "sed-p": case "sed.p": case "sed2":
const first = path.split(" ", 1)[0]
path = path.slice(first.length + 1).trim()
const second = cmd === "sed2" ? path.split(" ", 1)[0] : ""
path = path.slice(second.length).trim()
path = path && a.sed_(path, cmd.endsWith("p") ? SedContext.paste : SedContext.NONE,
second ? { r: first, k: second }
: (<RegExpOne> /^[@#$-]?[a-z]+$|^\.$/).test(first) ? { r: null, k: first } : { r: first, k: null } )
return [path, Urls.kEval.paste]
case "sed2":
cmd = path.split(" ", 1)[0]
path = cmd.length === path.length ? ""
: a.sed_(path.slice(cmd.length + 1).trim(), SedContext.NONE
, (<RegExpOne> /^[@#$-]?[a-z]+$|^\.$/).test(cmd) ? { r: null, k: cmd } : { r: cmd, k: null } )
return [path, Urls.kEval.paste]
case "u": case "url": case "search":
// here path is not empty, and so `decodeEscapedURL(path).trim()` is also not empty
arr = a.decodeEscapedURL_(path).split(a.spacesRe_);
Expand Down

0 comments on commit 41e2396

Please sign in to comment.