Skip to content

Commit

Permalink
Merge branch 'obsd-master'
Browse files Browse the repository at this point in the history
Conflicts:
	Makefile
  • Loading branch information
ThomasAdam committed Sep 14, 2015
2 parents ef35c9f + 16efa84 commit 74b958e
Show file tree
Hide file tree
Showing 14 changed files with 103 additions and 143 deletions.
1 change: 0 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ dist_tmux_SOURCES = \
cmd-command-prompt.c \
cmd-confirm-before.c \
cmd-copy-mode.c \
cmd-delete-buffer.c \
cmd-detach-client.c \
cmd-display-message.c \
cmd-display-panes.c \
Expand Down
6 changes: 3 additions & 3 deletions cmd-copy-mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ enum cmd_retval cmd_copy_mode_exec(struct cmd *, struct cmd_q *);

const struct cmd_entry cmd_copy_mode_entry = {
"copy-mode", NULL,
"Mt:u", 0, 0,
"[-Mu] " CMD_TARGET_PANE_USAGE,
"Met:u", 0, 0,
"[-Meu] " CMD_TARGET_PANE_USAGE,
0,
cmd_copy_mode_exec
};
Expand Down Expand Up @@ -66,7 +66,7 @@ cmd_copy_mode_exec(struct cmd *self, struct cmd_q *cmdq)
if (wp->mode != &window_copy_mode) {
if (window_pane_set_mode(wp, &window_copy_mode) != 0)
return (CMD_RETURN_NORMAL);
window_copy_init_from_pane(wp);
window_copy_init_from_pane(wp, args_has(self->args, 'e'));
}
if (args_has(args, 'M')) {
if (wp->mode != NULL && wp->mode != &window_copy_mode)
Expand Down
57 changes: 0 additions & 57 deletions cmd-delete-buffer.c

This file was deleted.

8 changes: 2 additions & 6 deletions cmd-paste-buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,8 @@ cmd_paste_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
bufferevent_write(wp->event, "\033[201~", 6);
}

if (args_has(args, 'd')) {
if (bufname == NULL)
paste_free_top();
else
paste_free_name(bufname);
}
if (pb != NULL && args_has(args, 'd'))
paste_free(pb);

return (CMD_RETURN_NORMAL);
}
7 changes: 5 additions & 2 deletions cmd-refresh-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,13 @@ cmd_refresh_client_exec(struct cmd *self, struct cmd_q *cmdq)
}
if (tty_set_size(&c->tty, w, h))
recalculate_sizes();
} else if (args_has(args, 'S'))
} else if (args_has(args, 'S')) {
c->flags |= CLIENT_STATUSFORCE;
server_status_client(c);
else
} else {
c->flags |= CLIENT_STATUSFORCE;
server_redraw_client(c);
}

return (CMD_RETURN_NORMAL);
}
52 changes: 26 additions & 26 deletions cmd-set-buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "tmux.h"

/*
* Add, set, or append to a paste buffer.
* Add, set, append to or delete a paste buffer.
*/

enum cmd_retval cmd_set_buffer_exec(struct cmd *, struct cmd_q *);
Expand All @@ -37,6 +37,14 @@ const struct cmd_entry cmd_set_buffer_entry = {
cmd_set_buffer_exec
};

const struct cmd_entry cmd_delete_buffer_entry = {
"delete-buffer", "deleteb",
"b:", 0, 0,
CMD_BUFFER_USAGE,
0,
cmd_set_buffer_exec
};

