From e01269669511b4ed841eed076a5fd008fad0cf3e Mon Sep 17 00:00:00 2001 From: speedie Date: Mon, 6 Mar 2023 16:23:03 +0100 Subject: [PATCH] add some comments to the top --- docs/example.Xresources | 1 + colors.h => libs/colors.h | 0 xresources.h => libs/xresources.h | 1 + options.h | 1 + spmenu.c | 39 ++++++++++++++++++++++++++----- 5 files changed, 36 insertions(+), 6 deletions(-) rename colors.h => libs/colors.h (100%) rename xresources.h => libs/xresources.h (99%) diff --git a/docs/example.Xresources b/docs/example.Xresources index 9aa7afa..0f8da58 100644 --- a/docs/example.Xresources +++ b/docs/example.Xresources @@ -56,6 +56,7 @@ spmenu.colorprompt: 1 spmenu.preselected: 0 spmenu.type: 1 spmenu.class: spmenu +spmenu.mon: -1 spmenu.leftarrow: < spmenu.rightarrow: > spmenu.password: . diff --git a/colors.h b/libs/colors.h similarity index 100% rename from colors.h rename to libs/colors.h diff --git a/xresources.h b/libs/xresources.h similarity index 99% rename from xresources.h rename to libs/xresources.h index 970035b..318a5da 100644 --- a/xresources.h +++ b/libs/xresources.h @@ -128,6 +128,7 @@ ResourcePref resources[] = { { "generatecache", INTEGER, &generatecache }, { "mode", INTEGER, &mode }, { "fast", INTEGER, &fast }, + { "mon", INTEGER, &mon }, { "pango_item", INTEGER, &pango_item }, { "pango_prompt", INTEGER, &pango_prompt }, { "pango_input", INTEGER, &pango_input }, diff --git a/options.h b/options.h index 92ba15d..7d47edc 100644 --- a/options.h +++ b/options.h @@ -7,6 +7,7 @@ static char class[] = "spmenu"; /* Class for spmenu */ static int fast = 0; /* Grab keyboard first */ static int xresources = 1; /* Enable .Xresources support */ +static int mon = -1; /* Monitor to run spmenu on */ /* Window options */ static int alpha = 1; /* Enable alpha */ diff --git a/spmenu.c b/spmenu.c index 1c2ad96..cd7a63d 100644 --- a/spmenu.c +++ b/spmenu.c @@ -1,4 +1,20 @@ -/* See LICENSE file for copyright and license details. */ +/* spmenu - speedie's dmenu fork + * + * If you're looking for functions used to draw text, see 'libs/draw.c' + * If you're looking for wrapper functions used inside the draw functions, see 'libs/sl/draw.c' + * If you're looking for functions used to draw images, see 'libs/img.c' + * If you're looking for the .Xresources array, see 'libs/xresources.h' + * + * To disable certain features, pass one or more of the following to the compiler: + * + * NOXINERAMA, NORTL, NOIMAGE + * + * You don't need to edit spmenu.c if you aren't making big changes to the software. + * + * After making changes, run 'make clean install' to install and 'make' to attempt a compilation. + * `make man` will generate a man page from 'docs/docs.md', which is a Markdown document. Run this before commiting. + * + * See LICENSE file for copyright and license details. */ #include #include #include @@ -30,6 +46,13 @@ #define USEXINERAMA 0 #endif +/* NOXINERAMA overrides XINERAMA */ +#ifdef NOXINERAMA +#define USEXINERAMA 0 +#else +#define USEXINERAMA 1 +#endif + /* include right to left language library */ #if USERTL #include @@ -87,6 +110,7 @@ #include "libs/schemes.h" #include "libs/arg.h" #include "libs/mode.h" +#include "libs/xrdb.h" static char text[BUFSIZ] = ""; @@ -125,15 +149,19 @@ static unsigned int selected = 0; static struct item *items = NULL, *backup_items; static struct item *matches, *matchend; static struct item *prev, *curr, *next, *sel; -static int mon = -1, screen; +static int screen; static int managed = 0; +/* image globals */ static int flip = 0; static int rotation = 0; static int imagew = 0; static int imageh = 0; static int imageg = 0; +/* set an integer if to 1 if we have right to left language support enabled + * doing it this way, because we can reduce the amount of #if and #else lines used. + */ #if USERTL static int isrtl = 1; #else @@ -190,13 +218,12 @@ static void readstdin(void); static void recalculatenumbers(void); static void usage(void); -#include "libs/xrdb.h" - /* user configuration */ #include "options.h" /* Include main header */ #include "keybinds.h" /* Include keybinds */ -#include "colors.h" /* Include colors */ -#include "xresources.h" /* Include .Xresources */ + +#include "libs/xresources.h" +#include "libs/colors.h" static char * cistrstr(const char *s, const char *sub); static int (*fstrncmp)(const char *, const char *, size_t) = strncasecmp;