diff options
author | sabetts <sabetts> | 2001-09-16 10:28:01 +0000 |
---|---|---|
committer | sabetts <sabetts> | 2001-09-16 10:28:01 +0000 |
commit | 263045888faed24f9a0be0b34d5105080cdd49a6 (patch) | |
tree | 4678e83f8b8d8122505d3e2060cb5f1c6779e253 | |
parent | 4b68178c380e2d3d9915bb2993b90cf5ab9c6be9 (diff) | |
download | ratpoison-263045888faed24f9a0be0b34d5105080cdd49a6.zip |
(format_window_name): Use 2 character escape codes,
like printf. Dependant code updated.
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | src/list.c | 98 | ||||
-rw-r--r-- | src/main.c | 2 |
3 files changed, 63 insertions, 40 deletions
@@ -1,5 +1,8 @@ 2001-09-16 shawn <sabetts@diggin.lamenet.tmp> + * src/list.c (format_window_name): Use 2 character escape codes, + like printf. Dependant code updated. + * configure.in: check for setpgrp. * src/actions.c (spawn): Only call setsid if it exists. @@ -610,60 +610,80 @@ print_window_information (rp_window *win) } /* format options - N - Window number - - - Window status (current window, last window, etc) - W - Window Name - w - Window res name - c - Window res class - n - X11 Window ID + %n - Window number + %s - Window status (current window, last window, etc) + %t - Window Name + %a - application name + %c - resource class + %i - X11 Window ID */ static void format_window_name (char *fmt, rp_window *win, rp_window *other_win, struct sbuf *buffer) { + int esc = 0; char dbuf[10]; for(; *fmt; fmt++) { - switch (*fmt) + if (*fmt == '%' && !esc) { - case 'N': - snprintf (dbuf, 10, "%d", win->number); - sbuf_concat (buffer, dbuf); - break; - - case '-': - if (win == current_window()) - sbuf_concat (buffer, "*"); - else if (win == other_win) - sbuf_concat (buffer, "+"); - else - sbuf_concat (buffer, "-"); - break; - - case 'W': - sbuf_concat (buffer, window_name (win)); - break; - - case 'w': - sbuf_concat (buffer, win->res_name); - break; - - case 'c': - sbuf_concat (buffer, win->res_class); - break; - - case 'n': - snprintf (dbuf, 9, "%ld", (unsigned long)win->w); - sbuf_concat (buffer, dbuf); - break; + esc = 1; + continue; + } - default: + if (esc) + { + switch (*fmt) + { + case 'n': + snprintf (dbuf, 10, "%d", win->number); + sbuf_concat (buffer, dbuf); + break; + + case 's': + if (win == current_window()) + sbuf_concat (buffer, "*"); + else if (win == other_win) + sbuf_concat (buffer, "+"); + else + sbuf_concat (buffer, "-"); + break; + + case 't': + sbuf_concat (buffer, window_name (win)); + break; + + case 'a': + sbuf_concat (buffer, win->res_name); + break; + + case 'c': + sbuf_concat (buffer, win->res_class); + break; + + case 'i': + snprintf (dbuf, 9, "%ld", (unsigned long)win->w); + sbuf_concat (buffer, dbuf); + break; + + case '%': + dbuf[0] = '%'; + dbuf[1] = 0; + sbuf_concat (buffer, dbuf); + break; + } + + /* Reset the 'escape' state. */ + esc = 0; + } + else + { + /* Insert the character. */ dbuf[0] = *fmt; dbuf[1] = 0; sbuf_concat (buffer, dbuf); - break; } } } @@ -373,7 +373,7 @@ init_defaults () defaults.wait_for_key_cursor = 1; - defaults.window_fmt = strdup ("N-W"); + defaults.window_fmt = strdup ("%n%s%t"); if (defaults.window_fmt == NULL) { PRINT_ERROR ("Not enough memory\n"); |