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 /src/list.c | |
parent | 4b68178c380e2d3d9915bb2993b90cf5ab9c6be9 (diff) | |
download | ratpoison-263045888faed24f9a0be0b34d5105080cdd49a6.zip |
(format_window_name): Use 2 character escape codes,
like printf. Dependant code updated.
Diffstat (limited to 'src/list.c')
-rw-r--r-- | src/list.c | 98 |
1 files changed, 59 insertions, 39 deletions
@@ -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; } } } |