Mark windows in yellow on status line when bell.

pull/1/head
Nicholas Marriott 2007-10-12 11:24:15 +00:00
parent d158938178
commit ad4a7423c0
10 changed files with 105 additions and 45 deletions

View File

@ -1,3 +1,7 @@
12 October 2007
* (nicm) Make status line mark window in yellow on bell.
04 October 2007
* (nicm) -d option to attach to detach all other clients on the same session.
@ -118,5 +122,5 @@
(including mutt, emacs). No status bar yet and no key remapping or other
customisation.
$Id: CHANGES,v 1.36 2007-10-04 21:21:48 nicm Exp $
$Id: CHANGES,v 1.37 2007-10-12 11:24:14 nicm Exp $

3
TODO
View File

@ -45,8 +45,7 @@
-- For 0.1 --------------------------------------------------------------------
- man page
- sort out bell: passing through should be optional, and toolbar should change
window colour or something
- sort out bell: passing through should be optional
- commands:
refresh session (similar to detach: -a for all, else if key redraw cur,
else do nothing)

View File

@ -1,4 +1,4 @@
/* $Id: client-msg.c,v 1.8 2007-10-05 14:23:28 nicm Exp $ */
/* $Id: client-msg.c,v 1.9 2007-10-12 11:24:15 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -67,8 +67,7 @@ client_msg_dispatch(struct client_ctx *cctx, char **error)
return (0);
}
}
if (i == NCLIENTMSG)
fatalx("unexpected message");
fatalx("unexpected message");
}
int

View File

@ -1,4 +1,4 @@
/* $Id: cmd-new-window.c,v 1.7 2007-10-04 22:04:01 nicm Exp $ */
/* $Id: cmd-new-window.c,v 1.8 2007-10-12 11:24:15 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -112,14 +112,8 @@ cmd_new_window_exec(void *ptr, struct cmd_ctx *ctx)
if (!data->flag_detached) {
session_select(s, i);
server_redraw_session(s);
} else {
/* XXX */
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);
if (c != NULL && c->session == s)
server_redraw_status(c);
}
}
} else
server_status_session(s);
if (!(ctx->flags & CMD_KEY))
server_write_client(c, MSG_EXIT, NULL, 0);

View File

@ -1,4 +1,4 @@
/* $Id: cmd-rename-window.c,v 1.4 2007-10-04 22:04:01 nicm Exp $ */
/* $Id: cmd-rename-window.c,v 1.5 2007-10-12 11:24:15 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -97,7 +97,6 @@ cmd_rename_window_exec(void *ptr, struct cmd_ctx *ctx)
struct client *c = ctx->client;
struct session *s = ctx->session;
struct window *w;
u_int i;
if (data == NULL)
return;
@ -111,12 +110,7 @@ cmd_rename_window_exec(void *ptr, struct cmd_ctx *ctx)
xfree(w->name);
w->name = xstrdup(data->newname);
/*XXX*/
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);
if (c != NULL && c->session == s)
server_redraw_status(c);
}
server_status_session(s);
if (!(ctx->flags & CMD_KEY))
server_write_client(c, MSG_EXIT, NULL, 0);

View File

