From: Michael Stapelberg Date: Fri, 10 Jun 2011 00:38:07 +0000 (+0200) Subject: Re-implement the 'mode' command X-Git-Tag: tree-pr4~86 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=39b1c1bf754ccc81a362dbe2be9b02ba9799baa5;p=i3%2Fi3 Re-implement the 'mode' command --- diff --git a/include/config.h b/include/config.h index c4fe6b08..f05de324 100644 --- a/include/config.h +++ b/include/config.h @@ -171,7 +171,7 @@ void grab_all_keys(xcb_connection_t *conn, bool bind_mode_switch); * Switches the key bindings to the given mode, if the mode exists * */ -void switch_mode(xcb_connection_t *conn, const char *new_mode); +void switch_mode(const char *new_mode); /** * Returns a pointer to the Binding with the specified modifiers and keycode diff --git a/src/cmdparse.l b/src/cmdparse.l index bc83b026..641265e6 100644 --- a/src/cmdparse.l +++ b/src/cmdparse.l @@ -112,7 +112,7 @@ border { return TOK_BORDER; } normal { return TOK_NORMAL; } none { return TOK_NONE; } 1pixel { return TOK_1PIXEL; } -mode { return TOK_MODE; } +mode { BEGIN(WANT_QSTRING); return TOK_MODE; } tiling { return TOK_TILING; } floating { return TOK_FLOATING; } toggle { return TOK_TOGGLE; } diff --git a/src/cmdparse.y b/src/cmdparse.y index a540efed..f86bead9 100644 --- a/src/cmdparse.y +++ b/src/cmdparse.y @@ -352,6 +352,7 @@ operation: | mark | resize | nop + | mode ; exec: @@ -784,3 +785,10 @@ direction: | TOK_LEFT { $$ = TOK_LEFT; } | TOK_RIGHT { $$ = TOK_RIGHT; } ; + +mode: + TOK_MODE STR + { + switch_mode($2); + } + ; diff --git a/src/config.c b/src/config.c index 572b4ab9..98b40dc4 100644 --- a/src/config.c +++ b/src/config.c @@ -150,7 +150,7 @@ void grab_all_keys(xcb_connection_t *conn, bool bind_mode_switch) { * Switches the key bindings to the given mode, if the mode exists * */ -void switch_mode(xcb_connection_t *conn, const char *new_mode) { +void switch_mode(const char *new_mode) { struct Mode *mode; LOG("Switching to mode %s\n", new_mode);