From: nicm Date: Tue, 12 May 2015 15:29:29 +0000 (+0000) Subject: Add a session_alerts format which is a list of all the alerts in the X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=fa9fc67029abcfada8c22cc3ad4b6d49796d71fe;p=openbsd Add a session_alerts format which is a list of all the alerts in the current session in symbolic form (something like "0!,4~,5!"). Use this in the default set-titles-string. Prompted by a request from Jan ONDREJ. --- diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c index 98def9dfe0e..8b47b361f92 100644 --- a/usr.bin/tmux/format.c +++ b/usr.bin/tmux/format.c @@ -1,4 +1,4 @@ -/* $OpenBSD: format.c,v 1.65 2015/05/08 16:18:04 nicm Exp $ */ +/* $OpenBSD: format.c,v 1.66 2015/05/12 15:29:29 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott @@ -494,6 +494,8 @@ format_defaults_session(struct format_tree *ft, struct session *s) { struct session_group *sg; time_t t; + struct winlink *wl; + char alerts[256], tmp[16]; ft->s = s; @@ -518,6 +520,24 @@ format_defaults_session(struct format_tree *ft, struct session *s) format_add(ft, "session_attached", "%u", s->attached); format_add(ft, "session_many_attached", "%d", s->attached > 1); + + *alerts = '\0'; + RB_FOREACH (wl, winlinks, &s->windows) { + if ((wl->flags & WINLINK_ALERTFLAGS) == 0) + continue; + snprintf(tmp, sizeof tmp, "%u", wl->idx); + + if (*alerts != '\0') + strlcat(alerts, ",", sizeof alerts); + strlcat(alerts, tmp, sizeof alerts); + if (wl->flags & WINLINK_ACTIVITY) + strlcat(alerts, "#", sizeof alerts); + if (wl->flags & WINLINK_BELL) + strlcat(alerts, "!", sizeof alerts); + if (wl->flags & WINLINK_SILENCE) + strlcat(alerts, "~", sizeof alerts); + } + format_add(ft, "session_alerts", "%s", alerts); } /* Set default format keys for a client. */ diff --git a/usr.bin/tmux/options-table.c b/usr.bin/tmux/options-table.c index 1920e0b6554..a71deb672ba 100644 --- a/usr.bin/tmux/options-table.c +++ b/usr.bin/tmux/options-table.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options-table.c,v 1.59 2015/05/12 15:27:46 nicm Exp $ */ +/* $OpenBSD: options-table.c,v 1.60 2015/05/12 15:29:29 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott @@ -296,7 +296,7 @@ const struct options_table_entry session_options_table[] = { { .name = "set-titles-string", .type = OPTIONS_TABLE_STRING, - .default_str = "#S:#I:#W - \"#T\"" + .default_str = "#S:#I:#W - \"#T\" #{session_alerts}" }, { .name = "status", diff --git a/usr.bin/tmux/tmux.1 b/usr.bin/tmux/tmux.1 index a1271352dba..7ca49f01b67 100644 --- a/usr.bin/tmux/tmux.1 +++ b/usr.bin/tmux/tmux.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tmux.1,v 1.429 2015/05/12 15:27:46 nicm Exp $ +.\" $OpenBSD: tmux.1,v 1.430 2015/05/12 15:29:29 nicm Exp $ .\" .\" Copyright (c) 2007 Nicholas Marriott .\" @@ -3304,6 +3304,7 @@ The following variables are available, where appropriate: .It Li "pane_width" Ta "" Ta "Width of pane" .It Li "scroll_region_lower" Ta "" Ta "Bottom of scroll region in pane" .It Li "scroll_region_upper" Ta "" Ta "Top of scroll region in pane" +.It Li "session_alerts" Ta "" Ta "List of window indexes with alerts" .It Li "session_attached" Ta "" Ta "Number of clients session is attached to" .It Li "session_activity" Ta "" Ta "Integer time of session last activity" .It Li "session_activity_string" Ta "" Ta "String time of session last activity"