Skip to content

Commit

Permalink
Adding pachtes sources
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrelamberty committed Apr 4, 2022
1 parent 2c827d1 commit 12c508a
Show file tree
Hide file tree
Showing 4 changed files with 310 additions and 0 deletions.
53 changes: 53 additions & 0 deletions patches/dmenu-caseinsensitive-5.0.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
diff --git a/dmenu.1 b/dmenu.1
index 323f93c..3e3b31b 100644
--- a/dmenu.1
+++ b/dmenu.1
@@ -3,7 +3,7 @@
dmenu \- dynamic menu
.SH SYNOPSIS
.B dmenu
-.RB [ \-bfiv ]
+.RB [ \-bfsv ]
.RB [ \-l
.IR lines ]
.RB [ \-m
@@ -44,8 +44,8 @@ dmenu appears at the bottom of the screen.
dmenu grabs the keyboard before reading stdin if not reading from a tty. This
is faster, but will lock up X until stdin reaches end\-of\-file.
.TP
-.B \-i
-dmenu matches menu items case insensitively.
+.B \-s
+dmenu matches menu items case sensitively.
.TP
.BI \-l " lines"
dmenu lists items vertically, with the given number of lines.
diff --git a/dmenu.c b/dmenu.c
index 65f25ce..855df59 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -55,8 +55,9 @@ static Clr *scheme[SchemeLast];

#include "config.h"

-static int (*fstrncmp)(const char *, const char *, size_t) = strncmp;
-static char *(*fstrstr)(const char *, const char *) = strstr;
+static char * cistrstr(const char *s, const char *sub);
+static int (*fstrncmp)(const char *, const char *, size_t) = strncasecmp;
+static char *(*fstrstr)(const char *, const char *) = cistrstr;

static void
appenditem(struct item *item, struct item **list, struct item **last)
@@ -709,9 +710,9 @@ main(int argc, char *argv[])
topbar = 0;
else if (!strcmp(argv[i], "-f")) /* grabs keyboard before reading stdin */
fast = 1;
- else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */
- fstrncmp = strncasecmp;
- fstrstr = cistrstr;
+ else if (!strcmp(argv[i], "-s")) { /* case-sensitive item matching */
+ fstrncmp = strncmp;
+ fstrstr = strstr;
} else if (i + 1 == argc)
usage();
/* these options take one argument */
56 changes: 56 additions & 0 deletions patches/dmenu-center-4.8.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
diff --git a/dmenu.c b/dmenu.c
index 5e9c367..2268ea9 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -88,6 +88,15 @@ calcoffsets(void)
break;
}

+static int
+max_textw(void)
+{
+ int len = 0;
+ for (struct item *item = items; item && item->text; item++)
+ len = MAX(TEXTW(item->text), len);
+ return len;
+}
+
static void
cleanup(void)
{
@@ -598,6 +607,7 @@ setup(void)
bh = drw->fonts->h + 2;
lines = MAX(lines, 0);
mh = (lines + 1) * bh;
+ promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
#ifdef XINERAMA
i = 0;
if (parentwin == root && (info = XineramaQueryScreens(dpy, &n))) {
@@ -624,9 +634,9 @@ setup(void)
if (INTERSECT(x, y, 1, 1, info[i]))
break;

- x = info[i].x_org;
- y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
- mw = info[i].width;
+ mw = MIN(MAX(max_textw() + promptw, 100), info[i].width);
+ x = info[i].x_org + ((info[i].width - mw) / 2);
+ y = info[i].y_org + ((info[i].height - mh) / 2);
XFree(info);
} else
#endif
@@ -634,11 +644,10 @@ setup(void)
if (!XGetWindowAttributes(dpy, parentwin, &wa))
die("could not get embedding window attributes: 0x%lx",
parentwin);
- x = 0;
- y = topbar ? 0 : wa.height - mh;
- mw = wa.width;
+ mw = MIN(MAX(max_textw() + promptw, 100), wa.width);
+ x = (wa.width - mw) / 2;
+ y = (wa.height - mh) / 2;
}
- promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
inputw = MIN(inputw, mw/3);
match();

