sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit bcddb0aa6d004844e07af8ae46efce41d4d4a039
parent 4040b2acf37b6fe4a7e87193df71a5911a433e5d
Author: efe <efe@efe.kim>
Date:   Thu, 23 Aug 2018 13:09:56 -0400

dmenu patch «print input text»

Just a simple dmenu patch and the corresponding wiki page for it.
It basically swaps Return and Shift+Return functions. I use it
for surf's url bar.

 Commiter: efe <efe@efe.kim>

 Changes to be committed:
	new file:   dmenu-printinputtext-20190822-bbc464d.diff
	new file:   printinputtext.md

Diffstat:
Atools.suckless.org/dmenu/patches/dmenu-printinputtext-20190822-bbc464d.diff | 87+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Atools.suckless.org/dmenu/patches/printinputtext.md | 29+++++++++++++++++++++++++++++
2 files changed, 116 insertions(+), 0 deletions(-)

diff --git a/tools.suckless.org/dmenu/patches/dmenu-printinputtext-20190822-bbc464d.diff b/tools.suckless.org/dmenu/patches/dmenu-printinputtext-20190822-bbc464d.diff @@ -0,0 +1,87 @@ +From fb5db7880838c7691fb789b7f204906a1539e833 Mon Sep 17 00:00:00 2001 +From: efe <efe@efe.kim> +Date: Wed, 22 Aug 2018 20:22:04 -0400 +Subject: [PATCH] print input text patch for dmenu + +--- + dmenu.1 | 8 ++++++-- + dmenu.c | 10 ++++++++-- + 2 files changed, 14 insertions(+), 4 deletions(-) + +diff --git a/dmenu.1 b/dmenu.1 +index c065087..8d6f155 100644 +--- a/dmenu.1 ++++ b/dmenu.1 +@@ -3,7 +3,7 @@ + dmenu \- dynamic menu + .SH SYNOPSIS + .B dmenu +-.RB [ \-bfiv ] ++.RB [ \-bfitv ] + .RB [ \-l + .IR lines ] + .RB [ \-m +@@ -75,6 +75,9 @@ defines the selected background color. + .BI \-sf " color" + defines the selected foreground color. + .TP ++.B \-t ++Return key prints input text instead of selection. ++.TP + .B \-v + prints version information to stdout, then exits. + .TP +@@ -89,13 +92,14 @@ Copy the selected item to the input field. + .TP + .B Return + Confirm selection. Prints the selected item to stdout and exits, returning +-success. ++success. If \-t option is given it confirms input instead of selection. + .TP + .B Ctrl-Return + Confirm selection. Prints the selected item to stdout and continues. + .TP + .B Shift\-Return + Confirm input. Prints the input text to stdout and exits, returning success. ++If \-t option is given it confirms selection instead of input. + .TP + .B Escape + Exit without selecting an item, returning failure. +diff --git a/dmenu.c b/dmenu.c +index 5c835dd..9abb7ce 100644 +--- a/dmenu.c ++++ b/dmenu.c +@@ -46,6 +46,7 @@ static struct item *items = NULL; + static struct item *matches, *matchend; + static struct item *prev, *curr, *next, *sel; + static int mon = -1, screen; ++static int use_text_input = 0; + + static Atom clip, utf8; + static Display *dpy; +@@ -466,7 +467,10 @@ insert: + break; + case XK_Return: + case XK_KP_Enter: +- puts((sel && !(ev->state & ShiftMask)) ? sel->text : text); ++ if (use_text_input) ++ puts((sel && (ev->state & ShiftMask)) ? sel->text : text); ++ else ++ puts((sel && !(ev->state & ShiftMask)) ? sel->text : text); + if (!(ev->state & ControlMask)) { + cleanup(); + exit(0); +@@ -707,7 +711,9 @@ main(int argc, char *argv[]) + else if (!strcmp(argv[i], "-i")) { /* case-insensitive item matching */ + fstrncmp = strncasecmp; + fstrstr = cistrstr; +- } else if (i + 1 == argc) ++ } else if (!strcmp(argv[i], "-t")) /* favors text input over selection */ ++ use_text_input = 1; ++ else if (i + 1 == argc) + usage(); + /* these options take one argument */ + else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */ +-- +2.11.0 + diff --git a/tools.suckless.org/dmenu/patches/printinputtext.md b/tools.suckless.org/dmenu/patches/printinputtext.md @@ -0,0 +1,29 @@ +print input text +================ + +Description +----------- + +This patch adds a flag (`-t`) which makes Return key to ignore selection +and print the input text to stdout. The flag basically swaps the functions +of Return and Shift+Return hotkeys. + +The default behaviour of dmenu makes sense when selecting from given options +(i.e. as a program launcher) but it is annoying when you might be entering +text that is different than the given options (i.e. as surf's url bar). + +Usage in Surf +------------- + +Just add the `-t` flag to the dmenu in the SETPROP function of surf's +config.def.h. Now the url bar should behave just like in all other browsers. + +Download +-------- + +* [dmenu-printinputtext-20190822-bbc464d.diff](dmenu-printinputtext-20190822-bbc464d.diff) + +Author +------ + +* efe - efe@efe.kim