enum cmd_retval
cmd_set_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
{
Expand All @@ -46,51 +54,43 @@ cmd_set_buffer_exec(struct cmd *self, struct cmd_q *cmdq)
const char *bufname, *olddata;
size_t bufsize, newsize;

bufname = NULL;
bufname = args_get(args, 'b');
if (bufname == NULL)
pb = paste_get_top(&bufname);
else
pb = paste_get_name(bufname);

if (args_has(args, 'n')) {
if (args->argc > 0) {
cmdq_error(cmdq, "don't provide data with n flag");
if (self->entry == &cmd_delete_buffer_entry) {
if (pb == NULL) {
cmdq_error(cmdq, "no buffer");
return (CMD_RETURN_ERROR);
}
paste_free(pb);
return (CMD_RETURN_NORMAL);
}

if (args_has(args, 'b'))
bufname = args_get(args, 'b');

if (bufname == NULL) {
pb = paste_get_top(&bufname);
if (pb == NULL) {
cmdq_error(cmdq, "no buffer");
return (CMD_RETURN_ERROR);
}
if (args_has(args, 'n')) {
if (pb == NULL) {
cmdq_error(cmdq, "no buffer");
return (CMD_RETURN_ERROR);
}

if (paste_rename(bufname, args_get(args, 'n'), &cause) != 0) {
cmdq_error(cmdq, "%s", cause);
free(cause);
return (CMD_RETURN_ERROR);
}

return (CMD_RETURN_NORMAL);
}

if (args->argc != 1) {
cmdq_error(cmdq, "no data specified");
return (CMD_RETURN_ERROR);
}
pb = NULL;

bufsize = 0;
bufdata = NULL;

if ((newsize = strlen(args->argv[0])) == 0)
return (CMD_RETURN_NORMAL);

if (args_has(args, 'b')) {
bufname = args_get(args, 'b');
pb = paste_get_name(bufname);
} else if (args_has(args, 'a'))
pb = paste_get_top(&bufname);
bufsize = 0;
bufdata = NULL;

if (args_has(args, 'a') && pb != NULL) {
olddata = paste_buffer_data(pb, &bufsize);
Expand Down
4 changes: 2 additions & 2 deletions cmd-wait-for.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ cmd_wait_for_add(const char *name)
void
cmd_wait_for_remove(struct wait_channel *wc)
{

if (wc->locked)
return;
if (!TAILQ_EMPTY(&wc->waiters) || !wc->woken)
Expand Down Expand Up @@ -241,7 +240,8 @@ cmd_wait_for_flush(void)
if (!cmdq_free(wq))
cmdq_continue(wq);
}
while ((wq = TAILQ_FIRST(&wc->lockers)) != NULL) {
wc->woken = 1;
TAILQ_FOREACH_SAFE(wq, &wc->lockers, waitentry, wq1) {
TAILQ_REMOVE(&wc->lockers, wq, waitentry);
if (!cmdq_free(wq))
cmdq_continue(wq);
Expand Down
18 changes: 11 additions & 7 deletions format.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ struct format_tree {
struct session *s;
struct window_pane *wp;

int status;
int flags;

RB_HEAD(format_entry_tree, format_entry) tree;
};
Expand Down Expand Up @@ -218,27 +218,31 @@ const char *
format_job_get(struct format_tree *ft, const char *cmd)
{
struct format_job fj0, *fj;
time_t t;

fj0.cmd = cmd;
if ((fj = RB_FIND(format_job_tree, &format_jobs, &fj0)) == NULL) {
fj = xcalloc(1, sizeof *fj);
fj->cmd = xstrdup(cmd);
fj->status = ft->status;

xasprintf(&fj->out, "<'%s' not ready>", fj->cmd);

RB_INSERT(format_job_tree, &format_jobs, fj);
}

if (fj->job == NULL && fj->last != time(NULL)) {
t = time(NULL);
if (fj->job == NULL && ((ft->flags & FORMAT_FORCE) || fj->last != t)) {
fj->job = job_run(fj->cmd, NULL, -1, format_job_callback,
NULL, fj);
if (fj->job == NULL) {
free(fj->out);
xasprintf(&fj->out, "<'%s' didn't start>", fj->cmd);
}
fj->last = t;
}
fj->last = time(NULL);

if (ft->flags & FORMAT_STATUS)
fj->status = 1;

return (fj->out);
}
Expand Down Expand Up @@ -455,12 +459,12 @@ format_cb_pane_tabs(struct format_tree *ft, struct format_entry *fe)
struct format_tree *
format_create(void)
{
return (format_create_status(0));
return (format_create_flags(0));
}

/* Create a new tree for the status line. */
struct format_tree *
format_create_status(int status)
format_create_flags(int flags)
{
struct format_tree *ft;

Expand All @@ -471,7 +475,7 @@ format_create_status(int status)

ft = xcalloc(1, sizeof *ft);
RB_INIT(&ft->tree);
ft->status = status;
ft->flags = flags;

format_add_cb(ft, "host", format_cb_host);
format_add_cb(ft, "host_short", format_cb_host_short);
Expand Down
37 changes: 7 additions & 30 deletions paste.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,6 @@ paste_get_top(const char **name)
return (pb);
}

/* Free the most recent buffer. */
int
paste_free_top(void)
{
struct paste_buffer *pb;

pb = paste_get_top(NULL);
if (pb == NULL)
return (-1);
return (paste_free_name(pb->name));
}

/* Get a paste buffer by name. */
struct paste_buffer *
paste_get_name(const char *name)
Expand All @@ -135,20 +123,10 @@ paste_get_name(const char *name)
return (RB_FIND(paste_name_tree, &paste_by_name, &pbfind));
}

/* Free a paste buffer by name. */
int
paste_free_name(const char *name)
/* Free a paste buffer. */
void
paste_free(struct paste_buffer *pb)
{
struct paste_buffer *pb, pbfind;

if (name == NULL || *name == '\0')
return (-1);

pbfind.name = (char *)name;
pb = RB_FIND(paste_name_tree, &paste_by_name, &pbfind);
if (pb == NULL)
return (-1);

RB_REMOVE(paste_name_tree, &paste_by_name, pb);
RB_REMOVE(paste_time_tree, &paste_by_time, pb);
if (pb->automatic)
Expand All @@ -157,7 +135,6 @@ paste_free_name(const char *name)
free(pb->data);
free(pb->name);
free(pb);
return (0);
}

/*
Expand All @@ -178,7 +155,7 @@ paste_add(char *data, size_t size)
if (paste_num_automatic < limit)
break;
if (pb->automatic)
paste_free_name(pb->name);
paste_free(pb);
}

pb = xmalloc(sizeof *pb);
Expand Down Expand Up @@ -256,7 +233,7 @@ paste_rename(const char *oldname, const char *newname, char **cause)
int
paste_set(char *data, size_t size, const char *name, char **cause)
{
struct paste_buffer *pb;
struct paste_buffer *pb, *old;

if (cause != NULL)
*cause = NULL;
Expand Down Expand Up @@ -287,8 +264,8 @@ paste_set(char *data, size_t size, const char *name, char **cause)
pb->automatic = 0;
pb->order = paste_next_order++;

if (paste_get_name(name) != NULL)
paste_free_name(name);
if ((old = paste_get_name(name)) != NULL)
paste_free(old);

RB_INSERT(paste_name_tree, &paste_by_name, pb);
RB_INSERT(paste_time_tree, &paste_by_time, pb);
Expand Down
3 changes: 2 additions & 1 deletion server-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,8 @@ server_client_check_redraw(struct client *c)
tty->flags = (tty->flags & ~(TTY_FREEZE|TTY_NOCURSOR)) | flags;
tty_update_mode(tty, tty->mode, NULL);

c->flags &= ~(CLIENT_REDRAW|CLIENT_STATUS|CLIENT_BORDERS);
c->flags &= ~(CLIENT_REDRAW|CLIENT_BORDERS|CLIENT_STATUS|
CLIENT_STATUSFORCE);
}

/* Set client title. */
Expand Down
5 changes: 4 additions & 1 deletion status.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,10 @@ status_replace(struct client *c, struct winlink *wl, const char *fmt, time_t t)
if (fmt == NULL)
return (xstrdup(""));

ft = format_create_status(1);
if (c->flags & CLIENT_STATUSFORCE)
ft = format_create_flags(FORMAT_STATUS|FORMAT_FORCE);
else
ft = format_create_flags(FORMAT_STATUS);
format_defaults(ft, c, NULL, wl, NULL);

expanded = format_expand_time(ft, fmt, t);
Expand Down
Loading

0 comments on commit 74b958e

Please sign in to comment.