Skip to content

Commit

Permalink
Merge branch 'master' into sixel
Browse files Browse the repository at this point in the history
  • Loading branch information
nicm committed Jan 12, 2020
2 parents dd3c72f + 61b075a commit 40ad010
Show file tree
Hide file tree
Showing 15 changed files with 700 additions and 93 deletions.
8 changes: 4 additions & 4 deletions cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,9 @@ load_cfg(const char *path, struct client *c, struct cmdq_item *item, int flags,

new_item0 = cmdq_get_command(pr->cmdlist, NULL, NULL, 0);
if (item != NULL)
cmdq_insert_after(item, new_item0);
new_item0 = cmdq_insert_after(item, new_item0);
else
cmdq_append(NULL, new_item0);
new_item0 = cmdq_append(NULL, new_item0);
cmd_list_free(pr->cmdlist);

if (new_item != NULL)
Expand Down Expand Up @@ -230,9 +230,9 @@ load_cfg_from_buffer(const void *buf, size_t len, const char *path,

new_item0 = cmdq_get_command(pr->cmdlist, NULL, NULL, 0);
if (item != NULL)
cmdq_insert_after(item, new_item0);
new_item0 = cmdq_insert_after(item, new_item0);
else
cmdq_append(NULL, new_item0);
new_item0 = cmdq_append(NULL, new_item0);
cmd_list_free(pr->cmdlist);

if (new_item != NULL)
Expand Down
2 changes: 1 addition & 1 deletion cmd-join-pane.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const struct cmd_entry cmd_move_pane_entry = {
.args = { "bdhvp:l:s:t:", 0, 0 },
.usage = "[-bdhv] [-p percentage|-l size] " CMD_SRCDST_PANE_USAGE,

.source = { 's', CMD_FIND_PANE, 0 },
.source = { 's', CMD_FIND_PANE, CMD_FIND_DEFAULT_MARKED },
.target = { 't', CMD_FIND_PANE, 0 },

.flags = 0,
Expand Down
28 changes: 20 additions & 8 deletions cmd-queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@ cmdq_get(struct client *c)
}

/* Append an item. */
void
struct cmdq_item *
cmdq_append(struct client *c, struct cmdq_item *item)
{
struct cmdq_list *queue = cmdq_get(c);
struct cmdq_item *next;

TAILQ_FOREACH(next, queue, entry) {
log_debug("%s %s: queue %s (%u)", __func__, cmdq_name(c),
next->name, next->group);
}
do {
next = item->next;
item->next = NULL;
Expand All @@ -73,16 +77,21 @@ cmdq_append(struct client *c, struct cmdq_item *item)

item = next;
} while (item != NULL);
return (TAILQ_LAST(queue, cmdq_list));
}

/* Insert an item. */
void
struct cmdq_item *
cmdq_insert_after(struct cmdq_item *after, struct cmdq_item *item)
{
struct client *c = after->client;
struct cmdq_list *queue = after->queue;
struct cmdq_item *next;

TAILQ_FOREACH(next, queue, entry) {
log_debug("%s %s: queue %s (%u)", __func__, cmdq_name(c),
next->name, next->group);
}
do {
next = item->next;
item->next = after->next;
Expand All @@ -100,6 +109,7 @@ cmdq_insert_after(struct cmdq_item *after, struct cmdq_item *item)
after = item;
item = next;
} while (item != NULL);
return (after);
}

/* Insert a hook. */
Expand Down Expand Up @@ -143,11 +153,10 @@ cmdq_insert_hook(struct session *s, struct cmdq_item *item,

new_item = cmdq_get_command(cmdlist, fs, NULL, CMDQ_NOHOOKS);
cmdq_format(new_item, "hook", "%s", name);
if (item != NULL) {
cmdq_insert_after(item, new_item);
item = new_item;
} else
cmdq_append(NULL, new_item);
if (item != NULL)
item = cmdq_insert_after(item, new_item);
else
item = cmdq_append(NULL, new_item);

a = options_array_next(a);
}
Expand Down Expand Up @@ -542,7 +551,10 @@ cmdq_error(struct cmdq_item *item, const char *fmt, ...)
msg = utf8_sanitize(tmp);
free(tmp);
}
file_error(c, "%s\n", msg);
if (c->flags & CLIENT_CONTROL)
file_print(c, "%s\n", msg);
else
file_error(c, "%s\n", msg);
c->retval = 1;
} else {
*msg = toupper((u_char) *msg);
Expand Down
4 changes: 2 additions & 2 deletions cmd-source-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ cmd_source_file_done(struct client *c, const char *path, int error,
static void
cmd_source_file_add(struct cmd_source_file_data *cdata, const char *path)
{
log_debug("%s: %s", __func__, path);
cdata->files = xreallocarray(cdata->files, cdata->nfiles + 1,
sizeof *cdata->files);
cdata->files[cdata->nfiles++] = xstrdup(path);
Expand All @@ -123,7 +124,6 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)
{
struct args *args = self->args;
struct cmd_source_file_data *cdata;
int flags = 0;
struct client *c = item->client;
enum cmd_retval retval = CMD_RETURN_NORMAL;
char *pattern, *cwd;
Expand Down Expand Up @@ -159,7 +159,7 @@ cmd_source_file_exec(struct cmd *self, struct cmdq_item *item)

if ((result = glob(pattern, 0, NULL, &g)) != 0) {
if (result != GLOB_NOMATCH ||
(~flags & CMD_PARSE_QUIET)) {
(~cdata->flags & CMD_PARSE_QUIET)) {
if (result == GLOB_NOMATCH)
error = strerror(ENOENT);
else if (result == GLOB_NOSPACE)
Expand Down
2 changes: 1 addition & 1 deletion cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ char *
cmd_template_replace(const char *template, const char *s, int idx)
{
char ch, *buf;
const char *ptr, *cp, quote[] = "\"\\$;";
const char *ptr, *cp, quote[] = "\"\\$;~";
int replaced, quoted;
size_t len;

Expand Down
8 changes: 6 additions & 2 deletions format-draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -849,8 +849,10 @@ format_trim_left(const char *expanded, u_int limit)
out += ud.size;
}
width += ud.width;
} else
} else {
cp -= ud.have;
cp++;
}
} else if (*cp > 0x1f && *cp < 0x7f) {
if (width + 1 <= limit)
*out++ = *cp;
Expand Down Expand Up @@ -896,8 +898,10 @@ format_trim_right(const char *expanded, u_int limit)
out += ud.size;
}
width += ud.width;
} else
} else {
cp -= ud.have;
cp++;
}
} else if (*cp > 0x1f && *cp < 0x7f) {
if (width >= skip)
*out++ = *cp;
Expand Down
Loading

0 comments on commit 40ad010

Please sign in to comment.