[PATCH] More window status indicators
I tend to have a lot of windows with long-ish processes running in them, and wanted a way to see their status at a glance. Specifically: 1) When a command completes the window status shows that it passed or failed, and the indicator disappears when I visit the window. 2) When a command starts, the window status gets a 'sticky' indicator showing that something is running. I can visit the window to see how a command is progressing, then when I switch to another window the running status stays. I was sort of able to do (1) using the alert and monitor-content indicators. I would use the return code of the finished command with my prompt command to echo a BEL char if it failed (causing the alert indicator), or the monitor-content would see my unlikely-to-appear prompt (causing that indicator). This worked okay, but sometimes processes would send a BEL and falsely trigger the done-and-failed indication, and the monitor-content indicator has the known behavior that some output causes the window to be rescanned and a previous prompt would falsely trigger the done-and-passed indication. I couldn't figure out a way to do (2). And so this patch. It does the simplest possible thing that would work: I copied the behavior of the alert indicator and check for certain low-number ASCII codes and change the indicator accordingly. Then I use the pre-command and post-command variables of my shell to send the appropriate ASCII codes. This works with zsh and tcsh (which I'm forced to use at work -- yeah yeah I know), and I have seen ways you could get the same behavior with bash. This is probably a rather naive approach; suggestions of a better way to do it are welcome. A cool extension of this would be allowing the user to add any number of regular/sticky indicators of their choosing. --- input.c | 11 +++ options-table.c | 45 + server-window.c | 42 +- status.c| 32 tmux.h |9 - window.c|6 ++ 6 files changed, 143 insertions(+), 2 deletions(-) diff --git a/input.c b/input.c index 960a0e6..e165771 100644 --- a/input.c +++ b/input.c @@ -971,6 +971,17 @@ input_c0_dispatch(struct input_ctx *ictx) case '\017':/* SI */ ictx->cell.attr &= ~GRID_ATTR_CHARSET; break; + + case '\006':/* ACK */ + wp->window->flags |= WINDOW_PROC_PASS; + break; + case '\025':/* NAK */ + wp->window->flags |= WINDOW_PROC_FAIL; + break; + case '\026':/* SYN */ + wp->window->flags |= WINDOW_PROC_RUNNING; + break; + default: log_debug("%s: unknown '%c'", __func__, ictx->ch); break; diff --git a/options-table.c b/options-table.c index 8ce838a..8e06927 100644 --- a/options-table.c +++ b/options-table.c @@ -655,6 +655,51 @@ const struct options_table_entry window_options_table[] = { .default_num = 8 }, + { .name = "window-status-proc-pass-attr", + .type = OPTIONS_TABLE_ATTRIBUTES, + .default_num = GRID_ATTR_REVERSE + }, + + { .name = "window-status-proc-pass-bg", + .type = OPTIONS_TABLE_COLOUR, + .default_num = 8 + }, + + { .name = "window-status-proc-pass-fg", + .type = OPTIONS_TABLE_COLOUR, + .default_num = 8 + }, + + { .name = "window-status-proc-fail-attr", + .type = OPTIONS_TABLE_ATTRIBUTES, + .default_num = GRID_ATTR_REVERSE + }, + + { .name = "window-status-proc-fail-bg", + .type = OPTIONS_TABLE_COLOUR, + .default_num = 8 + }, + + { .name = "window-status-proc-fail-fg", + .type = OPTIONS_TABLE_COLOUR, + .default_num = 8 + }, + + { .name = "window-status-proc-running-attr", + .type = OPTIONS_TABLE_ATTRIBUTES, + .default_num = GRID_ATTR_REVERSE + }, + + { .name = "window-status-proc-running-bg", + .type = OPTIONS_TABLE_COLOUR, + .default_num = 8 + }, + + { .name = "window-status-proc-running-fg", + .type = OPTIONS_TABLE_COLOUR, + .default_num = 8 + }, + { .name = "window-status-attr", .type = OPTIONS_TABLE_ATTRIBUTES, .default_num = 0 diff --git a/server-window.c b/server-window.c index fce6439..97b3bbf 100644 --- a/server-window.c +++ b/server-window.c @@ -29,6 +29,7 @@ int server_window_check_activity(struct session *, struct winlink *); intserver_window_check_silence(struct session *, struct winlink *); intserver_window_check_content( struct session *, struct winlink *, struct window_pane *); +intserver_window_check_proc(struct session *, struct winlink *); void ring_bell(struct session *); /* Window functions that need to ha
Re: [PATCH] More window status indicators
On Wed, Dec 12, 2012 at 2:21 PM, Nicholas Marriott wrote: > Hi > > You definitely shouldn't use C0 control codes for this, you should > probably use DCS but with a different prefix instead of "tmux;" which is > used for raw passthrough (look at input_dcs_dispatch). > Yes, I thought that was probably not the best way to do it. I don't know how DCS works, but I'm sure Google will help. > However, I'm not sure we need code to do this at all. Can't you use a > wrapper script that sets the colour/renames the window/etc? That's what > I do for ssh. > > For example something like: [example snipped] I think that would work for the 'sticky' status that I want, but I would still have to use the alert and monitor-content indicators for fail/pass which have the limitations I mentioned before. I'll work on the DCS method and post a new patch. I understand it will likely be rejected, but perhaps someone else will find it useful. I certainly do :) Scott -- LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d ___ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users
Re: [PATCH] More window status indicators
On Thu, Dec 13, 2012 at 9:57 AM, Nicholas Marriott wrote: > On Thu, Dec 13, 2012 at 09:38:01AM -0500, Scott Frazer wrote: >> On Wed, Dec 12, 2012 at 2:21 PM, Nicholas Marriott >> wrote: >> > Hi >> > >> > You definitely shouldn't use C0 control codes for this, you should >> > probably use DCS but with a different prefix instead of "tmux;" which is >> > used for raw passthrough (look at input_dcs_dispatch). >> > >> >> Yes, I thought that was probably not the best way to do it. I don't know how >> DCS works, but I'm sure Google will help. >> >> > However, I'm not sure we need code to do this at all. Can't you use a >> > wrapper script that sets the colour/renames the window/etc? That's what >> > I do for ssh. >> > >> > For example something like: >> >> [example snipped] >> >> I think that would work for the 'sticky' status that I want, but I would >> still >> have to use the alert and monitor-content indicators for fail/pass which have >> the limitations I mentioned before. I'll work on the DCS method and post a >> new patch. I understand it will likely be rejected, but perhaps someone else >> will find it useful. I certainly do :) > > You could check the return code and set different names/colours on > success or failure and bind a key to reset the window options, maybe not > quite as quick as it automatically removing the state but it'd work :-). I thought some more about your approach of using the command line, and while I liked it I didn't want to manually remove the pass/fail status when I visited a window. So I created this patch which adds an 'attention' indication that is higher priority than the regular colors/attributes, and gets automatically removed when you go to the window. Again it feels a bit hacky, but was a simple way to do it. I like it better than my first approach because you can add colors/attributes any way you want for any number of things. Scott --- options-table.c | 15 +++ status.c| 12 2 files changed, 27 insertions(+), 0 deletions(-) diff --git a/options-table.c b/options-table.c index 8ce838a..1e2bde1 100644 --- a/options-table.c +++ b/options-table.c @@ -655,6 +655,21 @@ const struct options_table_entry window_options_table[] = { .default_num = 8 }, + { .name = "window-status-attn-attr", + .type = OPTIONS_TABLE_ATTRIBUTES, + .default_num = 0 + }, + + { .name = "window-status-attn-bg", + .type = OPTIONS_TABLE_COLOUR, + .default_num = 8 + }, + + { .name = "window-status-attn-fg", + .type = OPTIONS_TABLE_COLOUR, + .default_num = 8 + }, + { .name = "window-status-attr", .type = OPTIONS_TABLE_ATTRIBUTES, .default_num = 0 diff --git a/status.c b/status.c index e841d80..9223401 100644 --- a/status.c +++ b/status.c @@ -692,6 +692,15 @@ status_print( attr = options_get_number(oo, "window-status-attr"); if (attr != 0) gc->attr = attr; + fg = options_get_number(oo, "window-status-attn-fg"); + if (fg != 8) + colour_set_fg(gc, fg); + bg = options_get_number(oo, "window-status-attn-bg"); + if (bg != 8) + colour_set_bg(gc, bg); + attr = options_get_number(oo, "window-status-attn-attr"); + if (attr != 0) + gc->attr = attr; fmt = options_get_string(oo, "window-status-format"); if (wl == s->curw) { fg = options_get_number(oo, "window-status-current-fg"); @@ -704,6 +713,9 @@ status_print( if (attr != 0) gc->attr = attr; fmt = options_get_string(oo, "window-status-current-format"); + options_set_number(oo, "window-status-attn-fg", 8); + options_set_number(oo, "window-status-attn-bg", 8); + options_set_number(oo, "window-status-attn-attr", 0); } if (wl->flags & WINLINK_BELL) { -- 1.7.8 -- LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d ___ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users