set status, status-fg, status-bg.

This commit is contained in:
Nicholas Marriott 2007-10-12 12:08:51 +00:00
parent ffa8dcc4da
commit 7ec5be30df
6 changed files with 64 additions and 17 deletions

9
NOTES
View File

@ -62,11 +62,6 @@ Commands:
set-option prefix key set-option prefix key
Set command prefix (meta) key. Set command prefix (meta) key.
XXX set-option status,status-fg,status-bg
Sessions are destroyed when no windows remain attached to them. Sessions are destroyed when no windows remain attached to them.
There is currently no command to change status bar colour, it can be altered
by adjusting the last argument of line 38 in status.c:
input_store_two(b, CODE_ATTRIBUTES, ATTR_REVERSE, 0x20);
0x47 is white-on-blue.

3
TODO
View File

@ -42,6 +42,8 @@
- Nested sessions over the network, plug-in another tmux as a window/subsession - Nested sessions over the network, plug-in another tmux as a window/subsession
- it would be nice to have multichar commands so you could have C-b K K for - it would be nice to have multichar commands so you could have C-b K K for
kill-window to limit accidental presses kill-window to limit accidental presses
- status-fg/status-bg should be able to a) use strings for colours "red" etc
b) set attributes too ("bold-red"?)
-- For 0.1 -------------------------------------------------------------------- -- For 0.1 --------------------------------------------------------------------
- man page - man page
@ -55,7 +57,6 @@
unlink window (error if window only linked to one session) unlink window (error if window only linked to one session)
kill window (C-b backsp) kill window (C-b backsp)
kill session (no not bind by default) kill session (no not bind by default)
set status on/off
set shell set shell
send prefix send prefix
- handle tmux in tmux (check $TMUX and abort) - handle tmux in tmux (check $TMUX and abort)

View File

