~mil/sxmo-devel

sxmo-dmenu: Add wrap around to top/bottom of list v1 SUPERSEDED

Galen Abell: 1
 Add wrap around to top/bottom of list

 1 files changed, 19 insertions(+), 7 deletions(-)
I noticed a problem with this patch, it has been applied but I might have to revert it again
(unless we can find a quick fix): When having long list in dmenu that
doesn't fit in one 'view', we could simply scroll down through the list and the view would update when reaching
the bottom items that were initially out of view. Now with this patch (and NOT
having DMENU_WRAP_AROUND set), the cursor dissappears 'out of view', so
you can't see what you select anymore.

Thanks for the documentation patch btw, I'll leave that one open pending
this issue though. If you happen to know of a quick fix, just send a
patch on top the new HEAD. I changed this patch's status to "Needs
revision" for now.

--

Maarten van Gompel (proycon)
https://proycon.anaproy.nl
Hmm, good catch. I'm not sure off the top of my head why that's
happening, so might be best to revert the original patch until I can
debug it and send a fix.

Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~mil/sxmo-devel/patches/13977/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH sxmo-dmenu] Add wrap around to top/bottom of list Export this patch

When paging up on the first item or down on the last item, the selection
will jump to the bottom or top item, respectively.
---
 dmenu.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/dmenu.c b/dmenu.c
index aaf4e5d..4b3139b 100644
--- a/dmenu.c
+++ b/dmenu.c
@@ -537,11 +537,21 @@ insert:
		if (lines > 0)
			return;
		/* fallthrough */
  case XF86XK_AudioRaiseVolume:
	case XF86XK_AudioRaiseVolume:
	case XK_Up:
		if (sel && sel->left && (sel = sel->left)->right == curr) {
		if (sel && sel->left) {
			sel = sel->left;
			curr = prev;
			calcoffsets();
		} else {
			// if there is no previous item, jump to the bottom of the list
			curr = matchend;
			calcoffsets();
			curr = prev;
			calcoffsets();
			while (next && (curr = curr->right))
				calcoffsets();
			sel = matchend;
		}
		break;
	case XK_Next:
@@ -578,12 +588,14 @@ insert:
		if (lines > 0)
			return;
		/* fallthrough */
  case XF86XK_AudioLowerVolume:
	case XF86XK_AudioLowerVolume:
	case XK_Down:
		if (sel && sel->right && (sel = sel->right) == next) {
			curr = next;
			calcoffsets();
		}
		if (sel && sel->right)
			sel = sel->right;
		else
			// if there is no next item, jump to the top of the list
			sel = curr = matches;
		calcoffsets();
		break;
	case XK_Tab:
		if (!sel)
-- 
2.28.0
shaun
It would be good to make this optional.  I rely on the fact that it
does not wrap around.

--
Shaun

On Sun, Sep 20, 2020 at 2:14 AM Galen Abell <galen@galenabell.com> wrote: