diff options
author | bptato <nincsnevem662@gmail.com> | 2024-03-30 03:21:10 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-03-30 03:24:36 +0100 |
commit | aede4bb9cdd89f18ef3e2a9fda1fa3e1ff1af917 (patch) | |
tree | 8cbf7a25d88c3b8758cfabb0176c579ae4646652 /src/local/pager.nim | |
parent | 40e79dd4b42f4d93a8de8e24786e450b59ddc4de (diff) | |
download | chawan-aede4bb9cdd89f18ef3e2a9fda1fa3e1ff1af917.tar.gz |
pager: edit source fixes
* URI-decode path name for local files in default config * (ab)use mailcap command quoting for passing params to editor command instead of replicating it badly in formatEditorName * rename mailcap enums
Diffstat (limited to 'src/local/pager.nim')
-rw-r--r-- | src/local/pager.nim | 35 |
1 files changed, 8 insertions, 27 deletions
diff --git a/src/local/pager.nim b/src/local/pager.nim index 5c639a20..25042f5f 100644 --- a/src/local/pager.nim +++ b/src/local/pager.nim @@ -801,39 +801,20 @@ proc toggleSource(pager: Pager) {.jsfunc.} = pager.container.sourcepair = container pager.addContainer(container) -func formatEditorName(editor, file: string; line: int): string = - result = newStringOfCap(editor.len + file.len) - var i = 0 - var filefound = false - while i < editor.len: - if editor[i] == '%' and i < editor.high: - if editor[i + 1] == 's': - result &= file - filefound = true - i += 2 - continue - elif editor[i + 1] == 'd': - result &= $line - i += 2 - continue - elif editor[i + 1] == '%': - result &= '%' - i += 2 - continue - result &= editor[i] - inc i - if not filefound: - if result[^1] != ' ': - result &= ' ' - result &= file - func getEditorCommand(pager: Pager; file: string; line = 1): string {.jsfunc.} = var editor = pager.config.external.editor if editor == "": editor = getEnv("EDITOR") if editor == "": editor = "vi %s +%d" - return formatEditorName(editor, file, line) + var canpipe = false + var s = unquoteCommand(editor, "", file, nil, canpipe, line) + if canpipe: + # %s not in command; add file name ourselves + if s[^1] != ' ': + s &= ' ' + s &= quoteFile(file, qsNormal) + return s proc openInEditor(pager: Pager; input: var string): bool = try: |