This commit is contained in:
Nicholas Marriott 2008-09-26 06:45:28 +00:00
parent df2b3bcf44
commit 62457bce0b
33 changed files with 224 additions and 224 deletions

34
CHANGES
View File

@ -90,7 +90,7 @@
A window may be restarted with the respawn-window command: A window may be restarted with the respawn-window command:
respawn-window [-k] [command] respawn-window [-k] [command]
If -k is given, any existing process running in the window is killed; If -k is given, any existing process running in the window is killed;
if command is omitted, the same command as when the window was first if command is omitted, the same command as when the window was first
created is used. created is used.
@ -149,7 +149,7 @@
* buffer-limit option to set maximum size of buffer stack. Default is 9. * buffer-limit option to set maximum size of buffer stack. Default is 9.
* Initial buffer improvements. Each session has a stack of buffers and each * Initial buffer improvements. Each session has a stack of buffers and each
buffer command takes a -b option to manipulate items on the stack. If -b buffer command takes a -b option to manipulate items on the stack. If -b
is omitted, the top entry is used. The following commands are currently is omitted, the top entry is used. The following commands are currently
available: available:
set-buffer [-b index] [-t target-session] string set-buffer [-b index] [-t target-session] string
@ -174,10 +174,10 @@
18 June 2008 18 June 2008
* New option, set-titles. On by default, this attempts to set the window title * New option, set-titles. On by default, this attempts to set the window title
using the \e]2;...\007 xterm code. using the \e]2;...\007 xterm code.
Note that elinks requires the STY environment variable (used by screen) to be Note that elinks requires the STY environment variable (used by screen) to be
set before it will set the window title. So, if you want window titles set by set before it will set the window title. So, if you want window titles set by
elinks, set STY before running it (any value will do). I can't do this for all elinks, set STY before running it (any value will do). I can't do this for all
windows since setting it to an invalid value breaks screen. windows since setting it to an invalid value breaks screen.
* Show arrows at either end of status line when scrolled if more windows * Show arrows at either end of status line when scrolled if more windows
@ -236,8 +236,8 @@
* Completely reorganise command parsing. Much more common code in cmd-generic.c * Completely reorganise command parsing. Much more common code in cmd-generic.c
and a new way of specifying windows, clients or sessions. Now, most commands and a new way of specifying windows, clients or sessions. Now, most commands
take a -t argument, which specifies a client, a session, or a window target. take a -t argument, which specifies a client, a session, or a window target.
Clients and sessions are given alone (sessions are fnmatch(3)d and Clients and sessions are given alone (sessions are fnmatch(3)d and
clients currently not), windows are give by (client|session):index. For clients currently not), windows are give by (client|session):index. For
example, if a user is in session "1" window 0 on /dev/ttypi, these should all example, if a user is in session "1" window 0 on /dev/ttypi, these should all
be equivalent: be equivalent:
@ -261,7 +261,7 @@
is annoying. But then using non-flagged arguments would mean renaming the is annoying. But then using non-flagged arguments would mean renaming the
current window would need to be something like: current window would need to be something like:
tmux renamew : newname tmux renamew : newname
It might be better not to try and be so consistent; comments to the usual It might be better not to try and be so consistent; comments to the usual
@ -300,7 +300,7 @@
accepts -c as well. accepts -c as well.
* -s to specify session name now supports fnmatch(3) wildcards; if multiple * -s to specify session name now supports fnmatch(3) wildcards; if multiple
sessions are found, or if no -s is specified, the most newly created is used. sessions are found, or if no -s is specified, the most newly created is used.
* If no command is specified, assume new-session. As a byproduct, clean up * If no command is specified, assume new-session. As a byproduct, clean up
command default values into seperate init functions. command default values into seperate init functions.
* kill-server command. * kill-server command.
@ -459,7 +459,7 @@
$ tmux bind q switch 0 $ tmux bind q switch 0
$ tmux bind w switch 1 $ tmux bind w switch 1
Then you can switch between sessions 0 and 1 with a key :-). Then you can switch between sessions 0 and 1 with a key :-).
* (nicm) Accept "-c client-tty" on command line to allow client manipulation * (nicm) Accept "-c client-tty" on command line to allow client manipulation
commands, and change detach-/refresh-session to detach-/refresh-client (this commands, and change detach-/refresh-session to detach-/refresh-client (this
loses the -a behaviour, but at some point -session versions may return, and loses the -a behaviour, but at some point -session versions may return, and
@ -468,7 +468,7 @@
12 November 2007 12 November 2007
* (nicm) If the terminal supports default colours (AX present), force black * (nicm) If the terminal supports default colours (AX present), force black
background and white foreground to default. This is useful on transparent background and white foreground to default. This is useful on transparent
*terms for programs which don't do it themselves (like most(1)). *terms for programs which don't do it themselves (like most(1)).
* (nicm) Fill in the rest of the man page. * (nicm) Fill in the rest of the man page.
@ -600,7 +600,7 @@
* (nicm) Deleting/inserting lines should follow scrolling region. Fix. * (nicm) Deleting/inserting lines should follow scrolling region. Fix.
* (nicm) Allow creation of detached sessions: "tmux new-session -d". * (nicm) Allow creation of detached sessions: "tmux new-session -d".
* (nicm) Permit error messages to be passed back for transient clients like * (nicm) Permit error messages to be passed back for transient clients like
rename. Also make rename -i work. rename. Also make rename -i work.
* (nicm) Pass through bell in any window to current. * (nicm) Pass through bell in any window to current.
@ -612,11 +612,11 @@
- Split key parsing off into a separate file. - Split key parsing off into a separate file.
This is step one towards hopefully allowing a status line. It requires This is step one towards hopefully allowing a status line. It requires
that we output data as if the terminal had one line less than it really does - that we output data as if the terminal had one line less than it really does -
a serious problem when it comes to things like scrolling. This change a serious problem when it comes to things like scrolling. This change
consolidates all the range checking and limiting together which should make consolidates all the range checking and limiting together which should make
it easier. it easier.
* (mxey) Added window remaming, like "tmux rename [-s session] [-i index] name" * (mxey) Added window remaming, like "tmux rename [-s session] [-i index] name"
27 September 2007 27 September 2007
* Split "tmux list" into "tmux list-sessions" (ls) and "list-windows" (lsw). * Split "tmux list" into "tmux list-sessions" (ls) and "list-windows" (lsw).
@ -636,7 +636,7 @@
tmux -s/socket -nabc new tmux -s/socket -nabc new
Becomes: Becomes:
tmux -S/socket new -sabc tmux -S/socket new -sabc
* Major tidy and split of client/server code. * Major tidy and split of client/server code.
@ -666,7 +666,7 @@
09 July 2007 09 July 2007
* Initial import to CVS. Basic functions are working, albeit with a couple of * Initial import to CVS. Basic functions are working, albeit with a couple of
showstopper memory bugs and many missing features. Detaching, reattaching, showstopper memory bugs and many missing features. Detaching, reattaching,
creating new sessions, listing sessions work acceptably for using with shells. creating new sessions, listing sessions work acceptably for using with shells.
Simple curses programs (top, systat, tetris) and more complicated ones (mutt, Simple curses programs (top, systat, tetris) and more complicated ones (mutt,
@ -674,4 +674,4 @@
(including mutt, emacs). No status bar yet and no key remapping or other (including mutt, emacs). No status bar yet and no key remapping or other
customisation. customisation.
$Id: CHANGES,v 1.161 2008-09-25 20:08:51 nicm Exp $ $Id: CHANGES,v 1.162 2008-09-26 06:45:25 nicm Exp $

View File

@ -1,4 +1,4 @@
# $Id: GNUmakefile,v 1.41 2008-09-25 23:28:12 nicm Exp $ # $Id: GNUmakefile,v 1.42 2008-09-26 06:45:25 nicm Exp $
.PHONY: clean .PHONY: clean
@ -66,7 +66,7 @@ CFLAGS+= -DNO_STRLCPY -DNO_STRTONUM -DNO_TREE_H -DNO_SETPROCTITLE \
-DBROKEN_VSNPRINTF -D_SGI_SOURCE -std=c99 -DBROKEN_VSNPRINTF -D_SGI_SOURCE -std=c99
LDFLAGS+= -L/usr/local/lib LDFLAGS+= -L/usr/local/lib
LIBS+= -lgen LIBS+= -lgen
endif endif
ifeq ($(shell uname),SunOS) ifeq ($(shell uname),SunOS)
INCDIRS+= -Icompat -I/usr/local/include/ncurses INCDIRS+= -Icompat -I/usr/local/include/ncurses
@ -76,7 +76,7 @@ CFLAGS+= -DNO_STRTONUM -DNO_TREE_H -DNO_PATHS_H -DNO_SETPROCTITLE \
-DNO_DAEMON -DNO_FORKPTY -DNO_PROGNAME -DNO_ASPRINTF -DNO_FGETLN -DNO_DAEMON -DNO_FORKPTY -DNO_PROGNAME -DNO_ASPRINTF -DNO_FGETLN
LDFLAGS+= -L/usr/local/lib LDFLAGS+= -L/usr/local/lib
LIBS+= -lsocket -lnsl LIBS+= -lsocket -lnsl
endif endif
ifeq ($(shell uname),Darwin) ifeq ($(shell uname),Darwin)
INCDIRS+= -Icompat INCDIRS+= -Icompat

View File

@ -1,4 +1,4 @@
/* $Id: cmd-command-prompt.c,v 1.5 2008-07-25 17:20:40 nicm Exp $ */ /* $Id: cmd-command-prompt.c,v 1.6 2008-09-26 06:45:25 nicm Exp $ */
/* /*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -82,7 +82,7 @@ cmd_command_prompt_callback(void *data, char *s)
} }
if (cmd == NULL) if (cmd == NULL)
return; return;
ctx.msgdata = NULL; ctx.msgdata = NULL;
ctx.cursession = c->session; ctx.cursession = c->session;
ctx.curclient = c; ctx.curclient = c;

View File

@ -1,4 +1,4 @@
/* $Id: cmd-delete-buffer.c,v 1.1 2008-06-20 17:31:48 nicm Exp $ */ /* $Id: cmd-delete-buffer.c,v 1.2 2008-09-26 06:45:25 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -57,7 +57,7 @@ cmd_delete_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
if (paste_free_index(&s->buffers, data->buffer) != 0) if (paste_free_index(&s->buffers, data->buffer) != 0)
ctx->error(ctx, "no buffer %d", data->buffer); ctx->error(ctx, "no buffer %d", data->buffer);
} }
if (ctx->cmdclient != NULL) if (ctx->cmdclient != NULL)
server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0); server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
} }

View File

@ -1,4 +1,4 @@
/* $Id: cmd-list-buffers.c,v 1.3 2008-06-20 19:03:45 nicm Exp $ */ /* $Id: cmd-list-buffers.c,v 1.4 2008-09-26 06:45:25 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -61,7 +61,7 @@ cmd_list_buffers_exec(struct cmd *self, struct cmd_ctx *ctx)
size = 0; size = 0;
tmp = NULL; tmp = NULL;
} }
idx = 0; idx = 0;
while ((pb = paste_walk_stack(&s->buffers, &idx)) != NULL) { while ((pb = paste_walk_stack(&s->buffers, &idx)) != NULL) {
if (tmp != NULL) { if (tmp != NULL) {

View File

@ -1,4 +1,4 @@
/* $Id: cmd-list-commands.c,v 1.1 2008-06-23 22:24:16 nicm Exp $ */ /* $Id: cmd-list-commands.c,v 1.2 2008-09-26 06:45:25 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -43,9 +43,9 @@ void
cmd_list_commands_exec(unused struct cmd *self, struct cmd_ctx *ctx) cmd_list_commands_exec(unused struct cmd *self, struct cmd_ctx *ctx)
{ {
const struct cmd_entry **entryp; const struct cmd_entry **entryp;
for (entryp = cmd_table; *entryp != NULL; entryp++) for (entryp = cmd_table; *entryp != NULL; entryp++)
ctx->print(ctx, "%s %s", (*entryp)->name, (*entryp)->usage); ctx->print(ctx, "%s %s", (*entryp)->name, (*entryp)->usage);
if (ctx->cmdclient != NULL) if (ctx->cmdclient != NULL)
server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0); server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);

View File

@ -1,4 +1,4 @@
/* $Id: cmd-list-windows.c,v 1.24 2008-09-25 20:08:52 nicm Exp $ */ /* $Id: cmd-list-windows.c,v 1.25 2008-09-26 06:45:25 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -65,7 +65,7 @@ cmd_list_windows_exec(struct cmd *self, struct cmd_ctx *ctx)
size += gd->size[i] * sizeof **gd->data; size += gd->size[i] * sizeof **gd->data;
size += gd->hsize * (sizeof *gd->data); size += gd->hsize * (sizeof *gd->data);
size += gd->hsize * (sizeof *gd->size); size += gd->hsize * (sizeof *gd->size);
if (w->fd != -1) if (w->fd != -1)
name = ttyname(w->fd); name = ttyname(w->fd);
else else

View File

@ -1,4 +1,4 @@
/* $Id: cmd-send-prefix.c,v 1.18 2008-06-23 07:41:21 nicm Exp $ */ /* $Id: cmd-send-prefix.c,v 1.19 2008-09-26 06:45:25 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -49,7 +49,7 @@ cmd_send_prefix_exec(struct cmd *self, struct cmd_ctx *ctx)
if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL) if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL)
return; return;
key = options_get_number(&s->options, "prefix"); key = options_get_number(&s->options, "prefix");
window_key(wl->window, ctx->curclient, key); window_key(wl->window, ctx->curclient, key);

View File

@ -1,4 +1,4 @@
/* $Id: cmd-set-buffer.c,v 1.2 2008-06-20 18:45:35 nicm Exp $ */ /* $Id: cmd-set-buffer.c,v 1.3 2008-09-26 06:45:25 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -59,7 +59,7 @@ cmd_set_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
if (paste_replace(&s->buffers, data->buffer, data->arg) != 0) if (paste_replace(&s->buffers, data->buffer, data->arg) != 0)
ctx->error(ctx, "no buffer %d", data->buffer); ctx->error(ctx, "no buffer %d", data->buffer);
} }
if (ctx->cmdclient != NULL) if (ctx->cmdclient != NULL)
server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0); server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
} }

View File

@ -1,4 +1,4 @@
/* $Id: cmd-set-option.c,v 1.42 2008-09-25 23:28:12 nicm Exp $ */ /* $Id: cmd-set-option.c,v 1.43 2008-09-26 06:45:25 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -59,7 +59,7 @@ const char *set_option_bell_action_list[] = {
"none", "any", "current", NULL "none", "any", "current", NULL
}; };
const char *set_option_mode_keys_list[] = { const char *set_option_mode_keys_list[] = {
"emacs", "vi", NULL "emacs", "vi", NULL
}; };
const struct set_option_entry set_option_table[NSETOPTION] = { const struct set_option_entry set_option_table[NSETOPTION] = {
{ "bell-action", SET_OPTION_CHOICE, 0, 0, set_option_bell_action_list }, { "bell-action", SET_OPTION_CHOICE, 0, 0, set_option_bell_action_list },
@ -79,7 +79,7 @@ const struct set_option_entry set_option_table[NSETOPTION] = {
{ "status-right", SET_OPTION_STRING, 0, 0, NULL }, { "status-right", SET_OPTION_STRING, 0, 0, NULL },
}; };
void set_option_string(struct cmd_ctx *, void set_option_string(struct cmd_ctx *,
struct options *, const struct set_option_entry *, char *); struct options *, const struct set_option_entry *, char *);
void set_option_number(struct cmd_ctx *, void set_option_number(struct cmd_ctx *,
struct options *, const struct set_option_entry *, char *); struct options *, const struct set_option_entry *, char *);
@ -240,7 +240,7 @@ set_option_number(struct cmd_ctx *ctx, struct options *oo,
} }
options_set_number(oo, entry->name, number); options_set_number(oo, entry->name, number);
} }
void void
set_option_key(struct cmd_ctx *ctx, struct options *oo, set_option_key(struct cmd_ctx *ctx, struct options *oo,
const struct set_option_entry *entry, char *value) const struct set_option_entry *entry, char *value)
@ -257,9 +257,9 @@ set_option_key(struct cmd_ctx *ctx, struct options *oo,
return; return;
} }
options_set_number(oo, entry->name, key); options_set_number(oo, entry->name, key);
} }
void void
set_option_colour(struct cmd_ctx *ctx, struct options *oo, set_option_colour(struct cmd_ctx *ctx, struct options *oo,
const struct set_option_entry *entry, char *value) const struct set_option_entry *entry, char *value)
@ -270,21 +270,21 @@ set_option_colour(struct cmd_ctx *ctx, struct options *oo,
ctx->error(ctx, "empty value"); ctx->error(ctx, "empty value");
return; return;
} }
if ((colour = colour_fromstring(value)) > 8) { if ((colour = colour_fromstring(value)) > 8) {
ctx->error(ctx, "bad colour: %s", value); ctx->error(ctx, "bad colour: %s", value);
return; return;
} }
options_set_number(oo, entry->name, colour); options_set_number(oo, entry->name, colour);
} }
void void
set_option_flag(struct cmd_ctx *ctx, struct options *oo, set_option_flag(struct cmd_ctx *ctx, struct options *oo,
const struct set_option_entry *entry, char *value) const struct set_option_entry *entry, char *value)
{ {
int flag; int flag;
if (value == NULL || *value == '\0') if (value == NULL || *value == '\0')
flag = !options_get_number(oo, entry->name); flag = !options_get_number(oo, entry->name);
else { else {
@ -304,7 +304,7 @@ set_option_flag(struct cmd_ctx *ctx, struct options *oo,
options_set_number(oo, entry->name, flag); options_set_number(oo, entry->name, flag);
} }
void void
set_option_choice(struct cmd_ctx *ctx, struct options *oo, set_option_choice(struct cmd_ctx *ctx, struct options *oo,
const struct set_option_entry *entry, char *value) const struct set_option_entry *entry, char *value)

View File

@ -1,4 +1,4 @@
/* $Id: cmd-show-buffer.c,v 1.1 2008-06-20 08:36:20 nicm Exp $ */ /* $Id: cmd-show-buffer.c,v 1.2 2008-09-26 06:45:26 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -68,7 +68,7 @@ cmd_show_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
buf = xmalloc(size + 1); buf = xmalloc(size + 1);
len = 0; len = 0;
ptr = pb->data; ptr = pb->data;
do { do {
buf[len++] = *ptr++; buf[len++] = *ptr++;
@ -83,7 +83,7 @@ cmd_show_buffer_exec(struct cmd *self, struct cmd_ctx *ctx)
buf[len] = '\0'; buf[len] = '\0';
ctx->print(ctx, buf); ctx->print(ctx, buf);
} }
if (ctx->cmdclient != NULL) if (ctx->cmdclient != NULL)
server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0); server_write_client(ctx->cmdclient, MSG_EXIT, NULL, 0);
} }

View File

@ -1,4 +1,4 @@
/* $Id: cmd-string.c,v 1.6 2008-08-01 20:25:13 nicm Exp $ */ /* $Id: cmd-string.c,v 1.7 2008-09-26 06:45:26 nicm Exp $ */
/* /*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -48,10 +48,10 @@ cmd_string_ungetc(unused const char *s, size_t *p)
(*p)--; (*p)--;
} }
/* /*
* Parse command string. Returns -1 on error. If returning -1, cause is error * Parse command string. Returns -1 on error. If returning -1, cause is error
* string, or NULL for empty command. * string, or NULL for empty command.
*/ */
int int
cmd_string_parse(const char *s, struct cmd **cmd, char **cause) cmd_string_parse(const char *s, struct cmd **cmd, char **cause)
{ {
@ -81,7 +81,7 @@ cmd_string_parse(const char *s, struct cmd **cmd, char **cause)
*cmd = NULL; *cmd = NULL;
rval = -1; rval = -1;
p = 0; p = 0;
for (;;) { for (;;) {
ch = cmd_string_getc(s, &p); ch = cmd_string_getc(s, &p);
@ -130,7 +130,7 @@ cmd_string_parse(const char *s, struct cmd **cmd, char **cause)
break; break;
if (argc == 0) if (argc == 0)
goto out; goto out;
*cmd = cmd_parse(argc, argv, cause); *cmd = cmd_parse(argc, argv, cause);
rval = 0; rval = 0;
goto out; goto out;
@ -143,10 +143,10 @@ cmd_string_parse(const char *s, struct cmd **cmd, char **cause)
break; break;
} }
} }
error: error:
xasprintf(cause, "bad command: %s", s); xasprintf(cause, "bad command: %s", s);
out: out:
if (buf != NULL) if (buf != NULL)
xfree(buf); xfree(buf);
@ -252,7 +252,7 @@ cmd_string_variable(const char *s, size_t *p)
buf = xrealloc(buf, 1, len + 1); buf = xrealloc(buf, 1, len + 1);
buf[len++] = ch; buf[len++] = ch;
for(;;) { for(;;) {
ch = cmd_string_getc(s, p); ch = cmd_string_getc(s, p);
if (ch == EOF || !cmd_string_other(ch)) if (ch == EOF || !cmd_string_other(ch))
@ -284,5 +284,5 @@ cmd_string_variable(const char *s, size_t *p)
error: error:
if (buf != NULL) if (buf != NULL)
xfree(buf); xfree(buf);
return (NULL); return (NULL);
} }

6
cmd.c
View File

@ -1,4 +1,4 @@
/* $Id: cmd.c,v 1.64 2008-09-25 23:28:15 nicm Exp $ */ /* $Id: cmd.c,v 1.65 2008-09-26 06:45:26 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -93,13 +93,13 @@ cmd_complete(const char *s)
continue; continue;
ARRAY_ADD(&list, (*entryp)->name); ARRAY_ADD(&list, (*entryp)->name);
} }
/* If none, bail now with the original string. */ /* If none, bail now with the original string. */
if (ARRAY_LENGTH(&list) == 0) { if (ARRAY_LENGTH(&list) == 0) {
ARRAY_FREE(&list); ARRAY_FREE(&list);
return (xstrdup(s)); return (xstrdup(s));
} }
/* If an exact match, return it, with a trailing space. */ /* If an exact match, return it, with a trailing space. */
if (ARRAY_LENGTH(&list) == 1) { if (ARRAY_LENGTH(&list) == 1) {
xasprintf(&s2, "%s ", ARRAY_FIRST(&list)); xasprintf(&s2, "%s ", ARRAY_FIRST(&list));

View File

@ -1,4 +1,4 @@
/* $Id: asprintf.c,v 1.3 2008-06-23 21:54:48 nicm Exp $ */ /* $Id: asprintf.c,v 1.4 2008-09-26 06:45:28 nicm Exp $ */
/* /*
* Copyright (c) 2006 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2006 Nicholas Marriott <nicm@users.sourceforge.net>
@ -58,32 +58,32 @@ error:
return (-1); return (-1);
} }
#else #else
int int
vasprintf(char **ret, const char *fmt, va_list ap) vasprintf(char **ret, const char *fmt, va_list ap)
{ {
va_list aq; va_list aq;
size_t len; size_t len;
char *buf; char *buf;
int n; int n;
len = 64; len = 64;
buf = xmalloc(len); buf = xmalloc(len);
for (;;) { for (;;) {
va_copy(aq, ap); va_copy(aq, ap);
n = vsnprintf(buf, len, fmt, aq); n = vsnprintf(buf, len, fmt, aq);
va_end(aq); va_end(aq);
if (n != -1) { if (n != -1) {
*ret = buf; *ret = buf;
return (n); return (n);
} }
if (len > SIZE_MAX / 2) { if (len > SIZE_MAX / 2) {
xfree(buf); xfree(buf);
return (-1); return (-1);
} }
len *= 2; len *= 2;
} }
} }
#endif #endif

View File

@ -1,4 +1,4 @@
/* $Id: forkpty-irix.c,v 1.1 2008-06-23 21:54:48 nicm Exp $ */ /* $Id: forkpty-irix.c,v 1.2 2008-09-26 06:45:28 nicm Exp $ */
/* /*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -50,7 +50,7 @@ forkpty(int *master,
close(*master); close(*master);
setsid(); setsid();
old = signal(SIGHUP, SIG_IGN); old = signal(SIGHUP, SIG_IGN);
vhangup(); vhangup();
signal(SIGHUP, old); signal(SIGHUP, old);

View File

@ -1,4 +1,4 @@
/* $Id: grid-view.c,v 1.1 2008-09-25 20:08:52 nicm Exp $ */ /* $Id: grid-view.c,v 1.2 2008-09-26 06:45:26 nicm Exp $ */
/* /*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -133,7 +133,7 @@ grid_view_insert_lines_region(
rlower = grid_view_y(gd, rlower); rlower = grid_view_y(gd, rlower);
py = grid_view_y(gd, py); py = grid_view_y(gd, py);
grid_move_lines(gd, py + ny, py, (rlower + 1) - py - ny); grid_move_lines(gd, py + ny, py, (rlower + 1) - py - ny);
} }
@ -178,7 +178,7 @@ grid_view_insert_cells(struct grid_data *gd, u_int px, u_int py, u_int nx)
px = grid_view_x(gd, px); px = grid_view_x(gd, px);
sx = grid_view_x(gd, gd->sx); sx = grid_view_x(gd, gd->sx);
grid_move_cells(gd, px + nx, px, py, (sx - 1) - (px + nx)); grid_move_cells(gd, px + nx, px, py, (sx - 1) - (px + nx));
} }
@ -193,7 +193,7 @@ grid_view_delete_cells(struct grid_data *gd, u_int px, u_int py, u_int nx)
px = grid_view_x(gd, px); px = grid_view_x(gd, px);
sx = grid_view_x(gd, gd->sx); sx = grid_view_x(gd, gd->sx);
grid_move_cells(gd, px, px + nx, py, (sx - 1) - (px + nx)); grid_move_cells(gd, px, px + nx, py, (sx - 1) - (px + nx));
} }

6
grid.c
View File

@ -1,4 +1,4 @@
/* $Id: grid.c,v 1.1 2008-09-25 20:08:52 nicm Exp $ */ /* $Id: grid.c,v 1.2 2008-09-26 06:45:26 nicm Exp $ */
/* /*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -214,14 +214,14 @@ grid_clear(struct grid_data *gd, u_int px, u_int py, u_int nx, u_int ny)
void void
grid_fill(struct grid_data *gd, grid_fill(struct grid_data *gd,
const struct grid_cell *gc, u_int px, u_int py, u_int nx, u_int ny) const struct grid_cell *gc, u_int px, u_int py, u_int nx, u_int ny)
{ {
u_int xx, yy; u_int xx, yy;
GRID_DEBUG(gd, "px=%u, py=%u, nx=%u, ny=%u", px, py, nx, ny); GRID_DEBUG(gd, "px=%u, py=%u, nx=%u, ny=%u", px, py, nx, ny);
if (nx == 0 || ny == 0) if (nx == 0 || ny == 0)
return; return;
grid_check_x(gd, px); grid_check_x(gd, px);
grid_check_x(gd, px + nx - 1); grid_check_x(gd, px + nx - 1);
grid_check_y(gd, py); grid_check_y(gd, py);

16
input.c
View File

@ -1,4 +1,4 @@
/* $Id: input.c,v 1.59 2008-09-25 20:08:52 nicm Exp $ */ /* $Id: input.c,v 1.60 2008-09-26 06:45:26 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -518,7 +518,7 @@ void
input_handle_character(u_char ch, struct input_ctx *ictx) input_handle_character(u_char ch, struct input_ctx *ictx)
{ {
if (ch > 0x7f) { if (ch > 0x7f) {
/* /*
* UTF-8 sequence. * UTF-8 sequence.
* *
* 11000010-11011111 C2-DF start of 2-byte sequence * 11000010-11011111 C2-DF start of 2-byte sequence
@ -528,7 +528,7 @@ input_handle_character(u_char ch, struct input_ctx *ictx)
memset(ictx->utf8_buf, 0xff, sizeof ictx->utf8_buf); memset(ictx->utf8_buf, 0xff, sizeof ictx->utf8_buf);
ictx->utf8_buf[0] = ch; ictx->utf8_buf[0] = ch;
ictx->utf8_off = 1; ictx->utf8_off = 1;
if (ch >= 0xc2 && ch <= 0xdf) { if (ch >= 0xc2 && ch <= 0xdf) {
log_debug2("-- u2 %zu: %hhu (%c)", ictx->off, ch, ch); log_debug2("-- u2 %zu: %hhu (%c)", ictx->off, ch, ch);
input_state(ictx, input_state_utf8); input_state(ictx, input_state_utf8);
@ -541,7 +541,7 @@ input_handle_character(u_char ch, struct input_ctx *ictx)
ictx->utf8_len = 2; ictx->utf8_len = 2;
return; return;
} }
if (ch >= 0xf0 && ch <= 0xf4) { if (ch >= 0xf0 && ch <= 0xf4) {
log_debug2("-- u4 %zu: %hhu (%c)", ictx->off, ch, ch); log_debug2("-- u4 %zu: %hhu (%c)", ictx->off, ch, ch);
input_state(ictx, input_state_utf8); input_state(ictx, input_state_utf8);
ictx->utf8_len = 3; ictx->utf8_len = 3;
@ -663,7 +663,7 @@ input_handle_standard_two(u_char ch, struct input_ctx *ictx)
screen_write_mousemode(&ictx->ctx, 0); screen_write_mousemode(&ictx->ctx, 0);
screen_write_clearscreen(&ictx->ctx); screen_write_clearscreen(&ictx->ctx);
screen_write_cursormove(&ictx->ctx, 0, 0); screen_write_cursormove(&ictx->ctx, 0, 0);
break; break;
case 'k': case 'k':
input_start_string(ictx, STRING_NAME); input_start_string(ictx, STRING_NAME);
@ -1145,7 +1145,7 @@ input_handle_sequence_sgr(struct input_ctx *ictx)
return; return;
if (o != 5) if (o != 5)
continue; continue;
i++; i++;
if (input_get_argument(ictx, i, &o, 0) != 0) if (input_get_argument(ictx, i, &o, 0) != 0)
return; return;
@ -1158,7 +1158,7 @@ input_handle_sequence_sgr(struct input_ctx *ictx)
} }
continue; continue;
} }
switch (m) { switch (m) {
case 0: case 0:
case 10: case 10:
@ -1213,7 +1213,7 @@ input_handle_sequence_sgr(struct input_ctx *ictx)
case 44: case 44:
case 45: case 45:
case 46: case 46:
case 47: case 47:
gc->flags &= ~GRID_FLAG_BG256; gc->flags &= ~GRID_FLAG_BG256;
gc->bg = m - 40; gc->bg = m - 40;
break; break;

4
log.c
View File

@ -1,4 +1,4 @@
/* $Id: log.c,v 1.7 2008-09-25 20:31:19 nicm Exp $ */ /* $Id: log.c,v 1.8 2008-09-26 06:45:26 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -72,7 +72,7 @@ log_open_file(int level, const char *path)
log_file = fopen(path, "w"); log_file = fopen(path, "w");
if (log_file == NULL) if (log_file == NULL)
return; return;
log_type = LOG_TYPE_FILE; log_type = LOG_TYPE_FILE;
log_level = level; log_level = level;

View File

@ -1,4 +1,4 @@
/* $Id: screen-redraw.c,v 1.12 2008-09-25 20:08:54 nicm Exp $ */ /* $Id: screen-redraw.c,v 1.13 2008-09-26 06:45:26 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -132,7 +132,7 @@ screen_redraw_cell(struct screen_redraw_ctx *ctx, u_int px, u_int py)
ctx->write(ctx->data, TTY_CURSORMOVE, ctx->s->cx, ctx->s->cy); ctx->write(ctx->data, TTY_CURSORMOVE, ctx->s->cx, ctx->s->cy);
} }
gc = grid_view_peek_cell(ctx->s->grid, px, py); gc = grid_view_peek_cell(ctx->s->grid, px, py);
if (screen_check_selection(ctx->s, px, py)) { if (screen_check_selection(ctx->s, px, py)) {
memcpy(&hc, gc, sizeof hc); memcpy(&hc, gc, sizeof hc);
hc.attr |= GRID_ATTR_REVERSE; hc.attr |= GRID_ATTR_REVERSE;

View File

@ -1,4 +1,4 @@
/* $Id: screen-write.c,v 1.14 2008-09-25 20:08:54 nicm Exp $ */ /* $Id: screen-write.c,v 1.15 2008-09-26 06:45:26 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -152,7 +152,7 @@ screen_write_cursordown(struct screen_write_ctx *ctx, u_int ny)
ny = screen_size_y(s) - 1 - s->cy; ny = screen_size_y(s) - 1 - s->cy;
if (ny == 0) if (ny == 0)
ny = 1; ny = 1;
s->cy += ny; s->cy += ny;
if (ctx->write != NULL) if (ctx->write != NULL)
@ -171,7 +171,7 @@ screen_write_cursorright(struct screen_write_ctx *ctx, u_int nx)
nx = 1; nx = 1;
s->cx += nx; s->cx += nx;
if (ctx->write != NULL) if (ctx->write != NULL)
ctx->write(ctx->data, TTY_CURSORRIGHT, nx); ctx->write(ctx->data, TTY_CURSORRIGHT, nx);
} }
@ -181,14 +181,14 @@ void
screen_write_cursorleft(struct screen_write_ctx *ctx, u_int nx) screen_write_cursorleft(struct screen_write_ctx *ctx, u_int nx)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
if (nx > s->cx) if (nx > s->cx)
nx = s->cx; nx = s->cx;
if (nx == 0) if (nx == 0)
nx = 1; nx = 1;
s->cx -= nx; s->cx -= nx;
if (ctx->write != NULL) if (ctx->write != NULL)
ctx->write(ctx->data, TTY_CURSORLEFT, nx); ctx->write(ctx->data, TTY_CURSORLEFT, nx);
} }
@ -198,14 +198,14 @@ void
screen_write_insertcharacter(struct screen_write_ctx *ctx, u_int nx) screen_write_insertcharacter(struct screen_write_ctx *ctx, u_int nx)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
if (nx > screen_size_x(s) - 1 - s->cx) if (nx > screen_size_x(s) - 1 - s->cx)
nx = screen_size_x(s) - 1 - s->cx; nx = screen_size_x(s) - 1 - s->cx;
if (nx == 0) if (nx == 0)
nx = 1; nx = 1;
grid_view_insert_cells(s->grid, s->cx, s->cy, nx); grid_view_insert_cells(s->grid, s->cx, s->cy, nx);
if (ctx->write != NULL) if (ctx->write != NULL)
ctx->write(ctx->data, TTY_INSERTCHARACTER, nx); ctx->write(ctx->data, TTY_INSERTCHARACTER, nx);
} }
@ -215,14 +215,14 @@ void
screen_write_deletecharacter(struct screen_write_ctx *ctx, u_int nx) screen_write_deletecharacter(struct screen_write_ctx *ctx, u_int nx)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
if (nx > screen_size_x(s) - 1 - s->cx) if (nx > screen_size_x(s) - 1 - s->cx)
nx = screen_size_x(s) - 1 - s->cx; nx = screen_size_x(s) - 1 - s->cx;
if (nx == 0) if (nx == 0)
nx = 1; nx = 1;
grid_view_delete_cells(s->grid, s->cx, s->cy, nx); grid_view_delete_cells(s->grid, s->cx, s->cy, nx);
if (ctx->write != NULL) if (ctx->write != NULL)
ctx->write(ctx->data, TTY_DELETECHARACTER, nx); ctx->write(ctx->data, TTY_DELETECHARACTER, nx);
} }
@ -243,8 +243,8 @@ screen_write_insertline(struct screen_write_ctx *ctx, u_int ny)
else { else {
grid_view_insert_lines_region( grid_view_insert_lines_region(
s->grid, s->rupper, s->rlower, s->cy, ny); s->grid, s->rupper, s->rlower, s->cy, ny);
} }
if (ctx->write != NULL) if (ctx->write != NULL)
ctx->write(ctx->data, TTY_INSERTLINE, ny); ctx->write(ctx->data, TTY_INSERTLINE, ny);
} }
@ -276,9 +276,9 @@ void
screen_write_clearline(struct screen_write_ctx *ctx) screen_write_clearline(struct screen_write_ctx *ctx)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
grid_view_clear(s->grid, 0, s->cy, screen_size_x(s), 1); grid_view_clear(s->grid, 0, s->cy, screen_size_x(s), 1);
if (ctx->write != NULL) if (ctx->write != NULL)
ctx->write(ctx->data, TTY_CLEARLINE); ctx->write(ctx->data, TTY_CLEARLINE);
} }
@ -288,9 +288,9 @@ void
screen_write_clearendofline(struct screen_write_ctx *ctx) screen_write_clearendofline(struct screen_write_ctx *ctx)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
grid_view_clear(s->grid, s->cx, s->cy, screen_size_x(s) - s->cx, 1); grid_view_clear(s->grid, s->cx, s->cy, screen_size_x(s) - s->cx, 1);
if (ctx->write != NULL) if (ctx->write != NULL)
ctx->write(ctx->data, TTY_CLEARENDOFLINE); ctx->write(ctx->data, TTY_CLEARENDOFLINE);
} }
@ -300,9 +300,9 @@ void
screen_write_clearstartofline(struct screen_write_ctx *ctx) screen_write_clearstartofline(struct screen_write_ctx *ctx)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1); grid_view_clear(s->grid, 0, s->cy, s->cx + 1, 1);
if (ctx->write != NULL) if (ctx->write != NULL)
ctx->write(ctx->data, TTY_CLEARSTARTOFLINE); ctx->write(ctx->data, TTY_CLEARSTARTOFLINE);
} }
@ -312,7 +312,7 @@ void
screen_write_cursormove(struct screen_write_ctx *ctx, u_int px, u_int py) screen_write_cursormove(struct screen_write_ctx *ctx, u_int px, u_int py)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
if (px > screen_size_x(s) - 1) if (px > screen_size_x(s) - 1)
px = screen_size_x(s) - 1; px = screen_size_x(s) - 1;
if (py > screen_size_y(s) - 1) if (py > screen_size_y(s) - 1)
@ -320,7 +320,7 @@ screen_write_cursormove(struct screen_write_ctx *ctx, u_int px, u_int py)
s->cx = px; s->cx = px;
s->cy = py; s->cy = py;
if (ctx->write != NULL) if (ctx->write != NULL)
ctx->write(ctx->data, TTY_CURSORMOVE, px, py); ctx->write(ctx->data, TTY_CURSORMOVE, px, py);
} }
@ -330,12 +330,12 @@ void
screen_write_cursormode(struct screen_write_ctx *ctx, int state) screen_write_cursormode(struct screen_write_ctx *ctx, int state)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
if (state) if (state)
s->mode |= MODE_CURSOR; s->mode |= MODE_CURSOR;
else else
s->mode &= ~MODE_CURSOR; s->mode &= ~MODE_CURSOR;
if (ctx->write != NULL) if (ctx->write != NULL)
ctx->write(ctx->data, TTY_CURSORMODE, state); ctx->write(ctx->data, TTY_CURSORMODE, state);
} }
@ -345,12 +345,12 @@ void
screen_write_reverseindex(struct screen_write_ctx *ctx) screen_write_reverseindex(struct screen_write_ctx *ctx)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
if (s->cy == s->rupper) if (s->cy == s->rupper)
grid_view_scroll_region_down(s->grid, s->rupper, s->rlower); grid_view_scroll_region_down(s->grid, s->rupper, s->rlower);
else if (s->cy > 0) else if (s->cy > 0)
s->cy--; s->cy--;
if (ctx->write != NULL) if (ctx->write != NULL)
ctx->write(ctx->data, TTY_REVERSEINDEX); ctx->write(ctx->data, TTY_REVERSEINDEX);
} }
@ -361,7 +361,7 @@ screen_write_scrollregion(
struct screen_write_ctx *ctx, u_int rupper, u_int rlower) struct screen_write_ctx *ctx, u_int rupper, u_int rlower)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
if (rupper > screen_size_y(s) - 1) if (rupper > screen_size_y(s) - 1)
rupper = screen_size_y(s) - 1; rupper = screen_size_y(s) - 1;
if (rlower > screen_size_y(s) - 1) if (rlower > screen_size_y(s) - 1)
@ -375,7 +375,7 @@ screen_write_scrollregion(
s->rupper = rupper; s->rupper = rupper;
s->rlower = rlower; s->rlower = rlower;
if (ctx->write != NULL) if (ctx->write != NULL)
ctx->write(ctx->data, TTY_SCROLLREGION, rupper, rlower); ctx->write(ctx->data, TTY_SCROLLREGION, rupper, rlower);
} }
@ -385,12 +385,12 @@ void
screen_write_insertmode(struct screen_write_ctx *ctx, int state) screen_write_insertmode(struct screen_write_ctx *ctx, int state)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
if (state) if (state)
s->mode |= MODE_INSERT; s->mode |= MODE_INSERT;
else else
s->mode &= ~MODE_INSERT; s->mode &= ~MODE_INSERT;
if (ctx->write != NULL) if (ctx->write != NULL)
ctx->write(ctx->data, TTY_INSERTMODE, state); ctx->write(ctx->data, TTY_INSERTMODE, state);
} }
@ -405,7 +405,7 @@ screen_write_mousemode(struct screen_write_ctx *ctx, int state)
s->mode |= MODE_MOUSE; s->mode |= MODE_MOUSE;
else else
s->mode &= ~MODE_MOUSE; s->mode &= ~MODE_MOUSE;
if (ctx->write != NULL) if (ctx->write != NULL)
ctx->write(ctx->data, TTY_MOUSEMODE, state); ctx->write(ctx->data, TTY_MOUSEMODE, state);
} }
@ -415,12 +415,12 @@ void
screen_write_linefeed(struct screen_write_ctx *ctx) screen_write_linefeed(struct screen_write_ctx *ctx)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
if (s->cy == s->rlower) if (s->cy == s->rlower)
grid_view_scroll_region_up(s->grid, s->rupper, s->rlower); grid_view_scroll_region_up(s->grid, s->rupper, s->rlower);
else if (s->cy < screen_size_x(s) - 1) else if (s->cy < screen_size_x(s) - 1)
s->cy++; s->cy++;
if (ctx->write != NULL) if (ctx->write != NULL)
ctx->write(ctx->data, TTY_LINEFEED); ctx->write(ctx->data, TTY_LINEFEED);
} }
@ -430,7 +430,7 @@ void
screen_write_carriagereturn(struct screen_write_ctx *ctx) screen_write_carriagereturn(struct screen_write_ctx *ctx)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
s->cx = 0; s->cx = 0;
if (ctx->write != NULL) if (ctx->write != NULL)
@ -442,12 +442,12 @@ void
screen_write_kcursormode(struct screen_write_ctx *ctx, int state) screen_write_kcursormode(struct screen_write_ctx *ctx, int state)
{ {
struct screen *s = ctx->s; struct screen *s = ctx->s;
if (state) if (state)
s->mode |= MODE_KCURSOR; s->mode |= MODE_KCURSOR;
else else
s->mode &= ~MODE_KCURSOR; s->mode &= ~MODE_KCURSOR;
if (ctx->write != NULL) if (ctx->write != NULL)
ctx->write(ctx->data, TTY_KCURSORMODE); ctx->write(ctx->data, TTY_KCURSORMODE);
} }
@ -461,8 +461,8 @@ screen_write_kkeypadmode(struct screen_write_ctx *ctx, int state)
if (state) if (state)
s->mode |= MODE_KKEYPAD; s->mode |= MODE_KKEYPAD;
else else
s->mode &= ~MODE_KKEYPAD; s->mode &= ~MODE_KKEYPAD;
if (ctx->write != NULL) if (ctx->write != NULL)
ctx->write(ctx->data, TTY_KKEYPADMODE); ctx->write(ctx->data, TTY_KKEYPADMODE);
} }
@ -479,7 +479,7 @@ screen_write_clearendofscreen(struct screen_write_ctx *ctx)
grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1); grid_view_clear(s->grid, s->cx, s->cy, sx - s->cx, 1);
grid_view_clear(s->grid, 0, s->cy + 1, sx, sy - (s->cy + 1)); grid_view_clear(s->grid, 0, s->cy + 1, sx, sy - (s->cy + 1));
if (ctx->write != NULL) if (ctx->write != NULL)
ctx->write(ctx->data, TTY_CLEARENDOFSCREEN); ctx->write(ctx->data, TTY_CLEARENDOFSCREEN);
} }
@ -496,8 +496,8 @@ screen_write_clearstartofscreen(struct screen_write_ctx *ctx)
if (s->cy > 0) if (s->cy > 0)
grid_view_clear(s->grid, 0, 0, sx, s->cy - 1); grid_view_clear(s->grid, 0, 0, sx, s->cy - 1);
grid_view_clear(s->grid, 0, s->cy, s->cx, 1); grid_view_clear(s->grid, 0, s->cy, s->cx, 1);
if (ctx->write != NULL) if (ctx->write != NULL)
ctx->write(ctx->data, TTY_CLEARSTARTOFSCREEN); ctx->write(ctx->data, TTY_CLEARSTARTOFSCREEN);
} }
@ -509,7 +509,7 @@ screen_write_clearscreen(struct screen_write_ctx *ctx)
struct screen *s = ctx->s; struct screen *s = ctx->s;
grid_view_clear(s->grid, 0, 0, screen_size_x(s), screen_size_y(s)); grid_view_clear(s->grid, 0, 0, screen_size_x(s), screen_size_y(s));
if (ctx->write != NULL) if (ctx->write != NULL)
ctx->write(ctx->data, TTY_CLEARSCREEN); ctx->write(ctx->data, TTY_CLEARSCREEN);
} }
@ -534,7 +534,7 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
width = 1; width = 1;
gc = &tc; gc = &tc;
} }
/* Check this will fit on the current line; scroll if not. */ /* Check this will fit on the current line; scroll if not. */
if (s->cx >= screen_size_x(s) + 1 - width) { if (s->cx >= screen_size_x(s) + 1 - width) {
screen_write_carriagereturn(ctx); screen_write_carriagereturn(ctx);
@ -556,7 +556,7 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
*/ */
hc = grid_view_peek_cell(gd, s->cx, s->cy); hc = grid_view_peek_cell(gd, s->cx, s->cy);
if (hc->flags & GRID_FLAG_PADDING) { if (hc->flags & GRID_FLAG_PADDING) {
/* /*
* A padding cell, so clear any following and leading padding * A padding cell, so clear any following and leading padding
* cells back to the character. Don't overwrite the current * cells back to the character. Don't overwrite the current
* cell as that happens later anyway. * cell as that happens later anyway.
@ -581,7 +581,7 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
grid_view_set_cell(gd, xx, s->cy, &grid_default_cell); grid_view_set_cell(gd, xx, s->cy, &grid_default_cell);
} }
} else if (utf8_width(hc->data) > 1) { } else if (utf8_width(hc->data) > 1) {
/* /*
* An UTF-8 wide cell; overwrite following padding cells only. * An UTF-8 wide cell; overwrite following padding cells only.
*/ */
xx = s->cx; xx = s->cx;
@ -605,7 +605,7 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
/* Write the actual cell. */ /* Write the actual cell. */
grid_view_set_cell(gd, s->cx, s->cy, gc); grid_view_set_cell(gd, s->cx, s->cy, gc);
s->cx += width; s->cx += width;
if (ctx->write != NULL) { if (ctx->write != NULL) {
if (screen_check_selection(ctx->s, s->cx, s->cy)) { if (screen_check_selection(ctx->s, s->cx, s->cy)) {
memcpy(&tc, gc, sizeof tc); memcpy(&tc, gc, sizeof tc);

View File

@ -1,4 +1,4 @@
/* $Id: screen.c,v 1.72 2008-09-25 20:08:54 nicm Exp $ */ /* $Id: screen.c,v 1.73 2008-09-26 06:45:26 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -51,8 +51,8 @@ screen_reinit(struct screen *s)
/* XXX */ /* XXX */
grid_clear_lines( grid_clear_lines(
s->grid, s->grid->hsize, s->grid->hsize + s->grid->sy - 1); s->grid, s->grid->hsize, s->grid->hsize + s->grid->sy - 1);
screen_clear_selection(s); screen_clear_selection(s);
} }
/* Destroy a screen. */ /* Destroy a screen. */
@ -150,7 +150,7 @@ screen_resize_y(struct screen *s, u_int sy)
} }
if (sy < oy) { if (sy < oy) {
/* Remove any remaining lines from the bottom. */ /* Remove any remaining lines from the bottom. */
grid_view_delete_lines(gd, sy, oy - sy); grid_view_delete_lines(gd, sy, oy - sy);
if (s->cy >= sy) if (s->cy >= sy)
s->cy = sy - 1; s->cy = sy - 1;
@ -171,7 +171,7 @@ screen_resize_y(struct screen *s, u_int sy)
} }
gd->sy = sy; gd->sy = sy;
s->rupper = 0; s->rupper = 0;
s->rlower = screen_size_y(s) - 1; s->rlower = screen_size_y(s) - 1;
} }

View File

@ -1,4 +1,4 @@
/* $Id: server-msg.c,v 1.51 2008-09-25 20:08:54 nicm Exp $ */ /* $Id: server-msg.c,v 1.52 2008-09-26 06:45:27 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -172,7 +172,7 @@ server_msg_fn_identify(struct hdr *hdr, struct client *c)
buffer_read(c->in, &data, sizeof data); buffer_read(c->in, &data, sizeof data);
term = cmd_recv_string(c->in); term = cmd_recv_string(c->in);
log_debug("identify msg from client: %u,%u (%d)", log_debug("identify msg from client: %u,%u (%d)",
data.sx, data.sy, data.version); data.sx, data.sy, data.version);
if (data.version != PROTOCOL_VERSION) { if (data.version != PROTOCOL_VERSION) {

View File

@ -1,4 +1,4 @@
/* $Id: server.c,v 1.81 2008-09-25 20:08:54 nicm Exp $ */ /* $Id: server.c,v 1.82 2008-09-26 06:45:27 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -389,7 +389,7 @@ server_check_timers(struct client *c)
if (gettimeofday(&tv, NULL) != 0) if (gettimeofday(&tv, NULL) != 0)
fatal("gettimeofday"); fatal("gettimeofday");
if (c->message_string != NULL && timercmp(&tv, &c->message_timer, >)) if (c->message_string != NULL && timercmp(&tv, &c->message_timer, >))
server_clear_client_message(c); server_clear_client_message(c);

View File

@ -1,4 +1,4 @@
/* $Id: session.c,v 1.42 2008-08-28 17:45:27 nicm Exp $ */ /* $Id: session.c,v 1.43 2008-09-26 06:45:27 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -206,7 +206,7 @@ session_new(struct session *s, const char *name, const char *cmd, int idx)
if (options_get_number(&s->options, "remain-by-default")) if (options_get_number(&s->options, "remain-by-default"))
w->flags |= WINDOW_ZOMBIFY; w->flags |= WINDOW_ZOMBIFY;
return (session_attach(s, w, idx)); return (session_attach(s, w, idx));
} }

View File

@ -1,4 +1,4 @@
/* $Id: status.c,v 1.47 2008-09-25 20:33:53 nicm Exp $ */ /* $Id: status.c,v 1.48 2008-09-26 06:45:27 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -221,7 +221,7 @@ draw:
screen_redraw_putc(&ctx, &gc, '>'); screen_redraw_putc(&ctx, &gc, '>');
gc.attr &= ~GRID_ATTR_REVERSE; gc.attr &= ~GRID_ATTR_REVERSE;
} }
screen_redraw_stop(&ctx); screen_redraw_stop(&ctx);
return; return;
@ -259,14 +259,14 @@ status_width(struct winlink *wl)
#ifndef BROKEN_VSNPRINTF #ifndef BROKEN_VSNPRINTF
return (xsnprintf(NULL, 0, "%d:%s ", wl->idx, wl->window->name)); return (xsnprintf(NULL, 0, "%d:%s ", wl->idx, wl->window->name));
#else #else
char *s; char *s;
size_t n; size_t n;
xasprintf(&s, "%d:%s ", wl->idx, wl->window->name);
n = strlen(s);
xfree(s);
return (n); xasprintf(&s, "%d:%s ", wl->idx, wl->window->name);
n = strlen(s);
xfree(s);
return (n);
#endif #endif
} }
@ -309,7 +309,7 @@ status_message_redraw(struct client *c)
xx = strlen(c->message_string); xx = strlen(c->message_string);
if (xx > c->sx) if (xx > c->sx)
xx = c->sx; xx = c->sx;
yy = c->sy - 1; yy = c->sy - 1;
memcpy(&gc, &grid_default_cell, sizeof gc); memcpy(&gc, &grid_default_cell, sizeof gc);
gc.attr |= GRID_ATTR_REVERSE; gc.attr |= GRID_ATTR_REVERSE;
@ -342,7 +342,7 @@ status_prompt_redraw(struct client *c)
xx = strlen(c->prompt_string); xx = strlen(c->prompt_string);
if (xx > c->sx) if (xx > c->sx)
xx = c->sx; xx = c->sx;
yy = c->sy - 1; yy = c->sy - 1;
memcpy(&gc, &grid_default_cell, sizeof gc); memcpy(&gc, &grid_default_cell, sizeof gc);
gc.attr |= GRID_ATTR_REVERSE; gc.attr |= GRID_ATTR_REVERSE;
@ -425,7 +425,7 @@ status_prompt_key(struct client *c, int key)
break; break;
if (c->prompt_index != strlen(c->prompt_buffer)) if (c->prompt_index != strlen(c->prompt_buffer))
break; break;
s = cmd_complete(c->prompt_buffer); s = cmd_complete(c->prompt_buffer);
xfree(c->prompt_buffer); xfree(c->prompt_buffer);
@ -440,7 +440,7 @@ status_prompt_key(struct client *c, int key)
if (c->prompt_index == size) if (c->prompt_index == size)
c->prompt_buffer[--c->prompt_index] = '\0'; c->prompt_buffer[--c->prompt_index] = '\0';
else { else {
memmove(c->prompt_buffer + c->prompt_index - 1, memmove(c->prompt_buffer + c->prompt_index - 1,
c->prompt_buffer + c->prompt_index, c->prompt_buffer + c->prompt_index,
size + 1 - c->prompt_index); size + 1 - c->prompt_index);
c->prompt_index--; c->prompt_index--;
@ -450,7 +450,7 @@ status_prompt_key(struct client *c, int key)
break; break;
case KEYC_DC: case KEYC_DC:
if (c->prompt_index != size) { if (c->prompt_index != size) {
memmove(c->prompt_buffer + c->prompt_index, memmove(c->prompt_buffer + c->prompt_index,
c->prompt_buffer + c->prompt_index + 1, c->prompt_buffer + c->prompt_index + 1,
size + 1 - c->prompt_index); size + 1 - c->prompt_index);
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_STATUS;
@ -476,7 +476,7 @@ status_prompt_key(struct client *c, int key)
c->prompt_buffer[c->prompt_index++] = key; c->prompt_buffer[c->prompt_index++] = key;
c->prompt_buffer[c->prompt_index] = '\0'; c->prompt_buffer[c->prompt_index] = '\0';
} else { } else {
memmove(c->prompt_buffer + c->prompt_index + 1, memmove(c->prompt_buffer + c->prompt_index + 1,
c->prompt_buffer + c->prompt_index, c->prompt_buffer + c->prompt_index,
size + 1 - c->prompt_index); size + 1 - c->prompt_index);
c->prompt_buffer[c->prompt_index++] = key; c->prompt_buffer[c->prompt_index++] = key;

6
tmux.c
View File

@ -1,4 +1,4 @@
/* $Id: tmux.c,v 1.77 2008-09-25 23:28:15 nicm Exp $ */ /* $Id: tmux.c,v 1.78 2008-09-26 06:45:28 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -61,8 +61,8 @@ const char *__progname = "tmux";
__dead void __dead void
usage(void) usage(void)
{ {
fprintf(stderr, fprintf(stderr, "usage: "
"usage: %s [-2dquVv] [-f file] [-S socket-path] [command [flags]]\n", "%s [-2dquVv] [-f file] [-S socket-path] [command [flags]]\n",
__progname); __progname);
exit(1); exit(1);
} }

10
tmux.h
View File

@ -1,4 +1,4 @@
/* $Id: tmux.h,v 1.190 2008-09-25 23:28:15 nicm Exp $ */ /* $Id: tmux.h,v 1.191 2008-09-26 06:45:28 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -433,12 +433,12 @@ struct grid_cell {
u_char fg; u_char fg;
u_char bg; u_char bg;
} __packed; } __packed;
/* Grid data. */ /* Grid data. */
struct grid_data { struct grid_data {
u_int sx; u_int sx;
u_int sy; u_int sy;
u_int hsize; u_int hsize;
u_int hlimit; u_int hlimit;
@ -824,7 +824,7 @@ struct set_option_entry {
enum { enum {
SET_OPTION_STRING, SET_OPTION_STRING,
SET_OPTION_NUMBER, SET_OPTION_NUMBER,
SET_OPTION_KEY, SET_OPTION_KEY,
SET_OPTION_COLOUR, SET_OPTION_COLOUR,
SET_OPTION_FLAG, SET_OPTION_FLAG,
SET_OPTION_CHOICE SET_OPTION_CHOICE
@ -832,7 +832,7 @@ struct set_option_entry {
u_int minimum; u_int minimum;
u_int maximum; u_int maximum;
const char **choices; const char **choices;
}; };
extern const struct set_option_entry set_option_table[]; extern const struct set_option_entry set_option_table[];

View File

@ -1,4 +1,4 @@
/* $Id: tty-keys.c,v 1.10 2008-08-28 17:45:28 nicm Exp $ */ /* $Id: tty-keys.c,v 1.11 2008-09-26 06:45:28 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -203,7 +203,7 @@ struct {
{ "-\033Os", KEYC_KP3_2 }, { "-\033Os", KEYC_KP3_2 },
{ "-\033OM", KEYC_KP3_3 }, { "-\033OM", KEYC_KP3_3 },
{ "-\033Op", KEYC_KP4_0 }, { "-\033Op", KEYC_KP4_0 },
{ "-\033On", KEYC_KP4_2 }, { "-\033On", KEYC_KP4_2 },
}; };
#define NTTYKEYS (sizeof tty_keys / sizeof tty_keys[0]) #define NTTYKEYS (sizeof tty_keys / sizeof tty_keys[0])
@ -322,7 +322,7 @@ tty_keys_next(struct tty *tty, int *code)
return (0); return (0);
} }
/* Escape but no key string. If the timer isn't started, start it. */ /* Escape but no key string. If the timer isn't started, start it. */
if (!(tty->flags & TTY_ESCAPE)) { if (!(tty->flags & TTY_ESCAPE)) {
tv.tv_sec = 0; tv.tv_sec = 0;
tv.tv_usec = 500 * 1000L; tv.tv_usec = 500 * 1000L;

28
tty.c
View File

@ -1,4 +1,4 @@
/* $Id: tty.c,v 1.43 2008-09-25 20:08:56 nicm Exp $ */ /* $Id: tty.c,v 1.44 2008-09-26 06:45:28 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -123,7 +123,7 @@ tty_open(struct tty *tty, char **cause)
xasprintf(cause, "%s: %s", tty->path, strerror(errno)); xasprintf(cause, "%s: %s", tty->path, strerror(errno));
return (-1); return (-1);
} }
if ((mode = fcntl(tty->fd, F_GETFL)) == -1) if ((mode = fcntl(tty->fd, F_GETFL)) == -1)
fatal("fcntl"); fatal("fcntl");
if (fcntl(tty->fd, F_SETFL, mode|O_NONBLOCK) == -1) if (fcntl(tty->fd, F_SETFL, mode|O_NONBLOCK) == -1)
@ -355,7 +355,7 @@ tty_find_term(char *name, int fd, char **cause)
*/ */
if (max_colors == 256 || strstr(name, "256col") != NULL) /* XXX HACK */ if (max_colors == 256 || strstr(name, "256col") != NULL) /* XXX HACK */
term->flags |= TERM_256COLOURS; term->flags |= TERM_256COLOURS;
return (term); return (term);
error: error:
@ -423,13 +423,13 @@ tty_strip(const char *s)
if (*ptr == '>') if (*ptr == '>')
ptr++; ptr++;
} }
buf[len++] = *ptr; buf[len++] = *ptr;
if (len == (sizeof buf) - 1) if (len == (sizeof buf) - 1)
break; break;
} }
buf[len] = '\0'; buf[len] = '\0';
return (buf); return (buf);
} }
@ -485,7 +485,7 @@ tty_vwrite(struct tty *tty, struct screen *s, int cmd, va_list ap)
{ {
if (tty->flags & TTY_FREEZE) if (tty->flags & TTY_FREEZE)
return; return;
if (tty->term == NULL) /* XXX XXX */ if (tty->term == NULL) /* XXX XXX */
return; return;
set_curterm(tty->term->term); set_curterm(tty->term->term);
@ -654,7 +654,7 @@ void
tty_cmd_clearendofline(struct tty *tty, struct screen *s, unused va_list ap) tty_cmd_clearendofline(struct tty *tty, struct screen *s, unused va_list ap)
{ {
u_int i; u_int i;
tty_reset(tty); tty_reset(tty);
if (clr_eol != NULL) if (clr_eol != NULL)
@ -704,7 +704,7 @@ tty_cmd_cursormode(struct tty *tty, unused struct screen *s, va_list ap)
return; return;
ua = va_arg(ap, int); ua = va_arg(ap, int);
if (ua && !(tty->flags & TTY_NOCURSOR)) if (ua && !(tty->flags & TTY_NOCURSOR))
tty_puts(tty, cursor_normal); tty_puts(tty, cursor_normal);
else else
@ -830,7 +830,7 @@ tty_cmd_clearstartofscreen(struct tty *tty, struct screen *s, unused va_list ap)
for (j = 0; j < s->cy; j++) { for (j = 0; j < s->cy; j++) {
for (i = 0; i < screen_size_x(s); i++) for (i = 0; i < screen_size_x(s); i++)
tty_putc(tty, ' '); tty_putc(tty, ' ');
} }
} }
for (i = 0; i < s->cx; i++) for (i = 0; i < s->cx; i++)
tty_putc(tty, ' '); tty_putc(tty, ' ');
@ -911,7 +911,7 @@ tty_reset(struct tty *tty)
tc->data = grid_default_cell.data; tc->data = grid_default_cell.data;
if (memcmp(tc, &grid_default_cell, sizeof *tc) == 0) if (memcmp(tc, &grid_default_cell, sizeof *tc) == 0)
return; return;
if (exit_alt_charset_mode != NULL && tc->attr & GRID_ATTR_CHARSET) if (exit_alt_charset_mode != NULL && tc->attr & GRID_ATTR_CHARSET)
tty_puts(tty, exit_alt_charset_mode); tty_puts(tty, exit_alt_charset_mode);
tty_puts(tty, exit_attribute_mode); tty_puts(tty, exit_attribute_mode);
@ -956,9 +956,9 @@ tty_attributes(struct tty *tty, const struct grid_cell *gc)
tty_attributes_fg(tty, gc); tty_attributes_fg(tty, gc);
tc->fg = gc->fg; tc->fg = gc->fg;
} }
/* Set background colour. */ /* Set background colour. */
if (gc->bg != tc->bg || if (gc->bg != tc->bg ||
(gc->flags & GRID_FLAG_BG256) != (tc->flags & GRID_FLAG_BG256)) { (gc->flags & GRID_FLAG_BG256) != (tc->flags & GRID_FLAG_BG256)) {
tty_attributes_bg(tty, gc); tty_attributes_bg(tty, gc);
tc->bg = gc->bg; tc->bg = gc->bg;
@ -984,7 +984,7 @@ tty_attributes_fg(struct tty *tty, const struct grid_cell *gc)
else if (fg > 7) else if (fg > 7)
fg -= 8; fg -= 8;
} }
if (fg == 8 && if (fg == 8 &&
!(tty->term->flags & TERM_HASDEFAULTS) && !(tty->term->flags & TERM_HASDEFAULTS) &&
!(tty->term_flags & TERM_HASDEFAULTS)) !(tty->term_flags & TERM_HASDEFAULTS))
@ -1014,7 +1014,7 @@ tty_attributes_bg(struct tty *tty, const struct grid_cell *gc)
else if (bg > 7) else if (bg > 7)
bg -= 8; bg -= 8;
} }
if (bg == 8 && if (bg == 8 &&
!(tty->term->flags & TERM_HASDEFAULTS) && !(tty->term->flags & TERM_HASDEFAULTS) &&
!(tty->term_flags & TERM_HASDEFAULTS)) !(tty->term_flags & TERM_HASDEFAULTS))

View File

@ -1,4 +1,4 @@
/* $Id: window-copy.c,v 1.31 2008-09-25 20:08:57 nicm Exp $ */ /* $Id: window-copy.c,v 1.32 2008-09-26 06:45:28 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -243,7 +243,7 @@ window_copy_write_column(
struct screen *s = &data->screen; struct screen *s = &data->screen;
screen_write_cursormove(ctx, px, 0); screen_write_cursormove(ctx, px, 0);
screen_write_copy(ctx, &w->base, screen_write_copy(ctx, &w->base,
data->ox, screen_hsize(&w->base) - data->oy, 1, screen_size_y(s)); data->ox, screen_hsize(&w->base) - data->oy, 1, screen_size_y(s));
} }
@ -657,16 +657,16 @@ window_copy_cursor_next_word(struct window *w)
if (data->oy == 0) if (data->oy == 0)
goto out; goto out;
} }
px = 0; px = 0;
window_copy_cursor_down(w); window_copy_cursor_down(w);
py =screen_hsize( py =screen_hsize(
&w->base) + data->cy - data->oy; &w->base) + data->cy - data->oy;
xx = window_copy_find_length(w, py); xx = window_copy_find_length(w, py);
} }
} }
if (skip) { if (skip) {
/* Currently skipping non-space (until space). */ /* Currently skipping non-space (until space). */
if (window_copy_is_space(w, px, py)) if (window_copy_is_space(w, px, py))
@ -706,7 +706,7 @@ out:
data->cx = screen_size_x(s) - 1; data->cx = screen_size_x(s) - 1;
} }
} }
if (window_copy_update_selection(w)) if (window_copy_update_selection(w))
window_copy_redraw_lines(w, data->cy, 1); window_copy_redraw_lines(w, data->cy, 1);
else else
@ -735,20 +735,20 @@ window_copy_cursor_previous_word(struct window *w)
break; break;
while (px == 0) { while (px == 0) {
if (data->cy == 0 && if (data->cy == 0 &&
(screen_hsize(&w->base) == 0 || (screen_hsize(&w->base) == 0 ||
data->oy >= screen_hsize(&w->base) - 1)) data->oy >= screen_hsize(&w->base) - 1))
goto out; goto out;
window_copy_cursor_up(w); window_copy_cursor_up(w);
py = screen_hsize( py = screen_hsize(
&w->base) + data->cy - data->oy; &w->base) + data->cy - data->oy;
px = window_copy_find_length(w, py); px = window_copy_find_length(w, py);
} }
goto out; goto out;
} }
if (skip) { if (skip) {
/* Currently skipping non-space (until space). */ /* Currently skipping non-space (until space). */
if (window_copy_is_space(w, px - 1, py)) if (window_copy_is_space(w, px - 1, py))
@ -758,7 +758,7 @@ window_copy_cursor_previous_word(struct window *w)
if (!window_copy_is_space(w, px - 1, py)) if (!window_copy_is_space(w, px - 1, py))
break; break;
} }
px--; px--;
} }
out: out:
@ -788,7 +788,7 @@ out:
data->cx = screen_size_x(s) - 1; data->cx = screen_size_x(s) - 1;
} }
} }
if (window_copy_update_selection(w)) if (window_copy_update_selection(w))
window_copy_redraw_lines(w, data->cy, 1); window_copy_redraw_lines(w, data->cy, 1);
else else

