summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsabetts <sabetts>2001-09-16 10:28:01 +0000
committersabetts <sabetts>2001-09-16 10:28:01 +0000
commit263045888faed24f9a0be0b34d5105080cdd49a6 (patch)
tree4678e83f8b8d8122505d3e2060cb5f1c6779e253 /src
parent4b68178c380e2d3d9915bb2993b90cf5ab9c6be9 (diff)
downloadratpoison-263045888faed24f9a0be0b34d5105080cdd49a6.zip
(format_window_name): Use 2 character escape codes,
like printf. Dependant code updated.
Diffstat (limited to 'src')
-rw-r--r--src/list.c98
-rw-r--r--src/main.c2
2 files changed, 60 insertions, 40 deletions
diff --git a/src/list.c b/src/list.c
index 619c907..d6d2bca 100644
--- a/src/list.c
+++ b/src/list.c
@@ -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;
}
}
}
diff --git a/src/main.c b/src/main.c
index e699cd1..33589b3 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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");