107 changes: 107 additions & 0 deletions patches/dmenu-grid-4.9.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
From 39ab9676914bd0d8105d0f96bbd7611a53077438 Mon Sep 17 00:00:00 2001
From: Miles Alan <m@milesalan.com>
Date: Sat, 4 Jul 2020 11:19:04 -0500
Subject: [PATCH] Add -g option to display entries in the given number of grid
columns

This option can be used in conjunction with -l to format dmenu's options in
arbitrary size grids. For example, to create a 4 column by 6 line grid, you
could use: dmenu -g 4 -l 6
---
config.def.h | 3 ++-
dmenu.1 | 7 ++++++-
dmenu.c | 22 ++++++++++++++++------
3 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/config.def.h b/config.def.h
index 1edb647..96cf3c9 100644
--- a/config.def.h
+++ b/config.def.h
@@ -13,8 +13,9 @@ static const char *colors[SchemeLast][2] = {
[SchemeSel] = { "#eeeeee", "#005577" },
[SchemeOut] = { "#000000", "#00ffff" },
};
-/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
+/* -l and -g options; controls number of lines and columns in grid if > 0 */
static unsigned int lines = 0;
+static unsigned int columns = 0;

/*
* Characters not considered part of a word while deleting words
diff --git a/dmenu.1 b/dmenu.1
index 323f93c..d0a734a 100644
--- a/dmenu.1
+++ b/dmenu.1
@@ -4,6 +4,8 @@ dmenu \- dynamic menu
.SH SYNOPSIS
.B dmenu
.RB [ \-bfiv ]
+.RB [ \-g
+.IR columns ]
.RB [ \-l
.IR lines ]
.RB [ \-m
@@ -47,8 +49,11 @@ is faster, but will lock up X until stdin reaches end\-of\-file.
.B \-i
dmenu matches menu items case insensitively.
.TP
+.BI \-g " columns"
+dmenu lists items in a grid with the given number of columns.
+.TP
.BI \-l " lines"
-dmenu lists items vertically, with the given number of lines.
+dmenu lists items in a grid with the given number of lines.
.TP
.BI \-m " monitor"
dmenu is displayed on the monitor number supplied. Monitor numbers are starting
diff --git a/dmenu.c b/dmenu.c
index 6b8f51b..d79b6bb 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -77,7 +77,7 @@ calcoffsets(void)
int i, n;

if (lines > 0)
- n = lines * bh;
+ n = lines * columns * bh;
else
n = mw - (promptw + inputw + TEXTW("<") + TEXTW(">"));
/* calculate which items will begin the next page and previous page */
@@ -152,9 +152,15 @@ drawmenu(void)
}

if (lines > 0) {
- /* draw vertical list */
- for (item = curr; item != next; item = item->right)
- drawitem(item, x, y += bh, mw - x);
+ /* draw grid */
+ int i = 0;
+ for (item = curr; item != next; item = item->right, i++)
+ drawitem(
+ item,
+ x + ((i / lines) * ((mw - x) / columns)),
+ y + (((i % lines) + 1) * bh),
+ (mw - x) / columns
+ );
} else if (matches) {
/* draw horizontal list */
x += inputw;
@@ -708,9 +714,13 @@ main(int argc, char *argv[])
} else if (i + 1 == argc)
usage();
/* these options take one argument */
- else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
+ else if (!strcmp(argv[i], "-g")) { /* number of columns in grid */
+ columns = atoi(argv[++i]);
+ if (lines == 0) lines = 1;
+ } else if (!strcmp(argv[i], "-l")) { /* number of lines in grid */
lines = atoi(argv[++i]);
- else if (!strcmp(argv[i], "-m"))
+ if (columns == 0) columns = 1;
+ } else if (!strcmp(argv[i], "-m"))
mon = atoi(argv[++i]);
else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
prompt = argv[++i];
--
2.23.1

