Informational messages on window option changes.

This commit is contained in:
Nicholas Marriott 2008-06-16 17:35:40 +00:00
parent 1726bf0ffc
commit 55d5b83408
11 changed files with 129 additions and 35 deletions

View File

@ -1,5 +1,7 @@
16 June 2008 16 June 2008
* Add some information messages when window options are changed, suggested by
Mike Erdely. Also add a -q command-line option to suppress them.
* show-window-options (showw) command. * show-window-options (showw) command.
15 June 2008 15 June 2008
@ -480,4 +482,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.121 2008-06-16 06:10:02 nicm Exp $ $Id: CHANGES,v 1.122 2008-06-16 17:35:40 nicm Exp $

1
TODO
View File

@ -66,6 +66,7 @@
- status bar customisation variables, show-activity, show-last-window - status bar customisation variables, show-activity, show-last-window
- figure out Linux tcsetattr problem, remove header bodge if unnecessary - figure out Linux tcsetattr problem, remove header bodge if unnecessary
- flags to centre screen in window - flags to centre screen in window
- get rid of DEFDATA etc
-- For 0.3 -------------------------------------------------------------------- -- For 0.3 --------------------------------------------------------------------
- clear EOL etc CANNOT rely on term using the current colour/attr and probably - clear EOL etc CANNOT rely on term using the current colour/attr and probably

3
cfg.c
View File

