~adnano/wmenu-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 2

[PATCH] port dmenu password patch

Details
Message ID
<20240226170900.9531-1-sewn@disroot.org>
DKIM signature
pass
Download raw message
Patch: +27 -5
---
 docs/wmenu.1.scd |  6 +++++-
 main.c           | 26 ++++++++++++++++++++++----
 2 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/docs/wmenu.1.scd b/docs/wmenu.1.scd
index 5fbf50e..7ef6ccd 100644
--- a/docs/wmenu.1.scd
+++ b/docs/wmenu.1.scd
@@ -6,7 +6,7 @@ wmenu - dynamic menu for Wayland

# SYNOPSIS

*wmenu* [-biv] \
*wmenu* [-Pbiv] \
  [-f _font_] \
  [-l _lines_] \
  [-o _output_] \
@@ -24,6 +24,10 @@ to those matching the tokens in the input.

# OPTIONS

*-P*
	wmenu will not directly display the keyboard input, but instead replace it
	with asterisks. All data from stdin will be ignored.

*-b*
	wmenu appears at the bottom of the screen.

diff --git a/main.c b/main.c
index 4202e4b..987dd60 100644
--- a/main.c
+++ b/main.c
@@ -66,6 +66,7 @@ struct menu_state {
	int promptw;
	int left_arrow, right_arrow;

	bool passwd;
	bool bottom;
	int (*fstrncmp)(const char *, const char *, size_t);
	char *font;
@@ -235,7 +236,7 @@ void scroll_matches(struct menu_state *state) {
void render_to_cairo(struct menu_state *state, cairo_t *cairo) {
	int width = state->width;
	int padding = state->padding;

	char *censort = NULL;

	cairo_set_operator(cairo, CAIRO_OPERATOR_SOURCE);
	cairo_set_source_u32(cairo, state->background);
@@ -257,11 +258,20 @@ void render_to_cairo(struct menu_state *state, cairo_t *cairo) {
	cairo_rectangle(cairo, x, 0, 300, state->height);
	cairo_fill(cairo);

	if (state->passwd) {
		if (!(censort = calloc(1, sizeof(state->text))))
			return;
		memset(censort, '*', strlen(state->text));
	}

	// Draw input
	render_text(state, cairo, state->text,
	render_text(state, cairo, state->passwd ? censort : state->text,
			x, 0, state->width, state->line_height,
			state->foreground, 0, padding, padding);

	if (censort)
		free(censort);

	// Draw cursor
	{
		int cursor_width = 2;
@@ -951,6 +961,11 @@ void read_stdin(struct menu_state *state) {
	char buf[sizeof state->text], *p;
	struct menu_item *item, **end;

	if (state->passwd) {
		state->inputw = state->lines = 0;
		return;
	}

	for(end = &state->items; fgets(buf, sizeof buf, stdin); *end = item, end = &item->next) {
		if((p = strchr(buf, '\n'))) {
			*p = '\0';
@@ -1081,12 +1096,15 @@ int main(int argc, char **argv) {
	};

	const char *usage =
		"Usage: wmenu [-biv] [-f font] [-l lines] [-o output] [-p prompt]\n"
		"Usage: wmenu [-Pbiv] [-f font] [-l lines] [-o output] [-p prompt]\n"
		"\t[-N color] [-n color] [-M color] [-m color] [-S color] [-s color]\n";

	int opt;
	while ((opt = getopt(argc, argv, "bhivf:l:o:p:N:n:M:m:S:s:")) != -1) {
	while ((opt = getopt(argc, argv, "Pbhivf:l:o:p:N:n:M:m:S:s:")) != -1) {
		switch (opt) {
		case 'P':
			state.passwd = true;
			break;
		case 'b':
			state.bottom = true;
			break;
-- 
2.43.2
Details
Message ID
<CZJ9CXM6KO65.1791VWRLAPUKT@maolood.com>
In-Reply-To
<20240226170900.9531-1-sewn@disroot.org> (view parent)
DKIM signature
pass
Download raw message
Hi, thanks for the patch!

The goal of wmenu is to have feature-parity with dmenu. I'm not really
interested in adding features that aren't present in dmenu at the moment, but I
might make an exception if this feature is popular enough.
Details
Message ID
<9d40def38b37a1f77655b7f5d36e5ee1@disroot.org>
In-Reply-To
<CZJ9CXM6KO65.1791VWRLAPUKT@maolood.com> (view parent)
DKIM signature
pass
Download raw message
On 2024-03-02 13:20, Adnan Maolood wrote:

> Hi, thanks for the patch!
> 
> The goal of wmenu is to have feature-parity with dmenu. I'm not really
> interested in adding features that aren't present in dmenu at the 
> moment, but I
> might make an exception if this feature is popular enough.

I suggest having a place for patches, such as a mailing list in the 
wmenu project
dedicated to patches.
Details
Message ID
<CZQ1DEWQ6ZK0.2Y68U1S6FXRUC@maolood.com>
In-Reply-To
<9d40def38b37a1f77655b7f5d36e5ee1@disroot.org> (view parent)
DKIM signature
pass
Download raw message
I've decided I'm willing to add this feature. Could you rebase this patch off of
the latest changes and resend it?
Reply to thread Export thread (mbox)