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
* 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.
15 June 2008
@ -480,4 +482,4 @@
(including mutt, emacs). No status bar yet and no key remapping or other
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
- figure out Linux tcsetattr problem, remove header bodge if unnecessary
- flags to centre screen in window
- get rid of DEFDATA etc
-- For 0.3 --------------------------------------------------------------------
- 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>
@ -123,6 +123,7 @@ load_cfg(const char *path, char **causep)
ctx.error = cfg_error;
ctx.print = cfg_print;
ctx.info = cfg_print;
ctx.cmdclient = NULL;
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>
@ -145,6 +145,14 @@ cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx)
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++) {
s = ARRAY_ITEM(&sessions, i);
if (s != NULL)
@ -165,6 +173,14 @@ cmd_set_window_option_exec(struct cmd *self, struct cmd_ctx *ctx)
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();
} else if (strcmp(data->option, "force-width") == 0) {
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;
else
wl->window->limitx = number;
ctx->info(ctx, "window %s:%d: set force-width %u",
s->name, wl->idx, number);
recalculate_sizes();
} else if (strcmp(data->option, "force-height") == 0) {
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;
else
wl->window->limity = number;
ctx->info(ctx, "window %s:%d: set force-height %u",
s->name, wl->idx, number);
recalculate_sizes();
} else {
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>
@ -28,6 +28,7 @@ struct bindings key_bindings;
void printflike2 key_bindings_error(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
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);
}
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
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.print = key_bindings_print;
ctx.info = key_bindings_info;
ctx.cmdclient = NULL;
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>
@ -138,8 +138,6 @@ screen_redraw_write_string(struct screen_redraw_ctx *ctx, const char *fmt, ...)
va_end(ap);
for (ptr = msg; *ptr != '\0'; ptr++) {
if (ctx->s->cx > screen_last_x(s))
break;
if (*ptr < 0x20)
continue;
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>
@ -159,25 +159,33 @@ server_write_message(struct client *c, const char *fmt, ...)
slines = options_get_number(&c->session->options, "status-lines");
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);
xvasprintf(&msg, fmt, ap);
va_end(ap);
msg = xrealloc(msg, 1, c->sx + 1);
msg[c->sx] = '\0';
size = strlen(msg);
if (size < c->sx - 1) {
msg = xrealloc(msg, 1, c->sx);
msg[c->sx - 1] = '\0';
memset(msg + size, SCREEN_DEFDATA, (c->sx - 1) - size);
}
if (size < c->sx)
memset(msg + size, ' ', c->sx - 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);
xfree(msg);
buffer_flush(c->tty.fd, c->tty.in, c->tty.out);
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) {
screen_redraw_lines(&ctx, c->sy - 1, 1);
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>
@ -34,6 +34,8 @@ void printflike2 server_msg_fn_command_error(
struct cmd_ctx *, const char *, ...);
void printflike2 server_msg_fn_command_print(
struct cmd_ctx *, const char *, ...);
void printflike2 server_msg_fn_command_info(
struct cmd_ctx *, const char *, ...);
struct server_msg {
enum hdrtype type;
@ -105,6 +107,23 @@ server_msg_fn_command_print(struct cmd_ctx *ctx, const char *fmt, ...)
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
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.print = server_msg_fn_command_print;
ctx.info = server_msg_fn_command_info;
ctx.msgdata = &data;
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>
.\"
@ -23,7 +23,7 @@
.Sh SYNOPSIS
.Nm tmux
.Bk -words
.Op Fl vV
.Op Fl vVq
.Op Fl f Ar file
.Op Fl S Ar socket-path
.Op Ar command Op Ar flags
@ -50,6 +50,26 @@ Communication takes place through a socket, by default placed in
.Pp
The options are as follows:
.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
Request verbose logging.
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.
.It Fl V
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
This specifies one of a set of commands used to control
.Nm ,
@ -574,6 +581,13 @@ Unlink
A window may be unlinked only if it is linked to multiple sessions - windows may
not be linked to no sessions.
.El
.Sh FILES
.Bl -tag -width Ds -compact
.It Pa ~/.tmux.conf
default
.Nm
configuration file
.El
.Sh SEE ALSO
.Xr pty 4
.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>
@ -48,6 +48,7 @@ struct options global_options;
char *paste_buffer;
int debug_level;
int be_quiet;
void sighandler(int);
__dead void usage(void);
@ -174,7 +175,7 @@ main(int argc, char **argv)
int n, opt;
client = path = name = NULL;
while ((opt = getopt(argc, argv, "f:S:vV")) != EOF) {
while ((opt = getopt(argc, argv, "f:S:qvV")) != EOF) {
switch (opt) {
case 'f':
cfg_file = xstrdup(optarg);
@ -182,6 +183,9 @@ main(int argc, char **argv)
case 'S':
path = xstrdup(optarg);
break;
case 'q':
be_quiet = 1;
break;
case 'v':
debug_level++;
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>
@ -685,6 +685,7 @@ struct cmd_ctx {
struct msg_command_data *msgdata;
void (*print)(struct cmd_ctx *, const char *, ...);
void (*info)(struct cmd_ctx *, const char *, ...);
void (*error)(struct cmd_ctx *, const char *, ...);
#define CMD_KEY 0x1
@ -760,6 +761,7 @@ extern struct options global_options;
extern char *cfg_file;
extern char *paste_buffer;
extern int debug_level;
extern int be_quiet;
void logfile(const char *);
void siginit(void);
void sigreset(void);