[util/rules] Move Fuzzy from rules to util

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-04-09 20:20:48 +02:00
parent 70d26b5b36
commit 97dc830db5
9 changed files with 22 additions and 26 deletions

View File

@ -26,7 +26,6 @@
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <stdbool.h>
#include <xcb/xcb.h> #include <xcb/xcb.h>
#include <xcb/xcb_aux.h> #include <xcb/xcb_aux.h>

View File

@ -20,7 +20,6 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdbool.h>
#include <xcb/xcb.h> #include <xcb/xcb.h>
#include <xcb/xcb_aux.h> #include <xcb/xcb_aux.h>

View File

@ -22,8 +22,6 @@
#ifndef AWESOME_CLIENT_H #ifndef AWESOME_CLIENT_H
#define AWESOME_CLIENT_H #define AWESOME_CLIENT_H
#include <stdbool.h>
#include <xcb/xcb_icccm.h> #include <xcb/xcb_icccm.h>
#include "structs.h" #include "structs.h"

View File

@ -133,6 +133,16 @@ char* a_strndup(const char* src, ssize_t l)
return _tmpStr; return _tmpStr;
} }
Fuzzy
fuzzy_get_from_str(const char *str)
{
if(!a_strcmp(str, "true") || !a_strcmp(str, "yes"))
return Yes;
else if(!a_strcmp(str, "false") || !a_strcmp(str, "no"))
return No;
return Maybe;
}
/** \brief safe limited strcpy. /** \brief safe limited strcpy.
* *
* Copies at most min(<tt>n-1</tt>, \c l) characters from \c src into \c dst, * Copies at most min(<tt>n-1</tt>, \c l) characters from \c src into \c dst,

View File

@ -25,6 +25,7 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h>
/** A list of possible position, not sex related */ /** A list of possible position, not sex related */
typedef enum typedef enum
@ -37,6 +38,14 @@ typedef enum
Auto Auto
} Position; } Position;
/** Fuzzy logic */
typedef enum
{
No = false,
Yes = true,
Maybe
} Fuzzy;
/** Link a name to a function */ /** Link a name to a function */
typedef struct typedef struct
{ {
@ -252,6 +261,7 @@ void _warn(int, const char *, const char *, ...)
__attribute__ ((format(printf, 3, 4))); __attribute__ ((format(printf, 3, 4)));
Position position_get_from_str(const char *); Position position_get_from_str(const char *);
Fuzzy fuzzy_get_from_str(const char *);
double compute_new_value_from_arg(const char *, double); double compute_new_value_from_arg(const char *, double);
void *name_func_lookup(const char *, const name_func_link_t *); void *name_func_lookup(const char *, const name_func_link_t *);

View File

@ -540,9 +540,9 @@ config_parse(const char *confpatharg)
rule->xprop = a_strdup(cfg_getstr(cfgsectmp, "xproperty_name")); rule->xprop = a_strdup(cfg_getstr(cfgsectmp, "xproperty_name"));
rule->xpropval_r = rules_compile_regex(cfg_getstr(cfgsectmp, "xproperty_value")); rule->xpropval_r = rules_compile_regex(cfg_getstr(cfgsectmp, "xproperty_value"));
rule->icon = a_strdup(cfg_getstr(cfgsectmp, "icon")); rule->icon = a_strdup(cfg_getstr(cfgsectmp, "icon"));
rule->isfloating = rules_get_fuzzy_from_str(cfg_getstr(cfgsectmp, "float")); rule->isfloating = fuzzy_get_from_str(cfg_getstr(cfgsectmp, "float"));
rule->screen = cfg_getint(cfgsectmp, "screen"); rule->screen = cfg_getint(cfgsectmp, "screen");
rule->ismaster = rules_get_fuzzy_from_str(cfg_getstr(cfgsectmp, "master")); rule->ismaster = fuzzy_get_from_str(cfg_getstr(cfgsectmp, "master"));
rule->opacity = cfg_getfloat(cfgsectmp, "opacity"); rule->opacity = cfg_getfloat(cfgsectmp, "opacity");
config_section_titlebar_init(cfg_getsec(cfgsectmp, "titlebar"), &rule->titlebar, 0); config_section_titlebar_init(cfg_getsec(cfgsectmp, "titlebar"), &rule->titlebar, 0);
if(rule->screen >= globalconf.screens_info->nscreen) if(rule->screen >= globalconf.screens_info->nscreen)

11
rules.c
View File

@ -111,15 +111,4 @@ rule_matching_client(Client *c)
return NULL; return NULL;
} }
Fuzzy
rules_get_fuzzy_from_str(const char *str)
{
if(!a_strcmp(str, "true") || !a_strcmp(str, "yes"))
return Yes;
else if(!a_strcmp(str, "false") || !a_strcmp(str, "no"))
return No;
return Maybe;
}
// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 // vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80

View File

@ -28,7 +28,6 @@
regex_t * rules_compile_regex(char *); regex_t * rules_compile_regex(char *);
bool tag_match_rule(Tag *, Rule *); bool tag_match_rule(Tag *, Rule *);
Fuzzy rules_get_fuzzy_from_str(const char *);
Rule * rule_matching_client(Client *); Rule * rule_matching_client(Client *);
DO_SLIST(Rule, rule, p_delete) DO_SLIST(Rule, rule, p_delete)

View File

@ -41,14 +41,6 @@ typedef enum
LAYER_FULLSCREEN LAYER_FULLSCREEN
} Layer; } Layer;
/** Rules for floating rule */
typedef enum
{
No = false,
Yes = true,
Maybe
} Fuzzy;
/** Cursors */ /** Cursors */
enum enum
{ CurNormal, CurResize, CurMove, CurLast }; { CurNormal, CurResize, CurMove, CurLast };