@ -1,4 +1,4 @@
/* $Id: server-fn.c,v 1.19 2007-10-04 19:22:26 nicm Exp $ */
/* $Id: server-fn.c,v 1.20 2007-10-12 11:24:15 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -123,7 +123,7 @@ server_write_window(
}
void
server_redraw_status(struct client *c)
server_status_client(struct client *c)
{
struct hdr hdr;
size_t size;
@ -192,7 +192,7 @@ server_redraw_client(struct client *c)
} else
buffer_reverse_add(c->out, sizeof hdr);
server_redraw_status(c);
server_status_client(c);
}
void
@ -208,6 +208,19 @@ server_redraw_session(struct session *s)
}
}
void
server_status_session(struct session *s)
{
struct client *c;
u_int i;
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);
if (c != NULL && c->session == s)
server_status_client(c);
}
}
void
server_clear_window(struct window *w)
{
@ -234,6 +247,21 @@ server_redraw_window(struct window *w)
}
}
void
server_status_window(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_status_client(c);
}
}
void
server_write_message(struct client *c, const char *fmt, ...)
{

View File

@ -1,4 +1,4 @@
/* $Id: server.c,v 1.26 2007-10-04 21:21:48 nicm Exp $ */
/* $Id: server.c,v 1.27 2007-10-12 11:24:15 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -322,10 +322,9 @@ server_lost_client(struct client *c)
void
server_handle_window(struct window *w)
{
struct client *c;
struct session *s;
struct buffer *b;
u_int i, j;
struct session *s;
u_int i;
b = buffer_create(BUFSIZ);
window_data(w, b);
@ -338,17 +337,13 @@ server_handle_window(struct window *w)
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
s = ARRAY_ITEM(&sessions, i);
if (s == NULL || !session_has(s, w))
continue;
for (j = 0; j < ARRAY_LENGTH(&clients); j++) {
c = ARRAY_ITEM(&clients, j);
if (c == NULL || c->session != s)
continue;
server_write_client(c, MSG_DATA, "\007", 1);
}
if (s != NULL)
session_addbell(s, w);
}
server_write_window(w, MSG_DATA, "\007", 1);
server_status_window(w);
w->flags &= ~WINDOW_BELL;
}

View File

@ -1,4 +1,4 @@
/* $Id: session.c,v 1.21 2007-10-03 23:32:26 nicm Exp $ */
/* $Id: session.c,v 1.22 2007-10-12 11:24:15 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -27,6 +27,36 @@
/* Global session list. */
struct sessions sessions;
void
session_cancelbell(struct session *s, struct window *w)
{
u_int i;
if (window_index(&s->bells, w, &i) == 0)
window_remove(&s->bells, w);
}
void
session_addbell(struct session *s, struct window *w)
{
u_int i;
/* Never bell in the current window. */
if (w == s->window || !session_has(s, w))
return;
if (window_index(&s->bells, w, &i) != 0)
window_add(&s->bells, w);
}
int
session_hasbell(struct session *s, struct window *w)
{
u_int i;
return (window_index(&s->bells, w, &i) == 0);
}
/* Find session by name. */
struct session *
session_find(const char *name)
@ -54,6 +84,7 @@ session_create(const char *name, const char *cmd, u_int sx, u_int sy)
s->tim = time(NULL);
s->window = s->last = NULL;
ARRAY_INIT(&s->windows);
ARRAY_INIT(&s->bells);
s->sx = sx;
s->sy = sy;
@ -186,6 +217,7 @@ session_next(struct session *s)
return (0);
s->last = s->window;
s->window = w;
session_cancelbell(s, w);
return (0);
}
@ -208,6 +240,7 @@ session_previous(struct session *s)
return (0);
s->last = s->window;
s->window = w;
session_cancelbell(s, w);
return (0);
}
@ -224,6 +257,7 @@ session_select(struct session *s, u_int i)
return (0);
s->last = s->window;
s->window = w;
session_cancelbell(s, w);
return (0);
}
@ -241,5 +275,6 @@ session_last(struct session *s)
s->last = s->window;
s->window = w;
session_cancelbell(s, w);
return (0);
}

View File

@ -1,4 +1,4 @@
/* $Id: status.c,v 1.3 2007-10-04 19:03:52 nicm Exp $ */
/* $Id: status.c,v 1.4 2007-10-12 11:24:15 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -42,8 +42,13 @@ status_write(struct client *c)
w = ARRAY_ITEM(&c->session->windows, i);
if (w == NULL)
continue;
if (session_hasbell(c->session, w))
input_store_two(b, CODE_ATTRIBUTES, ATTR_REVERSE, 0x30);
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))
input_store_two(b, CODE_ATTRIBUTES, ATTR_REVERSE, 0x20);
status_print(b, &size, " ");
if (size == 0)
break;
}

11
tmux.h
View File

@ -1,4 +1,4 @@
/* $Id: tmux.h,v 1.53 2007-10-10 19:45:20 nicm Exp $ */
/* $Id: tmux.h,v 1.54 2007-10-12 11:24:15 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -410,6 +410,8 @@ struct session {
struct window *last;
struct windows windows;
struct windows bells; /* windows with bells */
#define SESSION_UNATTACHED 0x1 /* not attached to any clients */
int flags;
};
@ -567,10 +569,12 @@ void server_write_session(
struct session *, enum hdrtype, const void *, size_t);
void server_write_window(
struct window *, enum hdrtype, const void *, size_t);
void server_redraw_status(struct client *);
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_write_message(struct client *, const char *, ...);
@ -647,6 +651,9 @@ void window_data(struct window *, struct buffer *);
/* session.c */
extern struct sessions sessions;
void session_cancelbell(struct session *, struct window *);
void session_addbell(struct session *, struct window *);
int session_hasbell(struct session *, struct window *);
struct session *session_find(const char *);
struct session *session_create(const char *, const char *, u_int, u_int);
void session_destroy(struct session *);