@ -1,4 +1,4 @@
/* $Id: cmd-set-option.c,v 1.4 2007-10-04 22:18:48 nicm Exp $ */ /* $Id: cmd-set-option.c,v 1.5 2007-10-12 12:08:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -91,7 +91,7 @@ cmd_set_option_exec(void *ptr, unused struct cmd_ctx *ctx)
struct cmd_set_option_data *data = ptr; struct cmd_set_option_data *data = ptr;
struct client *c = ctx->client; struct client *c = ctx->client;
const char *errstr; const char *errstr;
u_int number; u_int number, i;
int bool, key; int bool, key;
if (data == NULL) if (data == NULL)
@ -102,6 +102,7 @@ cmd_set_option_exec(void *ptr, unused struct cmd_ctx *ctx)
return; return;
} }
number = -1;
if (data->value != NULL) { if (data->value != NULL) {
number = strtonum(data->value, 0, UINT_MAX, &errstr); number = strtonum(data->value, 0, UINT_MAX, &errstr);
@ -126,6 +127,49 @@ cmd_set_option_exec(void *ptr, unused struct cmd_ctx *ctx)
return; return;
} }
prefix_key = key; prefix_key = key;
} else if (strcmp(data->option, "status") == 0) {
if (bool == -1) {
ctx->error(ctx, "bad value: %s", data->value);
return;
}
status_lines = bool;
recalculate_sizes();
} else if (strcmp(data->option, "status-fg") == 0) {
if (data->value == NULL) {
ctx->error(ctx, "invalid value");
return;
}
if (errstr != NULL || number > 7) {
ctx->error(ctx, "bad colour: %s", data->value);
return;
}
status_colour &= 0x0f;
status_colour |= number << 4;
if (status_lines > 0) {
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);
if (c != NULL && c->session != NULL)
server_redraw_client(c);
}
}
} else if (strcmp(data->option, "status-bg") == 0) {
if (data->value == NULL) {
ctx->error(ctx, "invalid value");
return;
}
if (errstr != NULL || number > 7) {
ctx->error(ctx, "bad colour: %s", data->value);
return;
}
status_colour &= 0xf0;
status_colour |= number;
if (status_lines > 0) {
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);
if (c != NULL && c->session != NULL)
server_redraw_client(c);
}
}
} else { } else {
ctx->error(ctx, "unknown option: %s", data->option); ctx->error(ctx, "unknown option: %s", data->option);
return; return;

View File

@ -1,4 +1,4 @@
/* $Id: status.c,v 1.4 2007-10-12 11:24:15 nicm Exp $ */ /* $Id: status.c,v 1.5 2007-10-12 12:08:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -35,20 +35,24 @@ status_write(struct client *c)
input_store_zero(b, CODE_CURSOROFF); input_store_zero(b, CODE_CURSOROFF);
input_store_two(b, CODE_CURSORMOVE, c->sy - status_lines + 1, 1); input_store_two(b, CODE_CURSORMOVE, c->sy - status_lines + 1, 1);
input_store_two(b, CODE_ATTRIBUTES, ATTR_REVERSE, 0x20); input_store_two(b, CODE_ATTRIBUTES, 0, status_colour);
size = c->sx; size = c->sx;
for (i = 0; i < ARRAY_LENGTH(&c->session->windows); i++) { for (i = 0; i < ARRAY_LENGTH(&c->session->windows); i++) {
w = ARRAY_ITEM(&c->session->windows, i); w = ARRAY_ITEM(&c->session->windows, i);
if (w == NULL) if (w == NULL)
continue; continue;
if (session_hasbell(c->session, w))
input_store_two(b, CODE_ATTRIBUTES, ATTR_REVERSE, 0x30); if (session_hasbell(c->session, w)) {
input_store_two(
b, CODE_ATTRIBUTES, ATTR_REVERSE, status_colour);
}
status_print(b, &size, status_print(b, &size,
"%u:%s%s", i, w->name, w == c->session->window ? "*" : ""); "%u:%s%s", i, w->name, w == c->session->window ? "*" : "");
if (session_hasbell(c->session, w)) if (session_hasbell(c->session, w))
input_store_two(b, CODE_ATTRIBUTES, ATTR_REVERSE, 0x20); input_store_two(b, CODE_ATTRIBUTES, 0, status_colour);
status_print(b, &size, " "); status_print(b, &size, " ");
if (size == 0) if (size == 0)
break; break;
} }

4
tmux.c
View File

@ -1,4 +1,4 @@
/* $Id: tmux.c,v 1.29 2007-10-04 11:52:03 nicm Exp $ */ /* $Id: tmux.c,v 1.30 2007-10-12 12:08:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -40,6 +40,7 @@ volatile sig_atomic_t sigterm;
int debug_level; int debug_level;
int prefix_key = META; int prefix_key = META;
u_int status_lines; u_int status_lines;
u_char status_colour;
char *default_command; char *default_command;
void sighandler(int); void sighandler(int);
@ -195,6 +196,7 @@ main(int argc, char **argv)
log_open(stderr, LOG_USER, debug_level); log_open(stderr, LOG_USER, debug_level);
status_lines = 1; status_lines = 1;
status_colour = 0x02;
shell = getenv("SHELL"); shell = getenv("SHELL");
if (shell == NULL || *shell == '\0') if (shell == NULL || *shell == '\0')

3
tmux.h
View File

@ -1,4 +1,4 @@
/* $Id: tmux.h,v 1.54 2007-10-12 11:24:15 nicm Exp $ */ /* $Id: tmux.h,v 1.55 2007-10-12 12:08:51 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -497,6 +497,7 @@ extern volatile sig_atomic_t sigterm;
extern int prefix_key; extern int prefix_key;
extern int debug_level; extern int debug_level;
extern u_int status_lines; extern u_int status_lines;
extern u_char status_colour;
extern char *default_command; extern char *default_command;
void usage(char **, const char *, ...); void usage(char **, const char *, ...);
void logfile(const char *); void logfile(const char *);