@ -1,4 +1,4 @@
/* $Id: cfg.c,v 1.7 2008-06-14 08:11:17 nicm Exp $ */ /* $Id: cfg.c,v 1.8 2008-06-16 17:35:40 nicm Exp $ */
/* /*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -123,6 +123,7 @@ load_cfg(const char *path, char **causep)
ctx.error = cfg_error; ctx.error = cfg_error;
ctx.print = cfg_print; ctx.print = cfg_print;
ctx.info = cfg_print;
ctx.cmdclient = NULL; ctx.cmdclient = NULL;
ctx.flags = 0; ctx.flags = 0;

View File

@ -1,4 +1,4 @@
/* $Id: cmd-set-window-option.c,v 1.7 2008-06-14 16:47:20 nicm Exp $ */ /* $Id: cmd-set-window-option.c,v 1.8 2008-06-16 17:35:40 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -145,6 +145,14 @@ cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx)
wl->window->flags &= ~WINDOW_MONITOR; wl->window->flags &= ~WINDOW_MONITOR;
} }
if (wl->window->flags & WINDOW_MONITOR) {
ctx->info(ctx, "window %s:%d: set %s",
s->name, wl->idx, data->option);
} else {
ctx->info(ctx, "window %s:%d: cleared %s",
s->name, wl->idx, data->option);
}
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)
@ -165,6 +173,14 @@ cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx)
wl->window->flags &= ~WINDOW_AGGRESSIVE; wl->window->flags &= ~WINDOW_AGGRESSIVE;
} }
if (wl->window->flags & WINDOW_AGGRESSIVE) {
ctx->info(ctx, "window %s:%d: set %s",
s->name, wl->idx, data->option);
} else {
ctx->info(ctx, "window %s:%d: cleared %s",
s->name, wl->idx, data->option);
}
recalculate_sizes(); recalculate_sizes();
} else if (strcmp(data->option, "force-width") == 0) { } else if (strcmp(data->option, "force-width") == 0) {
if (data->value == NULL || number == -1) { if (data->value == NULL || number == -1) {
@ -179,6 +195,10 @@ cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx)
wl->window->limitx = UINT_MAX; wl->window->limitx = UINT_MAX;
else else
wl->window->limitx = number; wl->window->limitx = number;
ctx->info(ctx, "window %s:%d: set force-width %u",
s->name, wl->idx, number);
recalculate_sizes(); recalculate_sizes();
} else if (strcmp(data->option, "force-height") == 0) { } else if (strcmp(data->option, "force-height") == 0) {
if (data->value == NULL || number == -1) { if (data->value == NULL || number == -1) {
@ -193,6 +213,10 @@ cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx)
wl->window->limity = UINT_MAX; wl->window->limity = UINT_MAX;
else else
wl->window->limity = number; wl->window->limity = number;
ctx->info(ctx, "window %s:%d: set force-height %u",
s->name, wl->idx, number);
recalculate_sizes(); recalculate_sizes();
} else { } else {
ctx->error(ctx, "unknown option: %s", data->option); ctx->error(ctx, "unknown option: %s", data->option);

View File

@ -1,4 +1,4 @@
/* $Id: key-bindings.c,v 1.30 2008-06-16 07:01:41 nicm Exp $ */ /* $Id: key-bindings.c,v 1.31 2008-06-16 17:35:40 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -28,6 +28,7 @@ struct bindings key_bindings;
void printflike2 key_bindings_error(struct cmd_ctx *, const char *, ...); void printflike2 key_bindings_error(struct cmd_ctx *, const char *, ...);
void printflike2 key_bindings_print(struct cmd_ctx *, const char *, ...); void printflike2 key_bindings_print(struct cmd_ctx *, const char *, ...);
void printflike2 key_bindings_info(struct cmd_ctx *, const char *, ...);
void void
key_bindings_add(int key, struct cmd *cmd) key_bindings_add(int key, struct cmd *cmd)
@ -172,6 +173,24 @@ key_bindings_print(struct cmd_ctx *ctx, const char *fmt, ...)
va_end(ap); va_end(ap);
} }
void printflike2
key_bindings_info(struct cmd_ctx *ctx, const char *fmt, ...)
{
va_list ap;
char *msg;
if (be_quiet)
return;
va_start(ap, fmt);
xvasprintf(&msg, fmt, ap);
va_end(ap);
*msg = toupper((u_char) *msg);
server_write_message(ctx->curclient, "%s", msg);
xfree(msg);
}
void void
key_bindings_dispatch(int key, struct client *c) key_bindings_dispatch(int key, struct client *c)
{ {
@ -194,6 +213,7 @@ key_bindings_dispatch(int key, struct client *c)
ctx.error = key_bindings_error; ctx.error = key_bindings_error;
ctx.print = key_bindings_print; ctx.print = key_bindings_print;
ctx.info = key_bindings_info;
ctx.cmdclient = NULL; ctx.cmdclient = NULL;
ctx.flags = CMD_KEY; ctx.flags = CMD_KEY;

View File

@ -1,4 +1,4 @@
/* $Id: screen-redraw.c,v 1.7 2008-06-14 18:38:55 nicm Exp $ */ /* $Id: screen-redraw.c,v 1.8 2008-06-16 17:35:40 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -138,8 +138,6 @@ screen_redraw_write_string(struct screen_redraw_ctx *ctx, const char *fmt, ...)
va_end(ap); va_end(ap);
for (ptr = msg; *ptr != '\0'; ptr++) { for (ptr = msg; *ptr != '\0'; ptr++) {
if (ctx->s->cx > screen_last_x(s))
break;
if (*ptr < 0x20) if (*ptr < 0x20)
continue; continue;
ctx->write(ctx->data, TTY_CHARACTER, *ptr); ctx->write(ctx->data, TTY_CHARACTER, *ptr);

View File

@ -1,4 +1,4 @@
/* $Id: server-fn.c,v 1.41 2008-06-14 16:47:20 nicm Exp $ */ /* $Id: server-fn.c,v 1.42 2008-06-16 17:35:40 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -159,25 +159,33 @@ server_write_message(struct client *c, const char *fmt, ...)
slines = options_get_number(&c->session->options, "status-lines"); slines = options_get_number(&c->session->options, "status-lines");
screen_redraw_start_client(&ctx, c); screen_redraw_start_client(&ctx, c);
screen_redraw_move_cursor(&ctx, 0, c->sy - 1);
screen_redraw_set_attributes(&ctx, ATTR_REVERSE, 0x88);
va_start(ap, fmt); va_start(ap, fmt);
xvasprintf(&msg, fmt, ap); xvasprintf(&msg, fmt, ap);
va_end(ap); va_end(ap);
msg = xrealloc(msg, 1, c->sx + 1);
msg[c->sx] = '\0';
size = strlen(msg); size = strlen(msg);
if (size < c->sx - 1) { if (size < c->sx)
msg = xrealloc(msg, 1, c->sx); memset(msg + size, ' ', c->sx - size);
msg[c->sx - 1] = '\0';
memset(msg + size, SCREEN_DEFDATA, (c->sx - 1) - size); screen_redraw_move_cursor(&ctx, 0, c->sy - 1);
} screen_redraw_set_attributes(&ctx, ATTR_REVERSE, 0x88);
screen_redraw_write_string(&ctx, "%s", msg); screen_redraw_write_string(&ctx, "%s", msg);
xfree(msg);
buffer_flush(c->tty.fd, c->tty.in, c->tty.out); buffer_flush(c->tty.fd, c->tty.in, c->tty.out);
usleep(750000); usleep(750000);
memset(msg, ' ', c->sx);
screen_redraw_move_cursor(&ctx, 0, c->sy - 1);
screen_redraw_set_attributes(&ctx, 0, 0x88);
screen_redraw_write_string(&ctx, "%s", msg);
xfree(msg);
if (slines == 0) { if (slines == 0) {
screen_redraw_lines(&ctx, c->sy - 1, 1); screen_redraw_lines(&ctx, c->sy - 1, 1);
screen_redraw_stop(&ctx); screen_redraw_stop(&ctx);

View File

@ -1,4 +1,4 @@
/* $Id: server-msg.c,v 1.45 2008-06-02 18:23:37 nicm Exp $ */ /* $Id: server-msg.c,v 1.46 2008-06-16 17:35:40 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -34,6 +34,8 @@ void printflike2 server_msg_fn_command_error(
struct cmd_ctx *, const char *, ...); struct cmd_ctx *, const char *, ...);
void printflike2 server_msg_fn_command_print( void printflike2 server_msg_fn_command_print(
struct cmd_ctx *, const char *, ...); struct cmd_ctx *, const char *, ...);
void printflike2 server_msg_fn_command_info(
struct cmd_ctx *, const char *, ...);
struct server_msg { struct server_msg {
enum hdrtype type; enum hdrtype type;
@ -105,6 +107,23 @@ server_msg_fn_command_print(struct cmd_ctx *ctx, const char *fmt, ...)
xfree(msg); xfree(msg);
} }
void printflike2
server_msg_fn_command_info(struct cmd_ctx *ctx, const char *fmt, ...)
{
va_list ap;
char *msg;
if (be_quiet)
return;
va_start(ap, fmt);
xvasprintf(&msg, fmt, ap);
va_end(ap);
server_write_client(ctx->cmdclient, MSG_PRINT, msg, strlen(msg));
xfree(msg);
}
int int
server_msg_fn_command(struct hdr *hdr, struct client *c) server_msg_fn_command(struct hdr *hdr, struct client *c)
{ {
@ -121,6 +140,7 @@ server_msg_fn_command(struct hdr *hdr, struct client *c)
ctx.error = server_msg_fn_command_error; ctx.error = server_msg_fn_command_error;
ctx.print = server_msg_fn_command_print; ctx.print = server_msg_fn_command_print;
ctx.info = server_msg_fn_command_info;
ctx.msgdata = &data; ctx.msgdata = &data;
ctx.curclient = NULL; ctx.curclient = NULL;

44
tmux.1
View File

@ -1,4 +1,4 @@
.\" $Id: tmux.1,v 1.34 2008-06-16 06:33:50 nicm Exp $ .\" $Id: tmux.1,v 1.35 2008-06-16 17:35:40 nicm Exp $
.\" .\"
.\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> .\" Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
.\" .\"
@ -23,7 +23,7 @@
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm tmux .Nm tmux
.Bk -words .Bk -words
.Op Fl vV .Op Fl vVq
.Op Fl f Ar file .Op Fl f Ar file
.Op Fl S Ar socket-path .Op Fl S Ar socket-path
.Op Ar command Op Ar flags .Op Ar command Op Ar flags
@ -50,6 +50,26 @@ Communication takes place through a socket, by default placed in
.Pp .Pp
The options are as follows: The options are as follows:
.Bl -tag -width "XXXXXXXXXXXX" .Bl -tag -width "XXXXXXXXXXXX"
.It Fl f Ar file
Specify an alternative configuration file.
By default,
.Nm
will look for a config file at
.Pa ~/.tmux.conf .
The configuration file is a set of
.Nm
commands which are executed in sequence when the server is first started.
.It Fl q
Suppress various information messages, for example when window flags are
altered.
.It Fl S Ar socket-path
Specify an alternative path to the server socket.
The default is
.Pa /tmp/tmux-UID ,
where
.Em UID
is the uid of the user who invoked
.Nm .
.It Fl v .It Fl v
Request verbose logging. Request verbose logging.
This option may be specified multiple times for increasing verbosity. This option may be specified multiple times for increasing verbosity.
@ -62,19 +82,6 @@ files in the current directory, where
is the pid of the server or client process. is the pid of the server or client process.
.It Fl V .It Fl V
Print program version. Print program version.
.It Fl f Ar file
Specify an alternative configuration file.
By default,
.Nm
will look for a config file at ~/.tmux.conf.
.It Fl S Ar socket-path
Specify an alternative path to the server socket.
The default is
.Pa /tmp/tmux-UID ,
where
.Em UID
is the uid of the user who invoked
.Nm .
.It Ar command Op Ar flags .It Ar command Op Ar flags
This specifies one of a set of commands used to control This specifies one of a set of commands used to control
.Nm , .Nm ,
@ -574,6 +581,13 @@ Unlink
A window may be unlinked only if it is linked to multiple sessions - windows may A window may be unlinked only if it is linked to multiple sessions - windows may
not be linked to no sessions. not be linked to no sessions.
.El .El
.Sh FILES
.Bl -tag -width Ds -compact
.It Pa ~/.tmux.conf
default
.Nm
configuration file
.El
.Sh SEE ALSO .Sh SEE ALSO
.Xr pty 4 .Xr pty 4
.Sh AUTHORS .Sh AUTHORS

8
tmux.c
View File

@ -1,4 +1,4 @@
/* $Id: tmux.c,v 1.55 2008-06-15 08:01:54 nicm Exp $ */ /* $Id: tmux.c,v 1.56 2008-06-16 17:35:40 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -48,6 +48,7 @@ struct options global_options;
char *paste_buffer; char *paste_buffer;
int debug_level; int debug_level;
int be_quiet;
void sighandler(int); void sighandler(int);
__dead void usage(void); __dead void usage(void);
@ -174,7 +175,7 @@ main(int argc, char **argv)
int n, opt; int n, opt;
client = path = name = NULL; client = path = name = NULL;
while ((opt = getopt(argc, argv, "f:S:vV")) != EOF) { while ((opt = getopt(argc, argv, "f:S:qvV")) != EOF) {
switch (opt) { switch (opt) {
case 'f': case 'f':
cfg_file = xstrdup(optarg); cfg_file = xstrdup(optarg);
@ -182,6 +183,9 @@ main(int argc, char **argv)
case 'S': case 'S':
path = xstrdup(optarg); path = xstrdup(optarg);
break; break;
case 'q':
be_quiet = 1;
break;
case 'v': case 'v':
debug_level++; debug_level++;
break; break;

4
tmux.h
View File

@ -1,4 +1,4 @@
/* $Id: tmux.h,v 1.143 2008-06-16 06:10:02 nicm Exp $ */ /* $Id: tmux.h,v 1.144 2008-06-16 17:35:40 nicm Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -685,6 +685,7 @@ struct cmd_ctx {
struct msg_command_data *msgdata; struct msg_command_data *msgdata;
void (*print)(struct cmd_ctx *, const char *, ...); void (*print)(struct cmd_ctx *, const char *, ...);
void (*info)(struct cmd_ctx *, const char *, ...);
void (*error)(struct cmd_ctx *, const char *, ...); void (*error)(struct cmd_ctx *, const char *, ...);
#define CMD_KEY 0x1 #define CMD_KEY 0x1
@ -760,6 +761,7 @@ extern struct options global_options;
extern char *cfg_file; extern char *cfg_file;
extern char *paste_buffer; extern char *paste_buffer;
extern int debug_level; extern int debug_level;
extern int be_quiet;
void logfile(const char *); void logfile(const char *);
void siginit(void); void siginit(void);
void sigreset(void); void sigreset(void);