replace a lot of suckless coding decisions with my own

This commit is contained in:
speedie 2023-05-06 14:29:45 +02:00
parent 104d46640b
commit c1d36670fa
21 changed files with 126 additions and 268 deletions

View file

@ -1,6 +1,4 @@
void void moveleft(Arg *arg) {
moveleft(Arg *arg)
{
struct item *tmpsel; struct item *tmpsel;
int i, offscreen = 0; int i, offscreen = 0;
int argu = arg->i ? arg->i : 1; int argu = arg->i ? arg->i : 1;
@ -36,9 +34,7 @@ moveleft(Arg *arg)
} }
} }
void void moveright(Arg *arg) {
moveright(Arg *arg)
{
struct item *tmpsel; struct item *tmpsel;
int i, offscreen = 0; int i, offscreen = 0;
int argu = arg->i ? arg->i : 1; int argu = arg->i ? arg->i : 1;
@ -73,10 +69,7 @@ moveright(Arg *arg)
} }
} }
void void movedown(Arg *arg) {
movedown(Arg *arg)
{
int argu = arg->i ? arg->i : 1; int argu = arg->i ? arg->i : 1;
for (int j = 0; j < argu; j++) { for (int j = 0; j < argu; j++) {
@ -89,9 +82,7 @@ movedown(Arg *arg)
drawmenu(); drawmenu();
} }
void void moveup(Arg *arg) {
moveup(Arg *arg)
{
int argu = arg->i ? arg->i : 1; int argu = arg->i ? arg->i : 1;
for (int j = 0; j < argu; j++) { for (int j = 0; j < argu; j++) {
@ -104,20 +95,18 @@ moveup(Arg *arg)
drawmenu(); drawmenu();
} }
void void complete(Arg *arg) {
complete(Arg *arg)
{
if (hideitem) return; if (hideitem) return;
strncpy(text, sel->clntext, sizeof text - 1); strncpy(text, sel->clntext, sizeof text - 1);
text[sizeof text - 1] = '\0'; text[sizeof text - 1] = '\0';
cursor = strlen(text); cursor = strlen(text);
match(); match();
drawmenu(); drawmenu();
} }
void void movenext(Arg *arg) {
movenext(Arg *arg)
{
if (!next) if (!next)
return; return;
@ -126,9 +115,7 @@ movenext(Arg *arg)
drawmenu(); drawmenu();
} }
void void moveprev(Arg *arg) {
moveprev(Arg *arg)
{
if (!prev) if (!prev)
return; return;
@ -137,9 +124,7 @@ moveprev(Arg *arg)
drawmenu(); drawmenu();
} }
void void movestart(Arg *arg) {
movestart(Arg *arg)
{
if (sel == matches) { if (sel == matches) {
cursor = 0; cursor = 0;
drawmenu(); drawmenu();
@ -151,9 +136,7 @@ movestart(Arg *arg)
drawmenu(); drawmenu();
} }
void void moveend(Arg *arg) {
moveend(Arg *arg)
{
if (text[cursor] != '\0') { if (text[cursor] != '\0') {
cursor = strlen(text); cursor = strlen(text);
drawmenu(); drawmenu();
@ -174,9 +157,7 @@ moveend(Arg *arg)
drawmenu(); drawmenu();
} }
void void paste(Arg *arg) {
paste(Arg *arg)
{
int clipboard; int clipboard;
if (arg->i == 1) { if (arg->i == 1) {
@ -190,9 +171,7 @@ paste(Arg *arg)
} }
void void viewhist(Arg *arg) {
viewhist(Arg *arg)
{
int i; int i;
if (histfile) { if (histfile) {
@ -218,9 +197,7 @@ viewhist(Arg *arg)
drawmenu(); drawmenu();
} }
void void deleteword(Arg *arg) {
deleteword(Arg *arg)
{
if (cursor == 0) return; if (cursor == 0) return;
while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)])) { while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)])) {
@ -232,9 +209,7 @@ deleteword(Arg *arg)
drawmenu(); drawmenu();
} }
void void moveword(Arg *arg) {
moveword(Arg *arg)
{
if (arg->i < 0) { // move cursor to the start of the word if (arg->i < 0) { // move cursor to the start of the word
while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)])) { while (cursor > 0 && strchr(worddelimiters, text[nextrune(-1)])) {
cursor = nextrune(-1); cursor = nextrune(-1);
@ -252,9 +227,7 @@ moveword(Arg *arg)
drawmenu(); drawmenu();
} }
void void movecursor(Arg *arg) {
movecursor(Arg *arg)
{
if (arg->i < 0) { if (arg->i < 0) {
if (cursor > 0) { if (cursor > 0) {
cursor = nextrune(-1); cursor = nextrune(-1);
@ -268,9 +241,7 @@ movecursor(Arg *arg)
drawmenu(); drawmenu();
} }
void void backspace(Arg *arg) {
backspace(Arg *arg)
{
if (cursor == 0) if (cursor == 0)
return; return;
@ -278,9 +249,7 @@ backspace(Arg *arg)
drawmenu(); drawmenu();
} }
void void selectitem(Arg *arg) {
selectitem(Arg *arg)
{
char *selection; char *selection;
if (sel && arg->i && !hideitem) { if (sel && arg->i && !hideitem) {
@ -299,31 +268,23 @@ selectitem(Arg *arg)
exit(0); exit(0);
} }
void void navhistory(Arg *arg) {
navhistory(Arg *arg)
{
navigatehistfile(arg->i); navigatehistfile(arg->i);
drawmenu(); drawmenu();
} }
void void restoresel(Arg *arg) {
restoresel(Arg *arg)
{
text[cursor] = '\0'; text[cursor] = '\0';
match(); match();
drawmenu(); drawmenu();
} }
void void clear(Arg *arg) {
clear(Arg *arg)
{
insert(NULL, 0 - cursor); insert(NULL, 0 - cursor);
drawmenu(); drawmenu();
} }
void void clearins(Arg *arg) {
clearins(Arg *arg)
{
insert(NULL, 0 - cursor); insert(NULL, 0 - cursor);
curMode = 1; curMode = 1;
@ -334,16 +295,12 @@ clearins(Arg *arg)
drawmenu(); drawmenu();
} }
void void quit(Arg *arg) {
quit(Arg *arg)
{
cleanup(); cleanup();
exit(1); exit(0);
} }
void void savehistory(char *input) {
savehistory(char *input)
{
unsigned int i; unsigned int i;
FILE *fp; FILE *fp;
@ -378,17 +335,13 @@ out:
free(history); free(history);
} }
void void setimgsize(Arg *arg) {
setimgsize(Arg *arg)
{
#if USEIMAGE #if USEIMAGE
setimagesize(imagewidth + arg->i, imageheight + arg->i); setimagesize(imagewidth + arg->i, imageheight + arg->i);
#endif #endif
} }
void void flipimg(Arg *arg) {
flipimg(Arg *arg)
{
#if USEIMAGE #if USEIMAGE
if (!image) return; if (!image) return;
@ -400,9 +353,7 @@ flipimg(Arg *arg)
#endif #endif
} }
void void setimgpos(Arg *arg) {
setimgpos(Arg *arg)
{
#if USEIMAGE #if USEIMAGE
if (!image || hideimage) return; if (!image || hideimage) return;
@ -416,9 +367,7 @@ setimgpos(Arg *arg)
#endif #endif
} }
void void setimggaps(Arg *arg) {
setimggaps(Arg *arg)
{
#if USEIMAGE #if USEIMAGE
imagegaps += arg->i; imagegaps += arg->i;
@ -435,9 +384,7 @@ setimggaps(Arg *arg)
#endif #endif
} }
void void rotateimg(Arg *arg) {
rotateimg(Arg *arg)
{
#if USEIMAGE #if USEIMAGE
if (!image || hideimage) return; if (!image || hideimage) return;
@ -448,9 +395,7 @@ rotateimg(Arg *arg)
#endif #endif
} }
void void toggleimg(Arg *arg) {
toggleimg(Arg *arg)
{
#if USEIMAGE #if USEIMAGE
hideimage = !hideimage; hideimage = !hideimage;
@ -460,9 +405,7 @@ toggleimg(Arg *arg)
#endif #endif
} }
void void defaultimg(Arg *arg) {
defaultimg(Arg *arg)
{
#if USEIMAGE #if USEIMAGE
if (hideimage || !image) return; if (hideimage || !image) return;
@ -477,9 +420,7 @@ defaultimg(Arg *arg)
#endif #endif
} }
void void setlines(Arg *arg) {
setlines(Arg *arg)
{
lines += arg->i; lines += arg->i;
if (lines < 0) lines = 0; if (lines < 0) lines = 0;
@ -488,9 +429,7 @@ setlines(Arg *arg)
drawmenu(); drawmenu();
} }
void void setcolumns(Arg *arg) {
setcolumns(Arg *arg)
{
columns += arg->i; columns += arg->i;
if (columns < 1) columns = 1; if (columns < 1) columns = 1;
@ -499,27 +438,31 @@ setcolumns(Arg *arg)
drawmenu(); drawmenu();
} }
void void spawn(Arg *arg) {
spawn(Arg *arg)
{
if (!system(arg->c)) if (!system(arg->c))
die("spmenu: failed to execute command '%s'", arg->c); die("spmenu: failed to execute command '%s'", arg->c);
else else
exit(0); exit(0);
} }
void void togglehighlight(Arg *arg) {
togglehighlight(Arg *arg)
{
hidehighlight = !hidehighlight; hidehighlight = !hidehighlight;
drawmenu(); drawmenu();
} }
void void setprofile(Arg *arg) {
setprofile(Arg *arg) if (!system("command -v spmenu_profile > /dev/null && spmenu_profile --spmenu-set-profile")) {
{
if (!system("command -v spmenu_profile > /dev/null && spmenu_profile --spmenu-set-profile"))
die("spmenu: failed to run profile menu\n"); die("spmenu: failed to run profile menu\n");
else } else {
exit(0); exit(0);
}
}
void switchmode(Arg *arg) {
curMode = !curMode;
allowkeys = !curMode;
strncpy(modetext, curMode ? instext : normtext, 15);
drawmenu();
} }

View file

@ -40,3 +40,4 @@ static void setcolumns(Arg *arg);
static void spawn(Arg *arg); static void spawn(Arg *arg);
static void togglehighlight(Arg *arg); static void togglehighlight(Arg *arg);
static void setprofile(Arg *arg); static void setprofile(Arg *arg);
static void switchmode(Arg *arg);

View file

@ -1,6 +1,4 @@
void void readargs(int argc, char *argv[]) {
readargs(int argc, char *argv[])
{
int i = 0; int i = 0;
int j = 0; int j = 0;
int k = 0; int k = 0;
@ -433,9 +431,7 @@ readargs(int argc, char *argv[])
insert(input, strlen(input)); insert(input, strlen(input));
} }
void void usage(void) {
usage(void)
{
// print help // print help
fputs("spmenu: fancy dynamic menu\n\n" fputs("spmenu: fancy dynamic menu\n\n"
"- Arguments -\n" "- Arguments -\n"

View file

@ -1,6 +1,4 @@
void void prepare_window_size(void) {
prepare_window_size(void)
{
// set horizontal and vertical padding // set horizontal and vertical padding
sp = menupaddingh; sp = menupaddingh;
vp = (menuposition == 1) ? menupaddingv : - menupaddingv; vp = (menuposition == 1) ? menupaddingv : - menupaddingv;
@ -8,9 +6,7 @@ prepare_window_size(void)
return; return;
} }
void void create_window(int x, int y, int w, int h) {
create_window(int x, int y, int w, int h)
{
XSetWindowAttributes swa; XSetWindowAttributes swa;
swa.override_redirect = managed ? False : True; swa.override_redirect = managed ? False : True;
@ -32,27 +28,22 @@ create_window(int x, int y, int w, int h)
return; return;
} }
void void set_window(void) {
set_window(void)
{
XClassHint ch = { class, class }; XClassHint ch = { class, class };
// set border and class // set border and class
XSetWindowBorder(dpy, win, scheme[SchemeBorder][ColBg].pixel); XSetWindowBorder(dpy, win, scheme[SchemeBorder][ColBg].pixel);
XSetClassHint(dpy, win, &ch); XSetClassHint(dpy, win, &ch);
return; return;
} }
void void set_prop(void) {
set_prop(void)
{
if (dockproperty) XChangeProperty(dpy, win, types, XA_ATOM, 32, PropModeReplace, (unsigned char *) &dock, 1); // set dock property if (dockproperty) XChangeProperty(dpy, win, types, XA_ATOM, 32, PropModeReplace, (unsigned char *) &dock, 1); // set dock property
return; return;
} }
void void resizeclient(void) {
resizeclient(void)
{
int omh = mh; int omh = mh;
int x, y; int x, y;
#if USEXINERAMA #if USEXINERAMA

View file

@ -1,22 +1,22 @@
// alpha array // alpha array
static unsigned int alphas[][2] = { static unsigned int alphas[][2] = {
// fg bg // fg bg
[SchemeLArrow] = { 255, 200 }, [SchemeLArrow] = { 255, 200 },
[SchemeRArrow] = { 255, 200 }, [SchemeRArrow] = { 255, 200 },
[SchemeItemNorm] = { 255, 200 }, [SchemeItemNorm] = { 255, 200 },
[SchemeItemSel] = { 255, 200 }, [SchemeItemSel] = { 255, 200 },
[SchemeItemNormPri] = { 255, 200 }, [SchemeItemNormPri] = { 255, 200 },
[SchemeItemSelPri] = { 255, 200 }, [SchemeItemSelPri] = { 255, 200 },
[SchemeMenu] = { 255, 200 }, [SchemeMenu] = { 255, 200 },
[SchemeInput] = { 255, 200 }, [SchemeInput] = { 255, 200 },
[SchemePrompt] = { 255, 200 }, [SchemePrompt] = { 255, 200 },
[SchemeNormHighlight] = { 255, 200 }, [SchemeNormHighlight] = { 255, 200 },
[SchemeSelHighlight] = { 255, 200 }, [SchemeSelHighlight] = { 255, 200 },
[SchemeMode] = { 255, 200 }, [SchemeMode] = { 255, 200 },
[SchemeCaret] = { 255, 200 }, [SchemeCaret] = { 255, 200 },
[SchemeNumber] = { 255, 200 }, [SchemeNumber] = { 255, 200 },
[SchemeBorder] = { 255, 200 }, [SchemeBorder] = { 255, 200 },
[SchemeCaps] = { 255, 200 }, [SchemeCaps] = { 255, 200 },
}; };
// colorscheme array // colorscheme array
@ -40,7 +40,7 @@ static char *colors[SchemeLast][2] = {
[SchemeBorder] = { NULL, col_border }, [SchemeBorder] = { NULL, col_border },
}; };
// sgr color array // sgr color array, first 16 colors are defined in the config, the rest are 256 colors
static char *textcolors[] = { static char *textcolors[] = {
col_sgr0, col_sgr0,
col_sgr1, col_sgr1,

View file

@ -1,9 +1,7 @@
#include <libconfig.h> #include <libconfig.h>
#include "../theme/theme.c" #include "../theme/theme.c"
void void conf_init(void) {
conf_init(void)
{
char *xdg_conf; char *xdg_conf;
char *cfgfile = NULL; char *cfgfile = NULL;
char *home = NULL; char *home = NULL;

View file

@ -1,4 +1,4 @@
// declare macros // declare various macros
#define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)) #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask) & (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask))
#define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask)
#define INTERSECT(x,y,w,h,r) (MAX(0, MIN((x)+(w),(r).x_org+(r).width) - MAX((x),(r).x_org)) \ #define INTERSECT(x,y,w,h,r) (MAX(0, MIN((x)+(w),(r).x_org+(r).width) - MAX((x),(r).x_org)) \
@ -13,11 +13,3 @@
// item // item
#define MAXITEMLENGTH 1024 #define MAXITEMLENGTH 1024
// user friendly names for all the modifiers we're using, but there are many more
#define Ctrl ControlMask
#define Shift ShiftMask
#define Alt Mod1Mask
#define AltGr Mod3Mask
#define Super Mod4Mask
#define ShiftGr Mod5Mask

View file

@ -6,6 +6,14 @@ typedef struct {
Arg arg; Arg arg;
} Key; } Key;
// user friendly names for all the modifiers we're using, but there are many more
#define Ctrl ControlMask
#define Shift ShiftMask
#define Alt Mod1Mask
#define AltGr Mod3Mask
#define Super Mod4Mask
#define ShiftGr Mod5Mask
static void updatenumlockmask(void); static void updatenumlockmask(void);
static void keypress(XEvent *e); static void keypress(XEvent *e);
static void grabkeyboard(void); static void grabkeyboard(void);

View file

@ -1,6 +1,4 @@
void void fuzzymatch(void) {
fuzzymatch(void)
{
struct item *it; struct item *it;
struct item **fuzzymatches = NULL; struct item **fuzzymatches = NULL;
struct item *lhpprefix, *hpprefixend; struct item *lhpprefix, *hpprefixend;
@ -83,9 +81,7 @@ fuzzymatch(void)
} }
} }
void void match(void) {
match(void)
{
if (fuzzy) { if (fuzzy) {
fuzzymatch(); fuzzymatch();
return; return;
@ -165,9 +161,7 @@ match(void)
calcoffsets(); calcoffsets();
} }
int int compare_distance(const void *a, const void *b) {
compare_distance(const void *a, const void *b)
{
struct item *da = *(struct item **) a; struct item *da = *(struct item **) a;
struct item *db = *(struct item **) b; struct item *db = *(struct item **) b;

View file

@ -1,10 +0,0 @@
void
switchmode(Arg *arg)
{
curMode = !curMode;
allowkeys = !curMode;
strncpy(modetext, curMode ? instext : normtext, 15);
drawmenu();
}

View file

@ -1,8 +0,0 @@
static char modetext[16] = "Insert"; // default mode text
// mode settings
static int curMode = 1; // 0 is command mode
static int allowkeys = 1; // whether or not to interpret a keypress as an insertion
// mode functions
static void switchmode(Arg *arg);

View file

@ -1,6 +1,4 @@
void void buttonpress(XEvent *e) {
buttonpress(XEvent *e)
{
struct item *item; struct item *item;
XButtonPressedEvent *ev = &e->xbutton; XButtonPressedEvent *ev = &e->xbutton;
int x = 0, y = 0, h = bh, w, item_num = 0; int x = 0, y = 0, h = bh, w, item_num = 0;

View file

@ -1,7 +1,5 @@
#if USERTL #if USERTL
void void apply_fribidi(char *str) {
apply_fribidi(char *str)
{
FriBidiStrIndex len = strlen(str); FriBidiStrIndex len = strlen(str);
FriBidiChar logical[BUFSIZ]; FriBidiChar logical[BUFSIZ];
FriBidiChar visual[BUFSIZ]; FriBidiChar visual[BUFSIZ];
@ -10,22 +8,18 @@ apply_fribidi(char *str)
fribidi_boolean result; fribidi_boolean result;
fribidi_text[0] = 0; fribidi_text[0] = 0;
if (len>0) {
if (len > 0) {
charset = fribidi_parse_charset("UTF-8"); charset = fribidi_parse_charset("UTF-8");
len = fribidi_charset_to_unicode(charset, str, len, logical); len = fribidi_charset_to_unicode(charset, str, len, logical);
result = fribidi_log2vis(logical, len, &base, visual, NULL, NULL, NULL); result = fribidi_log2vis(logical, len, &base, visual, NULL, NULL, NULL);
len = fribidi_unicode_to_charset(charset, visual, len, fribidi_text); len = fribidi_unicode_to_charset(charset, visual, len, fribidi_text);
} }
if (result) if (result||!result) return;
return;
else
return;
} }
#else #else
void void apply_fribidi(char *str) {
apply_fribidi(char *str)
{
return; return;
} }
#endif #endif

View file

@ -1,12 +1,8 @@
char char sixd_to_8bit(int x) {
sixd_to_8bit(int x)
{
return x == 0 ? 0 : 0x37 + 0x28 * x; return x == 0 ? 0 : 0x37 + 0x28 * x;
} }
void void init_appearance(void) {
init_appearance(void)
{
int i, j; int i, j;
char cbuf[8]; char cbuf[8];

View file

@ -6,9 +6,7 @@
#include "main.h" #include "main.h"
void * void * ecalloc(size_t nmemb, size_t size) {
ecalloc(size_t nmemb, size_t size)
{
void *p; void *p;
if (!(p = calloc(nmemb, size))) if (!(p = calloc(nmemb, size)))
@ -16,8 +14,7 @@ ecalloc(size_t nmemb, size_t size)
return p; return p;
} }
void void die(const char *fmt, ...) {
die(const char *fmt, ...) {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);

View file

@ -1,6 +1,4 @@
char ** char ** tokenize(char *source, const char *delim, int *llen) {
tokenize(char *source, const char *delim, int *llen)
{
int listlength = 0, list_size = 0; int listlength = 0, list_size = 0;
char **list = NULL, *token; char **list = NULL, *token;
@ -20,9 +18,7 @@ tokenize(char *source, const char *delim, int *llen)
return list; return list;
} }
int int arrayhas(char **list, int length, char *item) {
arrayhas(char **list, int length, char *item)
{
int i; int i;
for (i = 0; i < length; i++) { for (i = 0; i < length; i++) {

View file

@ -1,6 +1,4 @@
void void readstdin(void) {
readstdin(void)
{
char buf[sizeof text], *p; char buf[sizeof text], *p;
size_t i, imax = 0, itemsiz = 0; size_t i, imax = 0, itemsiz = 0;
unsigned int tmpmax = 0; unsigned int tmpmax = 0;

View file

@ -1,6 +1,4 @@
void void theme_load(void) {
theme_load(void)
{
char *xdg_conf; char *xdg_conf;
char *theme = NULL; char *theme = NULL;
char *home = NULL; char *home = NULL;

View file

@ -1,6 +1,4 @@
void void resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst) {
resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst)
{
char *sdst = NULL; char *sdst = NULL;
int *idst = NULL; int *idst = NULL;
float *fdst = NULL; float *fdst = NULL;
@ -29,9 +27,7 @@ resource_load(XrmDatabase db, char *name, enum resource_type rtype, void *dst)
} }
} }
void void load_xresources(void) {
load_xresources(void)
{
Display *display; Display *display;
char *resm; char *resm;
XrmDatabase db; XrmDatabase db;

View file

@ -158,6 +158,7 @@ ResourcePref resources[] = {
{ "pango_highlight", INTEGER, &pango_highlight }, { "pango_highlight", INTEGER, &pango_highlight },
}; };
// global colors
ResourcePref cols[] = { ResourcePref cols[] = {
{ "color10", STRING, &col_caretfg }, { "color10", STRING, &col_caretfg },
{ "color0", STRING, &col_caretbg }, { "color0", STRING, &col_caretbg },

View file

@ -94,6 +94,11 @@
// include macros and other defines // include macros and other defines
#include "libs/define.c" #include "libs/define.c"
// mode
static char modetext[16] = "Insert"; // default mode text
static int curMode = 1; // 0 is command mode
static int allowkeys = 1; // whether or not to interpret a keypress as an insertion
// various headers // various headers
#include "libs/libdrw/draw.h" #include "libs/libdrw/draw.h"
#include "libs/sl/main.h" #include "libs/sl/main.h"
@ -101,7 +106,6 @@
#include "libs/stream.h" #include "libs/stream.h"
#include "libs/schemes.h" #include "libs/schemes.h"
#include "libs/arg.h" #include "libs/arg.h"
#include "libs/mode.h"
#include "libs/xrdb.h" #include "libs/xrdb.h"
#include "libs/key.h" #include "libs/key.h"
#include "libs/mouse.h" #include "libs/mouse.h"
@ -208,6 +212,8 @@ static void navigatehistfile(int dir);
static void grabfocus(void); static void grabfocus(void);
static void pastesel(void); static void pastesel(void);
static void appenditem(struct item *item, struct item **list, struct item **last); static void appenditem(struct item *item, struct item **list, struct item **last);
static void xinitvisual(void);
static void setupdisplay(void);
static int max_textw(void); static int max_textw(void);
static size_t nextrune(int inc); static size_t nextrune(int inc);
@ -248,7 +254,6 @@ static char *(*fstrstr)(const char *, const char *) = cistrstr;
#include "libs/argv.h" #include "libs/argv.h"
#include "libs/argv.c" #include "libs/argv.c"
#include "libs/xrdb.c" #include "libs/xrdb.c"
#include "libs/mode.c"
#include "libs/client.h" #include "libs/client.h"
#include "libs/client.c" #include "libs/client.c"
#include "libs/match.h" #include "libs/match.h"
@ -257,9 +262,7 @@ static char *(*fstrstr)(const char *, const char *) = cistrstr;
#include "libs/arg.c" #include "libs/arg.c"
#include "libs/stream.c" #include "libs/stream.c"
void void appenditem(struct item *item, struct item **list, struct item **last) {
appenditem(struct item *item, struct item **list, struct item **last)
{
if (*last) if (*last)
(*last)->right = item; (*last)->right = item;
else else
@ -270,9 +273,7 @@ appenditem(struct item *item, struct item **list, struct item **last)
*last = item; *last = item;
} }
void void recalculatenumbers(void) {
recalculatenumbers(void)
{
unsigned int numer = 0, denom = 0; unsigned int numer = 0, denom = 0;
struct item *item; struct item *item;
if (matchend) { if (matchend) {
@ -290,9 +291,7 @@ recalculatenumbers(void)
snprintf(numbers, NUMBERSBUFSIZE, "%d/%d", numer, denom); snprintf(numbers, NUMBERSBUFSIZE, "%d/%d", numer, denom);
} }
void void calcoffsets(void) {
calcoffsets(void)
{
int i, n; int i, n;
if (lines > 0) if (lines > 0)
@ -327,9 +326,7 @@ calcoffsets(void)
break; break;
} }
int int max_textw(void) {
max_textw(void)
{
int len = 0; int len = 0;
for (struct item *item = items; item && item->text; item++) for (struct item *item = items; item && item->text; item++)
@ -338,9 +335,7 @@ max_textw(void)
return len; return len;
} }
void void cleanup(void) {
cleanup(void)
{
size_t i; size_t i;
#if USEIMAGE #if USEIMAGE
@ -363,9 +358,7 @@ cleanup(void)
XCloseDisplay(dpy); XCloseDisplay(dpy);
} }
char * char * cistrstr(const char *h, const char *n) {
cistrstr(const char *h, const char *n)
{
size_t i; size_t i;
if (!n[0]) if (!n[0])
@ -382,9 +375,7 @@ cistrstr(const char *h, const char *n)
return NULL; return NULL;
} }
void void grabfocus(void) {
grabfocus(void)
{
struct timespec ts = { .tv_sec = 0, .tv_nsec = 10000000 }; struct timespec ts = { .tv_sec = 0, .tv_nsec = 10000000 };
Window focuswin; Window focuswin;
int i, revertwin; int i, revertwin;
@ -419,9 +410,7 @@ grabfocus(void)
die("spmenu: cannot grab focus"); // not possible to grab focus, abort immediately die("spmenu: cannot grab focus"); // not possible to grab focus, abort immediately
} }
void void insert(const char *str, ssize_t n) {
insert(const char *str, ssize_t n)
{
if (strlen(text) + n > sizeof text - 1) if (strlen(text) + n > sizeof text - 1)
return; return;
@ -437,9 +426,7 @@ insert(const char *str, ssize_t n)
match(); match();
} }
size_t size_t nextrune(int inc) {
nextrune(int inc)
{
ssize_t n; ssize_t n;
// return location of next utf8 rune in the given direction (+1 or -1) // return location of next utf8 rune in the given direction (+1 or -1)
@ -448,9 +435,7 @@ nextrune(int inc)
return n; return n;
} }
void void pastesel(void) {
pastesel(void)
{
char *p, *q; char *p, *q;
int di; int di;
unsigned long dl; unsigned long dl;
@ -468,9 +453,7 @@ pastesel(void)
drawmenu(); drawmenu();
} }
void void xinitvisual(void) {
xinitvisual()
{
XVisualInfo *infos; XVisualInfo *infos;
XRenderPictFormat *fmt; XRenderPictFormat *fmt;
int nitems; int nitems;
@ -510,9 +493,7 @@ xinitvisual()
} }
} }
void void setupdisplay(void) {
setupdisplay(void)
{
int x, y, i; int x, y, i;
#if USEXINERAMA #if USEXINERAMA
int j, di; int j, di;
@ -679,9 +660,7 @@ setupdisplay(void)
drawmenu(); drawmenu();
} }
int int main(int argc, char *argv[]) {
main(int argc, char *argv[])
{
XWindowAttributes wa; XWindowAttributes wa;
readargs(argc, argv); // start by reading arguments readargs(argc, argv); // start by reading arguments