mirror of
https://github.com/tmux/tmux.git
synced 2024-12-13 18:38:48 +00:00
Add a bell-action option.
This commit is contained in:
parent
94f003bbec
commit
de24fbb35c
6
CHANGES
6
CHANGES
@ -1,5 +1,9 @@
|
||||
19 October 2007
|
||||
|
||||
* (nicm) bell-style option with three choices: "none" completely ignore bell;
|
||||
"any" pass through a bell in any window to current; "current" ignore bells
|
||||
except in current window. This applies only to the bell terminal signal,
|
||||
the status bar always reflects any bells.
|
||||
* (nicm) Refresh session command.
|
||||
|
||||
12 October 2007
|
||||
@ -131,5 +135,5 @@
|
||||
(including mutt, emacs). No status bar yet and no key remapping or other
|
||||
customisation.
|
||||
|
||||
$Id: CHANGES,v 1.42 2007-10-19 09:21:24 nicm Exp $
|
||||
$Id: CHANGES,v 1.43 2007-10-19 10:21:24 nicm Exp $
|
||||
|
||||
|
1
TODO
1
TODO
@ -46,7 +46,6 @@
|
||||
|
||||
-- For 0.1 --------------------------------------------------------------------
|
||||
- man page
|
||||
- sort out bell: passing through should be optional
|
||||
- commands:
|
||||
rename sessions
|
||||
swap windows
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: cmd-set-option.c,v 1.8 2007-10-19 09:21:26 nicm Exp $ */
|
||||
/* $Id: cmd-set-option.c,v 1.9 2007-10-19 10:21:33 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -171,6 +171,21 @@ cmd_set_option_exec(void *ptr, unused struct cmd_ctx *ctx)
|
||||
server_redraw_client(c);
|
||||
}
|
||||
}
|
||||
} else if (strcmp(data->option, "bell-action") == 0) {
|
||||
if (data->value == NULL) {
|
||||
ctx->error(ctx, "invalid value");
|
||||
return;
|
||||
}
|
||||
if (strcmp(data->value, "any") == 0)
|
||||
bell_action = BELL_ANY;
|
||||
else if (strcmp(data->value, "none") == 0)
|
||||
bell_action = BELL_NONE;
|
||||
else if (strcmp(data->value, "current") == 0)
|
||||
bell_action = BELL_CURRENT;
|
||||
else {
|
||||
ctx->error(ctx, "unknown bell-action: %s", data->value);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
ctx->error(ctx, "unknown option: %s", data->option);
|
||||
return;
|
||||
|
4
input.c
4
input.c
@ -1,4 +1,4 @@
|
||||
/* $Id: input.c,v 1.23 2007-10-12 11:44:30 nicm Exp $ */
|
||||
/* $Id: input.c,v 1.24 2007-10-19 10:21:33 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -390,7 +390,7 @@ input_handle_c0_control(u_char ch, struct input_ctx *ictx)
|
||||
break;
|
||||
case '\007': /* BELL */
|
||||
ictx->flags |= INPUT_BELL;
|
||||
break;
|
||||
return;
|
||||
case '\010': /* BS */
|
||||
if (ictx->s->cx > 0)
|
||||
ictx->s->cx--;
|
||||
|
6
resize.c
6
resize.c
@ -1,4 +1,4 @@
|
||||
/* $Id: resize.c,v 1.3 2007-10-05 18:25:05 nicm Exp $ */
|
||||
/* $Id: resize.c,v 1.4 2007-10-19 10:21:35 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -113,8 +113,8 @@ recalculate_sizes(void)
|
||||
log_debug("window size %u,%u (was %u,%u)",
|
||||
ssx, ssy, w->screen.sx, w->screen.sy);
|
||||
|
||||
server_clear_window(w);
|
||||
server_clear_window_cur(w);
|
||||
window_resize(w, ssx, ssy);
|
||||
server_redraw_window(w);
|
||||
server_redraw_window_cur(w);
|
||||
}
|
||||
}
|
||||
|
72
server-fn.c
72
server-fn.c
@ -1,4 +1,4 @@
|
||||
/* $Id: server-fn.c,v 1.20 2007-10-12 11:24:15 nicm Exp $ */
|
||||
/* $Id: server-fn.c,v 1.21 2007-10-19 10:21:35 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -105,7 +105,7 @@ server_write_session(
|
||||
}
|
||||
|
||||
void
|
||||
server_write_window(
|
||||
server_write_window_cur(
|
||||
struct window *w, enum hdrtype type, const void *buf, size_t len)
|
||||
{
|
||||
struct client *c;
|
||||
@ -122,6 +122,25 @@ server_write_window(
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
server_write_window_all(
|
||||
struct window *w, enum hdrtype type, const void *buf, size_t len)
|
||||
{
|
||||
struct client *c;
|
||||
u_int i;
|
||||
|
||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||
c = ARRAY_ITEM(&clients, i);
|
||||
if (c == NULL || c->session == NULL)
|
||||
continue;
|
||||
if (session_has(c->session, w)) {
|
||||
if (c->flags & CLIENT_HOLD) /* XXX OUTPUT only */
|
||||
continue;
|
||||
server_write_client(c, type, buf, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
server_status_client(struct client *c)
|
||||
{
|
||||
@ -222,7 +241,7 @@ server_status_session(struct session *s)
|
||||
}
|
||||
|
||||
void
|
||||
server_clear_window(struct window *w)
|
||||
server_clear_window_cur(struct window *w)
|
||||
{
|
||||
struct client *c;
|
||||
u_int i;
|
||||
@ -235,7 +254,22 @@ server_clear_window(struct window *w)
|
||||
}
|
||||
|
||||
void
|
||||
server_redraw_window(struct window *w)
|
||||
server_clear_window_all(struct window *w)
|
||||
{
|
||||
struct client *c;
|
||||
u_int i;
|
||||
|
||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||
c = ARRAY_ITEM(&clients, i);
|
||||
if (c == NULL || c->session == NULL)
|
||||
continue;
|
||||
if (session_has(c->session, w))
|
||||
server_redraw_client(c);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
server_redraw_window_cur(struct window *w)
|
||||
{
|
||||
struct client *c;
|
||||
u_int i;
|
||||
@ -248,7 +282,35 @@ server_redraw_window(struct window *w)
|
||||
}
|
||||
|
||||
void
|
||||
server_status_window(struct window *w)
|
||||
server_redraw_window_all(struct window *w)
|
||||
{
|
||||
struct client *c;
|
||||
u_int i;
|
||||
|
||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||
c = ARRAY_ITEM(&clients, i);
|
||||
if (c == NULL || c->session == NULL)
|
||||
continue;
|
||||
if (session_has(c->session, w))
|
||||
server_redraw_client(c);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
server_status_window_cur(struct window *w)
|
||||
{
|
||||
struct client *c;
|
||||
u_int i;
|
||||
|
||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||
c = ARRAY_ITEM(&clients, i);
|
||||
if (c != NULL && c->session != NULL && c->session->window == w)
|
||||
server_status_client(c);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
server_status_window_all(struct window *w)
|
||||
{
|
||||
struct client *c;
|
||||
u_int i;
|
||||
|
23
server.c
23
server.c
@ -1,4 +1,4 @@
|
||||
/* $Id: server.c,v 1.27 2007-10-12 11:24:15 nicm Exp $ */
|
||||
/* $Id: server.c,v 1.28 2007-10-19 10:21:35 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -328,8 +328,10 @@ server_handle_window(struct window *w)
|
||||
|
||||
b = buffer_create(BUFSIZ);
|
||||
window_data(w, b);
|
||||
if (BUFFER_USED(b) != 0)
|
||||
server_write_window(w, MSG_DATA, BUFFER_OUT(b), BUFFER_USED(b));
|
||||
if (BUFFER_USED(b) != 0) {
|
||||
server_write_window_cur(
|
||||
w, MSG_DATA, BUFFER_OUT(b), BUFFER_USED(b));
|
||||
}
|
||||
buffer_destroy(b);
|
||||
|
||||
if (!(w->flags & WINDOW_BELL))
|
||||
@ -341,8 +343,19 @@ server_handle_window(struct window *w)
|
||||
session_addbell(s, w);
|
||||
}
|
||||
|
||||
server_write_window(w, MSG_DATA, "\007", 1);
|
||||
server_status_window(w);
|
||||
switch (bell_action) {
|
||||
case BELL_ANY:
|
||||
server_write_window_all(w, MSG_DATA, "\007", 1);
|
||||
break;
|
||||
case BELL_CURRENT:
|
||||
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
|
||||
s = ARRAY_ITEM(&sessions, i);
|
||||
if (s != NULL && s->window == w)
|
||||
server_write_session(s, MSG_DATA, "\007", 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
server_status_window_all(w);
|
||||
|
||||
w->flags &= ~WINDOW_BELL;
|
||||
}
|
||||
|
5
tmux.c
5
tmux.c
@ -1,4 +1,4 @@
|
||||
/* $Id: tmux.c,v 1.32 2007-10-12 17:52:41 nicm Exp $ */
|
||||
/* $Id: tmux.c,v 1.33 2007-10-19 10:21:35 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -42,6 +42,7 @@ int prefix_key = META;
|
||||
u_int status_lines;
|
||||
u_char status_colour;
|
||||
char *default_command;
|
||||
int bell_action;
|
||||
|
||||
void sighandler(int);
|
||||
|
||||
@ -199,6 +200,8 @@ main(int argc, char **argv)
|
||||
status_lines = 1;
|
||||
status_colour = 0x02;
|
||||
|
||||
bell_action = BELL_ANY;
|
||||
|
||||
shell = getenv("SHELL");
|
||||
if (shell == NULL || *shell == '\0')
|
||||
shell = "/bin/ksh";
|
||||
|
19
tmux.h
19
tmux.h
@ -1,4 +1,4 @@
|
||||
/* $Id: tmux.h,v 1.59 2007-10-19 09:21:26 nicm Exp $ */
|
||||
/* $Id: tmux.h,v 1.60 2007-10-19 10:21:36 nicm Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||
@ -495,6 +495,10 @@ ARRAY_DECL(bindings, struct binding *);
|
||||
/* tmux.c */
|
||||
extern volatile sig_atomic_t sigwinch;
|
||||
extern volatile sig_atomic_t sigterm;
|
||||
#define BELL_NONE 0
|
||||
#define BELL_ANY 1
|
||||
#define BELL_CURRENT 2
|
||||
extern int bell_action;
|
||||
extern int prefix_key;
|
||||
extern int debug_level;
|
||||
extern u_int status_lines;
|
||||
@ -571,16 +575,21 @@ void server_write_client(
|
||||
struct client *, enum hdrtype, const void *, size_t);
|
||||
void server_write_session(
|
||||
struct session *, enum hdrtype, const void *, size_t);
|
||||
void server_write_window(
|
||||
void server_write_window_cur(
|
||||
struct window *, enum hdrtype, const void *, size_t);
|
||||
void server_write_window_all(
|
||||
struct window *, enum hdrtype, const void *, size_t);
|
||||
void server_status_client(struct client *);
|
||||
void server_clear_client(struct client *);
|
||||
void server_redraw_client(struct client *);
|
||||
void server_status_session(struct session *);
|
||||
void server_redraw_session(struct session *);
|
||||
void server_status_window(struct window *);
|
||||
void server_clear_window(struct window *);
|
||||
void server_redraw_window(struct window *);
|
||||
void server_status_window_cur(struct window *);
|
||||
void server_status_window_all(struct window *);
|
||||
void server_clear_window_cur(struct window *);
|
||||
void server_clear_window_all(struct window *);
|
||||
void server_redraw_window_cur(struct window *);
|
||||
void server_redraw_window_all(struct window *);
|
||||
void server_write_message(struct client *, const char *, ...);
|
||||
|
||||
/* status.c */
|
||||
|
Loading…
Reference in New Issue
Block a user