This commit is contained in:
Nicholas Marriott 2008-06-18 22:21:51 +00:00
parent 28aefe4162
commit 99df48d70f
28 changed files with 97 additions and 97 deletions

16
arg.c
View File

@ -1,4 +1,4 @@
/* $Id: arg.c,v 1.2 2008-06-05 21:54:47 nicm Exp $ */ /* $Id: arg.c,v 1.3 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -51,7 +51,7 @@ arg_lookup_session(const char *name)
ts = NULL; ts = NULL;
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) { for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
s = ARRAY_ITEM(&sessions, i); s = ARRAY_ITEM(&sessions, i);
if (s == NULL || fnmatch(name, s->name, 0) != 0) if (s == NULL || fnmatch(name, s->name, 0) != 0)
continue; continue;
@ -133,7 +133,7 @@ arg_parse_window(const char *arg, struct session **s, int *idx)
*s = arg_parse_session(NULL); *s = arg_parse_session(NULL);
return (0); return (0);
} }
/* Find the separator if any. */ /* Find the separator if any. */
arg2 = xstrdup(arg); arg2 = xstrdup(arg);
ptr = strrchr(arg2, ':'); ptr = strrchr(arg2, ':');
@ -147,7 +147,7 @@ arg_parse_window(const char *arg, struct session **s, int *idx)
if (errstr != NULL) { if (errstr != NULL) {
xfree(arg2); xfree(arg2);
return (1); return (1);
} }
xfree(arg2); xfree(arg2);
*s = arg_parse_session(NULL); *s = arg_parse_session(NULL);
@ -162,25 +162,25 @@ arg_parse_window(const char *arg, struct session **s, int *idx)
xfree(arg2); xfree(arg2);
*s = arg_parse_session(NULL); *s = arg_parse_session(NULL);
return (0); return (0);
} }
*idx = -1; *idx = -1;
goto lookup; goto lookup;
} }
/* If last, strip it and look up as a session. */ /* If last, strip it and look up as a session. */
if (ptr[1] == '\0') { if (ptr[1] == '\0') {
*ptr = '\0'; *ptr = '\0';
goto lookup; goto lookup;
} }
/* Present but not first and not last. Break and convert both. */ /* Present but not first and not last. Break and convert both. */
*ptr = '\0'; *ptr = '\0';
*idx = strtonum(ptr + 1, 0, INT_MAX, &errstr); *idx = strtonum(ptr + 1, 0, INT_MAX, &errstr);
if (errstr != NULL) { if (errstr != NULL) {
xfree(arg2); xfree(arg2);
return (1); return (1);
} }
lookup: lookup:
/* Look up as session. */ /* Look up as session. */

View File

