mirror of
https://github.com/tmux/tmux.git
synced 2025-01-07 16:28:48 +00:00
Add %%% to substitute with quotes escaped (convert " to \"). Use this
for the prompts in copy mode. Fixes problems with jumping to ' reported by Theo Buehler.
This commit is contained in:
parent
99c262b7d0
commit
8084a2c9e6
18
cmd.c
18
cmd.c
@ -653,8 +653,8 @@ char *
|
|||||||
cmd_template_replace(const char *template, const char *s, int idx)
|
cmd_template_replace(const char *template, const char *s, int idx)
|
||||||
{
|
{
|
||||||
char ch, *buf;
|
char ch, *buf;
|
||||||
const char *ptr;
|
const char *ptr, *cp;
|
||||||
int replaced;
|
int replaced, quoted;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
if (strchr(template, '%') == NULL)
|
if (strchr(template, '%') == NULL)
|
||||||
@ -676,9 +676,17 @@ cmd_template_replace(const char *template, const char *s, int idx)
|
|||||||
}
|
}
|
||||||
ptr++;
|
ptr++;
|
||||||
|
|
||||||
len += strlen(s);
|
quoted = (*ptr == '%');
|
||||||
buf = xrealloc(buf, len + 1);
|
if (quoted)
|
||||||
strlcat(buf, s, len + 1);
|
ptr++;
|
||||||
|
|
||||||
|
buf = xrealloc(buf, len + (strlen(s) * 2) + 1);
|
||||||
|
for (cp = s; *cp != '\0'; cp++) {
|
||||||
|
if (quoted && *cp == '"')
|
||||||
|
buf[len++] = '\\';
|
||||||
|
buf[len++] = *cp;
|
||||||
|
}
|
||||||
|
buf[len] = '\0';
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
buf = xrealloc(buf, len + 2);
|
buf = xrealloc(buf, len + 2);
|
||||||
|
@ -242,23 +242,23 @@ key_bindings_init(void)
|
|||||||
"bind -Tcopy-mode C-k send -X copy-end-of-line",
|
"bind -Tcopy-mode C-k send -X copy-end-of-line",
|
||||||
"bind -Tcopy-mode C-n send -X cursor-down",
|
"bind -Tcopy-mode C-n send -X cursor-down",
|
||||||
"bind -Tcopy-mode C-p send -X cursor-up",
|
"bind -Tcopy-mode C-p send -X cursor-up",
|
||||||
"bind -Tcopy-mode C-r command-prompt -p'search up' \"send -X search-backward '%%'\"",
|
"bind -Tcopy-mode C-r command-prompt -p'search up' \"send -X search-backward \\\"%%%\\\"\"",
|
||||||
"bind -Tcopy-mode C-s command-prompt -p'search down' \"send -X search-forward '%%'\"",
|
"bind -Tcopy-mode C-s command-prompt -p'search down' \"send -X search-forward \\\"%%%\\\"\"",
|
||||||
"bind -Tcopy-mode C-v send -X page-down",
|
"bind -Tcopy-mode C-v send -X page-down",
|
||||||
"bind -Tcopy-mode C-w send -X copy-selection-and-cancel",
|
"bind -Tcopy-mode C-w send -X copy-selection-and-cancel",
|
||||||
"bind -Tcopy-mode Escape send -X cancel",
|
"bind -Tcopy-mode Escape send -X cancel",
|
||||||
"bind -Tcopy-mode Space send -X page-down",
|
"bind -Tcopy-mode Space send -X page-down",
|
||||||
"bind -Tcopy-mode , send -X jump-reverse",
|
"bind -Tcopy-mode , send -X jump-reverse",
|
||||||
"bind -Tcopy-mode \\; send -X jump-again",
|
"bind -Tcopy-mode \\; send -X jump-again",
|
||||||
"bind -Tcopy-mode F command-prompt -1p'jump backward' \"send -X jump-backward '%%'\"",
|
"bind -Tcopy-mode F command-prompt -1p'jump backward' \"send -X jump-backward \\\"%%%\\\"\"",
|
||||||
"bind -Tcopy-mode N send -X search-reverse",
|
"bind -Tcopy-mode N send -X search-reverse",
|
||||||
"bind -Tcopy-mode R send -X rectangle-toggle",
|
"bind -Tcopy-mode R send -X rectangle-toggle",
|
||||||
"bind -Tcopy-mode T command-prompt -1p'jump to backward' \"send -X jump-to-backward '%%'\"",
|
"bind -Tcopy-mode T command-prompt -1p'jump to backward' \"send -X jump-to-backward \\\"%%%\\\"\"",
|
||||||
"bind -Tcopy-mode f command-prompt -1p'jump forward' \"send -X jump-forward '%%'\"",
|
"bind -Tcopy-mode f command-prompt -1p'jump forward' \"send -X jump-forward \\\"%%%\\\"\"",
|
||||||
"bind -Tcopy-mode g command-prompt -p'goto line' \"send -X goto-line '%%'\"",
|
"bind -Tcopy-mode g command-prompt -p'goto line' \"send -X goto-line '%%'\"",
|
||||||
"bind -Tcopy-mode n send -X search-again",
|
"bind -Tcopy-mode n send -X search-again",
|
||||||
"bind -Tcopy-mode q send -X cancel",
|
"bind -Tcopy-mode q send -X cancel",
|
||||||
"bind -Tcopy-mode t command-prompt -1p'jump to forward' \"send -X jump-to-forward '%%'\"",
|
"bind -Tcopy-mode t command-prompt -1p'jump to forward' \"send -X jump-to-forward \\\"%%%\\\"\"",
|
||||||
"bind -Tcopy-mode MouseDrag1Pane send -X begin-selection",
|
"bind -Tcopy-mode MouseDrag1Pane send -X begin-selection",
|
||||||
"bind -Tcopy-mode MouseDragEnd1Pane send -X copy-selection-and-cancel",
|
"bind -Tcopy-mode MouseDragEnd1Pane send -X copy-selection-and-cancel",
|
||||||
"bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up",
|
"bind -Tcopy-mode WheelUpPane send -N5 -X scroll-up",
|
||||||
@ -310,7 +310,7 @@ key_bindings_init(void)
|
|||||||
"bind -Tcopy-mode-vi Space send -X begin-selection",
|
"bind -Tcopy-mode-vi Space send -X begin-selection",
|
||||||
"bind -Tcopy-mode-vi '$' send -X end-of-line",
|
"bind -Tcopy-mode-vi '$' send -X end-of-line",
|
||||||
"bind -Tcopy-mode-vi , send -X jump-reverse",
|
"bind -Tcopy-mode-vi , send -X jump-reverse",
|
||||||
"bind -Tcopy-mode-vi / command-prompt -p'search down' \"send -X search-forward '%%'\"",
|
"bind -Tcopy-mode-vi / command-prompt -p'search down' \"send -X search-forward \\\"%%%\\\"\"",
|
||||||
"bind -Tcopy-mode-vi 0 send -X start-of-line",
|
"bind -Tcopy-mode-vi 0 send -X start-of-line",
|
||||||
"bind -Tcopy-mode-vi 1 command-prompt -Np'repeat' -I1 \"send -N '%%'\"",
|
"bind -Tcopy-mode-vi 1 command-prompt -Np'repeat' -I1 \"send -N '%%'\"",
|
||||||
"bind -Tcopy-mode-vi 2 command-prompt -Np'repeat' -I2 \"send -N '%%'\"",
|
"bind -Tcopy-mode-vi 2 command-prompt -Np'repeat' -I2 \"send -N '%%'\"",
|
||||||
@ -323,12 +323,12 @@ key_bindings_init(void)
|
|||||||
"bind -Tcopy-mode-vi 9 command-prompt -Np'repeat' -I9 \"send -N '%%'\"",
|
"bind -Tcopy-mode-vi 9 command-prompt -Np'repeat' -I9 \"send -N '%%'\"",
|
||||||
"bind -Tcopy-mode-vi : command-prompt -p'goto line' \"send -X goto-line '%%'\"",
|
"bind -Tcopy-mode-vi : command-prompt -p'goto line' \"send -X goto-line '%%'\"",
|
||||||
"bind -Tcopy-mode-vi \\; send -X jump-again",
|
"bind -Tcopy-mode-vi \\; send -X jump-again",
|
||||||
"bind -Tcopy-mode-vi ? command-prompt -p'search up' \"send -X search-backward '%%'\"",
|
"bind -Tcopy-mode-vi ? command-prompt -p'search up' \"send -X search-backward \\\"%%%\\\"\"",
|
||||||
"bind -Tcopy-mode-vi A send -X append-selection-and-cancel",
|
"bind -Tcopy-mode-vi A send -X append-selection-and-cancel",
|
||||||
"bind -Tcopy-mode-vi B send -X previous-space",
|
"bind -Tcopy-mode-vi B send -X previous-space",
|
||||||
"bind -Tcopy-mode-vi D send -X copy-end-of-line",
|
"bind -Tcopy-mode-vi D send -X copy-end-of-line",
|
||||||
"bind -Tcopy-mode-vi E send -X next-space-end",
|
"bind -Tcopy-mode-vi E send -X next-space-end",
|
||||||
"bind -Tcopy-mode-vi F command-prompt -1p'jump backward' \"send -X jump-backward '%%'\"",
|
"bind -Tcopy-mode-vi F command-prompt -1p'jump backward' \"send -X jump-backward \\\"%%%\\\"\"",
|
||||||
"bind -Tcopy-mode-vi G send -X history-bottom",
|
"bind -Tcopy-mode-vi G send -X history-bottom",
|
||||||
"bind -Tcopy-mode-vi H send -X top-line",
|
"bind -Tcopy-mode-vi H send -X top-line",
|
||||||
"bind -Tcopy-mode-vi J send -X scroll-down",
|
"bind -Tcopy-mode-vi J send -X scroll-down",
|
||||||
@ -336,13 +336,13 @@ key_bindings_init(void)
|
|||||||
"bind -Tcopy-mode-vi L send -X bottom-line",
|
"bind -Tcopy-mode-vi L send -X bottom-line",
|
||||||
"bind -Tcopy-mode-vi M send -X middle-line",
|
"bind -Tcopy-mode-vi M send -X middle-line",
|
||||||
"bind -Tcopy-mode-vi N send -X search-reverse",
|
"bind -Tcopy-mode-vi N send -X search-reverse",
|
||||||
"bind -Tcopy-mode-vi T command-prompt -1p'jump to backward' \"send -X jump-to-backward '%%'\"",
|
"bind -Tcopy-mode-vi T command-prompt -1p'jump to backward' \"send -X jump-to-backward \\\"%%%\\\"\"",
|
||||||
"bind -Tcopy-mode-vi V send -X select-line",
|
"bind -Tcopy-mode-vi V send -X select-line",
|
||||||
"bind -Tcopy-mode-vi W send -X next-space",
|
"bind -Tcopy-mode-vi W send -X next-space",
|
||||||
"bind -Tcopy-mode-vi ^ send -X back-to-indentation",
|
"bind -Tcopy-mode-vi ^ send -X back-to-indentation",
|
||||||
"bind -Tcopy-mode-vi b send -X previous-word",
|
"bind -Tcopy-mode-vi b send -X previous-word",
|
||||||
"bind -Tcopy-mode-vi e send -X next-word-end",
|
"bind -Tcopy-mode-vi e send -X next-word-end",
|
||||||
"bind -Tcopy-mode-vi f command-prompt -1p'jump forward' \"send -X jump-forward '%%'\"",
|
"bind -Tcopy-mode-vi f command-prompt -1p'jump forward' \"send -X jump-forward \\\"%%%\\\"\"",
|
||||||
"bind -Tcopy-mode-vi g send -X history-top",
|
"bind -Tcopy-mode-vi g send -X history-top",
|
||||||
"bind -Tcopy-mode-vi h send -X cursor-left",
|
"bind -Tcopy-mode-vi h send -X cursor-left",
|
||||||
"bind -Tcopy-mode-vi j send -X cursor-down",
|
"bind -Tcopy-mode-vi j send -X cursor-down",
|
||||||
@ -351,7 +351,7 @@ key_bindings_init(void)
|
|||||||
"bind -Tcopy-mode-vi n send -X search-again",
|
"bind -Tcopy-mode-vi n send -X search-again",
|
||||||
"bind -Tcopy-mode-vi o send -X other-end",
|
"bind -Tcopy-mode-vi o send -X other-end",
|
||||||
"bind -Tcopy-mode-vi q send -X cancel",
|
"bind -Tcopy-mode-vi q send -X cancel",
|
||||||
"bind -Tcopy-mode-vi t command-prompt -1p'jump to forward' \"send -X jump-to-forward '%%'\"",
|
"bind -Tcopy-mode-vi t command-prompt -1p'jump to forward' \"send -X jump-to-forward \\\"%%%\\\"\"",
|
||||||
"bind -Tcopy-mode-vi v send -X rectangle-toggle",
|
"bind -Tcopy-mode-vi v send -X rectangle-toggle",
|
||||||
"bind -Tcopy-mode-vi w send -X next-word",
|
"bind -Tcopy-mode-vi w send -X next-word",
|
||||||
"bind -Tcopy-mode-vi { send -X previous-paragraph",
|
"bind -Tcopy-mode-vi { send -X previous-paragraph",
|
||||||
|
6
tmux.1
6
tmux.1
@ -3147,6 +3147,7 @@ option.
|
|||||||
.Xc
|
.Xc
|
||||||
If this option is set, searches will wrap around the end of the pane contents.
|
If this option is set, searches will wrap around the end of the pane contents.
|
||||||
The default is on.
|
The default is on.
|
||||||
|
.Pp
|
||||||
.It Xo Ic xterm-keys
|
.It Xo Ic xterm-keys
|
||||||
.Op Ic on | off
|
.Op Ic on | off
|
||||||
.Xc
|
.Xc
|
||||||
@ -3157,7 +3158,6 @@ will generate
|
|||||||
function key sequences; these have a number included to indicate modifiers such
|
function key sequences; these have a number included to indicate modifiers such
|
||||||
as Shift, Alt or Ctrl.
|
as Shift, Alt or Ctrl.
|
||||||
The default is off.
|
The default is off.
|
||||||
.Pp
|
|
||||||
.El
|
.El
|
||||||
.It Xo Ic show-options
|
.It Xo Ic show-options
|
||||||
.Op Fl gqsvw
|
.Op Fl gqsvw
|
||||||
@ -3770,6 +3770,10 @@ Up to nine prompt responses may be replaced
|
|||||||
to
|
to
|
||||||
.Ql %9
|
.Ql %9
|
||||||
.Pc .
|
.Pc .
|
||||||
|
.Ql %%%
|
||||||
|
is like
|
||||||
|
.Ql %%
|
||||||
|
but any quotation marks are escaped.
|
||||||
.Pp
|
.Pp
|
||||||
.Fl 1
|
.Fl 1
|
||||||
makes the prompt only accept one key press, in this case the resulting input
|
makes the prompt only accept one key press, in this case the resulting input
|
||||||
|
Loading…
Reference in New Issue
Block a user