From 3229f7677f1cdb78bfb5fb269c09f6e825378bad Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 27 Jan 2012 22:11:03 +0000 Subject: [PATCH] Rip out the old command parser, remove migration code --- Makefile | 16 +- include/commands.h | 6 - src/assignments.c | 4 +- src/cmdparse.l | 214 ---------------- src/cmdparse.y | 626 --------------------------------------------- src/commands.c | 230 +---------------- src/handlers.c | 4 +- src/ipc.c | 2 +- src/move.c | 14 +- 9 files changed, 22 insertions(+), 1094 deletions(-) delete mode 100644 src/cmdparse.l delete mode 100644 src/cmdparse.y diff --git a/Makefile b/Makefile index 6e595de7..d5020384 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ TOPDIR=$(shell pwd) include $(TOPDIR)/common.mk # Depend on the object files of all source-files in src/*.c and on all header files -AUTOGENERATED:=src/cfgparse.tab.c src/cfgparse.yy.c src/cmdparse.tab.c src/cmdparse.yy.c +AUTOGENERATED:=src/cfgparse.tab.c src/cfgparse.yy.c FILES:=$(filter-out $(AUTOGENERATED),$(wildcard src/*.c)) FILES:=$(FILES:.c=.o) HEADERS:=$(filter-out include/loglevels.h,$(wildcard include/*.h)) @@ -28,7 +28,7 @@ src/%.o: src/%.c ${HEADERS} all: i3 subdirs -i3: libi3/libi3.a src/cfgparse.y.o src/cfgparse.yy.o src/cmdparse.y.o src/cmdparse.yy.o ${FILES} +i3: libi3/libi3.a src/cfgparse.y.o src/cfgparse.yy.o ${FILES} echo "[i3] LINK i3" $(CC) $(LDFLAGS) -o $@ $(filter-out libi3/libi3.a,$^) $(LIBS) @@ -75,22 +75,12 @@ src/cfgparse.yy.o: src/cfgparse.l src/cfgparse.y.o ${HEADERS} $(FLEX) -i -o$(@:.o=.c) $< $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cfgparse.l/ { print NR }' loglevels.tmp))" -c -o $@ $(@:.o=.c) -src/cmdparse.yy.o: src/cmdparse.l src/cmdparse.y.o ${HEADERS} - echo "[i3] LEX $<" - $(FLEX) -Pcmdyy -i -o$(@:.o=.c) $< - $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cmdparse.l/ { print NR }' loglevels.tmp))" -c -o $@ $(@:.o=.c) - src/cfgparse.y.o: src/cfgparse.y ${HEADERS} echo "[i3] YACC $<" $(BISON) --debug --verbose -b $(basename $< .y) -d $< $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cfgparse.y/ { print NR }' loglevels.tmp))" -c -o $@ $(<:.y=.tab.c) -src/cmdparse.y.o: src/cmdparse.y ${HEADERS} - echo "[i3] YACC $<" - $(BISON) -p cmdyy --debug --verbose -b $(basename $< .y) -d $< - $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cmdparse.y/ { print NR }' loglevels.tmp))" -c -o $@ $(<:.y=.tab.c) - install: all echo "[i3] INSTALL" @@ -140,7 +130,7 @@ dist: distclean rm -rf i3-${VERSION} clean: - rm -f src/*.o src/*.gcno src/cfgparse.tab.{c,h} src/cfgparse.yy.c src/cfgparse.{output,dot} src/cmdparse.tab.{c,h} src/cmdparse.yy.c src/cmdparse.{output,dot} loglevels.tmp include/loglevels.h include/GENERATED_* + rm -f src/*.o src/*.gcno src/cfgparse.tab.{c,h} src/cfgparse.yy.c src/cfgparse.{output,dot} loglevels.tmp include/loglevels.h include/GENERATED_* (which lcov >/dev/null 2>&1 && lcov -d . --zerocounters) || true $(MAKE) -C libi3 clean $(MAKE) -C docs clean diff --git a/include/commands.h b/include/commands.h index 73812451..a28b799f 100644 --- a/include/commands.h +++ b/include/commands.h @@ -22,12 +22,6 @@ typedef struct owindow { typedef TAILQ_HEAD(owindows_head, owindow) owindows_head; -void cmd_MIGRATION_enable(); -void cmd_MIGRATION_disable(); -void cmd_MIGRATION_save_new_parameters(Match *current_match, ...); -void cmd_MIGRATION_save_old_parameters(Match *current_match, ...); -void cmd_MIGRATION_validate(); - char *cmd_criteria_init(Match *current_match); char *cmd_criteria_match_windows(Match *current_match); char *cmd_criteria_add(Match *current_match, char *ctype, char *cvalue); diff --git a/src/assignments.c b/src/assignments.c index 9ef84707..05da7554 100644 --- a/src/assignments.c +++ b/src/assignments.c @@ -2,7 +2,7 @@ * vim:ts=4:sw=4:expandtab * * i3 - an improved dynamic tiling window manager - * © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE) + * © 2009-2012 Michael Stapelberg and contributors (see also: LICENSE) * * assignments.c: Assignments for specific windows (for_window). * @@ -41,7 +41,7 @@ void run_assignments(i3Window *window) { DLOG("execute command %s\n", current->dest.command); char *full_command; sasprintf(&full_command, "[id=\"%d\"] %s", window->id, current->dest.command); - char *json_result = parse_cmd(full_command); + char *json_result = parse_command(full_command); FREE(full_command); FREE(json_result); } diff --git a/src/cmdparse.l b/src/cmdparse.l deleted file mode 100644 index 47a4f4e0..00000000 --- a/src/cmdparse.l +++ /dev/null @@ -1,214 +0,0 @@ -/* - * vim:ts=4:sw=4:expandtab - * - * i3 - an improved dynamic tiling window manager - * © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE) - * - * cmdparse.l: the lexer for commands you send to i3 (or bind on keys) - * - */ -%option nounput -%option noinput -%option noyy_top_state -%option stack - -%{ -#include -#include -#include "cmdparse.tab.h" - -#include "config.h" -#include "util.h" -#include "libi3.h" - -int cmdyycolumn = 1; - -#define YY_DECL int yylex (struct context *context) - -#define YY_USER_ACTION { \ - context->first_column = cmdyycolumn; \ - context->last_column = cmdyycolumn+yyleng-1; \ - cmdyycolumn += yyleng; \ -} - -/* macro to first eat whitespace, then expect a string */ -#define WS_STRING do { \ - yy_push_state(WANT_STRING); \ - yy_push_state(EAT_WHITESPACE); \ -} while (0) - -%} - -EOL (\r?\n) - -/* handle everything up to \n as a string */ -%s WANT_STRING -/* eat a whitespace, then go to the next state on the stack */ -%s EAT_WHITESPACE -/* handle a quoted string or everything up to the next whitespace */ -%s WANT_QSTRING - -%x MOVE -%x MOVE_WS - -%x EXEC - -%x BUFFER_LINE - -%% - - { - /* This is called when a new line is lexed. We only want the - * first line to match to go into state BUFFER_LINE */ - if (context->line_number == 0) { - context->line_number = 1; - BEGIN(INITIAL); - yy_push_state(BUFFER_LINE); - } - } - -^[^\r\n]*/{EOL}? { - /* save whole line */ - context->line_copy = sstrdup(yytext); - - yyless(0); - yy_pop_state(); - yy_set_bol(true); - cmdyycolumn = 1; -} - - /* The next/prev/back_and_forth tokens are here to recognize them *before* - * handling strings ('workspace' command). While flex uses the longest - * match, in case of a tie the order of rules becomes relevant. Since the - * input is fully consumed (these are the last tokens), it comes to a tie. - * */ -next { BEGIN(INITIAL); return TOK_NEXT; } -prev { BEGIN(INITIAL); return TOK_PREV; } -next_on_output { BEGIN(INITIAL); return TOK_NEXT_ON_OUTPUT; } -prev_on_output { BEGIN(INITIAL); return TOK_PREV_ON_OUTPUT; } -back_and_forth { BEGIN(INITIAL); return TOK_BACK_AND_FORTH; } - - /* MOVE is the state after a 'move' token was processed. We need this state - * to skip some tokens (for making the commands clearer) and to properly - * move to the MOVE_WS state. */ -to { /* eat this token */ } -window { /* eat this token */ } -container { /* eat this token */ } -workspace { yy_pop_state(); yy_push_state(MOVE_WS); yy_push_state(EAT_WHITESPACE); return TOK_WORKSPACE; } -scratchpad { yy_pop_state(); return TOK_SCRATCHPAD; } -output { yy_pop_state(); return TOK_OUTPUT; } -up { yy_pop_state(); return TOK_UP; } -down { yy_pop_state(); return TOK_DOWN; } -left { yy_pop_state(); return TOK_LEFT; } -right { yy_pop_state(); return TOK_RIGHT; } - - /* MOVE_WS is the state after a 'workspace' token was processed in the MOVE - * state. We need a separate state to deal with the fact that the old - * 'move workspace ' command needs to be supported (the new command is - * 'move to workspace') while we also need to support - * 'move workspace to output '. */ -to { yy_pop_state(); return TOK_TO; } -[^t] { yy_pop_state(); yy_push_state(WANT_STRING); yyless(0); } - -\"[^\"]+\" { - BEGIN(INITIAL); - /* strip quotes */ - char *copy = sstrdup(yytext+1); - copy[strlen(copy)-1] = '\0'; - cmdyylval.string = copy; - return STR; - } -\"[^\"]+\" { - BEGIN(INITIAL); - /* strip quotes */ - char *copy = sstrdup(yytext+1); - copy[strlen(copy)-1] = '\0'; - cmdyylval.string = copy; - return STR; - } - -[^;\n]+ { BEGIN(INITIAL); cmdyylval.string = sstrdup(yytext); return STR; } - -[;\n] { BEGIN(INITIAL); return ';'; } -[ \t]* { yy_pop_state(); } - -[ \t]* { /* ignore whitespace */ ; } ---no-startup-id { printf("no startup id\n"); yy_pop_state(); return TOK_NO_STARTUP_ID; } -. { printf("anything else: *%s*\n", yytext); yyless(0); yy_pop_state(); yy_pop_state(); } -exec { WS_STRING; yy_push_state(EXEC); yy_push_state(EAT_WHITESPACE); return TOK_EXEC; } -exit { return TOK_EXIT; } -reload { return TOK_RELOAD; } -restart { return TOK_RESTART; } -kill { return TOK_KILL; } -window { return TOK_WINDOW; } -container { return TOK_CONTAINER; } -client { return TOK_CLIENT; } -fullscreen { return TOK_FULLSCREEN; } -global { return TOK_GLOBAL; } -layout { return TOK_LAYOUT; } -default { return TOK_DEFAULT; } -stacked { return TOK_STACKED; } -stacking { return TOK_STACKED; } -tabbed { return TOK_TABBED; } -border { return TOK_BORDER; } -normal { return TOK_NORMAL; } -none { return TOK_NONE; } -1pixel { return TOK_1PIXEL; } -mode { BEGIN(WANT_QSTRING); return TOK_MODE; } -tiling { return TOK_TILING; } -floating { return TOK_FLOATING; } -toggle { return TOK_TOGGLE; } -mode_toggle { return TOK_MODE_TOGGLE; } -workspace { WS_STRING; return TOK_WORKSPACE; } -output { WS_STRING; return TOK_OUTPUT; } -focus { return TOK_FOCUS; } -move { yy_push_state(MOVE); return TOK_MOVE; } -open { return TOK_OPEN; } -scratchpad { return TOK_SCRATCHPAD; } -show { return TOK_SHOW; } -split { return TOK_SPLIT; } -horizontal { return TOK_HORIZONTAL; } -vertical { return TOK_VERTICAL; } -up { return TOK_UP; } -down { return TOK_DOWN; } -left { return TOK_LEFT; } -right { return TOK_RIGHT; } -parent { return TOK_PARENT; } -child { return TOK_CHILD; } -resize { return TOK_RESIZE; } -shrink { return TOK_SHRINK; } -grow { return TOK_GROW; } -px { return TOK_PX; } -or { return TOK_OR; } -ppt { return TOK_PPT; } -to { return TOK_TO; } -nop { WS_STRING; return TOK_NOP; } -append_layout { WS_STRING; return TOK_APPEND_LAYOUT; } -mark { WS_STRING; return TOK_MARK; } - -enable { return TOK_ENABLE; } -true { return TOK_ENABLE; } -yes { return TOK_ENABLE; } -disable { return TOK_DISABLE; } -false { return TOK_DISABLE; } -no { return TOK_DISABLE; } - -class { BEGIN(WANT_QSTRING); return TOK_CLASS; } -instance { BEGIN(WANT_QSTRING); return TOK_INSTANCE; } -window_role { BEGIN(WANT_QSTRING); return TOK_WINDOW_ROLE; } -id { BEGIN(WANT_QSTRING); return TOK_ID; } -con_id { BEGIN(WANT_QSTRING); return TOK_CON_ID; } -con_mark { BEGIN(WANT_QSTRING); return TOK_MARK; } -title { BEGIN(WANT_QSTRING); return TOK_TITLE; } - -[0-9]+ { cmdyylval.number = atoi(yytext); return NUMBER; } - -. { return (int)yytext[0]; } - -<> { - while (yy_start_stack_ptr > 0) - yy_pop_state(); - yyterminate(); -} - -%% diff --git a/src/cmdparse.y b/src/cmdparse.y deleted file mode 100644 index 4a2c6ab3..00000000 --- a/src/cmdparse.y +++ /dev/null @@ -1,626 +0,0 @@ -%{ -/* - * vim:ts=4:sw=4:expandtab - * - * i3 - an improved dynamic tiling window manager - * © 2009-2012 Michael Stapelberg and contributors (see also: LICENSE) - * - * cmdparse.y: the parser for commands you send to i3 (or bind on keys) - * - */ -#include -#include -#include -#include -#include - -#include "all.h" - -typedef struct yy_buffer_state *YY_BUFFER_STATE; -extern int cmdyylex(struct context *context); -extern int cmdyyparse(void); -extern int cmdyylex_destroy(void); -extern FILE *cmdyyin; -YY_BUFFER_STATE cmdyy_scan_string(const char *); - -static struct context *context; -static Match current_match; - -/* Holds the JSON which will be returned via IPC or NULL for the default return - * message */ -static char *json_output; - -/* We don’t need yydebug for now, as we got decent error messages using - * yyerror(). Should you ever want to extend the parser, it might be handy - * to just comment it in again, so it stays here. */ -//int cmdyydebug = 1; - -void cmdyyerror(const char *error_message) { - ELOG("\n"); - ELOG("CMD: %s\n", error_message); - ELOG("CMD: in command:\n"); - ELOG("CMD: %s\n", context->line_copy); - ELOG("CMD: "); - for (int c = 1; c <= context->last_column; c++) - if (c >= context->first_column) - printf("^"); - else printf(" "); - printf("\n"); - ELOG("\n"); - context->compact_error = sstrdup(error_message); -} - -int cmdyywrap() { - return 1; -} - -char *parse_cmd(const char *new) { - cmd_MIGRATION_enable(); - char *output = parse_command(new); - if (output != NULL) { - printf("MIGRATION: new output != NULL: %s\n", output); - free(output); - } - cmd_MIGRATION_disable(); - - json_output = NULL; - LOG("COMMAND: *%s*\n", new); - cmdyy_scan_string(new); - - cmd_criteria_init(¤t_match); - context = scalloc(sizeof(struct context)); - context->filename = "cmd"; - if (cmdyyparse() != 0) { - fprintf(stderr, "Could not parse command\n"); - sasprintf(&json_output, "{\"success\":false, \"error\":\"%s at position %d\"}", - context->compact_error, context->first_column); - FREE(context->line_copy); - FREE(context->compact_error); - free(context); - return json_output; - } - printf("done, json output = %s\n", json_output); - - cmd_MIGRATION_validate(); - - cmdyylex_destroy(); - FREE(context->line_copy); - FREE(context->compact_error); - free(context); - return json_output; -} - -%} - -%error-verbose -%lex-param { struct context *context } - -%union { - char *string; - char chr; - int number; -} - -%token TOK_EXEC "exec" -%token TOK_EXIT "exit" -%token TOK_RELOAD "reload" -%token TOK_RESTART "restart" -%token TOK_KILL "kill" -%token TOK_WINDOW "window" -%token TOK_CONTAINER "container" -%token TOK_CLIENT "client" -%token TOK_FULLSCREEN "fullscreen" -%token TOK_GLOBAL "global" -%token TOK_LAYOUT "layout" -%token TOK_DEFAULT "default" -%token TOK_STACKED "stacked" -%token TOK_TABBED "tabbed" -%token TOK_BORDER "border" -%token TOK_NORMAL "normal" -%token TOK_NONE "none" -%token TOK_1PIXEL "1pixel" -%token TOK_MODE "mode" -%token TOK_TILING "tiling" -%token TOK_FLOATING "floating" -%token TOK_MODE_TOGGLE "mode_toggle" -%token TOK_ENABLE "enable" -%token TOK_DISABLE "disable" -%token TOK_WORKSPACE "workspace" -%token TOK_OUTPUT "output" -%token TOK_TOGGLE "toggle" -%token TOK_FOCUS "focus" -%token TOK_MOVE "move" -%token TOK_OPEN "open" -%token TOK_NEXT "next" -%token TOK_PREV "prev" -%token TOK_NEXT_ON_OUTPUT "next_on_output" -%token TOK_PREV_ON_OUTPUT "prev_on_output" -%token TOK_SCRATCHPAD "scratchpad" -%token TOK_SHOW "show" -%token TOK_SPLIT "split" -%token TOK_HORIZONTAL "horizontal" -%token TOK_VERTICAL "vertical" -%token TOK_UP "up" -%token TOK_DOWN "down" -%token TOK_LEFT "left" -%token TOK_RIGHT "right" -%token TOK_PARENT "parent" -%token TOK_CHILD "child" -%token TOK_APPEND_LAYOUT "append_layout" -%token TOK_MARK "mark" -%token TOK_RESIZE "resize" -%token TOK_GROW "grow" -%token TOK_SHRINK "shrink" -%token TOK_PX "px" -%token TOK_OR "or" -%token TOK_PPT "ppt" -%token TOK_NOP "nop" -%token TOK_BACK_AND_FORTH "back_and_forth" -%token TOK_NO_STARTUP_ID "--no-startup-id" -%token TOK_TO "to" - -%token TOK_CLASS "class" -%token TOK_INSTANCE "instance" -%token TOK_WINDOW_ROLE "window_role" -%token TOK_ID "id" -%token TOK_CON_ID "con_id" -%token TOK_TITLE "title" - -%token STR "" -%token NUMBER "" - -%type direction -%type split_direction -%type fullscreen_mode -%type level -%type window_mode -%type boolean -%type border_style -%type layout_mode -%type resize_px -%type resize_way -%type resize_tiling -%type optional_kill_mode -%type optional_no_startup_id - -%% - -commands: - commands ';' command - | command - { - cmd_criteria_init(¤t_match); - } - ; - -command: - match operations - ; - -match: - | matchstart criteria matchend - ; - -matchstart: - '[' - ; - -matchend: - ']' - { - json_output = cmd_criteria_match_windows(¤t_match); - } - ; - -criteria: - criteria criterion - | criterion - ; - -criterion: - TOK_CLASS '=' STR - { - cmd_criteria_add(¤t_match, "class", $3); - free($3); - } - | TOK_INSTANCE '=' STR - { - cmd_criteria_add(¤t_match, "instance", $3); - free($3); - } - | TOK_WINDOW_ROLE '=' STR - { - cmd_criteria_add(¤t_match, "window_role", $3); - free($3); - } - | TOK_CON_ID '=' STR - { - cmd_criteria_add(¤t_match, "con_id", $3); - free($3); - } - | TOK_ID '=' STR - { - cmd_criteria_add(¤t_match, "id", $3); - free($3); - } - | TOK_MARK '=' STR - { - cmd_criteria_add(¤t_match, "con_mark", $3); - free($3); - } - | TOK_TITLE '=' STR - { - cmd_criteria_add(¤t_match, "title", $3); - free($3); - } - ; - -operations: - operation - | operations ',' operation - ; - -operation: - exec - | exit - | restart - | reload - | border - | layout - | append_layout - | move - | workspace - | focus - | kill - | open - | fullscreen - | split - | floating - | mark - | resize - | nop - | scratchpad - | mode - ; - -exec: - TOK_EXEC optional_no_startup_id STR - { - json_output = cmd_exec(¤t_match, ($2 ? "--no-startup-id" : NULL), $3); - free($3); - } - ; - -optional_no_startup_id: - /* empty */ { $$ = false; } - | TOK_NO_STARTUP_ID { $$ = true; } - ; - -exit: - TOK_EXIT - { - json_output = cmd_exit(¤t_match); - } - ; - -reload: - TOK_RELOAD - { - json_output = cmd_reload(¤t_match); - } - ; - -restart: - TOK_RESTART - { - json_output = cmd_restart(¤t_match); - } - ; - -focus: - TOK_FOCUS - { - json_output = cmd_focus(¤t_match); - } - | TOK_FOCUS direction - { - json_output = cmd_focus_direction(¤t_match, - ($2 == TOK_LEFT ? "left" : - ($2 == TOK_RIGHT ? "right" : - ($2 == TOK_UP ? "up" : - "down")))); - } - | TOK_FOCUS TOK_OUTPUT STR - { - json_output = cmd_focus_output(¤t_match, $3); - free($3); - } - | TOK_FOCUS window_mode - { - - json_output = cmd_focus_window_mode(¤t_match, - ($2 == TOK_TILING ? "tiling" : - ($2 == TOK_FLOATING ? "floating" : - "mode_toggle"))); - } - | TOK_FOCUS level - { - json_output = cmd_focus_level(¤t_match, ($2 == TOK_PARENT ? "parent" : "child")); - } - ; - -window_mode: - TOK_TILING { $$ = TOK_TILING; } - | TOK_FLOATING { $$ = TOK_FLOATING; } - | TOK_MODE_TOGGLE { $$ = TOK_MODE_TOGGLE; } - ; - -level: - TOK_PARENT { $$ = TOK_PARENT; } - | TOK_CHILD { $$ = TOK_CHILD; } - ; - -kill: - TOK_KILL optional_kill_mode - { - json_output = cmd_kill(¤t_match, ($2 == KILL_WINDOW ? "window" : "client")); - } - ; - -optional_kill_mode: - /* empty */ { $$ = KILL_WINDOW; } - | TOK_WINDOW { $$ = KILL_WINDOW; } - | TOK_CLIENT { $$ = KILL_CLIENT; } - ; - -workspace: - TOK_WORKSPACE TOK_NEXT - { - json_output = cmd_workspace(¤t_match, "next"); - } - | TOK_WORKSPACE TOK_PREV - { - json_output = cmd_workspace(¤t_match, "prev"); - } - | TOK_WORKSPACE TOK_NEXT_ON_OUTPUT - { - json_output = cmd_workspace(¤t_match, "next_on_output"); - } - | TOK_WORKSPACE TOK_PREV_ON_OUTPUT - { - json_output = cmd_workspace(¤t_match, "prev_on_output"); - } - | TOK_WORKSPACE TOK_BACK_AND_FORTH - { - json_output = cmd_workspace_back_and_forth(¤t_match); - } - | TOK_WORKSPACE STR - { - json_output = cmd_workspace_name(¤t_match, $2); - free($2); - } - ; - -open: - TOK_OPEN - { - json_output = cmd_open(¤t_match); - } - ; - -fullscreen: - TOK_FULLSCREEN fullscreen_mode - { - json_output = cmd_fullscreen(¤t_match, ($2 == CF_OUTPUT ? "output" : "global")); - } - ; - -fullscreen_mode: - /* empty */ { $$ = CF_OUTPUT; } - | TOK_GLOBAL { $$ = CF_GLOBAL; } - ; - -split: - TOK_SPLIT split_direction - { - char buf[2] = {'\0', '\0'}; - buf[0] = $2; - json_output = cmd_split(¤t_match, buf); - } - ; - -split_direction: - TOK_HORIZONTAL { $$ = 'h'; } - | 'h' { $$ = 'h'; } - | TOK_VERTICAL { $$ = 'v'; } - | 'v' { $$ = 'v'; } - ; - -floating: - TOK_FLOATING boolean - { - json_output = cmd_floating(¤t_match, - ($2 == TOK_ENABLE ? "enable" : - ($2 == TOK_DISABLE ? "disable" : - "toggle"))); - } - ; - -boolean: - TOK_ENABLE { $$ = TOK_ENABLE; } - | TOK_DISABLE { $$ = TOK_DISABLE; } - | TOK_TOGGLE { $$ = TOK_TOGGLE; } - ; - -border: - TOK_BORDER border_style - { - json_output = cmd_border(¤t_match, - ($2 == BS_NORMAL ? "normal" : - ($2 == BS_NONE ? "none" : - ($2 == BS_1PIXEL ? "1pixel" : - "toggle")))); - } - ; - -border_style: - TOK_NORMAL { $$ = BS_NORMAL; } - | TOK_NONE { $$ = BS_NONE; } - | TOK_1PIXEL { $$ = BS_1PIXEL; } - | TOK_TOGGLE { $$ = TOK_TOGGLE; } - ; - -move: - TOK_MOVE direction resize_px - { - char buffer[128]; - snprintf(buffer, sizeof(buffer), "%d", $3); - json_output = cmd_move_direction(¤t_match, - ($2 == TOK_LEFT ? "left" : - ($2 == TOK_RIGHT ? "right" : - ($2 == TOK_UP ? "up" : - "down"))), - buffer); - } - | TOK_MOVE TOK_WORKSPACE STR - { - json_output = cmd_move_con_to_workspace_name(¤t_match, $3); - } - | TOK_MOVE TOK_WORKSPACE TOK_NEXT - { - json_output = cmd_move_con_to_workspace(¤t_match, "next"); - } - | TOK_MOVE TOK_WORKSPACE TOK_PREV - { - json_output = cmd_move_con_to_workspace(¤t_match, "prev"); - } - | TOK_MOVE TOK_WORKSPACE TOK_NEXT_ON_OUTPUT - { - json_output = cmd_move_con_to_workspace(¤t_match, "next_on_output"); - } - | TOK_MOVE TOK_WORKSPACE TOK_PREV_ON_OUTPUT - { - json_output = cmd_move_con_to_workspace(¤t_match, "prev_on_output"); - } - | TOK_MOVE TOK_OUTPUT STR - { - json_output = cmd_move_con_to_output(¤t_match, $3); - free($3); - } - | TOK_MOVE TOK_SCRATCHPAD - { - json_output = cmd_move_scratchpad(¤t_match); - } - | TOK_MOVE TOK_WORKSPACE TOK_TO TOK_OUTPUT STR - { - json_output = cmd_move_workspace_to_output(¤t_match, $5); - free($5); - } - ; - -append_layout: - TOK_APPEND_LAYOUT STR - { - json_output = cmd_append_layout(¤t_match, $2); - free($2); - } - ; - -layout: - TOK_LAYOUT layout_mode - { - json_output = cmd_layout(¤t_match, - ($2 == L_DEFAULT ? "default" : - ($2 == L_STACKED ? "stacked" : - "tabbed"))); - } - ; - -layout_mode: - TOK_DEFAULT { $$ = L_DEFAULT; } - | TOK_STACKED { $$ = L_STACKED; } - | TOK_TABBED { $$ = L_TABBED; } - ; - -mark: - TOK_MARK STR - { - json_output = cmd_mark(¤t_match, $2); - free($2); - } - ; - -nop: - TOK_NOP STR - { - json_output = cmd_nop(¤t_match, $2); - free($2); - } - ; - -scratchpad: - TOK_SCRATCHPAD TOK_SHOW - { - json_output = cmd_scratchpad_show(¤t_match); - } - ; - - -resize: - TOK_RESIZE resize_way direction resize_px resize_tiling - { - char buffer1[128], buffer2[128]; - snprintf(buffer1, sizeof(buffer1), "%d", $4); - snprintf(buffer2, sizeof(buffer2), "%d", $5); - json_output = cmd_resize(¤t_match, - ($2 == TOK_SHRINK ? "shrink" : "grow"), - ($3 == TOK_LEFT ? "left" : - ($3 == TOK_RIGHT ? "right" : - ($3 == TOK_DOWN ? "down" : - "up"))), - buffer1, - buffer2); - } - ; - -resize_px: - /* empty */ - { - $$ = 10; - } - | NUMBER TOK_PX - { - $$ = $1; - } - ; - -resize_tiling: - /* empty */ - { - $$ = 10; - } - | TOK_OR NUMBER TOK_PPT - { - $$ = $2; - } - ; - -resize_way: - TOK_GROW { $$ = TOK_GROW; } - | TOK_SHRINK { $$ = TOK_SHRINK; } - ; - -direction: - TOK_UP { $$ = TOK_UP; } - | TOK_DOWN { $$ = TOK_DOWN; } - | TOK_LEFT { $$ = TOK_LEFT; } - | TOK_RIGHT { $$ = TOK_RIGHT; } - ; - -mode: - TOK_MODE STR - { - json_output = cmd_mode(¤t_match, $2); - free($2); - } - ; diff --git a/src/commands.c b/src/commands.c index 1991fe27..dd1a6275 100644 --- a/src/commands.c +++ b/src/commands.c @@ -11,7 +11,6 @@ #include #include "all.h" -#include "cmdparse.tab.h" /** When the command did not include match criteria (!), we use the currently * focused command. Do not confuse this case with a command which included @@ -61,113 +60,9 @@ static Output *get_output_from_string(Output *current_output, const char *output return output; } -/******************************************************************************* - * Helper functions for the migration testing. We let the new parser call every - * function here and save the stack (current_match plus all parameters. Then we - * let the old parser call every function and actually execute the code. When - * there are differences between the first and the second invocation (or if - * there has not been a first invocation at all), we generate an error. - ******************************************************************************/ - -static bool migration_test = false; -typedef struct stackframe { - Match match; - int n_args; - char *args[10]; - TAILQ_ENTRY(stackframe) stackframes; -} stackframe; -static TAILQ_HEAD(stackframes_head, stackframe) old_stackframes = - TAILQ_HEAD_INITIALIZER(old_stackframes); -static struct stackframes_head new_stackframes = - TAILQ_HEAD_INITIALIZER(new_stackframes); -/* We use this char* to uniquely terminate the list of parameters to save. */ -static char *last_parameter = "0"; - -void cmd_MIGRATION_enable() { - migration_test = true; - /* clear the current stack */ - while (!TAILQ_EMPTY(&old_stackframes)) { - stackframe *current = TAILQ_FIRST(&old_stackframes); - for (int c = 0; c < current->n_args; c++) - if (current->args[c]) - free(current->args[c]); - TAILQ_REMOVE(&old_stackframes, current, stackframes); - free(current); - } - while (!TAILQ_EMPTY(&new_stackframes)) { - stackframe *current = TAILQ_FIRST(&new_stackframes); - for (int c = 0; c < current->n_args; c++) - if (current->args[c]) - free(current->args[c]); - TAILQ_REMOVE(&new_stackframes, current, stackframes); - free(current); - } -} - -void cmd_MIGRATION_disable() { - migration_test = false; -} - -void cmd_MIGRATION_save_new_parameters(Match *current_match, ...) { - va_list args; - - DLOG("saving parameters.\n"); - stackframe *frame = scalloc(sizeof(stackframe)); - match_copy(&(frame->match), current_match); - - /* All parameters are char*s */ - va_start(args, current_match); - while (true) { - char *parameter = va_arg(args, char*); - if (parameter == last_parameter) - break; - DLOG("parameter = %s\n", parameter); - if (parameter) - frame->args[frame->n_args] = sstrdup(parameter); - frame->n_args++; - } - va_end(args); - - TAILQ_INSERT_TAIL(&new_stackframes, frame, stackframes); -} - -void cmd_MIGRATION_save_old_parameters(Match *current_match, ...) { - va_list args; - - DLOG("saving new parameters.\n"); - stackframe *frame = scalloc(sizeof(stackframe)); - match_copy(&(frame->match), current_match); - - /* All parameters are char*s */ - va_start(args, current_match); - while (true) { - char *parameter = va_arg(args, char*); - if (parameter == last_parameter) - break; - DLOG("parameter = %s\n", parameter); - if (parameter) - frame->args[frame->n_args] = sstrdup(parameter); - frame->n_args++; - } - va_end(args); - - TAILQ_INSERT_TAIL(&old_stackframes, frame, stackframes); -} - -static bool re_differ(struct regex *new, struct regex *old) { - return ((new == NULL && old != NULL) || - (new != NULL && old == NULL) || - (new != NULL && old != NULL && - strcmp(new->pattern, old->pattern) != 0)); -} - -static bool str_differ(char *new, char *old) { - return ((new == NULL && old != NULL) || - (new != NULL && old == NULL) || - (new != NULL && old != NULL && - strcmp(new, old) != 0)); -} - +// This code is commented out because we might recycle it for popping up error +// messages on parser errors. +#if 0 static pid_t migration_pid = -1; /* @@ -259,69 +154,7 @@ void cmd_MIGRATION_start_nagbar() { #endif } -void cmd_MIGRATION_validate() { - DLOG("validating the different stacks now\n"); - int old_count = 0; - int new_count = 0; - stackframe *current; - TAILQ_FOREACH(current, &new_stackframes, stackframes) - new_count++; - TAILQ_FOREACH(current, &old_stackframes, stackframes) - old_count++; - if (new_count != old_count) { - ELOG("FAILED, new_count == %d != old_count == %d\n", new_count, old_count); - cmd_MIGRATION_start_nagbar(); - return; - } - DLOG("parameter count matching, comparing one by one...\n"); - - stackframe *new_frame = TAILQ_FIRST(&new_stackframes), - *old_frame = TAILQ_FIRST(&old_stackframes); - for (int i = 0; i < new_count; i++) { - if (new_frame->match.dock != old_frame->match.dock || - new_frame->match.id != old_frame->match.id || - new_frame->match.con_id != old_frame->match.con_id || - new_frame->match.floating != old_frame->match.floating || - new_frame->match.insert_where != old_frame->match.insert_where || - re_differ(new_frame->match.title, old_frame->match.title) || - re_differ(new_frame->match.application, old_frame->match.application) || - re_differ(new_frame->match.class, old_frame->match.class) || - re_differ(new_frame->match.instance, old_frame->match.instance) || - re_differ(new_frame->match.mark, old_frame->match.mark) || - re_differ(new_frame->match.role, old_frame->match.role) ) { - ELOG("FAILED, new_frame->match != old_frame->match (frame %d)\n", i); - cmd_MIGRATION_start_nagbar(); - return; - } - if (new_frame->n_args != old_frame->n_args) { - ELOG("FAILED, new_frame->n_args == %d != old_frame->n_args == %d (frame %d)\n", - new_frame->n_args, old_frame->n_args, i); - cmd_MIGRATION_start_nagbar(); - return; - } - for (int j = 0; j < new_frame->n_args; j++) { - if (str_differ(new_frame->args[j], old_frame->args[j])) { - ELOG("FAILED, new_frame->args[%d] == %s != old_frame->args[%d] == %s (frame %d)\n", - j, new_frame->args[j], j, old_frame->args[j], i); - cmd_MIGRATION_start_nagbar(); - return; - } - } - new_frame = TAILQ_NEXT(new_frame, stackframes); - old_frame = TAILQ_NEXT(old_frame, stackframes); - } - DLOG("OK\n"); -} - -#define MIGRATION_init(x, ...) do { \ - if (migration_test) { \ - cmd_MIGRATION_save_new_parameters(current_match, __FUNCTION__, ##__VA_ARGS__ , last_parameter); \ - return NULL; \ - } else { \ - cmd_MIGRATION_save_old_parameters(current_match, __FUNCTION__, ##__VA_ARGS__ , last_parameter); \ - } \ -} while (0) - +#endif /******************************************************************************* * Criteria functions. @@ -353,13 +186,6 @@ char *cmd_criteria_init(Match *current_match) { char *cmd_criteria_match_windows(Match *current_match) { owindow *next, *current; - /* The same as MIGRATION_init, but doesn’t return */ - if (migration_test) { - cmd_MIGRATION_save_new_parameters(current_match, __FUNCTION__, last_parameter); - } else { - cmd_MIGRATION_save_old_parameters(current_match, __FUNCTION__, last_parameter); - } - DLOG("match specification finished, matching...\n"); /* copy the old list head to iterate through it and start with a fresh * list which will contain only matching windows */ @@ -404,13 +230,6 @@ char *cmd_criteria_match_windows(Match *current_match) { } char *cmd_criteria_add(Match *current_match, char *ctype, char *cvalue) { - /* The same as MIGRATION_init, but doesn’t return */ - if (migration_test) { - cmd_MIGRATION_save_new_parameters(current_match, __FUNCTION__, last_parameter); - } else { - cmd_MIGRATION_save_old_parameters(current_match, __FUNCTION__, last_parameter); - } - DLOG("ctype=*%s*, cvalue=*%s*\n", ctype, cvalue); if (strcmp(ctype, "class") == 0) { @@ -477,8 +296,6 @@ char *cmd_criteria_add(Match *current_match, char *ctype, char *cvalue) { char *cmd_move_con_to_workspace(Match *current_match, char *which) { owindow *current; - MIGRATION_init(x, which); - DLOG("which=%s\n", which); HANDLE_EMPTY_MATCH; @@ -510,8 +327,6 @@ char *cmd_move_con_to_workspace(Match *current_match, char *which) { } char *cmd_move_con_to_workspace_name(Match *current_match, char *name) { - MIGRATION_init(x, name); - if (strncasecmp(name, "__i3_", strlen("__i3_")) == 0) { LOG("You cannot switch to the i3 internal workspaces.\n"); return sstrdup("{\"sucess\": false}"); @@ -542,7 +357,6 @@ char *cmd_move_con_to_workspace_name(Match *current_match, char *name) { } char *cmd_resize(Match *current_match, char *way, char *direction, char *resize_px, char *resize_ppt) { - MIGRATION_init(x, way, direction, resize_px, resize_ppt); /* resize [ px] [or ppt] */ DLOG("resizing in way %s, direction %s, px %s or ppt %s\n", way, direction, resize_px, resize_ppt); // TODO: We could either handle this in the parser itself as a separate token (and make the stack typed) or we need a better way to convert a string to a number with error checking @@ -641,7 +455,6 @@ char *cmd_resize(Match *current_match, char *way, char *direction, char *resize_ } char *cmd_border(Match *current_match, char *border_style_str) { - MIGRATION_init(x, border_style_str); DLOG("border style should be changed to %s\n", border_style_str); owindow *current; @@ -675,7 +488,6 @@ char *cmd_border(Match *current_match, char *border_style_str) { } char *cmd_nop(Match *current_match, char *comment) { - MIGRATION_init(x, comment); LOG("-------------------------------------------------\n"); LOG(" NOP: %s\n", comment); LOG("-------------------------------------------------\n"); @@ -684,7 +496,6 @@ char *cmd_nop(Match *current_match, char *comment) { } char *cmd_append_layout(Match *current_match, char *path) { - MIGRATION_init(x, path); LOG("Appending layout \"%s\"\n", path); tree_append_json(path); tree_render(); @@ -694,7 +505,6 @@ char *cmd_append_layout(Match *current_match, char *path) { } char *cmd_workspace(Match *current_match, char *which) { - MIGRATION_init(x, which); Con *ws; DLOG("which=%s\n", which); @@ -720,7 +530,6 @@ char *cmd_workspace(Match *current_match, char *which) { } char *cmd_workspace_back_and_forth(Match *current_match) { - MIGRATION_init(x); workspace_back_and_forth(); tree_render(); @@ -729,7 +538,6 @@ char *cmd_workspace_back_and_forth(Match *current_match) { } char *cmd_workspace_name(Match *current_match, char *name) { - MIGRATION_init(x, name); if (strncasecmp(name, "__i3_", strlen("__i3_")) == 0) { LOG("You cannot switch to the i3 internal workspaces.\n"); return sstrdup("{\"sucess\": false}"); @@ -758,7 +566,6 @@ char *cmd_workspace_name(Match *current_match, char *name) { } char *cmd_mark(Match *current_match, char *mark) { - MIGRATION_init(x, mark); DLOG("Clearing all windows which have that mark first\n"); Con *con; @@ -784,7 +591,6 @@ char *cmd_mark(Match *current_match, char *mark) { } char *cmd_mode(Match *current_match, char *mode) { - MIGRATION_init(x, mode); DLOG("mode=%s\n", mode); switch_mode(mode); @@ -793,7 +599,6 @@ char *cmd_mode(Match *current_match, char *mode) { } char *cmd_move_con_to_output(Match *current_match, char *name) { - MIGRATION_init(x, name); owindow *current; DLOG("should move window to output %s\n", name); @@ -845,7 +650,6 @@ char *cmd_move_con_to_output(Match *current_match, char *name) { } char *cmd_floating(Match *current_match, char *floating_mode) { - MIGRATION_init(x, floating_mode); owindow *current; DLOG("floating_mode=%s\n", floating_mode); @@ -874,7 +678,6 @@ char *cmd_floating(Match *current_match, char *floating_mode) { } char *cmd_move_workspace_to_output(Match *current_match, char *name) { - MIGRATION_init(x, name); DLOG("should move workspace to output %s\n", name); HANDLE_EMPTY_MATCH; @@ -923,7 +726,6 @@ char *cmd_move_workspace_to_output(Match *current_match, char *name) { } char *cmd_split(Match *current_match, char *direction) { - MIGRATION_init(x, direction); /* TODO: use matches */ LOG("splitting in direction %c\n", direction[0]); tree_split(focused, (direction[0] == 'v' ? VERT : HORIZ)); @@ -937,7 +739,6 @@ char *cmd_split(Match *current_match, char *direction) { char *cmd_kill(Match *current_match, char *kill_mode_str) { if (kill_mode_str == NULL) kill_mode_str = "window"; - MIGRATION_init(x, kill_mode_str); owindow *current; DLOG("kill_mode=%s\n", kill_mode_str); @@ -969,7 +770,6 @@ char *cmd_kill(Match *current_match, char *kill_mode_str) { } char *cmd_exec(Match *current_match, char *nosn, char *command) { - MIGRATION_init(x, nosn, command); bool no_startup_id = (nosn != NULL); DLOG("should execute %s, no_startup_id = %d\n", command, no_startup_id); @@ -980,7 +780,6 @@ char *cmd_exec(Match *current_match, char *nosn, char *command) { } char *cmd_focus_direction(Match *current_match, char *direction) { - MIGRATION_init(x, direction); if (focused && focused->type != CT_WORKSPACE && focused->fullscreen_mode != CF_NONE) { @@ -1010,7 +809,6 @@ char *cmd_focus_direction(Match *current_match, char *direction) { } char *cmd_focus_window_mode(Match *current_match, char *window_mode) { - MIGRATION_init(x, window_mode); if (focused && focused->type != CT_WORKSPACE && focused->fullscreen_mode != CF_NONE) { @@ -1046,7 +844,6 @@ char *cmd_focus_window_mode(Match *current_match, char *window_mode) { } char *cmd_focus_level(Match *current_match, char *level) { - MIGRATION_init(x, level); if (focused && focused->type != CT_WORKSPACE && focused->fullscreen_mode != CF_NONE) { @@ -1067,7 +864,6 @@ char *cmd_focus_level(Match *current_match, char *level) { } char *cmd_focus(Match *current_match) { - MIGRATION_init(x); DLOG("current_match = %p\n", current_match); if (focused && focused->type != CT_WORKSPACE && @@ -1132,7 +928,6 @@ char *cmd_focus(Match *current_match) { char *cmd_fullscreen(Match *current_match, char *fullscreen_mode) { if (fullscreen_mode == NULL) fullscreen_mode = "output"; - MIGRATION_init(x, fullscreen_mode); DLOG("toggling fullscreen, mode = %s\n", fullscreen_mode); owindow *current; @@ -1150,7 +945,6 @@ char *cmd_fullscreen(Match *current_match, char *fullscreen_mode) { } char *cmd_move_direction(Match *current_match, char *direction, char *move_px) { - MIGRATION_init(x, direction, move_px); // TODO: We could either handle this in the parser itself as a separate token (and make the stack typed) or we need a better way to convert a string to a number with error checking int px = atoi(move_px); @@ -1170,10 +964,10 @@ char *cmd_move_direction(Match *current_match, char *direction, char *move_px) { } floating_reposition(focused->parent, newrect); } else { - tree_move((strcmp(direction, "right") == 0 ? TOK_RIGHT : - (strcmp(direction, "left") == 0 ? TOK_LEFT : - (strcmp(direction, "up") == 0 ? TOK_UP : - TOK_DOWN)))); + tree_move((strcmp(direction, "right") == 0 ? D_RIGHT : + (strcmp(direction, "left") == 0 ? D_LEFT : + (strcmp(direction, "up") == 0 ? D_UP : + D_DOWN)))); tree_render(); } @@ -1185,7 +979,6 @@ char *cmd_move_direction(Match *current_match, char *direction, char *move_px) { char *cmd_layout(Match *current_match, char *layout_str) { if (strcmp(layout_str, "stacking") == 0) layout_str = "stacked"; - MIGRATION_init(x, layout_str); DLOG("changing layout to %s\n", layout_str); owindow *current; int layout = (strcmp(layout_str, "default") == 0 ? L_DEFAULT : @@ -1209,7 +1002,6 @@ char *cmd_layout(Match *current_match, char *layout_str) { } char *cmd_exit(Match *current_match) { - MIGRATION_init(x); LOG("Exiting due to user command.\n"); exit(0); @@ -1217,7 +1009,6 @@ char *cmd_exit(Match *current_match) { } char *cmd_reload(Match *current_match) { - MIGRATION_init(x); LOG("reloading\n"); kill_configerror_nagbar(false); load_configuration(conn, NULL, true); @@ -1230,7 +1021,6 @@ char *cmd_reload(Match *current_match) { } char *cmd_restart(Match *current_match) { - MIGRATION_init(x); LOG("restarting i3\n"); i3_restart(false); @@ -1239,7 +1029,6 @@ char *cmd_restart(Match *current_match) { } char *cmd_open(Match *current_match) { - MIGRATION_init(x); LOG("opening new container\n"); Con *con = tree_open_con(NULL, NULL); con_focus(con); @@ -1252,7 +1041,6 @@ char *cmd_open(Match *current_match) { } char *cmd_focus_output(Match *current_match, char *name) { - MIGRATION_init(x, name); owindow *current; DLOG("name = %s\n", name); @@ -1288,7 +1076,6 @@ char *cmd_focus_output(Match *current_match, char *name) { } char *cmd_move_scratchpad(Match *current_match) { - MIGRATION_init(x); DLOG("should move window to scratchpad\n"); owindow *current; @@ -1306,7 +1093,6 @@ char *cmd_move_scratchpad(Match *current_match) { } char *cmd_scratchpad_show(Match *current_match) { - MIGRATION_init(x); DLOG("should show scratchpad window\n"); owindow *current; diff --git a/src/handlers.c b/src/handlers.c index 507fffcf..a1f90ba6 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -2,7 +2,7 @@ * vim:ts=4:sw=4:expandtab * * i3 - an improved dynamic tiling window manager - * © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE) + * © 2009-2012 Michael Stapelberg and contributors (see also: LICENSE) * * handlers.c: Small handlers for various events (keypresses, focus changes, * …). @@ -118,7 +118,7 @@ static void handle_key_press(xcb_key_press_event_t *event) { } } - char *json_result = parse_cmd(bind->command); + char *json_result = parse_command(bind->command); FREE(json_result); return; } diff --git a/src/ipc.c b/src/ipc.c index ee418945..dee68e5f 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -119,7 +119,7 @@ IPC_HANDLER(command) { char *command = scalloc(message_size + 1); strncpy(command, (const char*)message, message_size); LOG("IPC: received: *%s*\n", command); - char *reply = parse_cmd((const char*)command); + char *reply = parse_command((const char*)command); char *save_reply = reply; free(command); diff --git a/src/move.c b/src/move.c index d1ac8a68..d3065c24 100644 --- a/src/move.c +++ b/src/move.c @@ -9,8 +9,6 @@ */ #include "all.h" -#include "cmdparse.tab.h" - typedef enum { BEFORE, AFTER } position_t; /* @@ -88,8 +86,8 @@ static void attach_to_workspace(Con *con, Con *ws) { } /* - * Moves the current container in the given direction (TOK_LEFT, TOK_RIGHT, - * TOK_UP, TOK_DOWN from cmdparse.l) + * Moves the current container in the given direction (D_LEFT, D_RIGHT, + * D_UP, D_DOWN). * */ void tree_move(int direction) { @@ -107,7 +105,7 @@ void tree_move(int direction) { return; } - orientation_t o = (direction == TOK_LEFT || direction == TOK_RIGHT ? HORIZ : VERT); + orientation_t o = (direction == D_LEFT || direction == D_RIGHT ? HORIZ : VERT); Con *same_orientation = con_parent_with_orientation(con, o); /* The do {} while is used to 'restart' at this point with a different @@ -136,14 +134,14 @@ void tree_move(int direction) { if (same_orientation == con->parent) { DLOG("We are in the same container\n"); Con *swap; - if ((swap = (direction == TOK_LEFT || direction == TOK_UP ? + if ((swap = (direction == D_LEFT || direction == D_UP ? TAILQ_PREV(con, nodes_head, nodes) : TAILQ_NEXT(con, nodes)))) { if (!con_is_leaf(swap)) { insert_con_into(con, con_descend_focused(swap), AFTER); goto end; } - if (direction == TOK_LEFT || direction == TOK_UP) + if (direction == D_LEFT || direction == D_UP) TAILQ_SWAP(swap, con, &(swap->parent->nodes_head), nodes); else TAILQ_SWAP(con, swap, &(swap->parent->nodes_head), nodes); @@ -174,7 +172,7 @@ void tree_move(int direction) { DLOG("above = %p\n", above); Con *next; position_t position; - if (direction == TOK_UP || direction == TOK_LEFT) { + if (direction == D_UP || direction == D_LEFT) { position = BEFORE; next = TAILQ_PREV(above, nodes_head, nodes); } else { -- 2.39.5