@ -1,4 +1,4 @@
/* $Id: buffer-poll.c,v 1.6 2008-06-18 20:11:25 nicm Exp $ */ /* $Id: buffer-poll.c,v 1.7 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -60,7 +60,7 @@ buffer_poll(struct pollfd *pfd, struct buffer *in, struct buffer *out)
buffer_add(in, n); buffer_add(in, n);
} }
if (BUFFER_USED(out) > 0 && pfd->revents & POLLOUT) { if (BUFFER_USED(out) > 0 && pfd->revents & POLLOUT) {
n = write(pfd->fd, BUFFER_OUT(out), BUFFER_USED(out)); n = write(pfd->fd, BUFFER_OUT(out), BUFFER_USED(out));
log_debug("buffer_poll: fd=%d, write=%zd", pfd->fd, n); log_debug("buffer_poll: fd=%d, write=%zd", pfd->fd, n);
if (n == -1) { if (n == -1) {
if (errno != EINTR && errno != EAGAIN) if (errno != EINTR && errno != EAGAIN)

View File

@ -1,4 +1,4 @@
/* $Id: cmd-attach-session.c,v 1.18 2008-06-05 21:25:00 nicm Exp $ */ /* $Id: cmd-attach-session.c,v 1.19 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -50,7 +50,7 @@ cmd_attach_session_exec(struct cmd *self, struct cmd_ctx *ctx)
if (ctx->flags & CMD_KEY) if (ctx->flags & CMD_KEY)
return; return;
if ((s = cmd_find_session(ctx, data->target)) == NULL) if ((s = cmd_find_session(ctx, data->target)) == NULL)
return; return;

View File

@ -1,4 +1,4 @@
/* $Id: cmd-copy-mode.c,v 1.10 2008-06-05 21:25:00 nicm Exp $ */ /* $Id: cmd-copy-mode.c,v 1.11 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -27,7 +27,7 @@
void cmd_copy_mode_exec(struct cmd *, struct cmd_ctx *); void 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,
CMD_TARGET_WINDOW_USAGE, CMD_TARGET_WINDOW_USAGE,
0, 0,
cmd_target_init, cmd_target_init,

View File

@ -1,4 +1,4 @@
/* $Id: cmd-generic.c,v 1.9 2008-06-05 23:17:03 nicm Exp $ */ /* $Id: cmd-generic.c,v 1.10 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -43,7 +43,7 @@ cmd_target_parse(struct cmd *self, int argc, char **argv, char **cause)
/* Don't use the entry version since it may be dependent on key. */ /* Don't use the entry version since it may be dependent on key. */
cmd_target_init(self, 0); cmd_target_init(self, 0);
data = self->data; data = self->data;
while ((opt = getopt(argc, argv, "dkt:")) != EOF) { while ((opt = getopt(argc, argv, "dkt:")) != EOF) {
switch (opt) { switch (opt) {
case 'd': case 'd':
@ -124,7 +124,7 @@ cmd_target_print(struct cmd *self, char *buf, size_t len)
{ {
struct cmd_target_data *data = self->data; struct cmd_target_data *data = self->data;
size_t off = 0; size_t off = 0;
off += xsnprintf(buf, len, "%s", self->entry->name); off += xsnprintf(buf, len, "%s", self->entry->name);
if (data == NULL) if (data == NULL)
return; return;
@ -155,7 +155,7 @@ cmd_srcdst_parse(struct cmd *self, int argc, char **argv, char **cause)
{ {
struct cmd_srcdst_data *data; struct cmd_srcdst_data *data;
int opt; int opt;
cmd_srcdst_init(self, 0); cmd_srcdst_init(self, 0);
data = self->data; data = self->data;
@ -247,7 +247,7 @@ cmd_srcdst_print(struct cmd *self, char *buf, size_t len)
{ {
struct cmd_srcdst_data *data = self->data; struct cmd_srcdst_data *data = self->data;
size_t off = 0; size_t off = 0;
off += xsnprintf(buf, len, "%s", self->entry->name); off += xsnprintf(buf, len, "%s", self->entry->name);
if (data == NULL) if (data == NULL)
return; return;

View File

@ -1,4 +1,4 @@
/* $Id: cmd-last-window.c,v 1.12 2008-06-06 20:02:27 nicm Exp $ */ /* $Id: cmd-last-window.c,v 1.13 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -27,7 +27,7 @@
void cmd_last_window_exec(struct cmd *, struct cmd_ctx *); void cmd_last_window_exec(struct cmd *, struct cmd_ctx *);
const struct cmd_entry cmd_last_window_entry = { const struct cmd_entry cmd_last_window_entry = {
"last-window", "last", "last-window", "last",
CMD_TARGET_SESSION_USAGE, CMD_TARGET_SESSION_USAGE,
0, 0,
cmd_target_init, cmd_target_init,
@ -44,7 +44,7 @@ cmd_last_window_exec(struct cmd *self, struct cmd_ctx *ctx)
{ {
struct cmd_target_data *data = self->data; struct cmd_target_data *data = self->data;
struct session *s; struct session *s;
if ((s = cmd_find_session(ctx, data->target)) == NULL) if ((s = cmd_find_session(ctx, data->target)) == NULL)
return; return;

View File

@ -1,4 +1,4 @@
/* $Id: cmd-link-window.c,v 1.22 2008-06-06 20:02:27 nicm Exp $ */ /* $Id: cmd-link-window.c,v 1.23 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -80,7 +80,7 @@ cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx)
*/ */
session_alert_cancel(s, wl_dst); session_alert_cancel(s, wl_dst);
winlink_remove(&s->windows, wl_dst); winlink_remove(&s->windows, wl_dst);
/* Force select/redraw if current. */ /* Force select/redraw if current. */
if (wl_dst == s->curw) { if (wl_dst == s->curw) {
data->flags &= ~CMD_DFLAG; data->flags &= ~CMD_DFLAG;
@ -88,7 +88,7 @@ cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx)
} }
if (wl_dst == s->lastw) if (wl_dst == s->lastw)
s->lastw = NULL; s->lastw = NULL;
/* /*
* Can't error out after this or there could be an * Can't error out after this or there could be an
* empty session! * empty session!

View File

@ -1,4 +1,4 @@
/* $Id: cmd-refresh-client.c,v 1.6 2008-06-05 21:25:00 nicm Exp $ */ /* $Id: cmd-refresh-client.c,v 1.7 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -47,7 +47,7 @@ cmd_refresh_client_exec(struct cmd *self, struct cmd_ctx *ctx)
if ((c = cmd_find_client(ctx, data->target)) == NULL) if ((c = cmd_find_client(ctx, data->target)) == NULL)
return; return;
server_redraw_client(c); server_redraw_client(c);
if (ctx->cmdclient != NULL) if (ctx->cmdclient != NULL)

View File

@ -1,4 +1,4 @@
/* $Id: cmd-rename-session.c,v 1.11 2008-06-05 21:25:00 nicm Exp $ */ /* $Id: cmd-rename-session.c,v 1.12 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -32,7 +32,7 @@ void 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",
CMD_TARGET_SESSION_USAGE " new-name", CMD_TARGET_SESSION_USAGE " new-name",
CMD_ONEARG, CMD_ONEARG,
cmd_target_init, cmd_target_init,
cmd_target_parse, cmd_target_parse,
cmd_rename_session_exec, cmd_rename_session_exec,

View File

@ -1,4 +1,4 @@
/* $Id: cmd-set-option.c,v 1.30 2008-06-18 20:11:25 nicm Exp $ */ /* $Id: cmd-set-option.c,v 1.31 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -338,5 +338,5 @@ cmd_set_option_print(struct cmd *self, char *buf, size_t len)
if (off < len && data->option != NULL) if (off < len && data->option != NULL)
off += xsnprintf(buf + off, len - off, " %s", data->option); off += xsnprintf(buf + off, len - off, " %s", data->option);
if (off < len && data->value != NULL) if (off < len && data->value != NULL)
off += xsnprintf(buf + off, len - off, " %s", data->value); off += xsnprintf(buf + off, len - off, " %s", data->value);
} }

View File

@ -1,4 +1,4 @@
/* $Id: cmd-set-window-option.c,v 1.9 2008-06-18 20:11:25 nicm Exp $ */ /* $Id: cmd-set-window-option.c,v 1.10 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -141,7 +141,7 @@ cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx)
else { else {
if (flag) if (flag)
wl->window->flags |= WINDOW_MONITOR; wl->window->flags |= WINDOW_MONITOR;
else else
wl->window->flags &= ~WINDOW_MONITOR; wl->window->flags &= ~WINDOW_MONITOR;
} }
@ -154,7 +154,7 @@ cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx)
} }
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) { for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
s = ARRAY_ITEM(&sessions, i); s = ARRAY_ITEM(&sessions, i);
if (s != NULL) if (s != NULL)
session_alert_cancel(s, wl); session_alert_cancel(s, wl);
} }
@ -169,7 +169,7 @@ cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx)
else { else {
if (flag) if (flag)
wl->window->flags |= WINDOW_AGGRESSIVE; wl->window->flags |= WINDOW_AGGRESSIVE;
else else
wl->window->flags &= ~WINDOW_AGGRESSIVE; wl->window->flags &= ~WINDOW_AGGRESSIVE;
} }
@ -278,5 +278,5 @@ cmd_set_window_option_print(struct cmd *self, char *buf, size_t len)
if (off < len && data->option != NULL) if (off < len && data->option != NULL)
off += xsnprintf(buf + off, len - off, " %s", data->option); off += xsnprintf(buf + off, len - off, " %s", data->option);
if (off < len && data->value != NULL) if (off < len && data->value != NULL)
off += xsnprintf(buf + off, len - off, " %s", data->value); off += xsnprintf(buf + off, len - off, " %s", data->value);
} }

View File

@ -1,4 +1,4 @@
/* $Id: cmd-show-options.c,v 1.2 2008-06-16 06:33:50 nicm Exp $ */ /* $Id: cmd-show-options.c,v 1.3 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -119,7 +119,7 @@ cmd_show_options_exec(struct cmd *self, struct cmd_ctx *ctx)
ctx->print(ctx, "%s %lld", o->name, o->value.number); ctx->print(ctx, "%s %lld", o->name, o->value.number);
break; break;
case OPTIONS_KEY: case OPTIONS_KEY:
ctx->print(ctx, "%s %s", o->name, ctx->print(ctx, "%s %s", o->name,
key_string_lookup_key(o->value.key)); key_string_lookup_key(o->value.key));
break; break;
case OPTIONS_COLOURS: case OPTIONS_COLOURS:

View File

@ -1,4 +1,4 @@
/* $Id: cmd-switch-client.c,v 1.9 2008-06-05 21:25:00 nicm Exp $ */ /* $Id: cmd-switch-client.c,v 1.10 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -103,7 +103,7 @@ cmd_switch_client_exec(struct cmd *self, struct cmd_ctx *ctx)
return; return;
if ((s = cmd_find_session(ctx, data->target)) == NULL) if ((s = cmd_find_session(ctx, data->target)) == NULL)
return; return;
c->session = s; c->session = s;
recalculate_sizes(); recalculate_sizes();

8
cmd.c
View File

@ -1,4 +1,4 @@
/* $Id: cmd.c,v 1.48 2008-06-16 22:03:27 nicm Exp $ */ /* $Id: cmd.c,v 1.49 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -262,10 +262,10 @@ cmd_current_session(struct cmd_ctx *ctx)
} }
return (s); return (s);
} }
ts = NULL; ts = NULL;
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) { for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
s = ARRAY_ITEM(&sessions, i); s = ARRAY_ITEM(&sessions, i);
if (s != NULL && (ts == NULL || timespeccmp(&s->ts, ts, >))) { if (s != NULL && (ts == NULL || timespeccmp(&s->ts, ts, >))) {
newest = ARRAY_ITEM(&sessions, i); newest = ARRAY_ITEM(&sessions, i);
ts = &s->ts; ts = &s->ts;
@ -278,7 +278,7 @@ struct client *
cmd_find_client(struct cmd_ctx *ctx, const char *arg) cmd_find_client(struct cmd_ctx *ctx, const char *arg)
{ {
struct client *c; struct client *c;
if ((c = arg_parse_client(arg)) == NULL) if ((c = arg_parse_client(arg)) == NULL)
c = ctx->curclient; c = ctx->curclient;
if (c == NULL) { if (c == NULL) {

View File

@ -1,4 +1,4 @@
/* $Id: asprintf.c,v 1.1 2008-06-18 20:12:19 nicm Exp $ */ /* $Id: asprintf.c,v 1.2 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2006 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2006 Nicholas Marriott <nicm@users.sourceforge.net>
@ -47,7 +47,7 @@ vasprintf(char **ret, const char *format, va_list ap)
xfree(*ret); xfree(*ret);
goto error; goto error;
} }
return (n); return (n);
error: error:

View File

@ -1,4 +1,4 @@
/* $Id: forkpty-sunos.c,v 1.4 2008-06-18 22:00:49 nicm Exp $ */ /* $Id: forkpty-sunos.c,v 1.5 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -39,12 +39,12 @@ forkpty(int *master,
goto out; goto out;
if (unlockpt(*master) != 0) if (unlockpt(*master) != 0)
goto out; goto out;
if ((path = ptsname(*master)) == NULL) if ((path = ptsname(*master)) == NULL)
goto out; goto out;
if ((slave = open(path, O_RDWR|O_NOCTTY)) == -1) if ((slave = open(path, O_RDWR|O_NOCTTY)) == -1)
goto out; goto out;
switch (pid = fork()) { switch (pid = fork()) {
case -1: case -1:
goto out; goto out;
@ -59,10 +59,10 @@ forkpty(int *master,
fatal("ioctl failed"); fatal("ioctl failed");
if (ioctl(slave, I_PUSH, "ldterm") == -1) if (ioctl(slave, I_PUSH, "ldterm") == -1)
fatal("ioctl failed"); fatal("ioctl failed");
if (ioctl(slave, TIOCSWINSZ, ws) == -1) if (ioctl(slave, TIOCSWINSZ, ws) == -1)
fatal("ioctl failed"); fatal("ioctl failed");
dup2(slave, 0); dup2(slave, 0);
dup2(slave, 1); dup2(slave, 1);
dup2(slave, 2); dup2(slave, 2);

View File

@ -1,4 +1,4 @@
/* $Id: input-keys.c,v 1.7 2008-06-06 17:20:29 nicm Exp $ */ /* $Id: input-keys.c,v 1.8 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -108,7 +108,7 @@ input_key(struct window *w, int key)
} }
} }
#endif #endif
for (i = 0; i < NINPUTKEYS; i++) { for (i = 0; i < NINPUTKEYS; i++) {
if (input_keys[i].key == key) if (input_keys[i].key == key)
break; break;

View File

@ -1,4 +1,4 @@
/* $Id: screen-display.c,v 1.16 2008-06-04 19:20:09 nicm Exp $ */ /* $Id: screen-display.c,v 1.17 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -439,7 +439,7 @@ screen_display_copy_area(struct screen *dst, struct screen *src,
} }
if (!screen_in_x(dst, px) || !screen_in_y(dst, py)) { if (!screen_in_x(dst, px) || !screen_in_y(dst, py)) {
SCREEN_DEBUG4(dst, px, py, nx, ny); SCREEN_DEBUG4(dst, px, py, nx, ny);
return; return;
} }
if (!screen_in_x(dst, px + nx - 1) || !screen_in_y(dst, py + ny - 1)) { if (!screen_in_x(dst, px + nx - 1) || !screen_in_y(dst, py + ny - 1)) {
SCREEN_DEBUG4(dst, px, py, nx, ny); SCREEN_DEBUG4(dst, px, py, nx, ny);

View File

@ -1,4 +1,4 @@
/* $Id: screen.c,v 1.61 2008-06-14 12:05:06 nicm Exp $ */ /* $Id: screen.c,v 1.62 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -45,7 +45,7 @@
* ----------- array base + hsize + dy * ----------- array base + hsize + dy
* *
* The screen_x/screen_y macros are used to convert a cell on the displayed * The screen_x/screen_y macros are used to convert a cell on the displayed
* area to an absolute position in the arrays. * area to an absolute position in the arrays.
* *
* Screen handling code is split into four files: * Screen handling code is split into four files:
* *
@ -54,7 +54,7 @@
* screen-display.c: Basic functions for manipulating the displayed * screen-display.c: Basic functions for manipulating the displayed
* part of the screen. x,y coordinates passed to these * part of the screen. x,y coordinates passed to these
* are relative to the display. These are largely * are relative to the display. These are largely
* utility functions for screen-write.c. * utility functions for screen-write.c.
* screen-redraw.c: Functions for redrawing all or part of a screen to * screen-redraw.c: Functions for redrawing all or part of a screen to
* one or more ttys. A context is filled via one of the * one or more ttys. A context is filled via one of the
* screen_redraw_start* variants which sets up (removes * screen_redraw_start* variants which sets up (removes

View File

@ -1,4 +1,4 @@
/* $Id: server-msg.c,v 1.46 2008-06-16 17:35:40 nicm Exp $ */ /* $Id: server-msg.c,v 1.47 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -222,7 +222,7 @@ server_msg_fn_exiting(struct hdr *hdr, struct client *c)
log_debug("exiting msg from client"); log_debug("exiting msg from client");
c->session = NULL; c->session = NULL;
tty_close(&c->tty); tty_close(&c->tty);
server_write_client(c, MSG_EXITED, NULL, 0); server_write_client(c, MSG_EXITED, NULL, 0);

View File

@ -1,4 +1,4 @@
/* $Id: server.c,v 1.67 2008-06-18 19:34:50 nicm Exp $ */ /* $Id: server.c,v 1.68 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -97,7 +97,7 @@ server_start(const char *path)
xmalloc_clear(); xmalloc_clear();
#endif #endif
/* /*
* Must daemonise before loading configuration as the PID changes so * Must daemonise before loading configuration as the PID changes so
* $TMUX would be wrong for sessions created in the config file. * $TMUX would be wrong for sessions created in the config file.
*/ */
@ -169,7 +169,7 @@ server_main(const char *srv_path, int srv_fd)
u_int i, n; u_int i, n;
siginit(); siginit();
pfds = NULL; pfds = NULL;
while (!sigterm) { while (!sigterm) {
/* Initialise pollfd array. */ /* Initialise pollfd array. */
@ -308,10 +308,10 @@ server_check_redraw(struct client *c)
if (c == NULL || c->session == NULL) if (c == NULL || c->session == NULL)
return; return;
s = c->session; s = c->session;
if (options_get_number(&s->options, "set-titles")) { if (options_get_number(&s->options, "set-titles")) {
xsnprintf(title, sizeof title, xsnprintf(title, sizeof title,
"%s:%u:%s - \"%s\"", s->name, s->curw->idx, "%s:%u:%s - \"%s\"", s->name, s->curw->idx,
s->curw->window->name, s->curw->window->base.title); s->curw->window->name, s->curw->window->base.title);
if (c->title == NULL || strcmp(title, c->title) != 0) { if (c->title == NULL || strcmp(title, c->title) != 0) {
if (c->title != NULL) if (c->title != NULL)
@ -328,7 +328,7 @@ server_check_redraw(struct client *c)
sy = screen_size_y(s->curw->window->screen); sy = screen_size_y(s->curw->window->screen);
if (sx < xx || sy < yy) { if (sx < xx || sy < yy) {
/* /*
* Fake up a blank(ish) screen and use it to draw the * Fake up a blank(ish) screen and use it to draw the
* empty regions. NOTE: because this uses * empty regions. NOTE: because this uses
* tty_write_client but doesn't write the client's * tty_write_client but doesn't write the client's
* screen, this can't use anything which relies on * screen, this can't use anything which relies on
@ -339,7 +339,7 @@ server_check_redraw(struct client *c)
if (sx < xx) if (sx < xx)
screen_redraw_columns(&ctx, sx, xx - sx); screen_redraw_columns(&ctx, sx, xx - sx);
if (sy < yy) { if (sy < yy) {
screen_fill_area(&screen, screen_fill_area(&screen,
0, sy, xx, 1, '-', 0, 0x70); 0, sy, xx, 1, '-', 0, 0x70);
screen_redraw_lines(&ctx, sy, yy - sy); screen_redraw_lines(&ctx, sy, yy - sy);
} }
@ -372,11 +372,11 @@ server_check_status(struct client *c)
interval = options_get_number(&c->session->options, "status-interval"); interval = options_get_number(&c->session->options, "status-interval");
if (nlines == 0 || interval == 0) if (nlines == 0 || interval == 0)
return; return;
if (clock_gettime(CLOCK_REALTIME, &ts) != 0) if (clock_gettime(CLOCK_REALTIME, &ts) != 0)
fatal("clock_gettime"); fatal("clock_gettime");
ts.tv_sec -= interval; ts.tv_sec -= interval;
if (timespeccmp(&c->status_ts, &ts, <)) if (timespeccmp(&c->status_ts, &ts, <))
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_STATUS;
} }
@ -428,7 +428,7 @@ server_handle_clients(struct pollfd **pfd)
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);
if (c != NULL) { if (c != NULL) {
log_debug("testing client %d (%d)", (*pfd)->fd, c->fd); log_debug("testing client %d (%d)", (*pfd)->fd, c->fd);
if (buffer_poll(*pfd, c->in, c->out) != 0) { if (buffer_poll(*pfd, c->in, c->out) != 0) {
server_lost_client(c); server_lost_client(c);

View File

@ -1,4 +1,4 @@
/* $Id: session.c,v 1.37 2008-06-07 07:27:28 nicm Exp $ */ /* $Id: session.c,v 1.38 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -121,7 +121,7 @@ session_create(const char *name, const char *cmd, u_int sx, u_int sy)
RB_INIT(&s->windows); RB_INIT(&s->windows);
TAILQ_INIT(&s->alerts); TAILQ_INIT(&s->alerts);
options_init(&s->options, &global_options); options_init(&s->options, &global_options);
s->sx = sx; s->sx = sx;
s->sy = sy; s->sy = sy;

View File

@ -1,4 +1,4 @@
/* $Id: status.c,v 1.29 2008-06-18 17:28:17 nicm Exp $ */ /* $Id: status.c,v 1.30 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -47,7 +47,7 @@ status_redraw(struct client *c)
larrow = rarrow = 0; larrow = rarrow = 0;
if (clock_gettime(CLOCK_REALTIME, &c->status_ts) != 0) if (clock_gettime(CLOCK_REALTIME, &c->status_ts) != 0)
fatal("clock_gettime failed"); fatal("clock_gettime failed");
colr = options_get_colours(&s->options, "status-colour"); colr = options_get_colours(&s->options, "status-colour");
yy = c->sy - yy; yy = c->sy - yy;
@ -74,7 +74,7 @@ status_redraw(struct client *c)
goto blank; goto blank;
xx = c->sx - xx; xx = c->sx - xx;
/* /*
* Right. We have xx characters to fill. Find out how much is to go in * Right. We have xx characters to fill. Find out how much is to go in
* them and the offset of the current window (it must be on screen). * them and the offset of the current window (it must be on screen).
*/ */
@ -125,7 +125,7 @@ status_redraw(struct client *c)
xx--; xx--;
} }
width = xx; width = xx;
draw: draw:
/* Bail here if anything is too small too. XXX. */ /* Bail here if anything is too small too. XXX. */
if (width == 0 || xx == 0) if (width == 0 || xx == 0)
@ -159,7 +159,7 @@ draw:
larrow = -1; larrow = -1;
} }
for (ptr = text; *ptr != '\0'; ptr++) { for (ptr = text; *ptr != '\0'; ptr++) {
if (offset >= start && offset < start + width) if (offset >= start && offset < start + width)
ctx.write(ctx.data, TTY_CHARACTER, *ptr); ctx.write(ctx.data, TTY_CHARACTER, *ptr);
offset++; offset++;
@ -205,7 +205,7 @@ draw:
else else
screen_redraw_move_cursor(&ctx, 0, yy); screen_redraw_move_cursor(&ctx, 0, yy);
ctx.write(ctx.data, TTY_CHARACTER, '<'); ctx.write(ctx.data, TTY_CHARACTER, '<');
} }
if (rarrow != 0) { if (rarrow != 0) {
if (rarrow == -1) if (rarrow == -1)
screen_redraw_set_attributes(&ctx, ATTR_REVERSE, colr); screen_redraw_set_attributes(&ctx, ATTR_REVERSE, colr);
@ -218,7 +218,7 @@ draw:
ctx.write(ctx.data, TTY_CHARACTER, '>'); ctx.write(ctx.data, TTY_CHARACTER, '>');
} }
screen_redraw_stop(&ctx); screen_redraw_stop(&ctx);
return; return;
blank: blank:
@ -226,9 +226,9 @@ blank:
screen_redraw_start_client(&ctx, c); screen_redraw_start_client(&ctx, c);
screen_redraw_set_attributes(&ctx, 0, colr); screen_redraw_set_attributes(&ctx, 0, colr);
screen_redraw_move_cursor(&ctx, 0, yy); screen_redraw_move_cursor(&ctx, 0, yy);
for (offset = 0; offset < c->sx; offset++) for (offset = 0; offset < c->sx; offset++)
ctx.write(ctx.data, TTY_CHARACTER, ' '); ctx.write(ctx.data, TTY_CHARACTER, ' ');
screen_redraw_stop(&ctx); screen_redraw_stop(&ctx);
} }
size_t size_t

8
tmux.c
View File

@ -1,4 +1,4 @@
/* $Id: tmux.c,v 1.60 2008-06-18 20:11:25 nicm Exp $ */ /* $Id: tmux.c,v 1.61 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -58,12 +58,12 @@ __dead void usage(void);
#ifdef NO_PROGNAME #ifdef NO_PROGNAME
const char *__progname = "tmux"; const char *__progname = "tmux";
#endif #endif
__dead void __dead void
usage(void) usage(void)
{ {
fprintf(stderr, fprintf(stderr,
"usage: %s [-v] [-f file] [-S socket-path] [command [flags]]\n", "usage: %s [-v] [-f file] [-S socket-path] [command [flags]]\n",
__progname); __progname);
exit(1); exit(1);
@ -240,7 +240,7 @@ main(int argc, char **argv)
if (access(cfg_file, R_OK) != 0) { if (access(cfg_file, R_OK) != 0) {
log_warn("%s", cfg_file); log_warn("%s", cfg_file);
exit(1); exit(1);
} }
} }
if (path == NULL) { if (path == NULL) {

8
tty.c
View File

@ -1,4 +1,4 @@
/* $Id: tty.c,v 1.27 2008-06-18 22:18:08 nicm Exp $ */ /* $Id: tty.c,v 1.28 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -90,7 +90,7 @@ tty_open(struct tty *tty, char **cause)
tio.c_iflag |= IGNBRK; tio.c_iflag |= IGNBRK;
tio.c_oflag &= ~(OPOST|ONLCR|OCRNL|ONLRET|OLCUC); tio.c_oflag &= ~(OPOST|ONLCR|OCRNL|ONLRET|OLCUC);
tio.c_lflag &= ~(IEXTEN|ICANON|ECHO|ECHOE|ECHONL|ECHOCTL|ECHOPRT|ECHOKE|ECHOCTL|ISIG); tio.c_lflag &= ~(IEXTEN|ICANON|ECHO|ECHOE|ECHONL|ECHOCTL|ECHOPRT|ECHOKE|ECHOCTL|ISIG);
tio.c_cc[VMIN] = 1; tio.c_cc[VMIN] = 1;
tio.c_cc[VTIME] = 0; tio.c_cc[VTIME] = 0;
if (tcsetattr(tty->fd, TCSANOW, &tio) != 0) if (tcsetattr(tty->fd, TCSANOW, &tio) != 0)
fatal("tcsetattr failed"); fatal("tcsetattr failed");
@ -136,7 +136,7 @@ tty_close(struct tty *tty)
} else { } else {
if (tcsetattr(tty->fd, TCSANOW, &tty->tio) != 0) if (tcsetattr(tty->fd, TCSANOW, &tty->tio) != 0)
fatal("tcsetattr failed"); fatal("tcsetattr failed");
tty_raw(tty, tparm(change_scroll_region, 0, ws.ws_row - 1)); tty_raw(tty, tparm(change_scroll_region, 0, ws.ws_row - 1));
if (keypad_local != NULL) if (keypad_local != NULL)
tty_raw(tty, keypad_local); tty_raw(tty, keypad_local);
@ -175,7 +175,7 @@ tty_find_term(char *name, int fd, char **cause)
{ {
struct tty_term *term; struct tty_term *term;
int error; int error;
TAILQ_FOREACH(term, &tty_terms, entry) { TAILQ_FOREACH(term, &tty_terms, entry) {
if (strcmp(term->name, name) == 0) { if (strcmp(term->name, name) == 0) {
term->references++; term->references++;

View File

@ -1,4 +1,4 @@
/* $Id: window-copy.c,v 1.17 2008-06-04 18:50:35 nicm Exp $ */ /* $Id: window-copy.c,v 1.18 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -71,7 +71,7 @@ struct window_copy_mode_data {
u_int selx; u_int selx;
u_int sely; u_int sely;
u_int cx; u_int cx;
u_int cy; u_int cy;
}; };

View File

@ -1,4 +1,4 @@
/* $Id: window-more.c,v 1.11 2008-06-03 21:42:37 nicm Exp $ */ /* $Id: window-more.c,v 1.12 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -94,7 +94,7 @@ window_more_init(struct window *w)
s = &data->screen; s = &data->screen;
screen_create(s, screen_size_x(&w->base), screen_size_y(&w->base), 0); screen_create(s, screen_size_x(&w->base), screen_size_y(&w->base), 0);
s->mode &= ~MODE_CURSOR; s->mode &= ~MODE_CURSOR;
return (s); return (s);
} }

View File

@ -1,4 +1,4 @@
/* $Id: window.c,v 1.43 2008-06-18 20:11:25 nicm Exp $ */ /* $Id: window.c,v 1.44 2008-06-18 22:21:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -165,7 +165,7 @@ winlink_previous(unused struct winlinks *wwl, struct winlink *wl)
} }
struct window * struct window *
window_create(const char *name, window_create(const char *name,
const char *cmd, const char **env, u_int sx, u_int sy, u_int hlimit) const char *cmd, const char **env, u_int sx, u_int sy, u_int hlimit)
{ {
struct window *w; struct window *w;
@ -189,7 +189,7 @@ window_create(const char *name,
sigreset(); sigreset();
log_debug("started child: cmd=%s; pid=%d", cmd, (int) getpid()); log_debug("started child: cmd=%s; pid=%d", cmd, (int) getpid());
log_close(); log_close();
execl(_PATH_BSHELL, "sh", "-c", cmd, (char *) NULL); execl(_PATH_BSHELL, "sh", "-c", cmd, (char *) NULL);
fatal("execl failed"); fatal("execl failed");
} }