View File

@ -1,4 +1,4 @@
/* $Id: window-more.c,v 1.19 2008-09-25 20:08:57 nicm Exp $ */ /* $Id: window-more.c,v 1.20 2008-09-26 06:45:28 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -172,7 +172,7 @@ window_more_write_line(struct window *w, struct screen_write_ctx *ctx, u_int py)
if (py == 0) { if (py == 0) {
size = xsnprintf(hdr, sizeof hdr, size = xsnprintf(hdr, sizeof hdr,
"[%u/%u]", data->top, ARRAY_LENGTH(&data->list)); "[%u/%u]", data->top, ARRAY_LENGTH(&data->list));
screen_write_cursormove(ctx, screen_size_x(s) - size, 0); screen_write_cursormove(ctx, screen_size_x(s) - size, 0);
gc.attr |= GRID_ATTR_BRIGHT|GRID_ATTR_REVERSE; gc.attr |= GRID_ATTR_BRIGHT|GRID_ATTR_REVERSE;
screen_write_puts(ctx, &gc, "%s", hdr); screen_write_puts(ctx, &gc, "%s", hdr);

View File

@ -1,4 +1,4 @@
/* $Id: window.c,v 1.49 2008-09-10 19:15:06 nicm Exp $ */ /* $Id: window.c,v 1.50 2008-09-26 06:45:28 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -261,7 +261,7 @@ window_spawn(struct window *w, const char *cmd, const char **envp)
fatal("fcntl failed"); fatal("fcntl failed");
if (fcntl(w->fd, F_SETFD, FD_CLOEXEC) == -1) if (fcntl(w->fd, F_SETFD, FD_CLOEXEC) == -1)
fatal("fcntl failed"); fatal("fcntl failed");
return (0); return (0);
} }