Even more cleanup

This commit is contained in:
Jacob 2023-08-07 05:54:59 +02:00
parent 10030e1c91
commit 0d4f3960b8
19 changed files with 311 additions and 333 deletions

View file

@ -1,4 +1,9 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
static void readargs(int argc, char *argv[]);
static void usage(int status);
static void comp_opts(void);
void readargs(int argc, char *argv[]) { void readargs(int argc, char *argv[]) {
int i = 0; int i = 0;
int j = 0; int j = 0;

View file

@ -1,4 +0,0 @@
/* See LICENSE file for copyright and license details. */
static void readargs(int argc, char *argv[]);
static void usage(int status);
static void comp_opts(void);

View file

@ -1,262 +0,0 @@
/* See LICENSE file for copyright and license details. */
// sgr color array, first 16 colors are defined in the config, the rest are 256 colors
static char *textcolors[] = {
col_sgr0,
col_sgr1,
col_sgr2,
col_sgr3,
col_sgr4,
col_sgr5,
col_sgr6,
col_sgr7,
col_sgr8,
col_sgr9,
col_sgr10,
col_sgr11,
col_sgr12,
col_sgr13,
col_sgr14,
col_sgr15,
"#00005f",
"#000087",
"#0000af",
"#0000d7",
"#0000ff",
"#005f00",
"#005f5f",
"#005f87",
"#005faf",
"#005fd7",
"#005fff",
"#008700",
"#00875f",
"#008787",
"#0087af",
"#0087d7",
"#0087ff",
"#00af00",
"#00af5f",
"#00af87",
"#00afaf",
"#00afd7",
"#00afff",
"#00d700",
"#00d75f",
"#00d787",
"#00d7af",
"#00d7d7",
"#00d7ff",
"#00ff00",
"#00ff5f",
"#00ff87",
"#00ffaf",
"#00ffd7",
"#00ffff",
"#5f0000",
"#5f005f",
"#5f0087",
"#5f00af",
"#5f00d7",
"#5f00ff",
"#5f5f00",
"#5f5f5f",
"#5f5f87",
"#5f5faf",
"#5f5fd7",
"#5f5fff",
"#5f8700",
"#5f875f",
"#5f8787",
"#5f87af",
"#5f87d7",
"#5f87ff",
"#5faf00",
"#5faf5f",
"#5faf87",
"#5fafaf",
"#5fafd7",
"#5fafff",
"#5fd700",
"#5fd75f",
"#5fd787",
"#5fd7af",
"#5fd7d7",
"#5fd7ff",
"#5fff00",
"#5fff5f",
"#5fff87",
"#5fffaf",
"#5fffd7",
"#5fffff",
"#870000",
"#87005f",
"#870087",
"#8700af",
"#8700d7",
"#8700ff",
"#875f00",
"#875f5f",
"#875f87",
"#875faf",
"#875fd7",
"#875fff",
"#878700",
"#87875f",
"#878787",
"#8787af",
"#8787d7",
"#8787ff",
"#87af00",
"#87af5f",
"#87af87",
"#87afaf",
"#87afd7",
"#87afff",
"#87d700",
"#87d75f",
"#87d787",
"#87d7af",
"#87d7d7",
"#87d7ff",
"#87ff00",
"#87ff5f",
"#87ff87",
"#87ffaf",
"#87ffd7",
"#87ffff",
"#af0000",
"#af005f",
"#af0087",
"#af00af",
"#af00d7",
"#af00ff",
"#af5f00",
"#af5f5f",
"#af5f87",
"#af5faf",
"#af5fd7",
"#af5fff",
"#af8700",
"#af875f",
"#af8787",
"#af87af",
"#af87d7",
"#af87ff",
"#afaf00",
"#afaf5f",
"#afaf87",
"#afafaf",
"#afafd7",
"#afafff",
"#afd700",
"#afd75f",
"#afd787",
"#afd7af",
"#afd7d7",
"#afd7ff",
"#afff00",
"#afff5f",
"#afff87",
"#afffaf",
"#afffd7",
"#afffff",
"#d70000",
"#d7005f",
"#d70087",
"#d700af",
"#d700d7",
"#d700ff",
"#d75f00",
"#d75f5f",
"#d75f87",
"#d75faf",
"#d75fd7",
"#d75fff",
"#d78700",
"#d7875f",
"#d78787",
"#d787af",
"#d787d7",
"#d787ff",
"#d7af00",
"#d7af5f",
"#d7af87",
"#d7afaf",
"#d7afd7",
"#d7afff",
"#d7d700",
"#d7d75f",
"#d7d787",
"#d7d7af",
"#d7d7d7",
"#d7d7ff",
"#d7ff00",
"#d7ff5f",
"#d7ff87",
"#d7ffaf",
"#d7ffd7",
"#d7ffff",
"#ff0000",
"#ff005f",
"#ff0087",
"#ff00af",
"#ff00d7",
"#ff00ff",
"#ff5f00",
"#ff5f5f",
"#ff5f87",
"#ff5faf",
"#ff5fd7",
"#ff5fff",
"#ff8700",
"#ff875f",
"#ff8787",
"#ff87af",
"#ff87d7",
"#ff87ff",
"#ffaf00",
"#ffaf5f",
"#ffaf87",
"#ffafaf",
"#ffafd7",
"#ffafff",
"#ffd700",
"#ffd75f",
"#ffd787",
"#ffd7af",
"#ffd7d7",
"#ffd7ff",
"#ffff00",
"#ffff5f",
"#ffff87",
"#ffffaf",
"#ffffd7",
"#ffffff",
"#080808",
"#121212",
"#1c1c1c",
"#262626",
"#303030",
"#3a3a3a",
"#444444",
"#4e4e4e",
"#585858",
"#626262",
"#6c6c6c",
"#767676",
"#808080",
"#8a8a8a",
"#949494",
"#9e9e9e",
"#a8a8a8",
"#b2b2b2",
"#bcbcbc",
"#c6c6c6",
"#d0d0d0",
"#dadada",
"#e4e4e4",
"#eeeeee",
};
static char *txtcols[256];

View file

@ -1,5 +1,7 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#if USECONFIG
#include <libconfig.h> #include <libconfig.h>
#include "config.h"
int bind_init(void) { int bind_init(void) {
char *xdg_conf; char *xdg_conf;
@ -1519,3 +1521,4 @@ void theme_load(void) {
config_destroy(&cfg); config_destroy(&cfg);
return; return;
} }
#endif

View file

@ -1,5 +1,5 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#if USECONFIG
#if USEX #if USEX
typedef struct { typedef struct {
char *key; char *key;
@ -703,3 +703,4 @@ static ClickType ctp[] = {
static void conf_init(void); static void conf_init(void);
static void theme_load(void); static void theme_load(void);
static int bind_init(void); static int bind_init(void);
#endif

View file

@ -1,6 +1,8 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#if USEIMAGE #if USEIMAGE
static int draw_icon(struct item *item, int x, int y, int w, int h);
int draw_icon(struct item *item, int x, int y, int w, int h) { int draw_icon(struct item *item, int x, int y, int w, int h) {
int ich = 0; int ich = 0;
int icw = 0; int icw = 0;

View file

@ -1,5 +0,0 @@
/* See LICENSE file for copyright and license details. */
#if USEIMAGE
static int draw_icon(struct item *item, int x, int y, int w, int h);
#endif

View file

@ -1,6 +1,30 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#if USEIMAGE #if USEIMAGE
#include <errno.h>
#include <pwd.h>
#include <Imlib2.h>
#include <openssl/evp.h>
static void setimagesize(int width, int height);
static void setimageopts(void);
static void cleanupimage(void);
static void drawimage(void);
static void flipimage(void);
static void loadimage(const char *file, int *width, int *height);
static void loadimagecache(const char *file, int *width, int *height);
static void resizetoimageheight(int imageheight);
static void store_image_vars(void);
#if USEWAYLAND
static void resizetoimageheight_wl(int imageheight);
#endif
#if USEX
static void resizetoimageheight_x11(int imageheight);
#endif
static Imlib_Image image = NULL;
void setimagesize(int width, int height) { void setimagesize(int width, int height) {
if (!image || hideimage || height < 5 || width < 5 || width > sp.mw - sp.bh) { if (!image || hideimage || height < 5 || width < 5 || width > sp.mw - sp.bh) {
return; return;

View file

@ -1,26 +0,0 @@
/* See LICENSE file for copyright and license details. */
#if USEIMAGE
#include <errno.h>
#include <pwd.h>
#include <Imlib2.h>
#include <openssl/evp.h>
static void setimagesize(int width, int height);
static void setimageopts(void);
static void cleanupimage(void);
static void drawimage(void);
static void flipimage(void);
static void loadimage(const char *file, int *width, int *height);
static void loadimagecache(const char *file, int *width, int *height);
static void resizetoimageheight(int imageheight);
#if USEWAYLAND
static void resizetoimageheight_wl(int imageheight);
#endif
#if USEX
static void resizetoimageheight_x11(int imageheight);
#endif
static void store_image_vars(void);
static Imlib_Image image = NULL;
#endif

View file

@ -1,9 +1,15 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#if USEREGEX #if USEREGEX
#include "regex/regex.h"
#include "regex/regex.c" #include "regex/regex.c"
#endif #endif
static void fuzzymatch(void);
static void match(void);
static int matchregex(const char *t, const char *itt);
static int compare_distance(const void *a, const void *b);
int matchregex(const char *t, const char *itt) { int matchregex(const char *t, const char *itt) {
#if USEREGEX #if USEREGEX
re_t reg = re_compile(t); re_t reg = re_compile(t);

View file

@ -1,10 +0,0 @@
/* See LICENSE file for copyright and license details. */
#if USEREGEX
#include "regex/regex.h"
#endif
static void fuzzymatch(void);
static void match(void);
static int matchregex(const char *t, const char *itt);
static int compare_distance(const void *a, const void *b);

View file

@ -1,5 +1,8 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
static char fribidi_text[BUFSIZ] = "";
static void apply_fribidi(char *str);
#if USERTL #if USERTL
void apply_fribidi(char *str) { void apply_fribidi(char *str) {
FriBidiStrIndex len = strlen(str); FriBidiStrIndex len = strlen(str);

View file

@ -1,4 +0,0 @@
/* See LICENSE file for copyright and license details. */
static char fribidi_text[BUFSIZ] = "";
static void apply_fribidi(char *str);

View file

@ -1,5 +1,7 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#include "schemes.h"
char sixd_to_8bit(int x) { char sixd_to_8bit(int x) {
return x == 0 ? 0 : 0x37 + 0x28 * x; return x == 0 ? 0 : 0x37 + 0x28 * x;
} }

View file

@ -1,3 +1,262 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
static char *textcolors[] = {
col_sgr0,
col_sgr1,
col_sgr2,
col_sgr3,
col_sgr4,
col_sgr5,
col_sgr6,
col_sgr7,
col_sgr8,
col_sgr9,
col_sgr10,
col_sgr11,
col_sgr12,
col_sgr13,
col_sgr14,
col_sgr15,
"#00005f",
"#000087",
"#0000af",
"#0000d7",
"#0000ff",
"#005f00",
"#005f5f",
"#005f87",
"#005faf",
"#005fd7",
"#005fff",
"#008700",
"#00875f",
"#008787",
"#0087af",
"#0087d7",
"#0087ff",
"#00af00",
"#00af5f",
"#00af87",
"#00afaf",
"#00afd7",
"#00afff",
"#00d700",
"#00d75f",
"#00d787",
"#00d7af",
"#00d7d7",
"#00d7ff",
"#00ff00",
"#00ff5f",
"#00ff87",
"#00ffaf",
"#00ffd7",
"#00ffff",
"#5f0000",
"#5f005f",
"#5f0087",
"#5f00af",
"#5f00d7",
"#5f00ff",
"#5f5f00",
"#5f5f5f",
"#5f5f87",
"#5f5faf",
"#5f5fd7",
"#5f5fff",
"#5f8700",
"#5f875f",
"#5f8787",
"#5f87af",
"#5f87d7",
"#5f87ff",
"#5faf00",
"#5faf5f",
"#5faf87",
"#5fafaf",
"#5fafd7",
"#5fafff",
"#5fd700",
"#5fd75f",
"#5fd787",
"#5fd7af",
"#5fd7d7",
"#5fd7ff",
"#5fff00",
"#5fff5f",
"#5fff87",
"#5fffaf",
"#5fffd7",
"#5fffff",
"#870000",
"#87005f",
"#870087",
"#8700af",
"#8700d7",
"#8700ff",
"#875f00",
"#875f5f",
"#875f87",
"#875faf",
"#875fd7",
"#875fff",
"#878700",
"#87875f",
"#878787",
"#8787af",
"#8787d7",
"#8787ff",
"#87af00",
"#87af5f",
"#87af87",
"#87afaf",
"#87afd7",
"#87afff",
"#87d700",
"#87d75f",
"#87d787",
"#87d7af",
"#87d7d7",
"#87d7ff",
"#87ff00",
"#87ff5f",
"#87ff87",
"#87ffaf",
"#87ffd7",
"#87ffff",
"#af0000",
"#af005f",
"#af0087",
"#af00af",
"#af00d7",
"#af00ff",
"#af5f00",
"#af5f5f",
"#af5f87",
"#af5faf",
"#af5fd7",
"#af5fff",
"#af8700",
"#af875f",
"#af8787",
"#af87af",
"#af87d7",
"#af87ff",
"#afaf00",
"#afaf5f",
"#afaf87",
"#afafaf",
"#afafd7",
"#afafff",
"#afd700",
"#afd75f",
"#afd787",
"#afd7af",
"#afd7d7",
"#afd7ff",
"#afff00",
"#afff5f",
"#afff87",
"#afffaf",
"#afffd7",
"#afffff",
"#d70000",
"#d7005f",
"#d70087",
"#d700af",
"#d700d7",
"#d700ff",
"#d75f00",
"#d75f5f",
"#d75f87",
"#d75faf",
"#d75fd7",
"#d75fff",
"#d78700",
"#d7875f",
"#d78787",
"#d787af",
"#d787d7",
"#d787ff",
"#d7af00",
"#d7af5f",
"#d7af87",
"#d7afaf",
"#d7afd7",
"#d7afff",
"#d7d700",
"#d7d75f",
"#d7d787",
"#d7d7af",
"#d7d7d7",
"#d7d7ff",
"#d7ff00",
"#d7ff5f",
"#d7ff87",
"#d7ffaf",
"#d7ffd7",
"#d7ffff",
"#ff0000",
"#ff005f",
"#ff0087",
"#ff00af",
"#ff00d7",
"#ff00ff",
"#ff5f00",
"#ff5f5f",
"#ff5f87",
"#ff5faf",
"#ff5fd7",
"#ff5fff",
"#ff8700",
"#ff875f",
"#ff8787",
"#ff87af",
"#ff87d7",
"#ff87ff",
"#ffaf00",
"#ffaf5f",
"#ffaf87",
"#ffafaf",
"#ffafd7",
"#ffafff",
"#ffd700",
"#ffd75f",
"#ffd787",
"#ffd7af",
"#ffd7d7",
"#ffd7ff",
"#ffff00",
"#ffff5f",
"#ffff87",
"#ffffaf",
"#ffffd7",
"#ffffff",
"#080808",
"#121212",
"#1c1c1c",
"#262626",
"#303030",
"#3a3a3a",
"#444444",
"#4e4e4e",
"#585858",
"#626262",
"#6c6c6c",
"#767676",
"#808080",
"#8a8a8a",
"#949494",
"#9e9e9e",
"#a8a8a8",
"#b2b2b2",
"#bcbcbc",
"#c6c6c6",
"#d0d0d0",
"#dadada",
"#e4e4e4",
"#eeeeee",
};
static char *txtcols[256];
static void init_appearance(void); static void init_appearance(void);

View file

@ -1,4 +0,0 @@
/* See LICENSE file for copyright and license details. */
#define CLEANMASK(mask) (mask & ~(x11.numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)

View file

@ -2,7 +2,6 @@
#if USEX #if USEX
#include "lib.h" #include "lib.h"
#include "def.h"
#include "init.h" #include "init.h"
#include "event.h" #include "event.h"
#include "xrdb.h" #include "xrdb.h"

View file

@ -1,5 +1,8 @@
/* See LICENSE file for copyright and license details. */ /* See LICENSE file for copyright and license details. */
#define CLEANMASK(mask) (mask & ~(x11.numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
static Atom clip, utf8, types, dock; static Atom clip, utf8, types, dock;
static Display *dpy; static Display *dpy;
static Window root, parentwin, win; static Window root, parentwin, win;

View file

@ -213,7 +213,6 @@ static struct item *mouseitem; // clicked item
#include "libs/main.h" #include "libs/main.h"
#include "libs/draw.h" #include "libs/draw.h"
#include "libs/stream.h" #include "libs/stream.h"
#include "libs/schemes.h"
#include "libs/arg.h" #include "libs/arg.h"
#include "libs/x11/inc.h" #include "libs/x11/inc.h"
#include "libs/wl/inc.h" #include "libs/wl/inc.h"
@ -350,28 +349,15 @@ static WlMouse wl_buttons[] = {
}; };
#endif #endif
// color array
#include "libs/colors.h"
// config file
#if USECONFIG
#include "libs/conf/config.h"
#include "libs/conf/config.c"
#endif
// include functions // include functions
#include "libs/img.h"
#include "libs/img.c" #include "libs/img.c"
#include "libs/icon.h"
#include "libs/icon.c" #include "libs/icon.c"
#include "libs/rtl.h"
#include "libs/rtl.c" #include "libs/rtl.c"
#include "libs/sort.c" #include "libs/sort.c"
#include "libs/match.h"
#include "libs/match.c" #include "libs/match.c"
#include "libs/draw.c"
#include "libs/schemes.c" #include "libs/schemes.c"
#include "libs/argv.h" #include "libs/draw.c"
#include "libs/conf/config.c"
#include "libs/argv.c" #include "libs/argv.c"
#include "libs/history.c" #include "libs/history.c"
#include "libs/arg.c" #include "libs/arg.c"