94 changes: 94 additions & 0 deletions patches/dmenu-lineheight-4.9.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
From 87f92a561c31246f6f9effc0e89ef92677c87746 Mon Sep 17 00:00:00 2001
From: astier <aleksandrs.stier@uni-bielefeld.de>
Date: Wed, 27 Feb 2019 21:44:55 +0100
Subject: [PATCH] Add an option which defines the lineheight

Despite both the panel and dmenu using the same font (a Terminus 12),
dmenu is shorter and the panel is visible from under the dmenu bar.
The appearance can be even more distracting when using similar colors
for background and selections. With the option added by this patch,
dmenu can be launched with a '-h 24', thus completely covering the panel.
---
config.def.h | 1 +
dmenu.1 | 3 +++
dmenu.c | 10 ++++++++--
3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/config.def.h b/config.def.h
index 1edb647..317fa2f 100644
--- a/config.def.h
+++ b/config.def.h
@@ -15,6 +15,7 @@ static const char *colors[SchemeLast][2] = {
};
/* -l option; if nonzero, dmenu uses vertical list with given number of lines */
static unsigned int lines = 0;
+static unsigned int lineheight = 0; /* -h option; minimum height of a menu line */

/*
* Characters not considered part of a word while deleting words
diff --git a/dmenu.1 b/dmenu.1
index 323f93c..7ef34d2 100644
--- a/dmenu.1
+++ b/dmenu.1
@@ -50,6 +50,9 @@ dmenu matches menu items case insensitively.
.BI \-l " lines"
dmenu lists items vertically, with the given number of lines.
.TP
+.BI \-h " height"
+dmenu uses a menu line of at least 'height' pixels tall, but no less than 8.
+.TP
.BI \-m " monitor"
dmenu is displayed on the monitor number supplied. Monitor numbers are starting
from 0.
diff --git a/dmenu.c b/dmenu.c
index 6b8f51b..45d1946 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -131,7 +131,7 @@ drawmenu(void)
{
unsigned int curpos;
struct item *item;
- int x = 0, y = 0, w;
+ int x = 0, y = 0, fh = drw->fonts->h, w;

drw_setscheme(drw, scheme[SchemeNorm]);
drw_rect(drw, 0, 0, mw, mh, 1, 1);
@@ -148,7 +148,7 @@ drawmenu(void)
curpos = TEXTW(text) - TEXTW(&text[cursor]);
if ((curpos += lrpad / 2 - 1) < w) {
drw_setscheme(drw, scheme[SchemeNorm]);
- drw_rect(drw, x + curpos, 2, 2, bh - 4, 1, 0);
+ drw_rect(drw, x + curpos, 2 + (bh-fh)/2, 2, fh - 4, 1, 0);
}

if (lines > 0) {
@@ -604,6 +604,7 @@ setup(void)

/* calculate menu geometry */
bh = drw->fonts->h + 2;
+ bh = MAX(bh,lineheight); /* make a menu line AT LEAST 'lineheight' tall */
lines = MAX(lines, 0);
mh = (lines + 1) * bh;
#ifdef XINERAMA
@@ -683,6 +684,7 @@ static void
usage(void)
{
fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
+ " [-h height]\n"
" [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr);
exit(1);
}
@@ -716,6 +718,10 @@ main(int argc, char *argv[])
prompt = argv[++i];
else if (!strcmp(argv[i], "-fn")) /* font or font set */
fonts[0] = argv[++i];
+ else if(!strcmp(argv[i], "-h")) { /* minimum height of one menu line */
+ lineheight = atoi(argv[++i]);
+ lineheight = MAX(lineheight,8); /* reasonable default in case of value too small/negative */
+ }
else if (!strcmp(argv[i], "-nb")) /* normal background color */
colors[SchemeNorm][ColBg] = argv[++i];
else if (!strcmp(argv[i], "-nf")) /* normal foreground color */
--
2.21.0

0 comments on commit 12c508a

Please sign in to comment.