Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam 2015-04-19 14:44:56 +01:00
commit 370cf75458
17 changed files with 147 additions and 85 deletions

View File

@ -561,7 +561,7 @@ client_dispatch_wait(void *data0)
data = imsg.data;
datalen = imsg.hdr.len - IMSG_HEADER_SIZE;
log_debug("got %d from server", imsg.hdr.type);
log_debug("got %u from server", imsg.hdr.type);
switch (imsg.hdr.type) {
case MSG_EXIT:
case MSG_SHUTDOWN:
@ -608,7 +608,7 @@ client_dispatch_wait(void *data0)
fatalx("bad MSG_VERSION size");
fprintf(stderr, "protocol version mismatch "
"(client %u, server %u)\n", PROTOCOL_VERSION,
"(client %d, server %u)\n", PROTOCOL_VERSION,
imsg.hdr.peerid);
client_exitval = 1;
@ -652,7 +652,7 @@ client_dispatch_attached(void)
data = imsg.data;
datalen = imsg.hdr.len - IMSG_HEADER_SIZE;
log_debug("got %d from server", imsg.hdr.type);
log_debug("got %u from server", imsg.hdr.type);
switch (imsg.hdr.type) {
case MSG_DETACH:
case MSG_DETACHKILL:

View File

@ -104,18 +104,34 @@ cmd_bind_key_mode_table(struct cmd *self, struct cmd_q *cmdq, int key)
return (CMD_RETURN_ERROR);
}
if (cmd != MODEKEYCOPY_COPYPIPE) {
if (args->argc != 2) {
cmdq_error(cmdq, "no argument allowed");
return (CMD_RETURN_ERROR);
switch (cmd) {
case MODEKEYCOPY_APPENDSELECTION:
case MODEKEYCOPY_COPYSELECTION:
case MODEKEYCOPY_STARTNAMEDBUFFER:
if (args->argc == 2)
arg = NULL;
else {
arg = args->argv[2];
if (strcmp(arg, "-x") != 0) {
cmdq_error(cmdq, "unknown argument");
return (CMD_RETURN_ERROR);
}
}
arg = NULL;
} else {
break;
case MODEKEYCOPY_COPYPIPE:
if (args->argc != 3) {
cmdq_error(cmdq, "no argument given");
return (CMD_RETURN_ERROR);
}
arg = args->argv[2];
break;
default:
if (args->argc != 2) {
cmdq_error(cmdq, "no argument allowed");
return (CMD_RETURN_ERROR);
}
arg = NULL;
break;
}
mtmp.key = key;

View File

@ -74,7 +74,7 @@ cmd_capture_pane_pending(struct args *args, struct window_pane *wp,
tmp[0] = line[i];
tmp[1] = '\0';
} else
xsnprintf(tmp, sizeof tmp, "\\%03o", line[i]);
xsnprintf(tmp, sizeof tmp, "\\%03hho", line[i]);
buf = cmd_capture_pane_append(buf, len, tmp,
strlen(tmp));
}

View File

@ -59,7 +59,7 @@ cmd_respawn_pane_exec(struct cmd *self, struct cmd_q *cmdq)
if (!args_has(self->args, 'k') && wp->fd != -1) {
if (window_pane_index(wp, &idx) != 0)
fatalx("index not found");
cmdq_error(cmdq, "pane still active: %s:%u.%u",
cmdq_error(cmdq, "pane still active: %s:%d.%u",
s->name, wl->idx, idx);
return (CMD_RETURN_ERROR);
}

View File

@ -147,7 +147,7 @@ colour_tostring(int c)
static char s[32];
if (c & 0x100) {
xsnprintf(s, sizeof s, "colour%u", c & ~0x100);
xsnprintf(s, sizeof s, "colour%d", c & ~0x100);
return (s);
}

View File

@ -38,6 +38,7 @@
int format_replace(struct format_tree *, const char *, size_t, char **,
size_t *, size_t *);
char *format_time_string(time_t);
char *format_get_command(struct window_pane *);
void format_defaults_pane_tabs(struct format_tree *, struct window_pane *);
@ -454,6 +455,18 @@ format_get_command(struct window_pane *wp)
return (out);
}
/* Get time as a string. */
char *
format_time_string(time_t t)
{
char *tim;
tim = ctime(&t);
*strchr(tim, '\n') = '\0';
return (tim);
}
/* Set defaults for any of arguments that are not NULL. */
void
format_defaults(struct format_tree *ft, struct client *c, struct session *s,
@ -481,7 +494,6 @@ void
format_defaults_session(struct format_tree *ft, struct session *s)
{
struct session_group *sg;
char *tim;
time_t t;
ft->s = s;
@ -499,21 +511,22 @@ format_defaults_session(struct format_tree *ft, struct session *s)
t = s->creation_time.tv_sec;
format_add(ft, "session_created", "%lld", (long long) t);
tim = ctime(&t);
*strchr(tim, '\n') = '\0';
format_add(ft, "session_created_string", "%s", tim);
format_add(ft, "session_created_string", "%s", format_time_string(t));
t = s->activity_time.tv_sec;
format_add(ft, "session_activity", "%lld", (long long) t);
format_add(ft, "session_activity_string", "%s", format_time_string(t));
format_add(ft, "session_attached", "%u", s->attached);
format_add(ft, "session_many_attached", "%u", s->attached > 1);
format_add(ft, "session_many_attached", "%d", s->attached > 1);
}
/* Set default format keys for a client. */
void
format_defaults_client(struct format_tree *ft, struct client *c)
{
char *tim;
time_t t;
struct session *s;
time_t t;
if (ft->s == NULL)
ft->s = c->session;
@ -527,15 +540,11 @@ format_defaults_client(struct format_tree *ft, struct client *c)
t = c->creation_time.tv_sec;
format_add(ft, "client_created", "%lld", (long long) t);
tim = ctime(&t);
*strchr(tim, '\n') = '\0';
format_add(ft, "client_created_string", "%s", tim);
format_add(ft, "client_created_string", "%s", format_time_string(t));
t = c->activity_time.tv_sec;
format_add(ft, "client_activity", "%lld", (long long) t);
tim = ctime(&t);
*strchr(tim, '\n') = '\0';
format_add(ft, "client_activity_string", "%s", tim);
format_add(ft, "client_activity_string", "%s", format_time_string(t));
format_add(ft, "client_prefix", "%d", !!(c->flags & CLIENT_PREFIX));
@ -573,7 +582,7 @@ format_defaults_window(struct format_tree *ft, struct window *w)
format_add(ft, "window_height", "%u", w->sy);
format_add(ft, "window_layout", "%s", layout);
format_add(ft, "window_panes", "%u", window_count_panes(w));
format_add(ft, "window_zoomed_flag", "%u",
format_add(ft, "window_zoomed_flag", "%d",
!!(w->flags & WINDOW_ZOOMED));
free(layout);
@ -598,13 +607,13 @@ format_defaults_winlink(struct format_tree *ft, struct session *s,
format_add(ft, "window_flags", "%s", flags);
format_add(ft, "window_active", "%d", wl == s->curw);
format_add(ft, "window_bell_flag", "%u",
format_add(ft, "window_bell_flag", "%d",
!!(wl->flags & WINLINK_BELL));
format_add(ft, "window_activity_flag", "%u",
format_add(ft, "window_activity_flag", "%d",
!!(wl->flags & WINLINK_ACTIVITY));
format_add(ft, "window_silence_flag", "%u",
format_add(ft, "window_silence_flag", "%d",
!!(wl->flags & WINLINK_SILENCE));
format_add(ft, "window_last_flag", "%u",
format_add(ft, "window_last_flag", "%d",
!!(wl == TAILQ_FIRST(&s->lastw)));
free(flags);
@ -624,7 +633,7 @@ format_defaults_pane_tabs(struct format_tree *ft, struct window_pane *wp)
if (EVBUFFER_LENGTH(buffer) > 0)
evbuffer_add(buffer, ",", 1);
evbuffer_add_printf(buffer, "%d", i);
evbuffer_add_printf(buffer, "%u", i);
}
format_add(ft, "pane_tabs", "%.*s", (int) EVBUFFER_LENGTH(buffer),
@ -697,16 +706,16 @@ format_defaults_pane(struct format_tree *ft, struct window_pane *wp)
free(cmd);
}
format_add(ft, "cursor_x", "%d", wp->base.cx);
format_add(ft, "cursor_y", "%d", wp->base.cy);
format_add(ft, "scroll_region_upper", "%d", wp->base.rupper);
format_add(ft, "scroll_region_lower", "%d", wp->base.rlower);
format_add(ft, "saved_cursor_x", "%d", wp->ictx.old_cx);
format_add(ft, "saved_cursor_y", "%d", wp->ictx.old_cy);
format_add(ft, "cursor_x", "%u", wp->base.cx);
format_add(ft, "cursor_y", "%u", wp->base.cy);
format_add(ft, "scroll_region_upper", "%u", wp->base.rupper);
format_add(ft, "scroll_region_lower", "%u", wp->base.rlower);
format_add(ft, "saved_cursor_x", "%u", wp->ictx.old_cx);
format_add(ft, "saved_cursor_y", "%u", wp->ictx.old_cy);
format_add(ft, "alternate_on", "%d", wp->saved_grid ? 1 : 0);
format_add(ft, "alternate_saved_x", "%d", wp->saved_cx);
format_add(ft, "alternate_saved_y", "%d", wp->saved_cy);
format_add(ft, "alternate_saved_x", "%u", wp->saved_cx);
format_add(ft, "alternate_saved_y", "%u", wp->saved_cy);
format_add(ft, "cursor_flag", "%d",
!!(wp->base.mode & MODE_CURSOR));

View File

@ -218,7 +218,7 @@ input_mouse(struct window_pane *wp, struct session *s, struct mouse_event *m)
* legacy format.
*/
if (m->sgr && (wp->screen->mode & MODE_MOUSE_SGR)) {
len = xsnprintf(buf, sizeof buf, "\033[<%d;%d;%d%c",
len = xsnprintf(buf, sizeof buf, "\033[<%u;%u;%u%c",
m->sgr_xb, m->x + 1, m->y + 1,
m->sgr_rel ? 'm' : 'M');
} else if (wp->screen->mode & MODE_MOUSE_UTF8) {

View File

@ -1717,7 +1717,7 @@ void
input_exit_osc(struct input_ctx *ictx)
{
u_char *p = ictx->input_buf;
int option;
u_int option;
if (ictx->flags & INPUT_DISCARD)
return;

View File

@ -246,9 +246,6 @@ paste_set(char *data, size_t size, const char *name, char **cause)
return (-1);
}
pb = paste_get_name(name);
if (pb != NULL)
paste_free_name(name);
pb = xmalloc(sizeof *pb);
@ -260,6 +257,9 @@ 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);
RB_INSERT(paste_name_tree, &paste_by_name, pb);
RB_INSERT(paste_time_tree, &paste_by_time, pb);

View File

@ -833,7 +833,7 @@ server_client_msg_dispatch(struct client *c)
continue;
}
log_debug("got %d from client %d", imsg.hdr.type, c->ibuf.fd);
log_debug("got %u from client %d", imsg.hdr.type, c->ibuf.fd);
switch (imsg.hdr.type) {
case MSG_IDENTIFY_FLAGS:
case MSG_IDENTIFY_TERM:

View File

@ -41,9 +41,9 @@ server_fill_environ(struct session *s, struct environ *env)
idx = s->id;
} else
idx = -1;
idx = (u_int)-1;
pid = getpid();
xsnprintf(var, sizeof var, "%s,%ld,%d", socket_path, pid, idx);
xsnprintf(var, sizeof var, "%s,%ld,%u", socket_path, pid, idx);
environ_set(env, "TMUX", var);
}

View File

@ -90,7 +90,7 @@ server_window_check_bell(struct session *s, struct winlink *wl)
if (c->session->curw->window == w)
status_message_set(c, "Bell in current window");
else if (action == BELL_ANY)
status_message_set(c, "Bell in window %u", wl->idx);
status_message_set(c, "Bell in window %d", wl->idx);
}
return (1);
@ -124,7 +124,7 @@ server_window_check_activity(struct session *s, struct winlink *wl)
c = ARRAY_ITEM(&clients, i);
if (c == NULL || c->session != s)
continue;
status_message_set(c, "Activity in window %u", wl->idx);
status_message_set(c, "Activity in window %d", wl->idx);
}
}
@ -175,7 +175,7 @@ server_window_check_silence(struct session *s, struct winlink *wl)
c = ARRAY_ITEM(&clients, i);
if (c == NULL || c->session != s)
continue;
status_message_set(c, "Silence in window %u", wl->idx);
status_message_set(c, "Silence in window %d", wl->idx);
}
}

12
style.c
View File

@ -160,13 +160,21 @@ style_update_new(struct options *oo, const char *name, const char *newname)
{
int value;
struct grid_cell *gc;
struct options_entry *o;
/* It's a colour or attribute, but with no -style equivalent. */
if (newname == NULL)
return;
gc = options_get_style(oo, newname);
value = options_get_number(oo, name);
o = options_find1(oo, newname);
if (o == NULL)
o = options_set_style (oo, newname, "default", 0);
gc = &o->style;
o = options_find1(oo, name);
if (o == NULL)
o = options_set_number (oo, name, 8);
value = o->num;
if (strstr(name, "-bg") != NULL)
colour_set_bg(gc, value);

28
tmux.1
View File

@ -751,7 +751,7 @@ behave like
.Ic attach-session
if
.Ar session-name
already exists; in the case,
already exists; in this case,
.Fl D
behaves like
.Fl d
@ -991,15 +991,27 @@ command and keys modified or removed with
.Ic bind-key
and
.Ic unbind-key .
One command accepts an argument,
.Ic copy-pipe ,
which copies the selection and pipes it to a command.
If
.Ic append-selection ,
.Ic copy-selection ,
or
.Ic start-named-buffer
are given the
.Fl x
flag,
.Nm
will not exit copy mode after copying.
.Ic copy-pipe
copies the selection and pipes it to a command.
For example the following will bind
.Ql C-w
not to exit after copying and
.Ql C-q
to copy the selection into
.Pa /tmp
as well as the paste buffer:
.Bd -literal -offset indent
bind-key -temacs-copy C-w copy-selection -x
bind-key -temacs-copy C-q copy-pipe "cat >/tmp/out"
.Ed
.Pp
@ -2503,9 +2515,9 @@ variable is set.
String used to set the window title if
.Ic set-titles
is on.
Character sequences are replaced as for the
.Ic status-left
option.
Formats are expanded, see the
.Sx FORMATS
section.
.It Xo Ic status
.Op Ic on | off
.Xc
@ -3153,6 +3165,8 @@ The following variables are available, where appropriate:
.It Li "scroll_region_lower" Ta "" Ta "Bottom of scroll region in pane"
.It Li "scroll_region_upper" Ta "" Ta "Top of scroll region in pane"
.It Li "session_attached" Ta "" Ta "Number of clients session is attached to"
.It Li "session_activity" Ta "" Ta "Integer time of session last activity"
.It Li "session_activity_string" Ta "" Ta "String time of session last activity"
.It Li "session_created" Ta "" Ta "Integer time session created"
.It Li "session_created_string" Ta "" Ta "String time session created"
.It Li "session_group" Ta "" Ta "Number of session group"

36
tty.c
View File

@ -629,7 +629,7 @@ tty_draw_line(struct tty *tty, struct screen *s, u_int py, u_int ox, u_int oy)
sx = tty->sx;
/*
* Don't move the cursor to the start permission if it will wrap there
* Don't move the cursor to the start position if it will wrap there
* itself.
*/
gl = NULL;
@ -1407,7 +1407,7 @@ tty_colours(struct tty *tty, const struct grid_cell *gc)
*
* Otherwise, try to set the default colour only as needed.
*/
have_ax = tty_term_has(tty->term, TTYC_AX);
have_ax = tty_term_flag(tty->term, TTYC_AX);
if (!have_ax && tty_term_has(tty->term, TTYC_OP))
tty_reset(tty);
else {
@ -1453,6 +1453,8 @@ tty_check_fg(struct tty *tty, struct grid_cell *gc)
{
u_int colours;
colours = tty_term_number(tty->term, TTYC_COLORS);
/* Is this a 256-colour colour? */
if (gc->flags & GRID_FLAG_FG256) {
/* And not a 256 colour mode? */
@ -1461,7 +1463,10 @@ tty_check_fg(struct tty *tty, struct grid_cell *gc)
gc->fg = colour_256to16(gc->fg);
if (gc->fg & 8) {
gc->fg &= 7;
gc->attr |= GRID_ATTR_BRIGHT;
if (colours >= 16)
gc->fg += 90;
else
gc->attr |= GRID_ATTR_BRIGHT;
} else
gc->attr &= ~GRID_ATTR_BRIGHT;
gc->flags &= ~GRID_FLAG_FG256;
@ -1470,7 +1475,6 @@ tty_check_fg(struct tty *tty, struct grid_cell *gc)
}
/* Is this an aixterm colour? */
colours = tty_term_number(tty->term, TTYC_COLORS);
if (gc->fg >= 90 && gc->fg <= 97 && colours < 16) {
gc->fg -= 90;
gc->attr |= GRID_ATTR_BRIGHT;
@ -1482,6 +1486,8 @@ tty_check_bg(struct tty *tty, struct grid_cell *gc)
{
u_int colours;
colours = tty_term_number(tty->term, TTYC_COLORS);
/* Is this a 256-colour colour? */
if (gc->flags & GRID_FLAG_BG256) {
/*
@ -1492,20 +1498,19 @@ tty_check_bg(struct tty *tty, struct grid_cell *gc)
if (!(tty->term->flags & TERM_256COLOURS) &&
!(tty->term_flags & TERM_256COLOURS)) {
gc->bg = colour_256to16(gc->bg);
if (gc->bg & 8)
if (gc->bg & 8) {
gc->bg &= 7;
gc->attr &= ~GRID_ATTR_BRIGHT;
if (colours >= 16)
gc->fg += 90;
}
gc->flags &= ~GRID_FLAG_BG256;
}
return;
}
/* Is this an aixterm colour? */
colours = tty_term_number(tty->term, TTYC_COLORS);
if (gc->bg >= 90 && gc->bg <= 97 && colours < 16) {
if (gc->bg >= 90 && gc->bg <= 97 && colours < 16)
gc->bg -= 90;
gc->attr |= GRID_ATTR_BRIGHT;
}
}
void
@ -1559,14 +1564,9 @@ tty_colours_bg(struct tty *tty, const struct grid_cell *gc)
/* Is this an aixterm bright colour? */
if (bg >= 90 && bg <= 97) {
/* 16 colour terminals or above only. */
if (tty_term_number(tty->term, TTYC_COLORS) >= 16) {
xsnprintf(s, sizeof s, "\033[%dm", bg + 10);
tty_puts(tty, s);
goto save_bg;
}
bg -= 90;
/* no such thing as a bold background */
xsnprintf(s, sizeof s, "\033[%dm", bg + 10);
tty_puts(tty, s);
goto save_bg;
}
/* Otherwise set the background colour. */

View File

@ -98,7 +98,7 @@ window_choose_add(struct window_pane *wp, struct window_choose_data *wcd)
item->pos = ARRAY_LENGTH(&data->list) - 1;
item->state = 0;
data->width = xsnprintf(tmp, sizeof tmp , "%u", item->pos);
data->width = xsnprintf(tmp, sizeof tmp , "%d", item->pos);
}
void

View File

@ -147,6 +147,7 @@ struct window_copy_mode_data {
enum window_copy_input_type inputtype;
const char *inputprompt;
char *inputstr;
int inputexit;
int numprefix;
@ -424,8 +425,12 @@ window_copy_key(struct window_pane *wp, struct session *sess, int key)
case MODEKEYCOPY_APPENDSELECTION:
if (sess != NULL) {
window_copy_append_selection(wp, NULL);
window_pane_reset_mode(wp);
return;
if (arg == NULL) {
window_pane_reset_mode(wp);
return;
}
window_copy_clear_selection(wp);
window_copy_redraw_screen(wp);
}
break;
case MODEKEYCOPY_CANCEL:
@ -572,8 +577,12 @@ window_copy_key(struct window_pane *wp, struct session *sess, int key)
case MODEKEYCOPY_COPYSELECTION:
if (sess != NULL) {
window_copy_copy_selection(wp, NULL);
window_pane_reset_mode(wp);
return;
if (arg == NULL) {
window_pane_reset_mode(wp);
return;
}
window_copy_clear_selection(wp);
window_copy_redraw_screen(wp);
}
break;
case MODEKEYCOPY_STARTOFLINE:
@ -718,6 +727,7 @@ window_copy_key(struct window_pane *wp, struct session *sess, int key)
goto input_on;
case MODEKEYCOPY_STARTNAMEDBUFFER:
data->inputtype = WINDOW_COPY_NAMEDBUFFER;
data->inputexit = (arg == NULL);
data->inputprompt = "Buffer";
*data->inputstr = '\0';
goto input_on;
@ -828,8 +838,13 @@ window_copy_key_input(struct window_pane *wp, int key)
case WINDOW_COPY_NAMEDBUFFER:
window_copy_copy_selection(wp, data->inputstr);
*data->inputstr = '\0';
window_pane_reset_mode(wp);
return (0);
if (data->inputexit) {
window_pane_reset_mode(wp);
return (0);
}
window_copy_clear_selection(wp);
window_copy_redraw_screen(wp);
break;
case WINDOW_COPY_GOTOLINE:
window_copy_goto_line(wp, data->inputstr);
*data->inputstr = '\0';
@ -1216,7 +1231,7 @@ window_copy_write_line(struct window_pane *wp, struct screen_write_ctx *ctx,
limit = screen_size_x(s) + 1;
if (data->inputtype == WINDOW_COPY_NUMERICPREFIX) {
xoff = size = xsnprintf(hdr, limit,
"Repeat: %u", data->numprefix);
"Repeat: %d", data->numprefix);
} else {
xoff = size = xsnprintf(hdr, limit,
"%s: %s", data->inputprompt, data->inputstr);