Abstract binding configuration to bindings.[ch]

Create files bindings.[ch] to contain functions for configuring,
finding, and running bindings.

Use the new function `configure_binding` for binding configuration. This
function adds a binding from config parameters.

Export the function `modifiers_from_str` from config_directives.h.

This change is made in preparation for the new bindmouse functionality.
This commit is contained in:
Tony Crisci
2014-01-27 22:45:01 -05:00
committed by Michael Stapelberg
parent da0acb2080
commit d24d8baeb5
5 changed files with 115 additions and 43 deletions

View File

@ -79,6 +79,7 @@
#include "scratchpad.h"
#include "commands.h"
#include "commands_parser.h"
#include "bindings.h"
#include "config_directives.h"
#include "config_parser.h"
#include "fake_outputs.h"

25
include/bindings.h Normal file
View File

@ -0,0 +1,25 @@
/*
* vim:ts=4:sw=4:expandtab
*
* i3 - an improved dynamic tiling window manager
* © 2009-2014 Michael Stapelberg and contributors (see also: LICENSE)
*
* bindings.h: Functions for configuring, finding, and running bindings.
*
*/
#pragma once
/**
* The name of the default mode.
*
*/
const char *DEFAULT_BINDING_MODE;
/**
* Adds a binding from config parameters given as strings and returns a
* pointer to the binding structure. Returns NULL if the input code could not
* be parsed.
*
*/
Binding *configure_binding(const char *bindtype, const char *modifiers, const char *input_code,
const char *release, const char *command, const char *mode);

View File

@ -11,6 +11,12 @@
#include "config_parser.h"
/**
* A utility function to convert a string of modifiers to the corresponding bit
* mask.
*/
uint32_t modifiers_from_str(const char *str);
/** The beginning of the prototype for every cfg_ function. */
#define I3_CFG Match *current_match, struct ConfigResult *result