Skip to content

Commit

Permalink
Mass rename struct cmd_q to struct cmdq_item and related.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicm committed Oct 16, 2016
1 parent ddc4512 commit b342bd0
Show file tree
Hide file tree
Showing 73 changed files with 1,001 additions and 971 deletions.
30 changes: 15 additions & 15 deletions cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static u_int cfg_ncauses;
struct client *cfg_client;

static enum cmd_retval
cfg_done(__unused struct cmd_q *cmdq, __unused void *data)
cfg_done(__unused struct cmdq_item *item, __unused void *data)
{
if (cfg_finished)
return (CMD_RETURN_NORMAL);
Expand Down Expand Up @@ -79,15 +79,15 @@ start_cfg(void)
}

int
load_cfg(const char *path, struct client *c, struct cmd_q *cmdq, int quiet)
load_cfg(const char *path, struct client *c, struct cmdq_item *item, int quiet)
{
FILE *f;
char delim[3] = { '\\', '\\', '\0' };
u_int found;
size_t line = 0;
char *buf, *cause1, *p;
struct cmd_list *cmdlist;
struct cmd_q *new_cmdq;
FILE *f;
char delim[3] = { '\\', '\\', '\0' };
u_int found;
size_t line = 0;
char *buf, *cause1, *p;
struct cmd_list *cmdlist;
struct cmdq_item *new_item;

log_debug("loading %s", path);
if ((f = fopen(path, "rb")) == NULL) {
Expand Down Expand Up @@ -123,11 +123,11 @@ load_cfg(const char *path, struct client *c, struct cmd_q *cmdq, int quiet)

if (cmdlist == NULL)
continue;
new_cmdq = cmdq_get_command(cmdlist, NULL, NULL, 0);
if (cmdq != NULL)
cmdq_insert_after(cmdq, new_cmdq);
new_item = cmdq_get_command(cmdlist, NULL, NULL, 0);
if (item != NULL)
cmdq_insert_after(item, new_item);
else
cmdq_append(c, new_cmdq);
cmdq_append(c, new_item);
cmd_list_free(cmdlist);

found++;
Expand All @@ -153,12 +153,12 @@ cfg_add_cause(const char *fmt, ...)
}

void
cfg_print_causes(struct cmd_q *cmdq)
cfg_print_causes(struct cmdq_item *item)
{
u_int i;

for (i = 0; i < cfg_ncauses; i++) {
cmdq_print(cmdq, "%s", cfg_causes[i]);
cmdq_print(item, "%s", cfg_causes[i]);
free(cfg_causes[i]);
}

Expand Down
27 changes: 14 additions & 13 deletions cmd-attach-session.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
* Attach existing session to the current terminal.
*/

static enum cmd_retval cmd_attach_session_exec(struct cmd *, struct cmd_q *);
static enum cmd_retval cmd_attach_session_exec(struct cmd *,
struct cmdq_item *);

const struct cmd_entry cmd_attach_session_entry = {
.name = "attach-session",
Expand All @@ -46,26 +47,26 @@ const struct cmd_entry cmd_attach_session_entry = {
};

enum cmd_retval
cmd_attach_session(struct cmd_q *cmdq, int dflag, int rflag, const char *cflag,
int Eflag)
cmd_attach_session(struct cmdq_item *item, int dflag, int rflag,
const char *cflag, int Eflag)
{
struct session *s = cmdq->state.tflag.s;
struct client *c = cmdq->client, *c_loop;
struct winlink *wl = cmdq->state.tflag.wl;
struct window_pane *wp = cmdq->state.tflag.wp;
struct session *s = item->state.tflag.s;
struct client *c = item->client, *c_loop;
struct winlink *wl = item->state.tflag.wl;
struct window_pane *wp = item->state.tflag.wp;
const char *update;
char *cause, *cwd;
struct format_tree *ft;

if (RB_EMPTY(&sessions)) {
cmdq_error(cmdq, "no sessions");
cmdq_error(item, "no sessions");
return (CMD_RETURN_ERROR);
}

if (c == NULL)
return (CMD_RETURN_NORMAL);
if (server_client_check_nested(c)) {
cmdq_error(cmdq, "sessions should be nested with care, "
cmdq_error(item, "sessions should be nested with care, "
"unset $TMUX to force");
return (CMD_RETURN_ERROR);
}
Expand All @@ -77,7 +78,7 @@ cmd_attach_session(struct cmd_q *cmdq, int dflag, int rflag, const char *cflag,
}

if (cflag != NULL) {
ft = format_create(cmdq, 0);
ft = format_create(item, 0);
format_defaults(ft, c, s, wl, wp);
cwd = format_expand(ft, cflag);
format_free(ft);
Expand Down Expand Up @@ -111,7 +112,7 @@ cmd_attach_session(struct cmd_q *cmdq, int dflag, int rflag, const char *cflag,
s->curw->flags &= ~WINLINK_ALERTFLAGS;
} else {
if (server_client_open(c, &cause) != 0) {
cmdq_error(cmdq, "open terminal failed: %s", cause);
cmdq_error(item, "open terminal failed: %s", cause);
free(cause);
return (CMD_RETURN_ERROR);
}
Expand Down Expand Up @@ -155,10 +156,10 @@ cmd_attach_session(struct cmd_q *cmdq, int dflag, int rflag, const char *cflag,
}

static enum cmd_retval
cmd_attach_session_exec(struct cmd *self, struct cmd_q *cmdq)
cmd_attach_session_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = self->args;

return (cmd_attach_session(cmdq, args_has(args, 'd'),
return (cmd_attach_session(item, args_has(args, 'd'),
args_has(args, 'r'), args_get(args, 'c'), args_has(args, 'E')));
}
26 changes: 13 additions & 13 deletions cmd-bind-key.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
* Bind a key to a command, this recurses through cmd_*.
*/

static enum cmd_retval cmd_bind_key_exec(struct cmd *, struct cmd_q *);
static enum cmd_retval cmd_bind_key_exec(struct cmd *, struct cmdq_item *);

static enum cmd_retval cmd_bind_key_mode_table(struct cmd *, struct cmd_q *,
key_code);
static enum cmd_retval cmd_bind_key_mode_table(struct cmd *,
struct cmdq_item *, key_code);

const struct cmd_entry cmd_bind_key_entry = {
.name = "bind-key",
Expand All @@ -45,7 +45,7 @@ const struct cmd_entry cmd_bind_key_entry = {
};

static enum cmd_retval
cmd_bind_key_exec(struct cmd *self, struct cmd_q *cmdq)
cmd_bind_key_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = self->args;
char *cause;
Expand All @@ -55,24 +55,24 @@ cmd_bind_key_exec(struct cmd *self, struct cmd_q *cmdq)

if (args_has(args, 't')) {
if (args->argc != 2 && args->argc != 3) {
cmdq_error(cmdq, "not enough arguments");
cmdq_error(item, "not enough arguments");
return (CMD_RETURN_ERROR);
}
} else {
if (args->argc < 2) {
cmdq_error(cmdq, "not enough arguments");
cmdq_error(item, "not enough arguments");
return (CMD_RETURN_ERROR);
}
}

key = key_string_lookup_string(args->argv[0]);
if (key == KEYC_NONE || key == KEYC_UNKNOWN) {
cmdq_error(cmdq, "unknown key: %s", args->argv[0]);
cmdq_error(item, "unknown key: %s", args->argv[0]);
return (CMD_RETURN_ERROR);
}

if (args_has(args, 't'))
return (cmd_bind_key_mode_table(self, cmdq, key));
return (cmd_bind_key_mode_table(self, item, key));

if (args_has(args, 'T'))
tablename = args_get(args, 'T');
Expand All @@ -84,7 +84,7 @@ cmd_bind_key_exec(struct cmd *self, struct cmd_q *cmdq)
cmdlist = cmd_list_parse(args->argc - 1, args->argv + 1, NULL, 0,
&cause);
if (cmdlist == NULL) {
cmdq_error(cmdq, "%s", cause);
cmdq_error(item, "%s", cause);
free(cause);
return (CMD_RETURN_ERROR);
}
Expand All @@ -94,7 +94,7 @@ cmd_bind_key_exec(struct cmd *self, struct cmd_q *cmdq)
}

static enum cmd_retval
cmd_bind_key_mode_table(struct cmd *self, struct cmd_q *cmdq, key_code key)
cmd_bind_key_mode_table(struct cmd *self, struct cmdq_item *item, key_code key)
{
struct args *args = self->args;
const char *tablename;
Expand All @@ -104,18 +104,18 @@ cmd_bind_key_mode_table(struct cmd *self, struct cmd_q *cmdq, key_code key)

tablename = args_get(args, 't');
if ((mtab = mode_key_findtable(tablename)) == NULL) {
cmdq_error(cmdq, "unknown key table: %s", tablename);
cmdq_error(item, "unknown key table: %s", tablename);
return (CMD_RETURN_ERROR);
}

cmd = mode_key_fromstring(mtab->cmdstr, args->argv[1]);
if (cmd == MODEKEY_NONE) {
cmdq_error(cmdq, "unknown command: %s", args->argv[1]);
cmdq_error(item, "unknown command: %s", args->argv[1]);
return (CMD_RETURN_ERROR);
}

if (args->argc != 2) {
cmdq_error(cmdq, "no argument allowed");
cmdq_error(item, "no argument allowed");
return (CMD_RETURN_ERROR);
}

Expand Down
24 changes: 12 additions & 12 deletions cmd-break-pane.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#define BREAK_PANE_TEMPLATE "#{session_name}:#{window_index}.#{pane_index}"

static enum cmd_retval cmd_break_pane_exec(struct cmd *, struct cmd_q *);
static enum cmd_retval cmd_break_pane_exec(struct cmd *, struct cmdq_item *);

const struct cmd_entry cmd_break_pane_entry = {
.name = "break-pane",
Expand All @@ -45,28 +45,28 @@ const struct cmd_entry cmd_break_pane_entry = {
};

static enum cmd_retval
cmd_break_pane_exec(struct cmd *self, struct cmd_q *cmdq)
cmd_break_pane_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = self->args;
struct winlink *wl = cmdq->state.sflag.wl;
struct session *src_s = cmdq->state.sflag.s;
struct session *dst_s = cmdq->state.tflag.s;
struct window_pane *wp = cmdq->state.sflag.wp;
struct winlink *wl = item->state.sflag.wl;
struct session *src_s = item->state.sflag.s;
struct session *dst_s = item->state.tflag.s;
struct window_pane *wp = item->state.sflag.wp;
struct window *w = wl->window;
char *name;
char *cause;
int idx = cmdq->state.tflag.idx;
int idx = item->state.tflag.idx;
struct format_tree *ft;
const char *template;
char *cp;

if (idx != -1 && winlink_find_by_index(&dst_s->windows, idx) != NULL) {
cmdq_error(cmdq, "index %d already in use", idx);
cmdq_error(item, "index %d already in use", idx);
return (CMD_RETURN_ERROR);
}

if (window_count_panes(w) == 1) {
cmdq_error(cmdq, "can't break with only one pane");
cmdq_error(item, "can't break with only one pane");
return (CMD_RETURN_ERROR);
}
server_unzoom_window(w);
Expand Down Expand Up @@ -101,11 +101,11 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_q *cmdq)
if ((template = args_get(args, 'F')) == NULL)
template = BREAK_PANE_TEMPLATE;

ft = format_create(cmdq, 0);
format_defaults(ft, cmdq->state.c, dst_s, wl, wp);
ft = format_create(item, 0);
format_defaults(ft, item->state.c, dst_s, wl, wp);

cp = format_expand(ft, template);
cmdq_print(cmdq, "%s", cp);
cmdq_print(item, "%s", cp);
free(cp);

format_free(ft);
Expand Down
30 changes: 15 additions & 15 deletions cmd-capture-pane.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@
* Write the entire contents of a pane to a buffer or stdout.
*/

static enum cmd_retval cmd_capture_pane_exec(struct cmd *, struct cmd_q *);
static enum cmd_retval cmd_capture_pane_exec(struct cmd *, struct cmdq_item *);

static char *cmd_capture_pane_append(char *, size_t *, char *,
size_t);
static char *cmd_capture_pane_pending(struct args *,
struct window_pane *, size_t *);
static char *cmd_capture_pane_history(struct args *, struct cmd_q *,
struct window_pane *, size_t *);
static char *cmd_capture_pane_append(char *, size_t *, char *, size_t);
static char *cmd_capture_pane_pending(struct args *, struct window_pane *,
size_t *);
static char *cmd_capture_pane_history(struct args *, struct cmdq_item *,
struct window_pane *, size_t *);

const struct cmd_entry cmd_capture_pane_entry = {
.name = "capture-pane",
Expand Down Expand Up @@ -92,7 +91,8 @@ cmd_capture_pane_pending(struct args *args, struct window_pane *wp,
}

static char *
cmd_capture_pane_history(struct args *args, struct cmd_q *cmdq,

cmd_capture_pane_history(struct args *args, struct cmdq_item *item,
struct window_pane *wp, size_t *len)
{
struct grid *gd;
Expand All @@ -109,7 +109,7 @@ cmd_capture_pane_history(struct args *args, struct cmd_q *cmdq,
gd = wp->saved_grid;
if (gd == NULL) {
if (!args_has(args, 'q')) {
cmdq_error(cmdq, "no alternate screen");
cmdq_error(item, "no alternate screen");
return (NULL);
}
return (xstrdup(""));
Expand Down Expand Up @@ -177,11 +177,11 @@ cmd_capture_pane_history(struct args *args, struct cmd_q *cmdq,
}

static enum cmd_retval
cmd_capture_pane_exec(struct cmd *self, struct cmd_q *cmdq)
cmd_capture_pane_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = self->args;
struct client *c;
struct window_pane *wp = cmdq->state.tflag.wp;
struct window_pane *wp = item->state.tflag.wp;
char *buf, *cause;
const char *bufname;
size_t len;
Expand All @@ -190,15 +190,15 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_q *cmdq)
if (args_has(args, 'P'))
buf = cmd_capture_pane_pending(args, wp, &len);
else
buf = cmd_capture_pane_history(args, cmdq, wp, &len);
buf = cmd_capture_pane_history(args, item, wp, &len);
if (buf == NULL)
return (CMD_RETURN_ERROR);

if (args_has(args, 'p')) {
c = cmdq->client;
c = item->client;
if (c == NULL ||
(c->session != NULL && !(c->flags & CLIENT_CONTROL))) {
cmdq_error(cmdq, "can't write to stdout");
cmdq_error(item, "can't write to stdout");
free(buf);
return (CMD_RETURN_ERROR);
}
Expand All @@ -213,7 +213,7 @@ cmd_capture_pane_exec(struct cmd *self, struct cmd_q *cmdq)
bufname = args_get(args, 'b');

if (paste_set(buf, len, bufname, &cause) != 0) {
cmdq_error(cmdq, "%s", cause);
cmdq_error(item, "%s", cause);
free(cause);
free(buf);
return (CMD_RETURN_ERROR);
Expand Down
Loading

0 comments on commit b342bd0

Please sign in to comment.