mirror of
https://github.com/tmux/tmux.git
synced 2025-01-07 16:28:48 +00:00
Merge branch 'master' of github.com:tmux/tmux
This commit is contained in:
commit
180ebf0208
@ -54,8 +54,7 @@ cmd_attach_session(struct cmdq_item *item, int dflag, int rflag,
|
|||||||
struct client *c = item->client, *c_loop;
|
struct client *c = item->client, *c_loop;
|
||||||
struct winlink *wl = item->state.tflag.wl;
|
struct winlink *wl = item->state.tflag.wl;
|
||||||
struct window_pane *wp = item->state.tflag.wp;
|
struct window_pane *wp = item->state.tflag.wp;
|
||||||
char *cause, *cwd;
|
char *cause;
|
||||||
struct format_tree *ft;
|
|
||||||
|
|
||||||
if (RB_EMPTY(&sessions)) {
|
if (RB_EMPTY(&sessions)) {
|
||||||
cmdq_error(item, "no sessions");
|
cmdq_error(item, "no sessions");
|
||||||
@ -77,13 +76,8 @@ cmd_attach_session(struct cmdq_item *item, int dflag, int rflag,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cflag != NULL) {
|
if (cflag != NULL) {
|
||||||
ft = format_create(item, FORMAT_NONE, 0);
|
|
||||||
format_defaults(ft, c, s, wl, wp);
|
|
||||||
cwd = format_expand(ft, cflag);
|
|
||||||
format_free(ft);
|
|
||||||
|
|
||||||
free((void *)s->cwd);
|
free((void *)s->cwd);
|
||||||
s->cwd = cwd;
|
s->cwd = format_single(item, cflag, c, s, wl, wp);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c->session != NULL) {
|
if (c->session != NULL) {
|
||||||
|
@ -48,6 +48,7 @@ static enum cmd_retval
|
|||||||
cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
|
struct client *c = item->state.c;
|
||||||
struct winlink *wl = item->state.sflag.wl;
|
struct winlink *wl = item->state.sflag.wl;
|
||||||
struct session *src_s = item->state.sflag.s;
|
struct session *src_s = item->state.sflag.s;
|
||||||
struct session *dst_s = item->state.tflag.s;
|
struct session *dst_s = item->state.tflag.s;
|
||||||
@ -55,7 +56,6 @@ cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
struct window *w = wl->window;
|
struct window *w = wl->window;
|
||||||
char *name, *cause;
|
char *name, *cause;
|
||||||
int idx = item->state.tflag.idx;
|
int idx = item->state.tflag.idx;
|
||||||
struct format_tree *ft;
|
|
||||||
const char *template;
|
const char *template;
|
||||||
char *cp;
|
char *cp;
|
||||||
|
|
||||||
@ -106,15 +106,9 @@ cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
if (args_has(args, 'P')) {
|
if (args_has(args, 'P')) {
|
||||||
if ((template = args_get(args, 'F')) == NULL)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
template = BREAK_PANE_TEMPLATE;
|
template = BREAK_PANE_TEMPLATE;
|
||||||
|
cp = format_single(item, template, c, dst_s, wl, wp);
|
||||||
ft = format_create(item, FORMAT_NONE, 0);
|
|
||||||
format_defaults(ft, item->state.c, dst_s, wl, wp);
|
|
||||||
|
|
||||||
cp = format_expand(ft, template);
|
|
||||||
cmdq_print(item, "%s", cp);
|
cmdq_print(item, "%s", cp);
|
||||||
free(cp);
|
free(cp);
|
||||||
|
|
||||||
format_free(ft);
|
|
||||||
}
|
}
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -69,10 +69,10 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
char *shellcmd, *cmd, *cause;
|
char *shellcmd, *cmd, *cause;
|
||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
struct cmdq_item *new_item;
|
struct cmdq_item *new_item;
|
||||||
|
struct client *c = item->state.c;
|
||||||
struct session *s = item->state.tflag.s;
|
struct session *s = item->state.tflag.s;
|
||||||
struct winlink *wl = item->state.tflag.wl;
|
struct winlink *wl = item->state.tflag.wl;
|
||||||
struct window_pane *wp = item->state.tflag.wp;
|
struct window_pane *wp = item->state.tflag.wp;
|
||||||
struct format_tree *ft;
|
|
||||||
const char *cwd;
|
const char *cwd;
|
||||||
|
|
||||||
if (item->client != NULL && item->client->session == NULL)
|
if (item->client != NULL && item->client->session == NULL)
|
||||||
@ -82,11 +82,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
else
|
else
|
||||||
cwd = NULL;
|
cwd = NULL;
|
||||||
|
|
||||||
ft = format_create(item, FORMAT_NONE, 0);
|
shellcmd = format_single(item, args->argv[0], c, s, wl, wp);
|
||||||
format_defaults(ft, item->state.c, s, wl, wp);
|
|
||||||
shellcmd = format_expand(ft, args->argv[0]);
|
|
||||||
format_free(ft);
|
|
||||||
|
|
||||||
if (args_has(args, 'F')) {
|
if (args_has(args, 'F')) {
|
||||||
cmd = NULL;
|
cmd = NULL;
|
||||||
if (*shellcmd != '0' && *shellcmd != '\0')
|
if (*shellcmd != '0' && *shellcmd != '\0')
|
||||||
|
@ -78,7 +78,6 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
char **argv, *cause, *cp;
|
char **argv, *cause, *cp;
|
||||||
int detached, already_attached, idx, argc;
|
int detached, already_attached, idx, argc;
|
||||||
u_int sx, sy;
|
u_int sx, sy;
|
||||||
struct format_tree *ft;
|
|
||||||
struct environ_entry *envent;
|
struct environ_entry *envent;
|
||||||
struct cmd_find_state fs;
|
struct cmd_find_state fs;
|
||||||
|
|
||||||
@ -155,10 +154,8 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
|
|
||||||
/* Get the new session working directory. */
|
/* Get the new session working directory. */
|
||||||
if (args_has(args, 'c')) {
|
if (args_has(args, 'c')) {
|
||||||
ft = format_create(item, FORMAT_NONE, 0);
|
cwd = args_get(args, 'c');
|
||||||
format_defaults(ft, c, NULL, NULL, NULL);
|
to_free = cwd = format_single(item, cwd, c, NULL, NULL, NULL);
|
||||||
to_free = cwd = format_expand(ft, args_get(args, 'c'));
|
|
||||||
format_free(ft);
|
|
||||||
} else if (c != NULL && c->session == NULL && c->cwd != NULL)
|
} else if (c != NULL && c->session == NULL && c->cwd != NULL)
|
||||||
cwd = c->cwd;
|
cwd = c->cwd;
|
||||||
else
|
else
|
||||||
@ -322,15 +319,9 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
if (args_has(args, 'P')) {
|
if (args_has(args, 'P')) {
|
||||||
if ((template = args_get(args, 'F')) == NULL)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
template = NEW_SESSION_TEMPLATE;
|
template = NEW_SESSION_TEMPLATE;
|
||||||
|
cp = format_single(item, template, c, s, NULL, NULL);
|
||||||
ft = format_create(item, FORMAT_NONE, 0);
|
|
||||||
format_defaults(ft, c, s, NULL, NULL);
|
|
||||||
|
|
||||||
cp = format_expand(ft, template);
|
|
||||||
cmdq_print(item, "%s", cp);
|
cmdq_print(item, "%s", cp);
|
||||||
free(cp);
|
free(cp);
|
||||||
|
|
||||||
format_free(ft);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!detached)
|
if (!detached)
|
||||||
|
@ -59,7 +59,6 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
const char *cmd, *path, *template, *cwd, *to_free;
|
const char *cmd, *path, *template, *cwd, *to_free;
|
||||||
char **argv, *cause, *cp;
|
char **argv, *cause, *cp;
|
||||||
int argc, detached;
|
int argc, detached;
|
||||||
struct format_tree *ft;
|
|
||||||
struct environ_entry *envent;
|
struct environ_entry *envent;
|
||||||
struct cmd_find_state fs;
|
struct cmd_find_state fs;
|
||||||
|
|
||||||
@ -95,10 +94,8 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
|
|
||||||
to_free = NULL;
|
to_free = NULL;
|
||||||
if (args_has(args, 'c')) {
|
if (args_has(args, 'c')) {
|
||||||
ft = format_create(item, FORMAT_NONE, 0);
|
cwd = args_get(args, 'c');
|
||||||
format_defaults(ft, c, s, NULL, NULL);
|
to_free = cwd = format_single(item, cwd, c, s, NULL, NULL);
|
||||||
cwd = to_free = format_expand(ft, args_get(args, 'c'));
|
|
||||||
format_free(ft);
|
|
||||||
} else if (item->client != NULL && item->client->session == NULL)
|
} else if (item->client != NULL && item->client->session == NULL)
|
||||||
cwd = item->client->cwd;
|
cwd = item->client->cwd;
|
||||||
else
|
else
|
||||||
@ -142,15 +139,9 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
if (args_has(args, 'P')) {
|
if (args_has(args, 'P')) {
|
||||||
if ((template = args_get(args, 'F')) == NULL)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
template = NEW_WINDOW_TEMPLATE;
|
template = NEW_WINDOW_TEMPLATE;
|
||||||
|
cp = format_single(item, template, c, s, wl, NULL);
|
||||||
ft = format_create(item, FORMAT_NONE, 0);
|
|
||||||
format_defaults(ft, c, s, wl, NULL);
|
|
||||||
|
|
||||||
cp = format_expand(ft, template);
|
|
||||||
cmdq_print(item, "%s", cp);
|
cmdq_print(item, "%s", cp);
|
||||||
free(cp);
|
free(cp);
|
||||||
|
|
||||||
format_free(ft);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (to_free != NULL)
|
if (to_free != NULL)
|
||||||
|
@ -86,11 +86,10 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct cmd_run_shell_data *cdata;
|
struct cmd_run_shell_data *cdata;
|
||||||
char *shellcmd;
|
struct client *c = item->state.c;
|
||||||
struct session *s = item->state.tflag.s;
|
struct session *s = item->state.tflag.s;
|
||||||
struct winlink *wl = item->state.tflag.wl;
|
struct winlink *wl = item->state.tflag.wl;
|
||||||
struct window_pane *wp = item->state.tflag.wp;
|
struct window_pane *wp = item->state.tflag.wp;
|
||||||
struct format_tree *ft;
|
|
||||||
const char *cwd;
|
const char *cwd;
|
||||||
|
|
||||||
if (item->client != NULL && item->client->session == NULL)
|
if (item->client != NULL && item->client->session == NULL)
|
||||||
@ -100,13 +99,8 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
else
|
else
|
||||||
cwd = NULL;
|
cwd = NULL;
|
||||||
|
|
||||||
ft = format_create(item, FORMAT_NONE, 0);
|
|
||||||
format_defaults(ft, item->state.c, s, wl, wp);
|
|
||||||
shellcmd = format_expand(ft, args->argv[0]);
|
|
||||||
format_free(ft);
|
|
||||||
|
|
||||||
cdata = xcalloc(1, sizeof *cdata);
|
cdata = xcalloc(1, sizeof *cdata);
|
||||||
cdata->cmd = shellcmd;
|
cdata->cmd = format_single(item, args->argv[0], c, s, wl, wp);
|
||||||
|
|
||||||
if (args_has(args, 't') && wp != NULL)
|
if (args_has(args, 't') && wp != NULL)
|
||||||
cdata->wp_id = wp->id;
|
cdata->wp_id = wp->id;
|
||||||
@ -116,7 +110,7 @@ cmd_run_shell_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
if (!args_has(args, 'b'))
|
if (!args_has(args, 'b'))
|
||||||
cdata->item = item;
|
cdata->item = item;
|
||||||
|
|
||||||
job_run(shellcmd, s, cwd, cmd_run_shell_callback, cmd_run_shell_free,
|
job_run(cdata->cmd, s, cwd, cmd_run_shell_callback, cmd_run_shell_free,
|
||||||
cdata);
|
cdata);
|
||||||
|
|
||||||
if (args_has(args, 'b'))
|
if (args_has(args, 'b'))
|
||||||
|
@ -53,6 +53,7 @@ static enum cmd_retval
|
|||||||
cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
|
cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
|
struct client *c = item->state.c;
|
||||||
struct session *s = item->state.tflag.s;
|
struct session *s = item->state.tflag.s;
|
||||||
struct winlink *wl = item->state.tflag.wl;
|
struct winlink *wl = item->state.tflag.wl;
|
||||||
struct window *w = wl->window;
|
struct window *w = wl->window;
|
||||||
@ -64,7 +65,6 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
int argc, size, percentage;
|
int argc, size, percentage;
|
||||||
enum layout_type type;
|
enum layout_type type;
|
||||||
struct layout_cell *lc;
|
struct layout_cell *lc;
|
||||||
struct format_tree *ft;
|
|
||||||
struct environ_entry *envent;
|
struct environ_entry *envent;
|
||||||
struct cmd_find_state fs;
|
struct cmd_find_state fs;
|
||||||
|
|
||||||
@ -91,10 +91,8 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
|
|
||||||
to_free = NULL;
|
to_free = NULL;
|
||||||
if (args_has(args, 'c')) {
|
if (args_has(args, 'c')) {
|
||||||
ft = format_create(item, FORMAT_NONE, 0);
|
cwd = args_get(args, 'c');
|
||||||
format_defaults(ft, item->state.c, s, NULL, NULL);
|
to_free = cwd = format_single(item, cwd, c, s, NULL, NULL);
|
||||||
to_free = cwd = format_expand(ft, args_get(args, 'c'));
|
|
||||||
format_free(ft);
|
|
||||||
} else if (item->client != NULL && item->client->session == NULL)
|
} else if (item->client != NULL && item->client->session == NULL)
|
||||||
cwd = item->client->cwd;
|
cwd = item->client->cwd;
|
||||||
else
|
else
|
||||||
@ -167,15 +165,9 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
if (args_has(args, 'P')) {
|
if (args_has(args, 'P')) {
|
||||||
if ((template = args_get(args, 'F')) == NULL)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
template = SPLIT_WINDOW_TEMPLATE;
|
template = SPLIT_WINDOW_TEMPLATE;
|
||||||
|
cp = format_single(item, template, c, s, wl, new_wp);
|
||||||
ft = format_create(item, FORMAT_NONE, 0);
|
|
||||||
format_defaults(ft, item->state.c, s, wl, new_wp);
|
|
||||||
|
|
||||||
cp = format_expand(ft, template);
|
|
||||||
cmdq_print(item, "%s", cp);
|
cmdq_print(item, "%s", cp);
|
||||||
free(cp);
|
free(cp);
|
||||||
|
|
||||||
format_free(ft);
|
|
||||||
}
|
}
|
||||||
notify_window("window-layout-changed", w);
|
notify_window("window-layout-changed", w);
|
||||||
|
|
||||||
|
@ -64,10 +64,9 @@ control_notify_window_layout_changed(struct window *w)
|
|||||||
{
|
{
|
||||||
struct client *c;
|
struct client *c;
|
||||||
struct session *s;
|
struct session *s;
|
||||||
struct format_tree *ft;
|
|
||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
const char *template;
|
const char *template;
|
||||||
char *expanded;
|
char *cp;
|
||||||
|
|
||||||
template = "%layout-change #{window_id} #{window_layout} "
|
template = "%layout-change #{window_id} #{window_layout} "
|
||||||
"#{window_visible_layout} #{window_flags}";
|
"#{window_visible_layout} #{window_flags}";
|
||||||
@ -88,15 +87,12 @@ control_notify_window_layout_changed(struct window *w)
|
|||||||
if (w->layout_root == NULL)
|
if (w->layout_root == NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ft = format_create(NULL, FORMAT_NONE, 0);
|
|
||||||
wl = winlink_find_by_window(&s->windows, w);
|
wl = winlink_find_by_window(&s->windows, w);
|
||||||
if (wl != NULL) {
|
if (wl != NULL) {
|
||||||
format_defaults(ft, c, NULL, wl, NULL);
|
cp = format_single(NULL, template, c, NULL, wl, NULL);
|
||||||
expanded = format_expand(ft, template);
|
control_write(c, "%s", cp);
|
||||||
control_write(c, "%s", expanded);
|
free(cp);
|
||||||
free(expanded);
|
|
||||||
}
|
}
|
||||||
format_free(ft);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
17
format.c
17
format.c
@ -519,7 +519,6 @@ format_merge(struct format_tree *ft, struct format_tree *from)
|
|||||||
if (fe->value != NULL)
|
if (fe->value != NULL)
|
||||||
format_add(ft, fe->key, "%s", fe->value);
|
format_add(ft, fe->key, "%s", fe->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create a new tree. */
|
/* Create a new tree. */
|
||||||
@ -1081,6 +1080,22 @@ format_expand(struct format_tree *ft, const char *fmt)
|
|||||||
return (buf);
|
return (buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Expand a single string. */
|
||||||
|
char *
|
||||||
|
format_single(struct cmdq_item *item, const char *fmt, struct client *c,
|
||||||
|
struct session *s, struct winlink *wl, struct window_pane *wp)
|
||||||
|
{
|
||||||
|
struct format_tree *ft;
|
||||||
|
char *expanded;
|
||||||
|
|
||||||
|
ft = format_create(item, FORMAT_NONE, 0);
|
||||||
|
format_defaults(ft, c, s, wl, wp);
|
||||||
|
|
||||||
|
expanded = format_expand(ft, fmt);
|
||||||
|
format_free(ft);
|
||||||
|
return (expanded);
|
||||||
|
}
|
||||||
|
|
||||||
/* Set defaults for any of arguments that are not NULL. */
|
/* Set defaults for any of arguments that are not NULL. */
|
||||||
void
|
void
|
||||||
format_defaults(struct format_tree *ft, struct client *c, struct session *s,
|
format_defaults(struct format_tree *ft, struct client *c, struct session *s,
|
||||||
|
@ -427,6 +427,8 @@ options_match(const char *s, int *idx, int* ambiguous)
|
|||||||
size_t namelen;
|
size_t namelen;
|
||||||
|
|
||||||
name = options_parse(s, idx);
|
name = options_parse(s, idx);
|
||||||
|
if (name == NULL)
|
||||||
|
return (NULL);
|
||||||
namelen = strlen(name);
|
namelen = strlen(name);
|
||||||
|
|
||||||
if (*name == '@') {
|
if (*name == '@') {
|
||||||
|
3
tmux.h
3
tmux.h
@ -1512,6 +1512,9 @@ void printflike(3, 4) format_add(struct format_tree *, const char *,
|
|||||||
const char *, ...);
|
const char *, ...);
|
||||||
char *format_expand_time(struct format_tree *, const char *, time_t);
|
char *format_expand_time(struct format_tree *, const char *, time_t);
|
||||||
char *format_expand(struct format_tree *, const char *);
|
char *format_expand(struct format_tree *, const char *);
|
||||||
|
char *format_single(struct cmdq_item *, const char *,
|
||||||
|
struct client *, struct session *, struct winlink *,
|
||||||
|
struct window_pane *);
|
||||||
void format_defaults(struct format_tree *, struct client *,
|
void format_defaults(struct format_tree *, struct client *,
|
||||||
struct session *, struct winlink *, struct window_pane *);
|
struct session *, struct winlink *, struct window_pane *);
|
||||||
void format_defaults_window(struct format_tree *, struct window *);
|
void format_defaults_window(struct format_tree *, struct window *);
|
||||||
|
8
tty.c
8
tty.c
@ -235,7 +235,7 @@ tty_start_tty(struct tty *tty)
|
|||||||
|
|
||||||
tty_putcode(tty, TTYC_SMCUP);
|
tty_putcode(tty, TTYC_SMCUP);
|
||||||
|
|
||||||
tty_putcode(tty, TTYC_RMKX);
|
tty_putcode(tty, TTYC_SMKX);
|
||||||
if (tty_use_acs(tty))
|
if (tty_use_acs(tty))
|
||||||
tty_putcode(tty, TTYC_ENACS);
|
tty_putcode(tty, TTYC_ENACS);
|
||||||
tty_putcode(tty, TTYC_CLEAR);
|
tty_putcode(tty, TTYC_CLEAR);
|
||||||
@ -573,12 +573,6 @@ tty_update_mode(struct tty *tty, int mode, struct screen *s)
|
|||||||
tty_puts(tty, "\033[?1006l");
|
tty_puts(tty, "\033[?1006l");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (changed & MODE_KKEYPAD) {
|
|
||||||
if (mode & MODE_KKEYPAD)
|
|
||||||
tty_putcode(tty, TTYC_SMKX);
|
|
||||||
else
|
|
||||||
tty_putcode(tty, TTYC_RMKX);
|
|
||||||
}
|
|
||||||
if (changed & MODE_BRACKETPASTE) {
|
if (changed & MODE_BRACKETPASTE) {
|
||||||
if (mode & MODE_BRACKETPASTE)
|
if (mode & MODE_BRACKETPASTE)
|
||||||
tty_puts(tty, "\033[?2004h");
|
tty_puts(tty, "\033[?2004h");
|
||||||
|
@ -1604,29 +1604,23 @@ window_copy_copy_buffer(struct window_pane *wp, const char *bufname, void *buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
window_copy_copy_pipe(struct window_pane *wp, struct session *sess,
|
window_copy_copy_pipe(struct window_pane *wp, struct session *s,
|
||||||
const char *bufname, const char *arg)
|
const char *bufname, const char *arg)
|
||||||
{
|
{
|
||||||
void *buf;
|
void *buf;
|
||||||
size_t len;
|
size_t len;
|
||||||
struct job *job;
|
struct job *job;
|
||||||
struct format_tree *ft;
|
char *expanded;
|
||||||
char *expanded;
|
|
||||||
|
|
||||||
buf = window_copy_get_selection(wp, &len);
|
buf = window_copy_get_selection(wp, &len);
|
||||||
if (buf == NULL)
|
if (buf == NULL)
|
||||||
return;
|
return;
|
||||||
|
expanded = format_single(NULL, arg, NULL, s, NULL, wp);
|
||||||
|
|
||||||
ft = format_create(NULL, FORMAT_NONE, 0);
|
job = job_run(expanded, s, NULL, NULL, NULL, NULL);
|
||||||
format_defaults(ft, NULL, sess, NULL, wp);
|
|
||||||
expanded = format_expand(ft, arg);
|
|
||||||
|
|
||||||
job = job_run(expanded, sess, NULL, NULL, NULL, NULL);
|
|
||||||
bufferevent_write(job->event, buf, len);
|
bufferevent_write(job->event, buf, len);
|
||||||
|
|
||||||
free(expanded);
|
free(expanded);
|
||||||
format_free(ft);
|
|
||||||
|
|
||||||
window_copy_copy_buffer(wp, bufname, buf, len);
|
window_copy_copy_buffer(wp, bufname, buf, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1927,14 +1921,22 @@ static void
|
|||||||
window_copy_cursor_left(struct window_pane *wp)
|
window_copy_cursor_left(struct window_pane *wp)
|
||||||
{
|
{
|
||||||
struct window_copy_mode_data *data = wp->modedata;
|
struct window_copy_mode_data *data = wp->modedata;
|
||||||
u_int py;
|
u_int py, cx;
|
||||||
|
struct grid_cell gc;
|
||||||
|
|
||||||
py = screen_hsize(data->backing) + data->cy - data->oy;
|
py = screen_hsize(data->backing) + data->cy - data->oy;
|
||||||
if (data->cx == 0 && py > 0) {
|
cx = data->cx;
|
||||||
|
while (cx > 0) {
|
||||||
|
grid_get_cell(data->backing->grid, cx, py, &gc);
|
||||||
|
if (~gc.flags & GRID_FLAG_PADDING)
|
||||||
|
break;
|
||||||
|
cx--;
|
||||||
|
}
|
||||||
|
if (cx == 0 && py > 0) {
|
||||||
window_copy_cursor_up(wp, 0);
|
window_copy_cursor_up(wp, 0);
|
||||||
window_copy_cursor_end_of_line(wp);
|
window_copy_cursor_end_of_line(wp);
|
||||||
} else if (data->cx > 0) {
|
} else if (cx > 0) {
|
||||||
window_copy_update_cursor(wp, data->cx - 1, data->cy);
|
window_copy_update_cursor(wp, cx - 1, data->cy);
|
||||||
if (window_copy_update_selection(wp, 1))
|
if (window_copy_update_selection(wp, 1))
|
||||||
window_copy_redraw_lines(wp, data->cy, 1);
|
window_copy_redraw_lines(wp, data->cy, 1);
|
||||||
}
|
}
|
||||||
@ -1944,21 +1946,29 @@ static void
|
|||||||
window_copy_cursor_right(struct window_pane *wp)
|
window_copy_cursor_right(struct window_pane *wp)
|
||||||
{
|
{
|
||||||
struct window_copy_mode_data *data = wp->modedata;
|
struct window_copy_mode_data *data = wp->modedata;
|
||||||
u_int px, py, yy;
|
u_int px, py, yy, cx, cy;
|
||||||
|
struct grid_cell gc;
|
||||||
|
|
||||||
py = screen_hsize(data->backing) + data->cy - data->oy;
|
py = screen_hsize(data->backing) + data->cy - data->oy;
|
||||||
yy = screen_hsize(data->backing) + screen_size_y(data->backing) - 1;
|
yy = screen_hsize(data->backing) + screen_size_y(data->backing) - 1;
|
||||||
if (data->screen.sel.flag && data->rectflag)
|
if (data->screen.sel.flag && data->rectflag)
|
||||||
px = screen_size_x(&data->screen);
|
px = screen_size_x(&data->screen);
|
||||||
else {
|
else
|
||||||
px = window_copy_find_length(wp, py);
|
px = window_copy_find_length(wp, py);
|
||||||
}
|
|
||||||
|
|
||||||
if (data->cx >= px && py < yy) {
|
if (data->cx >= px && py < yy) {
|
||||||
window_copy_cursor_start_of_line(wp);
|
window_copy_cursor_start_of_line(wp);
|
||||||
window_copy_cursor_down(wp, 0);
|
window_copy_cursor_down(wp, 0);
|
||||||
} else if (data->cx < px) {
|
} else if (data->cx < px) {
|
||||||
window_copy_update_cursor(wp, data->cx + 1, data->cy);
|
cx = data->cx + 1;
|
||||||
|
cy = screen_hsize(data->backing) + data->cy - data->oy;
|
||||||
|
while (cx < px) {
|
||||||
|
grid_get_cell(data->backing->grid, cx, cy, &gc);
|
||||||
|
if (~gc.flags & GRID_FLAG_PADDING)
|
||||||
|
break;
|
||||||
|
cx++;
|
||||||
|
}
|
||||||
|
window_copy_update_cursor(wp, cx, data->cy);
|
||||||
if (window_copy_update_selection(wp, 1))
|
if (window_copy_update_selection(wp, 1))
|
||||||
window_copy_redraw_lines(wp, data->cy, 1);
|
window_copy_redraw_lines(wp, data->cy, 1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user