mirror of
https://github.com/tmux/tmux.git
synced 2025-04-07 00:28:48 +00:00
Sync OpenBSD patchset 1151:
Make command exec functions return an enum rather than -1/0/1 values and add a new value to mean "leave client running but don't attach" to fix problems with using some commands in a command sequence. Most of the work by Thomas Adam, problem reported by "jspenguin" on SF bug 3535531.
This commit is contained in:
parent
a432fcd306
commit
1f5e6e35d5
cfg.ccmd-attach-session.ccmd-bind-key.ccmd-break-pane.ccmd-capture-pane.ccmd-choose-buffer.ccmd-choose-client.ccmd-choose-tree.ccmd-clear-history.ccmd-clock-mode.ccmd-command-prompt.ccmd-confirm-before.ccmd-copy-mode.ccmd-delete-buffer.ccmd-detach-client.ccmd-display-message.ccmd-display-panes.ccmd-find-window.ccmd-has-session.ccmd-if-shell.ccmd-join-pane.ccmd-kill-pane.ccmd-kill-server.ccmd-kill-session.ccmd-kill-window.ccmd-link-window.ccmd-list-buffers.ccmd-list-clients.ccmd-list-commands.ccmd-list-keys.ccmd-list-panes.ccmd-list-sessions.ccmd-list-windows.ccmd-list.ccmd-load-buffer.ccmd-lock-server.ccmd-move-window.ccmd-new-session.ccmd-new-window.ccmd-paste-buffer.ccmd-pipe-pane.ccmd-refresh-client.ccmd-rename-session.ccmd-rename-window.ccmd-resize-pane.ccmd-respawn-pane.ccmd-respawn-window.ccmd-rotate-window.ccmd-run-shell.ccmd-save-buffer.ccmd-select-layout.ccmd-select-pane.ccmd-select-window.ccmd-send-keys.ccmd-send-prefix.ccmd-server-info.ccmd-set-buffer.ccmd-set-environment.ccmd-set-option.ccmd-show-buffer.ccmd-show-environment.ccmd-show-messages.ccmd-show-options.ccmd-source-file.ccmd-split-window.ccmd-start-server.ccmd-suspend-client.ccmd-swap-pane.ccmd-swap-window.ccmd-switch-client.ccmd-unbind-key.ccmd-unlink-window.ccmd.cserver-client.ctmux.h
18
cfg.c
18
cfg.c
@ -81,7 +81,7 @@ load_cfg(const char *path, struct cmd_ctx *ctxin, struct causelist *causes)
|
|||||||
size_t len;
|
size_t len;
|
||||||
struct cmd_list *cmdlist;
|
struct cmd_list *cmdlist;
|
||||||
struct cmd_ctx ctx;
|
struct cmd_ctx ctx;
|
||||||
int retval;
|
enum cmd_retval retval;
|
||||||
|
|
||||||
if ((f = fopen(path, "rb")) == NULL) {
|
if ((f = fopen(path, "rb")) == NULL) {
|
||||||
cfg_add_cause(causes, "%s: %s", path, strerror(errno));
|
cfg_add_cause(causes, "%s: %s", path, strerror(errno));
|
||||||
@ -90,7 +90,7 @@ load_cfg(const char *path, struct cmd_ctx *ctxin, struct causelist *causes)
|
|||||||
n = 0;
|
n = 0;
|
||||||
|
|
||||||
line = NULL;
|
line = NULL;
|
||||||
retval = 0;
|
retval = CMD_RETURN_NORMAL;
|
||||||
while ((buf = fgetln(f, &len))) {
|
while ((buf = fgetln(f, &len))) {
|
||||||
if (buf[len - 1] == '\n')
|
if (buf[len - 1] == '\n')
|
||||||
len--;
|
len--;
|
||||||
@ -145,8 +145,18 @@ load_cfg(const char *path, struct cmd_ctx *ctxin, struct causelist *causes)
|
|||||||
ctx.info = cfg_print;
|
ctx.info = cfg_print;
|
||||||
|
|
||||||
cfg_cause = NULL;
|
cfg_cause = NULL;
|
||||||
if (cmd_list_exec(cmdlist, &ctx) == 1)
|
switch (cmd_list_exec(cmdlist, &ctx)) {
|
||||||
retval = 1;
|
case CMD_RETURN_YIELD:
|
||||||
|
if (retval != CMD_RETURN_ATTACH)
|
||||||
|
retval = CMD_RETURN_YIELD;
|
||||||
|
break;
|
||||||
|
case CMD_RETURN_ATTACH:
|
||||||
|
retval = CMD_RETURN_ATTACH;
|
||||||
|
break;
|
||||||
|
case CMD_RETURN_ERROR:
|
||||||
|
case CMD_RETURN_NORMAL:
|
||||||
|
break;
|
||||||
|
}
|
||||||
cmd_list_free(cmdlist);
|
cmd_list_free(cmdlist);
|
||||||
if (cfg_cause != NULL) {
|
if (cfg_cause != NULL) {
|
||||||
cfg_add_cause(
|
cfg_add_cause(
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
* Attach existing session to the current terminal.
|
* Attach existing session to the current terminal.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_attach_session_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_attach_session_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_attach_session_entry = {
|
const struct cmd_entry cmd_attach_session_entry = {
|
||||||
"attach-session", "attach",
|
"attach-session", "attach",
|
||||||
@ -38,7 +38,7 @@ const struct cmd_entry cmd_attach_session_entry = {
|
|||||||
cmd_attach_session_exec
|
cmd_attach_session_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -50,14 +50,14 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
if (RB_EMPTY(&sessions)) {
|
if (RB_EMPTY(&sessions)) {
|
||||||
ctx->error(ctx, "no sessions");
|
ctx->error(ctx, "no sessions");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, args_get(args, 't'), 1)) == NULL)
|
if ((s = cmd_find_session(ctx, args_get(args, 't'), 1)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (ctx->cmdclient == NULL && ctx->curclient == NULL)
|
if (ctx->cmdclient == NULL && ctx->curclient == NULL)
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
if (ctx->cmdclient == NULL) {
|
if (ctx->cmdclient == NULL) {
|
||||||
if (args_has(self->args, 'd')) {
|
if (args_has(self->args, 'd')) {
|
||||||
@ -84,7 +84,7 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (server_client_open(ctx->cmdclient, s, &cause) != 0) {
|
if (server_client_open(ctx->cmdclient, s, &cause) != 0) {
|
||||||
ctx->error(ctx, "open terminal failed: %s", cause);
|
ctx->error(ctx, "open terminal failed: %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(self->args, 'r'))
|
if (args_has(self->args, 'r'))
|
||||||
@ -107,5 +107,5 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
server_update_socket();
|
server_update_socket();
|
||||||
|
|
||||||
return (1); /* 1 means don't tell command client to exit */
|
return (CMD_RETURN_ATTACH);
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,10 @@
|
|||||||
* Bind a key to a command, this recurses through cmd_*.
|
* Bind a key to a command, this recurses through cmd_*.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_bind_key_check(struct args *);
|
enum cmd_retval cmd_bind_key_check(struct args *);
|
||||||
int cmd_bind_key_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_bind_key_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
int cmd_bind_key_table(struct cmd *, struct cmd_ctx *, int);
|
enum cmd_retval cmd_bind_key_table(struct cmd *, struct cmd_ctx *, int);
|
||||||
|
|
||||||
const struct cmd_entry cmd_bind_key_entry = {
|
const struct cmd_entry cmd_bind_key_entry = {
|
||||||
"bind-key", "bind",
|
"bind-key", "bind",
|
||||||
@ -42,20 +42,20 @@ const struct cmd_entry cmd_bind_key_entry = {
|
|||||||
cmd_bind_key_exec
|
cmd_bind_key_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_bind_key_check(struct args *args)
|
cmd_bind_key_check(struct args *args)
|
||||||
{
|
{
|
||||||
if (args_has(args, 't')) {
|
if (args_has(args, 't')) {
|
||||||
if (args->argc != 2)
|
if (args->argc != 2)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
} else {
|
} else {
|
||||||
if (args->argc < 2)
|
if (args->argc < 2)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_bind_key_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_bind_key_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -66,7 +66,7 @@ cmd_bind_key_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
key = key_string_lookup_string(args->argv[0]);
|
key = key_string_lookup_string(args->argv[0]);
|
||||||
if (key == KEYC_NONE) {
|
if (key == KEYC_NONE) {
|
||||||
ctx->error(ctx, "unknown key: %s", args->argv[0]);
|
ctx->error(ctx, "unknown key: %s", args->argv[0]);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(args, 't'))
|
if (args_has(args, 't'))
|
||||||
@ -76,16 +76,16 @@ cmd_bind_key_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (cmdlist == NULL) {
|
if (cmdlist == NULL) {
|
||||||
ctx->error(ctx, "%s", cause);
|
ctx->error(ctx, "%s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args_has(args, 'n'))
|
if (!args_has(args, 'n'))
|
||||||
key |= KEYC_PREFIX;
|
key |= KEYC_PREFIX;
|
||||||
key_bindings_add(key, args_has(args, 'r'), cmdlist);
|
key_bindings_add(key, args_has(args, 'r'), cmdlist);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_bind_key_table(struct cmd *self, struct cmd_ctx *ctx, int key)
|
cmd_bind_key_table(struct cmd *self, struct cmd_ctx *ctx, int key)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -97,25 +97,25 @@ cmd_bind_key_table(struct cmd *self, struct cmd_ctx *ctx, int key)
|
|||||||
tablename = args_get(args, 't');
|
tablename = args_get(args, 't');
|
||||||
if ((mtab = mode_key_findtable(tablename)) == NULL) {
|
if ((mtab = mode_key_findtable(tablename)) == NULL) {
|
||||||
ctx->error(ctx, "unknown key table: %s", tablename);
|
ctx->error(ctx, "unknown key table: %s", tablename);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd = mode_key_fromstring(mtab->cmdstr, args->argv[1]);
|
cmd = mode_key_fromstring(mtab->cmdstr, args->argv[1]);
|
||||||
if (cmd == MODEKEY_NONE) {
|
if (cmd == MODEKEY_NONE) {
|
||||||
ctx->error(ctx, "unknown command: %s", args->argv[1]);
|
ctx->error(ctx, "unknown command: %s", args->argv[1]);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
mtmp.key = key;
|
mtmp.key = key;
|
||||||
mtmp.mode = !!args_has(args, 'c');
|
mtmp.mode = !!args_has(args, 'c');
|
||||||
if ((mbind = RB_FIND(mode_key_tree, mtab->tree, &mtmp)) != NULL) {
|
if ((mbind = RB_FIND(mode_key_tree, mtab->tree, &mtmp)) != NULL) {
|
||||||
mbind->cmd = cmd;
|
mbind->cmd = cmd;
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
mbind = xmalloc(sizeof *mbind);
|
mbind = xmalloc(sizeof *mbind);
|
||||||
mbind->key = mtmp.key;
|
mbind->key = mtmp.key;
|
||||||
mbind->mode = mtmp.mode;
|
mbind->mode = mtmp.mode;
|
||||||
mbind->cmd = cmd;
|
mbind->cmd = cmd;
|
||||||
RB_INSERT(mode_key_tree, mtab->tree, mbind);
|
RB_INSERT(mode_key_tree, mtab->tree, mbind);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
* Break pane off into a window.
|
* Break pane off into a window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_break_pane_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_break_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_break_pane_entry = {
|
const struct cmd_entry cmd_break_pane_entry = {
|
||||||
"break-pane", "breakp",
|
"break-pane", "breakp",
|
||||||
@ -38,7 +38,7 @@ const struct cmd_entry cmd_break_pane_entry = {
|
|||||||
cmd_break_pane_exec
|
cmd_break_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -55,11 +55,11 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
char *cp;
|
char *cp;
|
||||||
|
|
||||||
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp)) == NULL)
|
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (window_count_panes(wl->window) == 1) {
|
if (window_count_panes(wl->window) == 1) {
|
||||||
ctx->error(ctx, "can't break with only one pane");
|
ctx->error(ctx, "can't break with only one pane");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
w = wl->window;
|
w = wl->window;
|
||||||
@ -110,5 +110,5 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
format_free(ft);
|
format_free(ft);
|
||||||
}
|
}
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
* Write the entire contents of a pane to a buffer.
|
* Write the entire contents of a pane to a buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_capture_pane_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_capture_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_capture_pane_entry = {
|
const struct cmd_entry cmd_capture_pane_entry = {
|
||||||
"capture-pane", "capturep",
|
"capture-pane", "capturep",
|
||||||
@ -39,7 +39,7 @@ const struct cmd_entry cmd_capture_pane_entry = {
|
|||||||
cmd_capture_pane_exec
|
cmd_capture_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -52,7 +52,7 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
size_t len, linelen;
|
size_t len, linelen;
|
||||||
|
|
||||||
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
|
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
s = &wp->base;
|
s = &wp->base;
|
||||||
gd = s->grid;
|
gd = s->grid;
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
if (!args_has(args, 'b')) {
|
if (!args_has(args, 'b')) {
|
||||||
paste_add(&global_buffers, buf, len, limit);
|
paste_add(&global_buffers, buf, len, limit);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
||||||
@ -111,14 +111,14 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
ctx->error(ctx, "buffer %s", cause);
|
ctx->error(ctx, "buffer %s", cause);
|
||||||
free(buf);
|
free(buf);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paste_replace(&global_buffers, buffer, buf, len) != 0) {
|
if (paste_replace(&global_buffers, buffer, buf, len) != 0) {
|
||||||
ctx->error(ctx, "no buffer %d", buffer);
|
ctx->error(ctx, "no buffer %d", buffer);
|
||||||
free(buf);
|
free(buf);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
* Enter choice mode to choose a buffer.
|
* Enter choice mode to choose a buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_choose_buffer_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_choose_buffer_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
void cmd_choose_buffer_callback(struct window_choose_data *);
|
void cmd_choose_buffer_callback(struct window_choose_data *);
|
||||||
void cmd_choose_buffer_free(struct window_choose_data *);
|
void cmd_choose_buffer_free(struct window_choose_data *);
|
||||||
@ -42,7 +42,7 @@ const struct cmd_entry cmd_choose_buffer_entry = {
|
|||||||
cmd_choose_buffer_exec
|
cmd_choose_buffer_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -55,20 +55,20 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
if (ctx->curclient == NULL) {
|
if (ctx->curclient == NULL) {
|
||||||
ctx->error(ctx, "must be run interactively");
|
ctx->error(ctx, "must be run interactively");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((template = args_get(args, 'F')) == NULL)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
template = DEFAULT_BUFFER_LIST_TEMPLATE;
|
template = DEFAULT_BUFFER_LIST_TEMPLATE;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (paste_get_top(&global_buffers) == NULL)
|
if (paste_get_top(&global_buffers) == NULL)
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
if (args->argc != 0)
|
if (args->argc != 0)
|
||||||
action = xstrdup(args->argv[0]);
|
action = xstrdup(args->argv[0]);
|
||||||
@ -96,7 +96,7 @@ cmd_choose_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
window_choose_ready(wl->window->active,
|
window_choose_ready(wl->window->active,
|
||||||
0, cmd_choose_buffer_callback, cmd_choose_buffer_free);
|
0, cmd_choose_buffer_callback, cmd_choose_buffer_free);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
* Enter choice mode to choose a client.
|
* Enter choice mode to choose a client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_choose_client_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_choose_client_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
void cmd_choose_client_callback(struct window_choose_data *);
|
void cmd_choose_client_callback(struct window_choose_data *);
|
||||||
void cmd_choose_client_free(struct window_choose_data *);
|
void cmd_choose_client_free(struct window_choose_data *);
|
||||||
@ -47,7 +47,7 @@ struct cmd_choose_client_data {
|
|||||||
char *template;
|
char *template;
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_choose_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_choose_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -60,14 +60,14 @@ cmd_choose_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
if (ctx->curclient == NULL) {
|
if (ctx->curclient == NULL) {
|
||||||
ctx->error(ctx, "must be run interactively");
|
ctx->error(ctx, "must be run interactively");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
if ((template = args_get(args, 'F')) == NULL)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
template = DEFAULT_CLIENT_TEMPLATE;
|
template = DEFAULT_CLIENT_TEMPLATE;
|
||||||
@ -104,7 +104,7 @@ cmd_choose_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
window_choose_ready(wl->window->active,
|
window_choose_ready(wl->window->active,
|
||||||
cur, cmd_choose_client_callback, cmd_choose_client_free);
|
cur, cmd_choose_client_callback, cmd_choose_client_free);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -70,7 +70,7 @@ const struct cmd_entry cmd_choose_window_entry = {
|
|||||||
cmd_choose_tree_exec
|
cmd_choose_tree_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -89,17 +89,17 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
if (ctx->curclient == NULL) {
|
if (ctx->curclient == NULL) {
|
||||||
ctx->error(ctx, "must be run interactively");
|
ctx->error(ctx, "must be run interactively");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
s = ctx->curclient->session;
|
s = ctx->curclient->session;
|
||||||
tty = &ctx->curclient->tty;
|
tty = &ctx->curclient->tty;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
/* Sort out which command this is. */
|
/* Sort out which command this is. */
|
||||||
wflag = sflag = 0;
|
wflag = sflag = 0;
|
||||||
@ -221,7 +221,7 @@ windows_only:
|
|||||||
window_choose_ready(wl->window->active, cur_win,
|
window_choose_ready(wl->window->active, cur_win,
|
||||||
cmd_choose_tree_callback, cmd_choose_tree_free);
|
cmd_choose_tree_callback, cmd_choose_tree_free);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -248,4 +248,3 @@ cmd_choose_tree_free(struct window_choose_data *cdata)
|
|||||||
free(cdata);
|
free(cdata);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
* Clear pane history.
|
* Clear pane history.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_clear_history_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_clear_history_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_clear_history_entry = {
|
const struct cmd_entry cmd_clear_history_entry = {
|
||||||
"clear-history", "clearhist",
|
"clear-history", "clearhist",
|
||||||
@ -36,7 +36,7 @@ const struct cmd_entry cmd_clear_history_entry = {
|
|||||||
cmd_clear_history_exec
|
cmd_clear_history_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_clear_history_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_clear_history_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -44,11 +44,11 @@ cmd_clear_history_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct grid *gd;
|
struct grid *gd;
|
||||||
|
|
||||||
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
|
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
gd = wp->base.grid;
|
gd = wp->base.grid;
|
||||||
|
|
||||||
grid_move_lines(gd, 0, gd->hsize, gd->sy);
|
grid_move_lines(gd, 0, gd->hsize, gd->sy);
|
||||||
gd->hsize = 0;
|
gd->hsize = 0;
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
* Enter clock mode.
|
* Enter clock mode.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_clock_mode_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_clock_mode_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_clock_mode_entry = {
|
const struct cmd_entry cmd_clock_mode_entry = {
|
||||||
"clock-mode", NULL,
|
"clock-mode", NULL,
|
||||||
@ -36,16 +36,16 @@ const struct cmd_entry cmd_clock_mode_entry = {
|
|||||||
cmd_clock_mode_exec
|
cmd_clock_mode_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_clock_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_clock_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
|
|
||||||
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
|
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
window_pane_set_mode(wp, &window_clock_mode);
|
window_pane_set_mode(wp, &window_clock_mode);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
void cmd_command_prompt_key_binding(struct cmd *, int);
|
void cmd_command_prompt_key_binding(struct cmd *, int);
|
||||||
int cmd_command_prompt_check(struct args *);
|
int cmd_command_prompt_check(struct args *);
|
||||||
int cmd_command_prompt_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_command_prompt_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
int cmd_command_prompt_callback(void *, const char *);
|
int cmd_command_prompt_callback(void *, const char *);
|
||||||
void cmd_command_prompt_free(void *);
|
void cmd_command_prompt_free(void *);
|
||||||
@ -84,7 +84,7 @@ cmd_command_prompt_key_binding(struct cmd *self, int key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -95,10 +95,10 @@ cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
size_t n;
|
size_t n;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (c->prompt_string != NULL)
|
if (c->prompt_string != NULL)
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
cdata = xmalloc(sizeof *cdata);
|
cdata = xmalloc(sizeof *cdata);
|
||||||
cdata->c = c;
|
cdata->c = c;
|
||||||
@ -141,7 +141,7 @@ cmd_command_prompt_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
cmd_command_prompt_free, cdata, 0);
|
cmd_command_prompt_free, cdata, 0);
|
||||||
free(prompt);
|
free(prompt);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -26,11 +26,11 @@
|
|||||||
* Asks for confirmation before executing a command.
|
* Asks for confirmation before executing a command.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_confirm_before_key_binding(struct cmd *, int);
|
void cmd_confirm_before_key_binding(struct cmd *, int);
|
||||||
int cmd_confirm_before_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_confirm_before_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
int cmd_confirm_before_callback(void *, const char *);
|
int cmd_confirm_before_callback(void *, const char *);
|
||||||
void cmd_confirm_before_free(void *);
|
void cmd_confirm_before_free(void *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_confirm_before_entry = {
|
const struct cmd_entry cmd_confirm_before_entry = {
|
||||||
"confirm-before", "confirm",
|
"confirm-before", "confirm",
|
||||||
@ -65,7 +65,7 @@ cmd_confirm_before_key_binding(struct cmd *self, int key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_confirm_before_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_confirm_before_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -76,11 +76,11 @@ cmd_confirm_before_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
if (ctx->curclient == NULL) {
|
if (ctx->curclient == NULL) {
|
||||||
ctx->error(ctx, "must be run interactively");
|
ctx->error(ctx, "must be run interactively");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if ((prompt = args_get(args, 'p')) != NULL)
|
if ((prompt = args_get(args, 'p')) != NULL)
|
||||||
xasprintf(&new_prompt, "%s ", prompt);
|
xasprintf(&new_prompt, "%s ", prompt);
|
||||||
@ -99,7 +99,7 @@ cmd_confirm_before_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
PROMPT_SINGLE);
|
PROMPT_SINGLE);
|
||||||
|
|
||||||
free(new_prompt);
|
free(new_prompt);
|
||||||
return (1);
|
return (CMD_RETURN_YIELD);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
* Enter copy mode.
|
* Enter copy mode.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_copy_mode_key_binding(struct cmd *, int);
|
void cmd_copy_mode_key_binding(struct cmd *, int);
|
||||||
int cmd_copy_mode_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_copy_mode_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_copy_mode_entry = {
|
const struct cmd_entry cmd_copy_mode_entry = {
|
||||||
"copy-mode", NULL,
|
"copy-mode", NULL,
|
||||||
@ -45,20 +45,20 @@ cmd_copy_mode_key_binding(struct cmd *self, int key)
|
|||||||
args_set(self->args, 'u', NULL);
|
args_set(self->args, 'u', NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_copy_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_copy_mode_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
|
|
||||||
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
|
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (window_pane_set_mode(wp, &window_copy_mode) != 0)
|
if (window_pane_set_mode(wp, &window_copy_mode) != 0)
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
window_copy_init_from_pane(wp);
|
window_copy_init_from_pane(wp);
|
||||||
if (wp->mode == &window_copy_mode && args_has(self->args, 'u'))
|
if (wp->mode == &window_copy_mode && args_has(self->args, 'u'))
|
||||||
window_copy_pageup(wp);
|
window_copy_pageup(wp);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
* Delete a paste buffer.
|
* Delete a paste buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_delete_buffer_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_delete_buffer_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_delete_buffer_entry = {
|
const struct cmd_entry cmd_delete_buffer_entry = {
|
||||||
"delete-buffer", "deleteb",
|
"delete-buffer", "deleteb",
|
||||||
@ -38,7 +38,7 @@ const struct cmd_entry cmd_delete_buffer_entry = {
|
|||||||
cmd_delete_buffer_exec
|
cmd_delete_buffer_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_delete_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_delete_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -47,20 +47,20 @@ cmd_delete_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
if (!args_has(args, 'b')) {
|
if (!args_has(args, 'b')) {
|
||||||
paste_free_top(&global_buffers);
|
paste_free_top(&global_buffers);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
ctx->error(ctx, "buffer %s", cause);
|
ctx->error(ctx, "buffer %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paste_free_index(&global_buffers, buffer) != 0) {
|
if (paste_free_index(&global_buffers, buffer) != 0) {
|
||||||
ctx->error(ctx, "no buffer %d", buffer);
|
ctx->error(ctx, "no buffer %d", buffer);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
* Detach a client.
|
* Detach a client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_detach_client_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_detach_client_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_detach_client_entry = {
|
const struct cmd_entry cmd_detach_client_entry = {
|
||||||
"detach-client", "detach",
|
"detach-client", "detach",
|
||||||
@ -36,7 +36,7 @@ const struct cmd_entry cmd_detach_client_entry = {
|
|||||||
cmd_detach_client_exec
|
cmd_detach_client_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_detach_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_detach_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -53,7 +53,7 @@ cmd_detach_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (args_has(args, 's')) {
|
if (args_has(args, 's')) {
|
||||||
s = cmd_find_session(ctx, args_get(args, 's'), 0);
|
s = cmd_find_session(ctx, args_get(args, 's'), 0);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
c = ARRAY_ITEM(&clients, i);
|
c = ARRAY_ITEM(&clients, i);
|
||||||
@ -63,7 +63,7 @@ cmd_detach_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
} else {
|
} else {
|
||||||
c = cmd_find_client(ctx, args_get(args, 't'));
|
c = cmd_find_client(ctx, args_get(args, 't'));
|
||||||
if (c == NULL)
|
if (c == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (args_has(args, 'a')) {
|
if (args_has(args, 'a')) {
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
@ -76,5 +76,5 @@ cmd_detach_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
server_write_client(c, msgtype, NULL, 0);
|
server_write_client(c, msgtype, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
* Displays a message in the status line.
|
* Displays a message in the status line.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_display_message_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_display_message_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_display_message_entry = {
|
const struct cmd_entry cmd_display_message_entry = {
|
||||||
"display-message", "display",
|
"display-message", "display",
|
||||||
@ -39,7 +39,7 @@ const struct cmd_entry cmd_display_message_entry = {
|
|||||||
cmd_display_message_exec
|
cmd_display_message_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_display_message_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_display_message_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -55,21 +55,21 @@ cmd_display_message_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, args_get(args, 'c'))) == NULL)
|
if ((c = cmd_find_client(ctx, args_get(args, 'c'))) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (args_has(args, 't')) {
|
if (args_has(args, 't')) {
|
||||||
wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp);
|
wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp);
|
||||||
if (wl == NULL)
|
if (wl == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
} else {
|
} else {
|
||||||
wl = cmd_find_pane(ctx, NULL, &s, &wp);
|
wl = cmd_find_pane(ctx, NULL, &s, &wp);
|
||||||
if (wl == NULL)
|
if (wl == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(args, 'F') && args->argc != 0) {
|
if (args_has(args, 'F') && args->argc != 0) {
|
||||||
ctx->error(ctx, "only one of -F or argument must be given");
|
ctx->error(ctx, "only one of -F or argument must be given");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
template = args_get(args, 'F');
|
template = args_get(args, 'F');
|
||||||
@ -96,5 +96,5 @@ cmd_display_message_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
free(msg);
|
free(msg);
|
||||||
format_free(ft);
|
format_free(ft);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
* Display panes on a client.
|
* Display panes on a client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_display_panes_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_display_panes_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_display_panes_entry = {
|
const struct cmd_entry cmd_display_panes_entry = {
|
||||||
"display-panes", "displayp",
|
"display-panes", "displayp",
|
||||||
@ -36,16 +36,16 @@ const struct cmd_entry cmd_display_panes_entry = {
|
|||||||
cmd_display_panes_exec
|
cmd_display_panes_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_display_panes_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_display_panes_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
server_set_identify(c);
|
server_set_identify(c);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
* Find window containing text.
|
* Find window containing text.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_find_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_find_window_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
u_int cmd_find_window_match_flags(struct args *);
|
u_int cmd_find_window_match_flags(struct args *);
|
||||||
void cmd_find_window_callback(struct window_choose_data *);
|
void cmd_find_window_callback(struct window_choose_data *);
|
||||||
@ -74,7 +74,7 @@ cmd_find_window_match_flags(struct args *args)
|
|||||||
return (match_flags);
|
return (match_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -90,12 +90,12 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
if (ctx->curclient == NULL) {
|
if (ctx->curclient == NULL) {
|
||||||
ctx->error(ctx, "must be run interactively");
|
ctx->error(ctx, "must be run interactively");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
s = ctx->curclient->session;
|
s = ctx->curclient->session;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if ((template = args_get(args, 'F')) == NULL)
|
if ((template = args_get(args, 'F')) == NULL)
|
||||||
template = DEFAULT_FIND_WINDOW_TEMPLATE;
|
template = DEFAULT_FIND_WINDOW_TEMPLATE;
|
||||||
@ -150,7 +150,7 @@ cmd_find_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
ctx->error(ctx, "no windows matching: %s", str);
|
ctx->error(ctx, "no windows matching: %s", str);
|
||||||
ARRAY_FREE(&list_idx);
|
ARRAY_FREE(&list_idx);
|
||||||
ARRAY_FREE(&list_ctx);
|
ARRAY_FREE(&list_ctx);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ARRAY_LENGTH(&list_idx) == 1) {
|
if (ARRAY_LENGTH(&list_idx) == 1) {
|
||||||
@ -189,7 +189,7 @@ out:
|
|||||||
ARRAY_FREE(&list_idx);
|
ARRAY_FREE(&list_idx);
|
||||||
ARRAY_FREE(&list_ctx);
|
ARRAY_FREE(&list_ctx);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
* Cause client to report an error and exit with 1 if session doesn't exist.
|
* Cause client to report an error and exit with 1 if session doesn't exist.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_has_session_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_has_session_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_has_session_entry = {
|
const struct cmd_entry cmd_has_session_entry = {
|
||||||
"has-session", "has",
|
"has-session", "has",
|
||||||
@ -36,13 +36,13 @@ const struct cmd_entry cmd_has_session_entry = {
|
|||||||
cmd_has_session_exec
|
cmd_has_session_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_has_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_has_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
|
|
||||||
if (cmd_find_session(ctx, args_get(args, 't'), 0) == NULL)
|
if (cmd_find_session(ctx, args_get(args, 't'), 0) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
* Executes a tmux command if a shell command returns true or false.
|
* Executes a tmux command if a shell command returns true or false.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_if_shell_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_if_shell_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
void cmd_if_shell_callback(struct job *);
|
void cmd_if_shell_callback(struct job *);
|
||||||
void cmd_if_shell_free(void *);
|
void cmd_if_shell_free(void *);
|
||||||
@ -50,7 +50,7 @@ struct cmd_if_shell_data {
|
|||||||
struct cmd_ctx ctx;
|
struct cmd_ctx ctx;
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_if_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_if_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -72,7 +72,7 @@ cmd_if_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
job_run(shellcmd, cmd_if_shell_callback, cmd_if_shell_free, cdata);
|
job_run(shellcmd, cmd_if_shell_callback, cmd_if_shell_free, cdata);
|
||||||
|
|
||||||
return (1); /* don't let client exit */
|
return (CMD_RETURN_YIELD); /* don't let client exit */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -28,10 +28,10 @@
|
|||||||
* Join or move a pane into another (like split/swap/kill).
|
* Join or move a pane into another (like split/swap/kill).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_join_pane_key_binding(struct cmd *, int);
|
void cmd_join_pane_key_binding(struct cmd *, int);
|
||||||
int cmd_join_pane_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_join_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
int join_pane(struct cmd *, struct cmd_ctx *, int);
|
enum cmd_retval join_pane(struct cmd *, struct cmd_ctx *, int);
|
||||||
|
|
||||||
const struct cmd_entry cmd_join_pane_entry = {
|
const struct cmd_entry cmd_join_pane_entry = {
|
||||||
"join-pane", "joinp",
|
"join-pane", "joinp",
|
||||||
@ -67,13 +67,13 @@ cmd_join_pane_key_binding(struct cmd *self, int key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_join_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_join_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
return (join_pane(self, ctx, self->entry == &cmd_join_pane_entry));
|
return (join_pane(self, ctx, self->entry == &cmd_join_pane_entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
join_pane(struct cmd *self, struct cmd_ctx *ctx, int not_same_window)
|
join_pane(struct cmd *self, struct cmd_ctx *ctx, int not_same_window)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -88,22 +88,22 @@ join_pane(struct cmd *self, struct cmd_ctx *ctx, int not_same_window)
|
|||||||
|
|
||||||
dst_wl = cmd_find_pane(ctx, args_get(args, 't'), &dst_s, &dst_wp);
|
dst_wl = cmd_find_pane(ctx, args_get(args, 't'), &dst_s, &dst_wp);
|
||||||
if (dst_wl == NULL)
|
if (dst_wl == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
dst_w = dst_wl->window;
|
dst_w = dst_wl->window;
|
||||||
dst_idx = dst_wl->idx;
|
dst_idx = dst_wl->idx;
|
||||||
|
|
||||||
src_wl = cmd_find_pane(ctx, args_get(args, 's'), NULL, &src_wp);
|
src_wl = cmd_find_pane(ctx, args_get(args, 's'), NULL, &src_wp);
|
||||||
if (src_wl == NULL)
|
if (src_wl == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
src_w = src_wl->window;
|
src_w = src_wl->window;
|
||||||
|
|
||||||
if (not_same_window && src_w == dst_w) {
|
if (not_same_window && src_w == dst_w) {
|
||||||
ctx->error(ctx, "can't join a pane to its own window");
|
ctx->error(ctx, "can't join a pane to its own window");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (!not_same_window && src_wp == dst_wp) {
|
if (!not_same_window && src_wp == dst_wp) {
|
||||||
ctx->error(ctx, "source and target panes must be different");
|
ctx->error(ctx, "source and target panes must be different");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
type = LAYOUT_TOPBOTTOM;
|
type = LAYOUT_TOPBOTTOM;
|
||||||
@ -116,14 +116,14 @@ join_pane(struct cmd *self, struct cmd_ctx *ctx, int not_same_window)
|
|||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
ctx->error(ctx, "size %s", cause);
|
ctx->error(ctx, "size %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else if (args_has(args, 'p')) {
|
} else if (args_has(args, 'p')) {
|
||||||
percentage = args_strtonum(args, 'p', 0, 100, &cause);
|
percentage = args_strtonum(args, 'p', 0, 100, &cause);
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
ctx->error(ctx, "percentage %s", cause);
|
ctx->error(ctx, "percentage %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (type == LAYOUT_TOPBOTTOM)
|
if (type == LAYOUT_TOPBOTTOM)
|
||||||
size = (dst_wp->sy * percentage) / 100;
|
size = (dst_wp->sy * percentage) / 100;
|
||||||
@ -133,7 +133,7 @@ join_pane(struct cmd *self, struct cmd_ctx *ctx, int not_same_window)
|
|||||||
lc = layout_split_pane(dst_wp, type, size, args_has(args, 'b'));
|
lc = layout_split_pane(dst_wp, type, size, args_has(args, 'b'));
|
||||||
if (lc == NULL) {
|
if (lc == NULL) {
|
||||||
ctx->error(ctx, "create pane failed: pane too small");
|
ctx->error(ctx, "create pane failed: pane too small");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
layout_close_pane(src_wp);
|
layout_close_pane(src_wp);
|
||||||
@ -167,5 +167,5 @@ join_pane(struct cmd *self, struct cmd_ctx *ctx, int not_same_window)
|
|||||||
server_status_session(dst_s);
|
server_status_session(dst_s);
|
||||||
|
|
||||||
notify_window_layout_changed(dst_w);
|
notify_window_layout_changed(dst_w);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
* Kill pane.
|
* Kill pane.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_kill_pane_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_kill_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_kill_pane_entry = {
|
const struct cmd_entry cmd_kill_pane_entry = {
|
||||||
"kill-pane", "killp",
|
"kill-pane", "killp",
|
||||||
@ -38,7 +38,7 @@ const struct cmd_entry cmd_kill_pane_entry = {
|
|||||||
cmd_kill_pane_exec
|
cmd_kill_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_kill_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_kill_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -46,13 +46,13 @@ cmd_kill_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct window_pane *loopwp, *nextwp, *wp;
|
struct window_pane *loopwp, *nextwp, *wp;
|
||||||
|
|
||||||
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp)) == NULL)
|
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (window_count_panes(wl->window) == 1) {
|
if (window_count_panes(wl->window) == 1) {
|
||||||
/* Only one pane, kill the window. */
|
/* Only one pane, kill the window. */
|
||||||
server_kill_window(wl->window);
|
server_kill_window(wl->window);
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(self->args, 'a')) {
|
if (args_has(self->args, 'a')) {
|
||||||
@ -71,5 +71,5 @@ cmd_kill_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
server_redraw_window(wl->window);
|
server_redraw_window(wl->window);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
* Kill the server and do nothing else.
|
* Kill the server and do nothing else.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_kill_server_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_kill_server_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_kill_server_entry = {
|
const struct cmd_entry cmd_kill_server_entry = {
|
||||||
"kill-server", NULL,
|
"kill-server", NULL,
|
||||||
@ -40,10 +40,10 @@ const struct cmd_entry cmd_kill_server_entry = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_kill_server_exec(unused struct cmd *self, unused struct cmd_ctx *ctx)
|
cmd_kill_server_exec(unused struct cmd *self, unused struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
kill(getpid(), SIGTERM);
|
kill(getpid(), SIGTERM);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
* Note this deliberately has no alias to make it hard to hit by accident.
|
* Note this deliberately has no alias to make it hard to hit by accident.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_kill_session_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_kill_session_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_kill_session_entry = {
|
const struct cmd_entry cmd_kill_session_entry = {
|
||||||
"kill-session", NULL,
|
"kill-session", NULL,
|
||||||
@ -39,14 +39,14 @@ const struct cmd_entry cmd_kill_session_entry = {
|
|||||||
cmd_kill_session_exec
|
cmd_kill_session_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_kill_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_kill_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct session *s, *s2, *s3;
|
struct session *s, *s2, *s3;
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (args_has(args, 'a')) {
|
if (args_has(args, 'a')) {
|
||||||
RB_FOREACH_SAFE(s2, sessions, &sessions, s3) {
|
RB_FOREACH_SAFE(s2, sessions, &sessions, s3) {
|
||||||
@ -59,5 +59,5 @@ cmd_kill_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
server_destroy_session(s);
|
server_destroy_session(s);
|
||||||
session_destroy(s);
|
session_destroy(s);
|
||||||
}
|
}
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
* Destroy window.
|
* Destroy window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_kill_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_kill_window_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_kill_window_entry = {
|
const struct cmd_entry cmd_kill_window_entry = {
|
||||||
"kill-window", "killw",
|
"kill-window", "killw",
|
||||||
@ -36,7 +36,7 @@ const struct cmd_entry cmd_kill_window_entry = {
|
|||||||
cmd_kill_window_exec
|
cmd_kill_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_kill_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_kill_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -44,7 +44,7 @@ cmd_kill_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct session *s;
|
struct session *s;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, args_get(args, 't'), &s)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), &s)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (args_has(args, 'a')) {
|
if (args_has(args, 'a')) {
|
||||||
RB_FOREACH_SAFE(wl2, winlinks, &s->windows, wl3) {
|
RB_FOREACH_SAFE(wl2, winlinks, &s->windows, wl3) {
|
||||||
@ -55,5 +55,5 @@ cmd_kill_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
server_kill_window(wl->window);
|
server_kill_window(wl->window);
|
||||||
|
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
* Link a window into another session.
|
* Link a window into another session.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_link_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_link_window_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_link_window_entry = {
|
const struct cmd_entry cmd_link_window_entry = {
|
||||||
"link-window", "linkw",
|
"link-window", "linkw",
|
||||||
@ -38,7 +38,7 @@ const struct cmd_entry cmd_link_window_entry = {
|
|||||||
cmd_link_window_exec
|
cmd_link_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -48,18 +48,18 @@ cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
int idx, kflag, dflag;
|
int idx, kflag, dflag;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, args_get(args, 's'), &src)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 's'), &src)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
if ((idx = cmd_find_index(ctx, args_get(args, 't'), &dst)) == -2)
|
if ((idx = cmd_find_index(ctx, args_get(args, 't'), &dst)) == -2)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
kflag = args_has(self->args, 'k');
|
kflag = args_has(self->args, 'k');
|
||||||
dflag = args_has(self->args, 'd');
|
dflag = args_has(self->args, 'd');
|
||||||
if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) {
|
if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) {
|
||||||
ctx->error(ctx, "can't link window: %s", cause);
|
ctx->error(ctx, "can't link window: %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
* List paste buffers.
|
* List paste buffers.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_list_buffers_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_list_buffers_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_buffers_entry = {
|
const struct cmd_entry cmd_list_buffers_entry = {
|
||||||
"list-buffers", "lsb",
|
"list-buffers", "lsb",
|
||||||
@ -40,7 +40,7 @@ const struct cmd_entry cmd_list_buffers_entry = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_list_buffers_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
cmd_list_buffers_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -66,5 +66,5 @@ cmd_list_buffers_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
format_free(ft);
|
format_free(ft);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ const struct cmd_entry cmd_list_clients_entry = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_list_clients_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_list_clients_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -55,7 +55,7 @@ cmd_list_clients_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (args_has(args, 't')) {
|
if (args_has(args, 't')) {
|
||||||
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
} else
|
} else
|
||||||
s = NULL;
|
s = NULL;
|
||||||
|
|
||||||
@ -82,5 +82,5 @@ cmd_list_clients_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
format_free(ft);
|
format_free(ft);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
* List all commands with usages.
|
* List all commands with usages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_list_commands_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_list_commands_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_commands_entry = {
|
const struct cmd_entry cmd_list_commands_entry = {
|
||||||
"list-commands", "lscm",
|
"list-commands", "lscm",
|
||||||
@ -37,7 +37,7 @@ const struct cmd_entry cmd_list_commands_entry = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_list_commands_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
cmd_list_commands_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
const struct cmd_entry **entryp;
|
const struct cmd_entry **entryp;
|
||||||
@ -45,5 +45,5 @@ cmd_list_commands_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
for (entryp = cmd_table; *entryp != NULL; entryp++)
|
for (entryp = cmd_table; *entryp != NULL; entryp++)
|
||||||
ctx->print(ctx, "%s %s", (*entryp)->name, (*entryp)->usage);
|
ctx->print(ctx, "%s %s", (*entryp)->name, (*entryp)->usage);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -26,9 +26,8 @@
|
|||||||
* List key bindings.
|
* List key bindings.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_list_keys_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_list_keys_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
enum cmd_retval cmd_list_keys_table(struct cmd *, struct cmd_ctx *);
|
||||||
int cmd_list_keys_table(struct cmd *, struct cmd_ctx *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_keys_entry = {
|
const struct cmd_entry cmd_list_keys_entry = {
|
||||||
"list-keys", "lsk",
|
"list-keys", "lsk",
|
||||||
@ -40,7 +39,7 @@ const struct cmd_entry cmd_list_keys_entry = {
|
|||||||
cmd_list_keys_exec
|
cmd_list_keys_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_list_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_list_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -95,7 +94,7 @@ cmd_list_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
ctx->print(ctx, "bind-key %s", tmp);
|
ctx->print(ctx, "bind-key %s", tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -111,7 +110,7 @@ cmd_list_keys_table(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
tablename = args_get(args, 't');
|
tablename = args_get(args, 't');
|
||||||
if ((mtab = mode_key_findtable(tablename)) == NULL) {
|
if ((mtab = mode_key_findtable(tablename)) == NULL) {
|
||||||
ctx->error(ctx, "unknown key table: %s", tablename);
|
ctx->error(ctx, "unknown key table: %s", tablename);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
width = 0;
|
width = 0;
|
||||||
@ -145,5 +144,5 @@ cmd_list_keys_table(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
* List panes on given window.
|
* List panes on given window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_list_panes_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_list_panes_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
void cmd_list_panes_server(struct cmd *, struct cmd_ctx *);
|
void cmd_list_panes_server(struct cmd *, struct cmd_ctx *);
|
||||||
void cmd_list_panes_session(
|
void cmd_list_panes_session(
|
||||||
@ -45,7 +45,7 @@ const struct cmd_entry cmd_list_panes_entry = {
|
|||||||
cmd_list_panes_exec
|
cmd_list_panes_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_list_panes_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_list_panes_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -57,16 +57,16 @@ cmd_list_panes_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
else if (args_has(args, 's')) {
|
else if (args_has(args, 's')) {
|
||||||
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
cmd_list_panes_session(self, s, ctx, 1);
|
cmd_list_panes_session(self, s, ctx, 1);
|
||||||
} else {
|
} else {
|
||||||
wl = cmd_find_window(ctx, args_get(args, 't'), &s);
|
wl = cmd_find_window(ctx, args_get(args, 't'), &s);
|
||||||
if (wl == NULL)
|
if (wl == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
cmd_list_panes_window(self, s, wl, ctx, 0);
|
cmd_list_panes_window(self, s, wl, ctx, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
* List all sessions.
|
* List all sessions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_list_sessions_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_list_sessions_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_list_sessions_entry = {
|
const struct cmd_entry cmd_list_sessions_entry = {
|
||||||
"list-sessions", "ls",
|
"list-sessions", "ls",
|
||||||
@ -40,7 +40,7 @@ const struct cmd_entry cmd_list_sessions_entry = {
|
|||||||
cmd_list_sessions_exec
|
cmd_list_sessions_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_list_sessions_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_list_sessions_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -67,5 +67,5 @@ cmd_list_sessions_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
* List windows on given session.
|
* List windows on given session.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_list_windows_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_list_windows_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
void cmd_list_windows_server(struct cmd *, struct cmd_ctx *);
|
void cmd_list_windows_server(struct cmd *, struct cmd_ctx *);
|
||||||
void cmd_list_windows_session(
|
void cmd_list_windows_session(
|
||||||
@ -43,7 +43,7 @@ const struct cmd_entry cmd_list_windows_entry = {
|
|||||||
cmd_list_windows_exec
|
cmd_list_windows_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_list_windows_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_list_windows_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -54,11 +54,11 @@ cmd_list_windows_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
else {
|
else {
|
||||||
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
cmd_list_windows_session(self, s, ctx, 0);
|
cmd_list_windows_session(self, s, ctx, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
34
cmd-list.c
34
cmd-list.c
@ -79,12 +79,13 @@ bad:
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_list_exec(struct cmd_list *cmdlist, struct cmd_ctx *ctx)
|
cmd_list_exec(struct cmd_list *cmdlist, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct client *c = ctx->curclient;
|
struct client *c = ctx->curclient;
|
||||||
struct cmd *cmd;
|
struct cmd *cmd;
|
||||||
int n, retval, guards;
|
enum cmd_retval retval;
|
||||||
|
int guards, n;
|
||||||
|
|
||||||
guards = 0;
|
guards = 0;
|
||||||
if (c != NULL && c->session != NULL)
|
if (c != NULL && c->session != NULL)
|
||||||
@ -98,21 +99,17 @@ cmd_list_exec(struct cmd_list *cmdlist, struct cmd_ctx *ctx)
|
|||||||
if (guards)
|
if (guards)
|
||||||
ctx->print(ctx, "%%end");
|
ctx->print(ctx, "%%end");
|
||||||
|
|
||||||
/* Return of -1 is an error. */
|
switch (n)
|
||||||
if (n == -1)
|
{
|
||||||
return (-1);
|
case CMD_RETURN_ERROR:
|
||||||
|
return (CMD_RETURN_ERROR);
|
||||||
/*
|
case CMD_RETURN_ATTACH:
|
||||||
* A 1 return value means the command client is being attached
|
/* Client is being attached (send MSG_READY). */
|
||||||
* (sent MSG_READY).
|
retval = CMD_RETURN_ATTACH;
|
||||||
*/
|
|
||||||
if (n == 1) {
|
|
||||||
retval = 1;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The command client has been attached, so mangle the
|
* Mangle the context to treat any following commands
|
||||||
* context to treat any following commands as if they
|
* as if they were called from inside.
|
||||||
* were called from inside.
|
|
||||||
*/
|
*/
|
||||||
if (ctx->curclient == NULL) {
|
if (ctx->curclient == NULL) {
|
||||||
ctx->curclient = ctx->cmdclient;
|
ctx->curclient = ctx->cmdclient;
|
||||||
@ -122,6 +119,13 @@ cmd_list_exec(struct cmd_list *cmdlist, struct cmd_ctx *ctx)
|
|||||||
ctx->print = key_bindings_print;
|
ctx->print = key_bindings_print;
|
||||||
ctx->info = key_bindings_info;
|
ctx->info = key_bindings_info;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case CMD_RETURN_YIELD:
|
||||||
|
if (retval == CMD_RETURN_NORMAL)
|
||||||
|
retval = CMD_RETURN_YIELD;
|
||||||
|
break;
|
||||||
|
case CMD_RETURN_NORMAL:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (retval);
|
return (retval);
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
* Loads a paste buffer from a file.
|
* Loads a paste buffer from a file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_load_buffer_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_load_buffer_exec(struct cmd *, struct cmd_ctx *);
|
||||||
void cmd_load_buffer_callback(struct client *, int, void *);
|
void cmd_load_buffer_callback(struct client *, int, void *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_load_buffer_entry = {
|
const struct cmd_entry cmd_load_buffer_entry = {
|
||||||
"load-buffer", "loadb",
|
"load-buffer", "loadb",
|
||||||
@ -43,7 +43,7 @@ const struct cmd_entry cmd_load_buffer_entry = {
|
|||||||
cmd_load_buffer_exec
|
cmd_load_buffer_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -63,7 +63,7 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
ctx->error(ctx, "buffer %s", cause);
|
ctx->error(ctx, "buffer %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,9 +77,9 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (error != 0) {
|
if (error != 0) {
|
||||||
ctx->error(ctx, "%s: %s", path, cause);
|
ctx->error(ctx, "%s: %s", path, cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
return (1);
|
return (CMD_RETURN_YIELD);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c != NULL)
|
if (c != NULL)
|
||||||
@ -97,7 +97,7 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
if ((f = fopen(path, "rb")) == NULL) {
|
if ((f = fopen(path, "rb")) == NULL) {
|
||||||
ctx->error(ctx, "%s: %s", path, strerror(errno));
|
ctx->error(ctx, "%s: %s", path, strerror(errno));
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
pdata = NULL;
|
pdata = NULL;
|
||||||
@ -123,21 +123,21 @@ cmd_load_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
limit = options_get_number(&global_options, "buffer-limit");
|
limit = options_get_number(&global_options, "buffer-limit");
|
||||||
if (buffer == -1) {
|
if (buffer == -1) {
|
||||||
paste_add(&global_buffers, pdata, psize, limit);
|
paste_add(&global_buffers, pdata, psize, limit);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
if (paste_replace(&global_buffers, buffer, pdata, psize) != 0) {
|
if (paste_replace(&global_buffers, buffer, pdata, psize) != 0) {
|
||||||
ctx->error(ctx, "no buffer %d", buffer);
|
ctx->error(ctx, "no buffer %d", buffer);
|
||||||
free(pdata);
|
free(pdata);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
free(pdata);
|
free(pdata);
|
||||||
if (f != NULL)
|
if (f != NULL)
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
* Lock commands.
|
* Lock commands.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_lock_server_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_lock_server_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_lock_server_entry = {
|
const struct cmd_entry cmd_lock_server_entry = {
|
||||||
"lock-server", "lock",
|
"lock-server", "lock",
|
||||||
@ -61,7 +61,7 @@ const struct cmd_entry cmd_lock_client_entry = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_lock_server_exec(struct cmd *self, unused struct cmd_ctx *ctx)
|
cmd_lock_server_exec(struct cmd *self, unused struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -72,14 +72,14 @@ cmd_lock_server_exec(struct cmd *self, unused struct cmd_ctx *ctx)
|
|||||||
server_lock();
|
server_lock();
|
||||||
else if (self->entry == &cmd_lock_session_entry) {
|
else if (self->entry == &cmd_lock_session_entry) {
|
||||||
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
server_lock_session(s);
|
server_lock_session(s);
|
||||||
} else {
|
} else {
|
||||||
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
server_lock_client(c);
|
server_lock_client(c);
|
||||||
}
|
}
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
* Move a window.
|
* Move a window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_move_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_move_window_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_move_window_entry = {
|
const struct cmd_entry cmd_move_window_entry = {
|
||||||
"move-window", "movew",
|
"move-window", "movew",
|
||||||
@ -38,7 +38,7 @@ const struct cmd_entry cmd_move_window_entry = {
|
|||||||
cmd_move_window_exec
|
cmd_move_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_move_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_move_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -49,28 +49,28 @@ cmd_move_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
if (args_has(args, 'r')) {
|
if (args_has(args, 'r')) {
|
||||||
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
session_renumber_windows(s);
|
session_renumber_windows(s);
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, args_get(args, 's'), &src)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 's'), &src)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
if ((idx = cmd_find_index(ctx, args_get(args, 't'), &dst)) == -2)
|
if ((idx = cmd_find_index(ctx, args_get(args, 't'), &dst)) == -2)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
kflag = args_has(self->args, 'k');
|
kflag = args_has(self->args, 'k');
|
||||||
dflag = args_has(self->args, 'd');
|
dflag = args_has(self->args, 'd');
|
||||||
if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) {
|
if (server_link_window(src, wl, dst, idx, kflag, !dflag, &cause) != 0) {
|
||||||
ctx->error(ctx, "can't move window: %s", cause);
|
ctx->error(ctx, "can't move window: %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
server_unlink_window(src, wl);
|
server_unlink_window(src, wl);
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
* Create a new session and attach to the current terminal unless -d is given.
|
* Create a new session and attach to the current terminal unless -d is given.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_new_session_check(struct args *);
|
enum cmd_retval cmd_new_session_check(struct args *);
|
||||||
int cmd_new_session_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_new_session_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_new_session_entry = {
|
const struct cmd_entry cmd_new_session_entry = {
|
||||||
"new-session", "new",
|
"new-session", "new",
|
||||||
@ -44,15 +44,15 @@ const struct cmd_entry cmd_new_session_entry = {
|
|||||||
cmd_new_session_exec
|
cmd_new_session_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_new_session_check(struct args *args)
|
cmd_new_session_check(struct args *args)
|
||||||
{
|
{
|
||||||
if (args_has(args, 't') && (args->argc != 0 || args_has(args, 'n')))
|
if (args_has(args, 't') && (args->argc != 0 || args_has(args, 'n')))
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -71,11 +71,11 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (newname != NULL) {
|
if (newname != NULL) {
|
||||||
if (!session_check_name(newname)) {
|
if (!session_check_name(newname)) {
|
||||||
ctx->error(ctx, "bad session name: %s", newname);
|
ctx->error(ctx, "bad session name: %s", newname);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (session_find(newname) != NULL) {
|
if (session_find(newname) != NULL) {
|
||||||
ctx->error(ctx, "duplicate session: %s", newname);
|
ctx->error(ctx, "duplicate session: %s", newname);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (target != NULL) {
|
if (target != NULL) {
|
||||||
groupwith = cmd_find_session(ctx, target, 0);
|
groupwith = cmd_find_session(ctx, target, 0);
|
||||||
if (groupwith == NULL)
|
if (groupwith == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
} else
|
} else
|
||||||
groupwith = NULL;
|
groupwith = NULL;
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (server_client_open(ctx->cmdclient, NULL, &cause) != 0) {
|
if (server_client_open(ctx->cmdclient, NULL, &cause) != 0) {
|
||||||
ctx->error(ctx, "open terminal failed: %s", cause);
|
ctx->error(ctx, "open terminal failed: %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
args_get(args, 'x'), 1, USHRT_MAX, &errstr);
|
args_get(args, 'x'), 1, USHRT_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
ctx->error(ctx, "width %s", errstr);
|
ctx->error(ctx, "width %s", errstr);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args_has(args, 'y')) {
|
if (args_has(args, 'y')) {
|
||||||
@ -171,7 +171,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
args_get(args, 'y'), 1, USHRT_MAX, &errstr);
|
args_get(args, 'y'), 1, USHRT_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
ctx->error(ctx, "height %s", errstr);
|
ctx->error(ctx, "height %s", errstr);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -202,7 +202,7 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (s == NULL) {
|
if (s == NULL) {
|
||||||
ctx->error(ctx, "create session failed: %s", cause);
|
ctx->error(ctx, "create session failed: %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
environ_free(&env);
|
environ_free(&env);
|
||||||
|
|
||||||
@ -269,5 +269,5 @@ cmd_new_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
ARRAY_FREE(&cfg_causes);
|
ARRAY_FREE(&cfg_causes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (!detached); /* 1 means don't tell command client to exit */
|
return (detached ? CMD_RETURN_NORMAL : CMD_RETURN_ATTACH);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ const struct cmd_entry cmd_new_window_entry = {
|
|||||||
cmd_new_window_exec
|
cmd_new_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -56,7 +56,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (args_has(args, 'a')) {
|
if (args_has(args, 'a')) {
|
||||||
wl = cmd_find_window(ctx, args_get(args, 't'), &s);
|
wl = cmd_find_window(ctx, args_get(args, 't'), &s);
|
||||||
if (wl == NULL)
|
if (wl == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
idx = wl->idx + 1;
|
idx = wl->idx + 1;
|
||||||
|
|
||||||
/* Find the next free index. */
|
/* Find the next free index. */
|
||||||
@ -66,7 +66,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
if (last == INT_MAX) {
|
if (last == INT_MAX) {
|
||||||
ctx->error(ctx, "no free window indexes");
|
ctx->error(ctx, "no free window indexes");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Move everything from last - 1 to idx up a bit. */
|
/* Move everything from last - 1 to idx up a bit. */
|
||||||
@ -77,7 +77,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((idx = cmd_find_index(ctx, args_get(args, 't'), &s)) == -2)
|
if ((idx = cmd_find_index(ctx, args_get(args, 't'), &s)) == -2)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
detached = args_has(args, 'd');
|
detached = args_has(args, 'd');
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (wl == NULL) {
|
if (wl == NULL) {
|
||||||
ctx->error(ctx, "create window failed: %s", cause);
|
ctx->error(ctx, "create window failed: %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (!detached) {
|
if (!detached) {
|
||||||
session_select(s, wl->idx);
|
session_select(s, wl->idx);
|
||||||
@ -139,5 +139,5 @@ cmd_new_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
format_free(ft);
|
format_free(ft);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
* Paste paste buffer if present.
|
* Paste paste buffer if present.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_paste_buffer_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_paste_buffer_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
void cmd_paste_buffer_filter(struct window_pane *,
|
void cmd_paste_buffer_filter(struct window_pane *,
|
||||||
const char *, size_t, const char *, int bracket);
|
const char *, size_t, const char *, int bracket);
|
||||||
@ -42,7 +42,7 @@ const struct cmd_entry cmd_paste_buffer_entry = {
|
|||||||
cmd_paste_buffer_exec
|
cmd_paste_buffer_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -55,7 +55,7 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
int pflag;
|
int pflag;
|
||||||
|
|
||||||
if (cmd_find_pane(ctx, args_get(args, 't'), &s, &wp) == NULL)
|
if (cmd_find_pane(ctx, args_get(args, 't'), &s, &wp) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (!args_has(args, 'b'))
|
if (!args_has(args, 'b'))
|
||||||
buffer = -1;
|
buffer = -1;
|
||||||
@ -64,7 +64,7 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
ctx->error(ctx, "buffer %s", cause);
|
ctx->error(ctx, "buffer %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
pb = paste_get_index(&global_buffers, buffer);
|
pb = paste_get_index(&global_buffers, buffer);
|
||||||
if (pb == NULL) {
|
if (pb == NULL) {
|
||||||
ctx->error(ctx, "no buffer %d", buffer);
|
ctx->error(ctx, "no buffer %d", buffer);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +99,7 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
paste_free_index(&global_buffers, buffer);
|
paste_free_index(&global_buffers, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Add bytes to a buffer and filter '\n' according to separator. */
|
/* Add bytes to a buffer and filter '\n' according to separator. */
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
* Open pipe to redirect pane output. If already open, close first.
|
* Open pipe to redirect pane output. If already open, close first.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_pipe_pane_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_pipe_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
void cmd_pipe_pane_error_callback(struct bufferevent *, short, void *);
|
void cmd_pipe_pane_error_callback(struct bufferevent *, short, void *);
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ const struct cmd_entry cmd_pipe_pane_entry = {
|
|||||||
cmd_pipe_pane_exec
|
cmd_pipe_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -55,7 +55,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
int old_fd, pipe_fd[2], null_fd;
|
int old_fd, pipe_fd[2], null_fd;
|
||||||
|
|
||||||
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
|
if (cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
c = cmd_find_client(ctx, NULL);
|
c = cmd_find_client(ctx, NULL);
|
||||||
|
|
||||||
/* Destroy the old pipe. */
|
/* Destroy the old pipe. */
|
||||||
@ -68,7 +68,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
/* If no pipe command, that is enough. */
|
/* If no pipe command, that is enough. */
|
||||||
if (args->argc == 0 || *args->argv[0] == '\0')
|
if (args->argc == 0 || *args->argv[0] == '\0')
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* With -o, only open the new pipe if there was no previous one. This
|
* With -o, only open the new pipe if there was no previous one. This
|
||||||
@ -77,19 +77,19 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
* bind ^p pipep -o 'cat >>~/output'
|
* bind ^p pipep -o 'cat >>~/output'
|
||||||
*/
|
*/
|
||||||
if (args_has(self->args, 'o') && old_fd != -1)
|
if (args_has(self->args, 'o') && old_fd != -1)
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
/* Open the new pipe. */
|
/* Open the new pipe. */
|
||||||
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe_fd) != 0) {
|
if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, pipe_fd) != 0) {
|
||||||
ctx->error(ctx, "socketpair error: %s", strerror(errno));
|
ctx->error(ctx, "socketpair error: %s", strerror(errno));
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fork the child. */
|
/* Fork the child. */
|
||||||
switch (fork()) {
|
switch (fork()) {
|
||||||
case -1:
|
case -1:
|
||||||
ctx->error(ctx, "fork error: %s", strerror(errno));
|
ctx->error(ctx, "fork error: %s", strerror(errno));
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
case 0:
|
case 0:
|
||||||
/* Child process. */
|
/* Child process. */
|
||||||
close(pipe_fd[0]);
|
close(pipe_fd[0]);
|
||||||
@ -126,7 +126,7 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
bufferevent_enable(wp->pipe_event, EV_WRITE);
|
bufferevent_enable(wp->pipe_event, EV_WRITE);
|
||||||
|
|
||||||
setblocking(wp->pipe_fd, 0);
|
setblocking(wp->pipe_fd, 0);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
* Refresh client.
|
* Refresh client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_refresh_client_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_refresh_client_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_refresh_client_entry = {
|
const struct cmd_entry cmd_refresh_client_entry = {
|
||||||
"refresh-client", "refresh",
|
"refresh-client", "refresh",
|
||||||
@ -36,14 +36,14 @@ const struct cmd_entry cmd_refresh_client_entry = {
|
|||||||
cmd_refresh_client_exec
|
cmd_refresh_client_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_refresh_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_refresh_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (args_has(args, 'S')) {
|
if (args_has(args, 'S')) {
|
||||||
status_update_jobs(c);
|
status_update_jobs(c);
|
||||||
@ -51,5 +51,5 @@ cmd_refresh_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
} else
|
} else
|
||||||
server_redraw_client(c);
|
server_redraw_client(c);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
* Change session name.
|
* Change session name.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_rename_session_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_rename_session_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_rename_session_entry = {
|
const struct cmd_entry cmd_rename_session_entry = {
|
||||||
"rename-session", "rename",
|
"rename-session", "rename",
|
||||||
@ -38,7 +38,7 @@ const struct cmd_entry cmd_rename_session_entry = {
|
|||||||
cmd_rename_session_exec
|
cmd_rename_session_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_rename_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_rename_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -48,15 +48,15 @@ cmd_rename_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
newname = args->argv[0];
|
newname = args->argv[0];
|
||||||
if (!session_check_name(newname)) {
|
if (!session_check_name(newname)) {
|
||||||
ctx->error(ctx, "bad session name: %s", newname);
|
ctx->error(ctx, "bad session name: %s", newname);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (session_find(newname) != NULL) {
|
if (session_find(newname) != NULL) {
|
||||||
ctx->error(ctx, "duplicate session: %s", newname);
|
ctx->error(ctx, "duplicate session: %s", newname);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
RB_REMOVE(sessions, &sessions, s);
|
RB_REMOVE(sessions, &sessions, s);
|
||||||
free(s->name);
|
free(s->name);
|
||||||
@ -66,5 +66,5 @@ cmd_rename_session_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
server_status_session(s);
|
server_status_session(s);
|
||||||
notify_session_renamed(s);
|
notify_session_renamed(s);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
* Rename a window.
|
* Rename a window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_rename_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_rename_window_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_rename_window_entry = {
|
const struct cmd_entry cmd_rename_window_entry = {
|
||||||
"rename-window", "renamew",
|
"rename-window", "renamew",
|
||||||
@ -38,7 +38,7 @@ const struct cmd_entry cmd_rename_window_entry = {
|
|||||||
cmd_rename_window_exec
|
cmd_rename_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_rename_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_rename_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -46,12 +46,12 @@ cmd_rename_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct winlink *wl;
|
struct winlink *wl;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, args_get(args, 't'), &s)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), &s)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
window_set_name(wl->window, args->argv[0]);
|
window_set_name(wl->window, args->argv[0]);
|
||||||
options_set_number(&wl->window->options, "automatic-rename", 0);
|
options_set_number(&wl->window->options, "automatic-rename", 0);
|
||||||
|
|
||||||
server_status_window(wl->window);
|
server_status_window(wl->window);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
* Increase or decrease pane size.
|
* Increase or decrease pane size.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_resize_pane_key_binding(struct cmd *, int);
|
void cmd_resize_pane_key_binding(struct cmd *, int);
|
||||||
int cmd_resize_pane_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_resize_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_resize_pane_entry = {
|
const struct cmd_entry cmd_resize_pane_entry = {
|
||||||
"resize-pane", "resizep",
|
"resize-pane", "resizep",
|
||||||
@ -81,7 +81,7 @@ cmd_resize_pane_key_binding(struct cmd *self, int key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_resize_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_resize_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -91,7 +91,7 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
u_int adjust;
|
u_int adjust;
|
||||||
|
|
||||||
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp)) == NULL)
|
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (args->argc == 0)
|
if (args->argc == 0)
|
||||||
adjust = 1;
|
adjust = 1;
|
||||||
@ -99,7 +99,7 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
adjust = strtonum(args->argv[0], 1, INT_MAX, &errstr);
|
adjust = strtonum(args->argv[0], 1, INT_MAX, &errstr);
|
||||||
if (errstr != NULL) {
|
if (errstr != NULL) {
|
||||||
ctx->error(ctx, "adjustment %s", errstr);
|
ctx->error(ctx, "adjustment %s", errstr);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,5 +114,5 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, adjust);
|
layout_resize_pane(wp, LAYOUT_TOPBOTTOM, adjust);
|
||||||
server_redraw_window(wl->window);
|
server_redraw_window(wl->window);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
* Respawn a pane (restart the command). Kill existing if -k given.
|
* Respawn a pane (restart the command). Kill existing if -k given.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_respawn_pane_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_respawn_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_respawn_pane_entry = {
|
const struct cmd_entry cmd_respawn_pane_entry = {
|
||||||
"respawn-pane", "respawnp",
|
"respawn-pane", "respawnp",
|
||||||
@ -40,7 +40,7 @@ const struct cmd_entry cmd_respawn_pane_entry = {
|
|||||||
cmd_respawn_pane_exec
|
cmd_respawn_pane_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_respawn_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_respawn_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -54,7 +54,7 @@ cmd_respawn_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
u_int idx;
|
u_int idx;
|
||||||
|
|
||||||
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp)) == NULL)
|
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
w = wl->window;
|
w = wl->window;
|
||||||
|
|
||||||
if (!args_has(self->args, 'k') && wp->fd != -1) {
|
if (!args_has(self->args, 'k') && wp->fd != -1) {
|
||||||
@ -62,7 +62,7 @@ cmd_respawn_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
fatalx("index not found");
|
fatalx("index not found");
|
||||||
ctx->error(ctx, "pane still active: %s:%u.%u",
|
ctx->error(ctx, "pane still active: %s:%u.%u",
|
||||||
s->name, wl->idx, idx);
|
s->name, wl->idx, idx);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
environ_init(&env);
|
environ_init(&env);
|
||||||
@ -82,11 +82,11 @@ cmd_respawn_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
ctx->error(ctx, "respawn pane failed: %s", cause);
|
ctx->error(ctx, "respawn pane failed: %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
environ_free(&env);
|
environ_free(&env);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
wp->flags |= PANE_REDRAW;
|
wp->flags |= PANE_REDRAW;
|
||||||
server_status_window(w);
|
server_status_window(w);
|
||||||
|
|
||||||
environ_free(&env);
|
environ_free(&env);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
* Respawn a window (restart the command). Kill existing if -k given.
|
* Respawn a window (restart the command). Kill existing if -k given.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_respawn_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_respawn_window_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_respawn_window_entry = {
|
const struct cmd_entry cmd_respawn_window_entry = {
|
||||||
"respawn-window", "respawnw",
|
"respawn-window", "respawnw",
|
||||||
@ -39,7 +39,7 @@ const struct cmd_entry cmd_respawn_window_entry = {
|
|||||||
cmd_respawn_window_exec
|
cmd_respawn_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -52,7 +52,7 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
char *cause;
|
char *cause;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, args_get(args, 't'), &s)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), &s)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
w = wl->window;
|
w = wl->window;
|
||||||
|
|
||||||
if (!args_has(self->args, 'k')) {
|
if (!args_has(self->args, 'k')) {
|
||||||
@ -61,7 +61,7 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
continue;
|
continue;
|
||||||
ctx->error(ctx,
|
ctx->error(ctx,
|
||||||
"window still active: %s:%d", s->name, wl->idx);
|
"window still active: %s:%d", s->name, wl->idx);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
free(cause);
|
free(cause);
|
||||||
environ_free(&env);
|
environ_free(&env);
|
||||||
server_destroy_pane(wp);
|
server_destroy_pane(wp);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
layout_init(w);
|
layout_init(w);
|
||||||
window_pane_reset_mode(wp);
|
window_pane_reset_mode(wp);
|
||||||
@ -97,5 +97,5 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
server_redraw_window(w);
|
server_redraw_window(w);
|
||||||
|
|
||||||
environ_free(&env);
|
environ_free(&env);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
* Rotate the panes in a window.
|
* Rotate the panes in a window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_rotate_window_key_binding(struct cmd *, int);
|
void cmd_rotate_window_key_binding(struct cmd *, int);
|
||||||
int cmd_rotate_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_rotate_window_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_rotate_window_entry = {
|
const struct cmd_entry cmd_rotate_window_entry = {
|
||||||
"rotate-window", "rotatew",
|
"rotate-window", "rotatew",
|
||||||
@ -45,7 +45,7 @@ cmd_rotate_window_key_binding(struct cmd *self, int key)
|
|||||||
args_set(self->args, 'D', NULL);
|
args_set(self->args, 'D', NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_rotate_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_rotate_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -56,7 +56,7 @@ cmd_rotate_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
u_int sx, sy, xoff, yoff;
|
u_int sx, sy, xoff, yoff;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
w = wl->window;
|
w = wl->window;
|
||||||
|
|
||||||
if (args_has(self->args, 'D')) {
|
if (args_has(self->args, 'D')) {
|
||||||
@ -115,5 +115,5 @@ cmd_rotate_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
server_redraw_window(w);
|
server_redraw_window(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -29,10 +29,9 @@
|
|||||||
* Runs a command without a window.
|
* Runs a command without a window.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_run_shell_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_run_shell_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
void cmd_run_shell_callback(struct job *);
|
||||||
void cmd_run_shell_callback(struct job *);
|
void cmd_run_shell_free(void *);
|
||||||
void cmd_run_shell_free(void *);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_run_shell_entry = {
|
const struct cmd_entry cmd_run_shell_entry = {
|
||||||
"run-shell", "run",
|
"run-shell", "run",
|
||||||
@ -49,7 +48,7 @@ struct cmd_run_shell_data {
|
|||||||
struct cmd_ctx ctx;
|
struct cmd_ctx ctx;
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_run_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_run_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -67,7 +66,7 @@ cmd_run_shell_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
job_run(shellcmd, cmd_run_shell_callback, cmd_run_shell_free, cdata);
|
job_run(shellcmd, cmd_run_shell_callback, cmd_run_shell_free, cdata);
|
||||||
|
|
||||||
return (1); /* don't let client exit */
|
return (CMD_RETURN_YIELD); /* don't let client exit */
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
* Saves a paste buffer to a file.
|
* Saves a paste buffer to a file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_save_buffer_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_save_buffer_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_save_buffer_entry = {
|
const struct cmd_entry cmd_save_buffer_entry = {
|
||||||
"save-buffer", "saveb",
|
"save-buffer", "saveb",
|
||||||
@ -41,7 +41,7 @@ const struct cmd_entry cmd_save_buffer_entry = {
|
|||||||
cmd_save_buffer_exec
|
cmd_save_buffer_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -57,20 +57,20 @@ cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (!args_has(args, 'b')) {
|
if (!args_has(args, 'b')) {
|
||||||
if ((pb = paste_get_top(&global_buffers)) == NULL) {
|
if ((pb = paste_get_top(&global_buffers)) == NULL) {
|
||||||
ctx->error(ctx, "no buffers");
|
ctx->error(ctx, "no buffers");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
ctx->error(ctx, "buffer %s", cause);
|
ctx->error(ctx, "buffer %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
pb = paste_get_index(&global_buffers, buffer);
|
pb = paste_get_index(&global_buffers, buffer);
|
||||||
if (pb == NULL) {
|
if (pb == NULL) {
|
||||||
ctx->error(ctx, "no buffer %d", buffer);
|
ctx->error(ctx, "no buffer %d", buffer);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (strcmp(path, "-") == 0) {
|
if (strcmp(path, "-") == 0) {
|
||||||
if (c == NULL) {
|
if (c == NULL) {
|
||||||
ctx->error(ctx, "%s: can't write to stdout", path);
|
ctx->error(ctx, "%s: can't write to stdout", path);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
evbuffer_add(c->stdout_data, pb->data, pb->size);
|
evbuffer_add(c->stdout_data, pb->data, pb->size);
|
||||||
server_push_stdout(c);
|
server_push_stdout(c);
|
||||||
@ -105,15 +105,15 @@ cmd_save_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
umask(mask);
|
umask(mask);
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
ctx->error(ctx, "%s: %s", path, strerror(errno));
|
ctx->error(ctx, "%s: %s", path, strerror(errno));
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (fwrite(pb->data, 1, pb->size, f) != pb->size) {
|
if (fwrite(pb->data, 1, pb->size, f) != pb->size) {
|
||||||
ctx->error(ctx, "%s: fwrite error", path);
|
ctx->error(ctx, "%s: fwrite error", path);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
* Switch window to selected layout.
|
* Switch window to selected layout.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_select_layout_key_binding(struct cmd *, int);
|
void cmd_select_layout_key_binding(struct cmd *, int);
|
||||||
int cmd_select_layout_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_select_layout_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_select_layout_entry = {
|
const struct cmd_entry cmd_select_layout_entry = {
|
||||||
"select-layout", "selectl",
|
"select-layout", "selectl",
|
||||||
@ -90,7 +90,7 @@ cmd_select_layout_key_binding(struct cmd *self, int key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -100,7 +100,7 @@ cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
int next, previous, layout;
|
int next, previous, layout;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), NULL)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
w = wl->window;
|
w = wl->window;
|
||||||
|
|
||||||
next = self->entry == &cmd_next_layout_entry;
|
next = self->entry == &cmd_next_layout_entry;
|
||||||
@ -114,13 +114,13 @@ cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (args_has(self->args, 'U')) {
|
if (args_has(self->args, 'U')) {
|
||||||
if ((layoutname = layout_list_redo(w)) == NULL) {
|
if ((layoutname = layout_list_redo(w)) == NULL) {
|
||||||
ctx->info(ctx, "no more layout history");
|
ctx->info(ctx, "no more layout history");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
goto set_layout;
|
goto set_layout;
|
||||||
} else if (args_has(self->args, 'u')) {
|
} else if (args_has(self->args, 'u')) {
|
||||||
if ((layoutname = layout_list_undo(w)) == NULL) {
|
if ((layoutname = layout_list_undo(w)) == NULL) {
|
||||||
ctx->info(ctx, "no more layout history");
|
ctx->info(ctx, "no more layout history");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
goto set_layout;
|
goto set_layout;
|
||||||
}
|
}
|
||||||
@ -132,7 +132,7 @@ cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
layout = layout_set_previous(wl->window);
|
layout = layout_set_previous(wl->window);
|
||||||
server_redraw_window(wl->window);
|
server_redraw_window(wl->window);
|
||||||
ctx->info(ctx, "arranging in: %s", layout_set_name(layout));
|
ctx->info(ctx, "arranging in: %s", layout_set_name(layout));
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->argc == 0)
|
if (args->argc == 0)
|
||||||
@ -143,19 +143,19 @@ cmd_select_layout_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
layout = layout_set_select(wl->window, layout);
|
layout = layout_set_select(wl->window, layout);
|
||||||
server_redraw_window(wl->window);
|
server_redraw_window(wl->window);
|
||||||
ctx->info(ctx, "arranging in: %s", layout_set_name(layout));
|
ctx->info(ctx, "arranging in: %s", layout_set_name(layout));
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->argc == 0)
|
if (args->argc == 0)
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
layoutname = args->argv[0];
|
layoutname = args->argv[0];
|
||||||
|
|
||||||
set_layout:
|
set_layout:
|
||||||
if (layout_parse(wl->window, layoutname) == -1) {
|
if (layout_parse(wl->window, layoutname) == -1) {
|
||||||
ctx->error(ctx, "can't set layout: %s", layoutname);
|
ctx->error(ctx, "can't set layout: %s", layoutname);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
server_redraw_window(wl->window);
|
server_redraw_window(wl->window);
|
||||||
ctx->info(ctx, "arranging in: %s", layoutname);
|
ctx->info(ctx, "arranging in: %s", layoutname);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,8 @@
|
|||||||
* Select pane.
|
* Select pane.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_select_pane_key_binding(struct cmd *, int);
|
void cmd_select_pane_key_binding(struct cmd *, int);
|
||||||
int cmd_select_pane_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_select_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_select_pane_entry = {
|
const struct cmd_entry cmd_select_pane_entry = {
|
||||||
"select-pane", "selectp",
|
"select-pane", "selectp",
|
||||||
@ -63,7 +63,7 @@ cmd_select_pane_key_binding(struct cmd *self, int key)
|
|||||||
args_set(self->args, 't', ":.+");
|
args_set(self->args, 't', ":.+");
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_select_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_select_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -73,26 +73,26 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (self->entry == &cmd_last_pane_entry || args_has(args, 'l')) {
|
if (self->entry == &cmd_last_pane_entry || args_has(args, 'l')) {
|
||||||
wl = cmd_find_window(ctx, args_get(args, 't'), NULL);
|
wl = cmd_find_window(ctx, args_get(args, 't'), NULL);
|
||||||
if (wl == NULL)
|
if (wl == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (wl->window->last == NULL) {
|
if (wl->window->last == NULL) {
|
||||||
ctx->error(ctx, "no last pane");
|
ctx->error(ctx, "no last pane");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
window_set_active_pane(wl->window, wl->window->last);
|
window_set_active_pane(wl->window, wl->window->last);
|
||||||
server_status_window(wl->window);
|
server_status_window(wl->window);
|
||||||
server_redraw_window_borders(wl->window);
|
server_redraw_window_borders(wl->window);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp)) == NULL)
|
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), NULL, &wp)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (!window_pane_visible(wp)) {
|
if (!window_pane_visible(wp)) {
|
||||||
ctx->error(ctx, "pane not visible");
|
ctx->error(ctx, "pane not visible");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(self->args, 'L'))
|
if (args_has(self->args, 'L'))
|
||||||
@ -105,12 +105,12 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
wp = window_pane_find_down(wp);
|
wp = window_pane_find_down(wp);
|
||||||
if (wp == NULL) {
|
if (wp == NULL) {
|
||||||
ctx->error(ctx, "pane not found");
|
ctx->error(ctx, "pane not found");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
window_set_active_pane(wl->window, wp);
|
window_set_active_pane(wl->window, wp);
|
||||||
server_status_window(wl->window);
|
server_status_window(wl->window);
|
||||||
server_redraw_window_borders(wl->window);
|
server_redraw_window_borders(wl->window);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
* Select window by index.
|
* Select window by index.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_select_window_key_binding(struct cmd *, int);
|
void cmd_select_window_key_binding(struct cmd *, int);
|
||||||
int cmd_select_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_select_window_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_select_window_entry = {
|
const struct cmd_entry cmd_select_window_entry = {
|
||||||
"select-window", "selectw",
|
"select-window", "selectw",
|
||||||
@ -83,7 +83,7 @@ cmd_select_window_key_binding(struct cmd *self, int key)
|
|||||||
args_set(self->args, 'a', NULL);
|
args_set(self->args, 'a', NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_select_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_select_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -104,23 +104,23 @@ cmd_select_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (next || previous || last) {
|
if (next || previous || last) {
|
||||||
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
activity = args_has(self->args, 'a');
|
activity = args_has(self->args, 'a');
|
||||||
if (next) {
|
if (next) {
|
||||||
if (session_next(s, activity) != 0) {
|
if (session_next(s, activity) != 0) {
|
||||||
ctx->error(ctx, "no next window");
|
ctx->error(ctx, "no next window");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else if (previous) {
|
} else if (previous) {
|
||||||
if (session_previous(s, activity) != 0) {
|
if (session_previous(s, activity) != 0) {
|
||||||
ctx->error(ctx, "no previous window");
|
ctx->error(ctx, "no previous window");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (session_last(s) != 0) {
|
if (session_last(s) != 0) {
|
||||||
ctx->error(ctx, "no last window");
|
ctx->error(ctx, "no last window");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,12 +128,12 @@ cmd_select_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
} else {
|
} else {
|
||||||
wl = cmd_find_window(ctx, args_get(args, 't'), &s);
|
wl = cmd_find_window(ctx, args_get(args, 't'), &s);
|
||||||
if (wl == NULL)
|
if (wl == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (session_select(s, wl->idx) == 0)
|
if (session_select(s, wl->idx) == 0)
|
||||||
server_redraw_session(s);
|
server_redraw_session(s);
|
||||||
}
|
}
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
* Send keys to client.
|
* Send keys to client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_send_keys_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_send_keys_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_send_keys_entry = {
|
const struct cmd_entry cmd_send_keys_entry = {
|
||||||
"send-keys", "send",
|
"send-keys", "send",
|
||||||
@ -39,7 +39,7 @@ const struct cmd_entry cmd_send_keys_entry = {
|
|||||||
cmd_send_keys_exec
|
cmd_send_keys_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_send_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_send_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -50,7 +50,7 @@ cmd_send_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
int i, key;
|
int i, key;
|
||||||
|
|
||||||
if (cmd_find_pane(ctx, args_get(args, 't'), &s, &wp) == NULL)
|
if (cmd_find_pane(ctx, args_get(args, 't'), &s, &wp) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (args_has(args, 'R')) {
|
if (args_has(args, 'R')) {
|
||||||
ictx = &wp->ictx;
|
ictx = &wp->ictx;
|
||||||
@ -80,5 +80,5 @@ cmd_send_keys_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
* Send prefix key as a key.
|
* Send prefix key as a key.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_send_prefix_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_send_prefix_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_send_prefix_entry = {
|
const struct cmd_entry cmd_send_prefix_entry = {
|
||||||
"send-prefix", NULL,
|
"send-prefix", NULL,
|
||||||
@ -36,7 +36,7 @@ const struct cmd_entry cmd_send_prefix_entry = {
|
|||||||
cmd_send_prefix_exec
|
cmd_send_prefix_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_send_prefix_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_send_prefix_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -45,7 +45,7 @@ cmd_send_prefix_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
int key;
|
int key;
|
||||||
|
|
||||||
if (cmd_find_pane(ctx, args_get(args, 't'), &s, &wp) == NULL)
|
if (cmd_find_pane(ctx, args_get(args, 't'), &s, &wp) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (args_has(args, '2'))
|
if (args_has(args, '2'))
|
||||||
key = options_get_number(&s->options, "prefix2");
|
key = options_get_number(&s->options, "prefix2");
|
||||||
@ -53,5 +53,5 @@ cmd_send_prefix_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
key = options_get_number(&s->options, "prefix");
|
key = options_get_number(&s->options, "prefix");
|
||||||
window_pane_key(wp, s, key);
|
window_pane_key(wp, s, key);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
* Show various information about server.
|
* Show various information about server.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_server_info_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_server_info_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_server_info_entry = {
|
const struct cmd_entry cmd_server_info_entry = {
|
||||||
"server-info", "info",
|
"server-info", "info",
|
||||||
@ -43,7 +43,7 @@ const struct cmd_entry cmd_server_info_entry = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct tty_term *term;
|
struct tty_term *term;
|
||||||
@ -179,5 +179,5 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
job->cmd, job->fd, job->pid, job->status);
|
job->cmd, job->fd, job->pid, job->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
* Add or set a paste buffer.
|
* Add or set a paste buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_set_buffer_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_set_buffer_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_set_buffer_entry = {
|
const struct cmd_entry cmd_set_buffer_entry = {
|
||||||
"set-buffer", "setb",
|
"set-buffer", "setb",
|
||||||
@ -39,7 +39,7 @@ const struct cmd_entry cmd_set_buffer_entry = {
|
|||||||
cmd_set_buffer_exec
|
cmd_set_buffer_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_set_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_set_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -55,7 +55,7 @@ cmd_set_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
if (!args_has(args, 'b')) {
|
if (!args_has(args, 'b')) {
|
||||||
paste_add(&global_buffers, pdata, psize, limit);
|
paste_add(&global_buffers, pdata, psize, limit);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
||||||
@ -63,14 +63,14 @@ cmd_set_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
ctx->error(ctx, "buffer %s", cause);
|
ctx->error(ctx, "buffer %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
free(pdata);
|
free(pdata);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paste_replace(&global_buffers, buffer, pdata, psize) != 0) {
|
if (paste_replace(&global_buffers, buffer, pdata, psize) != 0) {
|
||||||
ctx->error(ctx, "no buffer %d", buffer);
|
ctx->error(ctx, "no buffer %d", buffer);
|
||||||
free(pdata);
|
free(pdata);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
* Set an environment variable.
|
* Set an environment variable.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_set_environment_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_set_environment_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_set_environment_entry = {
|
const struct cmd_entry cmd_set_environment_entry = {
|
||||||
"set-environment", "setenv",
|
"set-environment", "setenv",
|
||||||
@ -39,7 +39,7 @@ const struct cmd_entry cmd_set_environment_entry = {
|
|||||||
cmd_set_environment_exec
|
cmd_set_environment_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_set_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_set_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -50,11 +50,11 @@ cmd_set_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
name = args->argv[0];
|
name = args->argv[0];
|
||||||
if (*name == '\0') {
|
if (*name == '\0') {
|
||||||
ctx->error(ctx, "empty variable name");
|
ctx->error(ctx, "empty variable name");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (strchr(name, '=') != NULL) {
|
if (strchr(name, '=') != NULL) {
|
||||||
ctx->error(ctx, "variable name contains =");
|
ctx->error(ctx, "variable name contains =");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args->argc < 1)
|
if (args->argc < 1)
|
||||||
@ -66,29 +66,29 @@ cmd_set_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
env = &global_environ;
|
env = &global_environ;
|
||||||
else {
|
else {
|
||||||
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
env = &s->environ;
|
env = &s->environ;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_has(self->args, 'u')) {
|
if (args_has(self->args, 'u')) {
|
||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
ctx->error(ctx, "can't specify a value with -u");
|
ctx->error(ctx, "can't specify a value with -u");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
environ_unset(env, name);
|
environ_unset(env, name);
|
||||||
} else if (args_has(self->args, 'r')) {
|
} else if (args_has(self->args, 'r')) {
|
||||||
if (value != NULL) {
|
if (value != NULL) {
|
||||||
ctx->error(ctx, "can't specify a value with -r");
|
ctx->error(ctx, "can't specify a value with -r");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
environ_set(env, name, NULL);
|
environ_set(env, name, NULL);
|
||||||
} else {
|
} else {
|
||||||
if (value == NULL) {
|
if (value == NULL) {
|
||||||
ctx->error(ctx, "no value specified");
|
ctx->error(ctx, "no value specified");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
environ_set(env, name, value);
|
environ_set(env, name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
* Set an option.
|
* Set an option.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_set_option_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_set_option_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
int cmd_set_option_unset(struct cmd *, struct cmd_ctx *,
|
int cmd_set_option_unset(struct cmd *, struct cmd_ctx *,
|
||||||
const struct options_table_entry *, struct options *,
|
const struct options_table_entry *, struct options *,
|
||||||
@ -78,7 +78,7 @@ const struct cmd_entry cmd_set_window_option_entry = {
|
|||||||
cmd_set_option_exec
|
cmd_set_option_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -95,7 +95,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
optstr = args->argv[0];
|
optstr = args->argv[0];
|
||||||
if (*optstr == '\0') {
|
if (*optstr == '\0') {
|
||||||
ctx->error(ctx, "invalid option");
|
ctx->error(ctx, "invalid option");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (args->argc < 2)
|
if (args->argc < 2)
|
||||||
valstr = NULL;
|
valstr = NULL;
|
||||||
@ -106,11 +106,11 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
table = oe = NULL;
|
table = oe = NULL;
|
||||||
if (options_table_find(optstr, &table, &oe) != 0) {
|
if (options_table_find(optstr, &table, &oe) != 0) {
|
||||||
ctx->error(ctx, "ambiguous option: %s", optstr);
|
ctx->error(ctx, "ambiguous option: %s", optstr);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (oe == NULL) {
|
if (oe == NULL) {
|
||||||
ctx->error(ctx, "unknown option: %s", optstr);
|
ctx->error(ctx, "unknown option: %s", optstr);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Work out the tree from the table. */
|
/* Work out the tree from the table. */
|
||||||
@ -122,7 +122,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
else {
|
else {
|
||||||
wl = cmd_find_window(ctx, args_get(args, 't'), NULL);
|
wl = cmd_find_window(ctx, args_get(args, 't'), NULL);
|
||||||
if (wl == NULL)
|
if (wl == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
oo = &wl->window->options;
|
oo = &wl->window->options;
|
||||||
}
|
}
|
||||||
} else if (table == session_options_table) {
|
} else if (table == session_options_table) {
|
||||||
@ -131,21 +131,21 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
else {
|
else {
|
||||||
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
oo = &s->options;
|
oo = &s->options;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ctx->error(ctx, "unknown table");
|
ctx->error(ctx, "unknown table");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unset or set the option. */
|
/* Unset or set the option. */
|
||||||
if (args_has(args, 'u')) {
|
if (args_has(args, 'u')) {
|
||||||
if (cmd_set_option_unset(self, ctx, oe, oo, valstr) != 0)
|
if (cmd_set_option_unset(self, ctx, oe, oo, valstr) != 0)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
} else {
|
} else {
|
||||||
if (cmd_set_option_set(self, ctx, oe, oo, valstr) != 0)
|
if (cmd_set_option_set(self, ctx, oe, oo, valstr) != 0)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Start or stop timers when automatic-rename changed. */
|
/* Start or stop timers when automatic-rename changed. */
|
||||||
@ -168,7 +168,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
server_redraw_client(c);
|
server_redraw_client(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unset an option. */
|
/* Unset an option. */
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
* Show a paste buffer.
|
* Show a paste buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_show_buffer_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_show_buffer_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_show_buffer_entry = {
|
const struct cmd_entry cmd_show_buffer_entry = {
|
||||||
"show-buffer", "showb",
|
"show-buffer", "showb",
|
||||||
@ -38,7 +38,7 @@ const struct cmd_entry cmd_show_buffer_entry = {
|
|||||||
cmd_show_buffer_exec
|
cmd_show_buffer_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_show_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_show_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -50,25 +50,25 @@ cmd_show_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
u_int width;
|
u_int width;
|
||||||
|
|
||||||
if ((s = cmd_find_session(ctx, NULL, 0)) == NULL)
|
if ((s = cmd_find_session(ctx, NULL, 0)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (!args_has(args, 'b')) {
|
if (!args_has(args, 'b')) {
|
||||||
if ((pb = paste_get_top(&global_buffers)) == NULL) {
|
if ((pb = paste_get_top(&global_buffers)) == NULL) {
|
||||||
ctx->error(ctx, "no buffers");
|
ctx->error(ctx, "no buffers");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
buffer = args_strtonum(args, 'b', 0, INT_MAX, &cause);
|
||||||
if (cause != NULL) {
|
if (cause != NULL) {
|
||||||
ctx->error(ctx, "buffer %s", cause);
|
ctx->error(ctx, "buffer %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
pb = paste_get_index(&global_buffers, buffer);
|
pb = paste_get_index(&global_buffers, buffer);
|
||||||
if (pb == NULL) {
|
if (pb == NULL) {
|
||||||
ctx->error(ctx, "no buffer %d", buffer);
|
ctx->error(ctx, "no buffer %d", buffer);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,5 +107,5 @@ cmd_show_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
free(in);
|
free(in);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
* Show environment.
|
* Show environment.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_show_environment_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_show_environment_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_show_environment_entry = {
|
const struct cmd_entry cmd_show_environment_entry = {
|
||||||
"show-environment", "showenv",
|
"show-environment", "showenv",
|
||||||
@ -39,7 +39,7 @@ const struct cmd_entry cmd_show_environment_entry = {
|
|||||||
cmd_show_environment_exec
|
cmd_show_environment_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_show_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_show_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -51,7 +51,7 @@ cmd_show_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
env = &global_environ;
|
env = &global_environ;
|
||||||
else {
|
else {
|
||||||
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
if ((s = cmd_find_session(ctx, args_get(args, 't'), 0)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
env = &s->environ;
|
env = &s->environ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,13 +59,13 @@ cmd_show_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
envent = environ_find(env, args->argv[0]);
|
envent = environ_find(env, args->argv[0]);
|
||||||
if (envent == NULL) {
|
if (envent == NULL) {
|
||||||
ctx->error(ctx, "unknown variable: %s", args->argv[0]);
|
ctx->error(ctx, "unknown variable: %s", args->argv[0]);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (envent->value != NULL)
|
if (envent->value != NULL)
|
||||||
ctx->print(ctx, "%s=%s", envent->name, envent->value);
|
ctx->print(ctx, "%s=%s", envent->name, envent->value);
|
||||||
else
|
else
|
||||||
ctx->print(ctx, "-%s", envent->name);
|
ctx->print(ctx, "-%s", envent->name);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
RB_FOREACH(envent, environ, env) {
|
RB_FOREACH(envent, environ, env) {
|
||||||
@ -75,5 +75,5 @@ cmd_show_environment_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
ctx->print(ctx, "-%s", envent->name);
|
ctx->print(ctx, "-%s", envent->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
* Show client message log.
|
* Show client message log.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_show_messages_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_show_messages_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_show_messages_entry = {
|
const struct cmd_entry cmd_show_messages_entry = {
|
||||||
"show-messages", "showmsgs",
|
"show-messages", "showmsgs",
|
||||||
@ -39,7 +39,7 @@ const struct cmd_entry cmd_show_messages_entry = {
|
|||||||
cmd_show_messages_exec
|
cmd_show_messages_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_show_messages_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_show_messages_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -49,7 +49,7 @@ cmd_show_messages_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
u_int i;
|
u_int i;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&c->message_log); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&c->message_log); i++) {
|
||||||
msg = &ARRAY_ITEM(&c->message_log, i);
|
msg = &ARRAY_ITEM(&c->message_log, i);
|
||||||
@ -60,5 +60,5 @@ cmd_show_messages_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
ctx->print(ctx, "%s %s", tim, msg->msg);
|
ctx->print(ctx, "%s %s", tim, msg->msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
* Show options.
|
* Show options.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_show_options_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_show_options_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_show_options_entry = {
|
const struct cmd_entry cmd_show_options_entry = {
|
||||||
"show-options", "show",
|
"show-options", "show",
|
||||||
@ -49,7 +49,7 @@ const struct cmd_entry cmd_show_window_options_entry = {
|
|||||||
cmd_show_options_exec
|
cmd_show_options_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -71,7 +71,7 @@ cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
else {
|
else {
|
||||||
wl = cmd_find_window(ctx, args_get(args, 't'), NULL);
|
wl = cmd_find_window(ctx, args_get(args, 't'), NULL);
|
||||||
if (wl == NULL)
|
if (wl == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
oo = &wl->window->options;
|
oo = &wl->window->options;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -81,7 +81,7 @@ cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
else {
|
else {
|
||||||
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
oo = &s->options;
|
oo = &s->options;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,14 +90,14 @@ cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
table = oe = NULL;
|
table = oe = NULL;
|
||||||
if (options_table_find(args->argv[0], &table, &oe) != 0) {
|
if (options_table_find(args->argv[0], &table, &oe) != 0) {
|
||||||
ctx->error(ctx, "ambiguous option: %s", args->argv[0]);
|
ctx->error(ctx, "ambiguous option: %s", args->argv[0]);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if (oe == NULL) {
|
if (oe == NULL) {
|
||||||
ctx->error(ctx, "unknown option: %s", args->argv[0]);
|
ctx->error(ctx, "unknown option: %s", args->argv[0]);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
if ((o = options_find1(oo, oe->name)) == NULL)
|
if ((o = options_find1(oo, oe->name)) == NULL)
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
optval = options_table_print_entry(oe, o);
|
optval = options_table_print_entry(oe, o);
|
||||||
ctx->print(ctx, "%s %s", oe->name, optval);
|
ctx->print(ctx, "%s %s", oe->name, optval);
|
||||||
} else {
|
} else {
|
||||||
@ -109,5 +109,5 @@ cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
* Sources a configuration file.
|
* Sources a configuration file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_source_file_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_source_file_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_source_file_entry = {
|
const struct cmd_entry cmd_source_file_entry = {
|
||||||
"source-file", "source",
|
"source-file", "source",
|
||||||
@ -38,7 +38,7 @@ const struct cmd_entry cmd_source_file_entry = {
|
|||||||
cmd_source_file_exec
|
cmd_source_file_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_source_file_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_source_file_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
|
@ -27,8 +27,8 @@
|
|||||||
* Split a window (add a new pane).
|
* Split a window (add a new pane).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_split_window_key_binding(struct cmd *, int);
|
void cmd_split_window_key_binding(struct cmd *, int);
|
||||||
int cmd_split_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_split_window_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_split_window_entry = {
|
const struct cmd_entry cmd_split_window_entry = {
|
||||||
"split-window", "splitw",
|
"split-window", "splitw",
|
||||||
@ -49,7 +49,7 @@ cmd_split_window_key_binding(struct cmd *self, int key)
|
|||||||
args_set(self->args, 'h', NULL);
|
args_set(self->args, 'h', NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -70,7 +70,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
char *cp;
|
char *cp;
|
||||||
|
|
||||||
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp)) == NULL)
|
if ((wl = cmd_find_pane(ctx, args_get(args, 't'), &s, &wp)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
w = wl->window;
|
w = wl->window;
|
||||||
|
|
||||||
environ_init(&env);
|
environ_init(&env);
|
||||||
@ -155,7 +155,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
format_free(ft);
|
format_free(ft);
|
||||||
}
|
}
|
||||||
notify_window_layout_changed(w);
|
notify_window_layout_changed(w);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
environ_free(&env);
|
environ_free(&env);
|
||||||
@ -163,5 +163,5 @@ error:
|
|||||||
window_remove_pane(w, new_wp);
|
window_remove_pane(w, new_wp);
|
||||||
ctx->error(ctx, "create pane failed: %s", cause);
|
ctx->error(ctx, "create pane failed: %s", cause);
|
||||||
free(cause);
|
free(cause);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
* Start the server and do nothing else.
|
* Start the server and do nothing else.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_start_server_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_start_server_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_start_server_entry = {
|
const struct cmd_entry cmd_start_server_entry = {
|
||||||
"start-server", "start",
|
"start-server", "start",
|
||||||
@ -37,8 +37,8 @@ const struct cmd_entry cmd_start_server_entry = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* ARGSUSED */
|
/* ARGSUSED */
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_start_server_exec(unused struct cmd *self, unused struct cmd_ctx *ctx)
|
cmd_start_server_exec(unused struct cmd *self, unused struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
* Suspend client with SIGTSTP.
|
* Suspend client with SIGTSTP.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_suspend_client_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_suspend_client_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_suspend_client_entry = {
|
const struct cmd_entry cmd_suspend_client_entry = {
|
||||||
"suspend-client", "suspendc",
|
"suspend-client", "suspendc",
|
||||||
@ -39,18 +39,18 @@ const struct cmd_entry cmd_suspend_client_entry = {
|
|||||||
cmd_suspend_client_exec
|
cmd_suspend_client_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_suspend_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_suspend_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
struct client *c;
|
struct client *c;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
if ((c = cmd_find_client(ctx, args_get(args, 't'))) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
tty_stop_tty(&c->tty);
|
tty_stop_tty(&c->tty);
|
||||||
c->flags |= CLIENT_SUSPENDED;
|
c->flags |= CLIENT_SUSPENDED;
|
||||||
server_write_client(c, MSG_SUSPEND, NULL, 0);
|
server_write_client(c, MSG_SUSPEND, NULL, 0);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
* Swap two panes.
|
* Swap two panes.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_swap_pane_key_binding(struct cmd *, int);
|
void cmd_swap_pane_key_binding(struct cmd *, int);
|
||||||
int cmd_swap_pane_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_swap_pane_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_swap_pane_entry = {
|
const struct cmd_entry cmd_swap_pane_entry = {
|
||||||
"swap-pane", "swapp",
|
"swap-pane", "swapp",
|
||||||
@ -49,7 +49,7 @@ cmd_swap_pane_key_binding(struct cmd *self, int key)
|
|||||||
args_set(self->args, 'D', NULL);
|
args_set(self->args, 'D', NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -61,7 +61,7 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
dst_wl = cmd_find_pane(ctx, args_get(args, 't'), NULL, &dst_wp);
|
dst_wl = cmd_find_pane(ctx, args_get(args, 't'), NULL, &dst_wp);
|
||||||
if (dst_wl == NULL)
|
if (dst_wl == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
dst_w = dst_wl->window;
|
dst_w = dst_wl->window;
|
||||||
|
|
||||||
if (!args_has(args, 's')) {
|
if (!args_has(args, 's')) {
|
||||||
@ -75,16 +75,16 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (src_wp == NULL)
|
if (src_wp == NULL)
|
||||||
src_wp = TAILQ_LAST(&dst_w->panes, window_panes);
|
src_wp = TAILQ_LAST(&dst_w->panes, window_panes);
|
||||||
} else
|
} else
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
} else {
|
} else {
|
||||||
src_wl = cmd_find_pane(ctx, args_get(args, 's'), NULL, &src_wp);
|
src_wl = cmd_find_pane(ctx, args_get(args, 's'), NULL, &src_wp);
|
||||||
if (src_wl == NULL)
|
if (src_wl == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
src_w = src_wl->window;
|
src_w = src_wl->window;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (src_wp == dst_wp)
|
if (src_wp == dst_wp)
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
tmp_wp = TAILQ_PREV(dst_wp, window_panes, entry);
|
tmp_wp = TAILQ_PREV(dst_wp, window_panes, entry);
|
||||||
TAILQ_REMOVE(&dst_w->panes, dst_wp, entry);
|
TAILQ_REMOVE(&dst_w->panes, dst_wp, entry);
|
||||||
@ -138,5 +138,5 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
server_redraw_window(src_w);
|
server_redraw_window(src_w);
|
||||||
server_redraw_window(dst_w);
|
server_redraw_window(dst_w);
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ const struct cmd_entry cmd_swap_window_entry = {
|
|||||||
cmd_swap_window_exec
|
cmd_swap_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_swap_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_swap_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -50,21 +50,21 @@ cmd_swap_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
target_src = args_get(args, 's');
|
target_src = args_get(args, 's');
|
||||||
if ((wl_src = cmd_find_window(ctx, target_src, &src)) == NULL)
|
if ((wl_src = cmd_find_window(ctx, target_src, &src)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
target_dst = args_get(args, 't');
|
target_dst = args_get(args, 't');
|
||||||
if ((wl_dst = cmd_find_window(ctx, target_dst, &dst)) == NULL)
|
if ((wl_dst = cmd_find_window(ctx, target_dst, &dst)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
sg_src = session_group_find(src);
|
sg_src = session_group_find(src);
|
||||||
sg_dst = session_group_find(dst);
|
sg_dst = session_group_find(dst);
|
||||||
if (src != dst &&
|
if (src != dst &&
|
||||||
sg_src != NULL && sg_dst != NULL && sg_src == sg_dst) {
|
sg_src != NULL && sg_dst != NULL && sg_src == sg_dst) {
|
||||||
ctx->error(ctx, "can't move window, sessions are grouped");
|
ctx->error(ctx, "can't move window, sessions are grouped");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wl_dst->window == wl_src->window)
|
if (wl_dst->window == wl_src->window)
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
|
||||||
w = wl_dst->window;
|
w = wl_dst->window;
|
||||||
wl_dst->window = wl_src->window;
|
wl_dst->window = wl_src->window;
|
||||||
@ -83,5 +83,5 @@ cmd_swap_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
}
|
}
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,8 @@
|
|||||||
* Switch client to a different session.
|
* Switch client to a different session.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void cmd_switch_client_key_binding(struct cmd *, int);
|
void cmd_switch_client_key_binding(struct cmd *, int);
|
||||||
int cmd_switch_client_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_switch_client_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_switch_client_entry = {
|
const struct cmd_entry cmd_switch_client_entry = {
|
||||||
"switch-client", "switchc",
|
"switch-client", "switchc",
|
||||||
@ -57,7 +57,7 @@ cmd_switch_client_key_binding(struct cmd *self, int key)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_switch_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_switch_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -65,7 +65,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
struct session *s;
|
struct session *s;
|
||||||
|
|
||||||
if ((c = cmd_find_client(ctx, args_get(args, 'c'))) == NULL)
|
if ((c = cmd_find_client(ctx, args_get(args, 'c'))) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (args_has(args, 'r')) {
|
if (args_has(args, 'r')) {
|
||||||
if (c->flags & CLIENT_READONLY) {
|
if (c->flags & CLIENT_READONLY) {
|
||||||
@ -81,24 +81,24 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
if (args_has(args, 'n')) {
|
if (args_has(args, 'n')) {
|
||||||
if ((s = session_next_session(c->session)) == NULL) {
|
if ((s = session_next_session(c->session)) == NULL) {
|
||||||
ctx->error(ctx, "can't find next session");
|
ctx->error(ctx, "can't find next session");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else if (args_has(args, 'p')) {
|
} else if (args_has(args, 'p')) {
|
||||||
if ((s = session_previous_session(c->session)) == NULL) {
|
if ((s = session_previous_session(c->session)) == NULL) {
|
||||||
ctx->error(ctx, "can't find previous session");
|
ctx->error(ctx, "can't find previous session");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else if (args_has(args, 'l')) {
|
} else if (args_has(args, 'l')) {
|
||||||
if (c->last_session != NULL && session_alive(c->last_session))
|
if (c->last_session != NULL && session_alive(c->last_session))
|
||||||
s = c->last_session;
|
s = c->last_session;
|
||||||
if (s == NULL) {
|
if (s == NULL) {
|
||||||
ctx->error(ctx, "can't find last session");
|
ctx->error(ctx, "can't find last session");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
s = cmd_find_session(ctx, args_get(args, 't'), 0);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
|
|
||||||
if (c->session != NULL)
|
if (c->session != NULL)
|
||||||
c->last_session = c->session;
|
c->last_session = c->session;
|
||||||
@ -110,5 +110,5 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
server_redraw_client(c);
|
server_redraw_client(c);
|
||||||
s->curw->flags &= ~WINLINK_ALERTFLAGS;
|
s->curw->flags &= ~WINLINK_ALERTFLAGS;
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,9 @@
|
|||||||
* Unbind key from command.
|
* Unbind key from command.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_unbind_key_check(struct args *);
|
enum cmd_retval cmd_unbind_key_check(struct args *);
|
||||||
int cmd_unbind_key_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_unbind_key_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
enum cmd_retval cmd_unbind_key_table(struct cmd *, struct cmd_ctx *, int);
|
||||||
int cmd_unbind_key_table(struct cmd *, struct cmd_ctx *, int);
|
|
||||||
|
|
||||||
const struct cmd_entry cmd_unbind_key_entry = {
|
const struct cmd_entry cmd_unbind_key_entry = {
|
||||||
"unbind-key", "unbind",
|
"unbind-key", "unbind",
|
||||||
@ -41,17 +40,17 @@ const struct cmd_entry cmd_unbind_key_entry = {
|
|||||||
cmd_unbind_key_exec
|
cmd_unbind_key_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_unbind_key_check(struct args *args)
|
cmd_unbind_key_check(struct args *args)
|
||||||
{
|
{
|
||||||
if (args_has(args, 'a') && args->argc != 0)
|
if (args_has(args, 'a') && args->argc != 0)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
if (!args_has(args, 'a') && args->argc != 1)
|
if (!args_has(args, 'a') && args->argc != 1)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_unbind_key_exec(struct cmd *self, unused struct cmd_ctx *ctx)
|
cmd_unbind_key_exec(struct cmd *self, unused struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -62,7 +61,7 @@ cmd_unbind_key_exec(struct cmd *self, unused struct cmd_ctx *ctx)
|
|||||||
key = key_string_lookup_string(args->argv[0]);
|
key = key_string_lookup_string(args->argv[0]);
|
||||||
if (key == KEYC_NONE) {
|
if (key == KEYC_NONE) {
|
||||||
ctx->error(ctx, "unknown key: %s", args->argv[0]);
|
ctx->error(ctx, "unknown key: %s", args->argv[0]);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
key = KEYC_NONE;
|
key = KEYC_NONE;
|
||||||
@ -75,16 +74,16 @@ cmd_unbind_key_exec(struct cmd *self, unused struct cmd_ctx *ctx)
|
|||||||
bd = RB_ROOT(&key_bindings);
|
bd = RB_ROOT(&key_bindings);
|
||||||
key_bindings_remove(bd->key);
|
key_bindings_remove(bd->key);
|
||||||
}
|
}
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!args_has(args, 'n'))
|
if (!args_has(args, 'n'))
|
||||||
key |= KEYC_PREFIX;
|
key |= KEYC_PREFIX;
|
||||||
key_bindings_remove(key);
|
key_bindings_remove(key);
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_unbind_key_table(struct cmd *self, struct cmd_ctx *ctx, int key)
|
cmd_unbind_key_table(struct cmd *self, struct cmd_ctx *ctx, int key)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -95,7 +94,7 @@ cmd_unbind_key_table(struct cmd *self, struct cmd_ctx *ctx, int key)
|
|||||||
tablename = args_get(args, 't');
|
tablename = args_get(args, 't');
|
||||||
if ((mtab = mode_key_findtable(tablename)) == NULL) {
|
if ((mtab = mode_key_findtable(tablename)) == NULL) {
|
||||||
ctx->error(ctx, "unknown key table: %s", tablename);
|
ctx->error(ctx, "unknown key table: %s", tablename);
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key == KEYC_NONE) {
|
if (key == KEYC_NONE) {
|
||||||
@ -104,7 +103,7 @@ cmd_unbind_key_table(struct cmd *self, struct cmd_ctx *ctx, int key)
|
|||||||
RB_REMOVE(mode_key_tree, mtab->tree, mbind);
|
RB_REMOVE(mode_key_tree, mtab->tree, mbind);
|
||||||
free(mbind);
|
free(mbind);
|
||||||
}
|
}
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
mtmp.key = key;
|
mtmp.key = key;
|
||||||
@ -113,5 +112,5 @@ cmd_unbind_key_table(struct cmd *self, struct cmd_ctx *ctx, int key)
|
|||||||
RB_REMOVE(mode_key_tree, mtab->tree, mbind);
|
RB_REMOVE(mode_key_tree, mtab->tree, mbind);
|
||||||
free(mbind);
|
free(mbind);
|
||||||
}
|
}
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
* Unlink a window, unless it would be destroyed by doing so (only one link).
|
* Unlink a window, unless it would be destroyed by doing so (only one link).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cmd_unlink_window_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_unlink_window_exec(struct cmd *, struct cmd_ctx *);
|
||||||
|
|
||||||
const struct cmd_entry cmd_unlink_window_entry = {
|
const struct cmd_entry cmd_unlink_window_entry = {
|
||||||
"unlink-window", "unlinkw",
|
"unlink-window", "unlinkw",
|
||||||
@ -36,7 +36,7 @@ const struct cmd_entry cmd_unlink_window_entry = {
|
|||||||
cmd_unlink_window_exec
|
cmd_unlink_window_exec
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_unlink_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
cmd_unlink_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
struct args *args = self->args;
|
struct args *args = self->args;
|
||||||
@ -47,7 +47,7 @@ cmd_unlink_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
u_int references;
|
u_int references;
|
||||||
|
|
||||||
if ((wl = cmd_find_window(ctx, args_get(args, 't'), &s)) == NULL)
|
if ((wl = cmd_find_window(ctx, args_get(args, 't'), &s)) == NULL)
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
w = wl->window;
|
w = wl->window;
|
||||||
|
|
||||||
sg = session_group_find(s);
|
sg = session_group_find(s);
|
||||||
@ -60,11 +60,11 @@ cmd_unlink_window_exec(struct cmd *self, struct cmd_ctx *ctx)
|
|||||||
|
|
||||||
if (!args_has(self->args, 'k') && w->references == references) {
|
if (!args_has(self->args, 'k') && w->references == references) {
|
||||||
ctx->error(ctx, "window is only linked to one session");
|
ctx->error(ctx, "window is only linked to one session");
|
||||||
return (-1);
|
return (CMD_RETURN_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
server_unlink_window(s, wl);
|
server_unlink_window(s, wl);
|
||||||
recalculate_sizes();
|
recalculate_sizes();
|
||||||
|
|
||||||
return (0);
|
return (CMD_RETURN_NORMAL);
|
||||||
}
|
}
|
||||||
|
2
cmd.c
2
cmd.c
@ -279,7 +279,7 @@ usage:
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
enum cmd_retval
|
||||||
cmd_exec(struct cmd *cmd, struct cmd_ctx *ctx)
|
cmd_exec(struct cmd *cmd, struct cmd_ctx *ctx)
|
||||||
{
|
{
|
||||||
return (cmd->entry->exec(cmd, ctx));
|
return (cmd->entry->exec(cmd, ctx));
|
||||||
|
@ -867,8 +867,16 @@ server_client_msg_command(struct client *c, struct msg_command_data *data)
|
|||||||
}
|
}
|
||||||
cmd_free_argv(argc, argv);
|
cmd_free_argv(argc, argv);
|
||||||
|
|
||||||
if (cmd_list_exec(cmdlist, &ctx) != 1)
|
switch (cmd_list_exec(cmdlist, &ctx))
|
||||||
|
{
|
||||||
|
case CMD_RETURN_ERROR:
|
||||||
|
case CMD_RETURN_NORMAL:
|
||||||
c->flags |= CLIENT_EXIT;
|
c->flags |= CLIENT_EXIT;
|
||||||
|
break;
|
||||||
|
case CMD_RETURN_ATTACH:
|
||||||
|
case CMD_RETURN_YIELD:
|
||||||
|
break;
|
||||||
|
}
|
||||||
cmd_list_free(cmdlist);
|
cmd_list_free(cmdlist);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
13
tmux.h
13
tmux.h
@ -1327,6 +1327,13 @@ struct cmd_list {
|
|||||||
TAILQ_HEAD(, cmd) list;
|
TAILQ_HEAD(, cmd) list;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum cmd_retval {
|
||||||
|
CMD_RETURN_ERROR = -1,
|
||||||
|
CMD_RETURN_NORMAL = 0,
|
||||||
|
CMD_RETURN_YIELD,
|
||||||
|
CMD_RETURN_ATTACH
|
||||||
|
};
|
||||||
|
|
||||||
struct cmd_entry {
|
struct cmd_entry {
|
||||||
const char *name;
|
const char *name;
|
||||||
const char *alias;
|
const char *alias;
|
||||||
@ -1345,7 +1352,7 @@ struct cmd_entry {
|
|||||||
|
|
||||||
void (*key_binding)(struct cmd *, int);
|
void (*key_binding)(struct cmd *, int);
|
||||||
int (*check)(struct args *);
|
int (*check)(struct args *);
|
||||||
int (*exec)(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval (*exec)(struct cmd *, struct cmd_ctx *);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Key binding. */
|
/* Key binding. */
|
||||||
@ -1637,7 +1644,7 @@ int cmd_unpack_argv(char *, size_t, int, char ***);
|
|||||||
char **cmd_copy_argv(int, char *const *);
|
char **cmd_copy_argv(int, char *const *);
|
||||||
void cmd_free_argv(int, char **);
|
void cmd_free_argv(int, char **);
|
||||||
struct cmd *cmd_parse(int, char **, char **);
|
struct cmd *cmd_parse(int, char **, char **);
|
||||||
int cmd_exec(struct cmd *, struct cmd_ctx *);
|
enum cmd_retval cmd_exec(struct cmd *, struct cmd_ctx *);
|
||||||
void cmd_free(struct cmd *);
|
void cmd_free(struct cmd *);
|
||||||
size_t cmd_print(struct cmd *, char *, size_t);
|
size_t cmd_print(struct cmd *, char *, size_t);
|
||||||
struct session *cmd_current_session(struct cmd_ctx *, int);
|
struct session *cmd_current_session(struct cmd_ctx *, int);
|
||||||
@ -1741,7 +1748,7 @@ extern const struct cmd_entry cmd_up_pane_entry;
|
|||||||
|
|
||||||
/* cmd-list.c */
|
/* cmd-list.c */
|
||||||
struct cmd_list *cmd_list_parse(int, char **, char **);
|
struct cmd_list *cmd_list_parse(int, char **, char **);
|
||||||
int cmd_list_exec(struct cmd_list *, struct cmd_ctx *);
|
enum cmd_retval cmd_list_exec(struct cmd_list *, struct cmd_ctx *);
|
||||||
void cmd_list_free(struct cmd_list *);
|
void cmd_list_free(struct cmd_list *);
|
||||||
size_t cmd_list_print(struct cmd_list *, char *, size_t);
|
size_t cmd_list_print(struct cmd_list *, char *, size_t);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user