~mil/sxmo-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
6 3

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

Details
Message ID
<20200920091432.25946-1-galen@galenabell.com>
DKIM signature
pass
Download raw message
Patch: +19 -7
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
Details
Message ID
<CAMQv9hA_k=sUV=ems9GL7i9JT53syBM2f_eurB08kP5ruT+KUg@mail.gmail.com>
In-Reply-To
<20200920091432.25946-1-galen@galenabell.com> (view parent)
DKIM signature
pass
Download raw message
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:
>
> 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
Details
Message ID
<C5S60KPC38TQ.U47C5BABHYDT@freya>
In-Reply-To
<CAMQv9hA_k=sUV=ems9GL7i9JT53syBM2f_eurB08kP5ruT+KUg@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
> It would be good to make this optional. I rely on the fact that it
> does not wrap around.

Good call; just sent an updated patch that only enables this behavior if
the DMENU_WRAP_AROUND environment variable is set.
Details
Message ID
<20201031204255.w5hcmpii2i6ojrpi@worker.anaproy.lxd>
In-Reply-To
<C5S60KPC38TQ.U47C5BABHYDT@freya> (view parent)
DKIM signature
missing
Download raw message
On 20-09-20 01:38, Galen Abell wrote:
> > It would be good to make this optional. I rely on the fact that it
> > does not wrap around.
>
> Good call; just sent an updated patch that only enables this behavior if
> the DMENU_WRAP_AROUND environment variable is set.

Thanks for your patch! I have now applied it, could you perhaps submit a
small patch for the documentation that documents this feature?

--

Maarten van Gompel (proycon)
https://proycon.anaproy.nl
Details
Message ID
<20201102121055.pz3d2uh4eugf5prs@worker.anaproy.lxd>
In-Reply-To
<20201031204255.w5hcmpii2i6ojrpi@worker.anaproy.lxd> (view parent)
DKIM signature
missing
Download raw message
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
Details
Message ID
<C6SS5G0BBCUJ.2UNM7EB1C1JN4@asgard>
In-Reply-To
<20201102121055.pz3d2uh4eugf5prs@worker.anaproy.lxd> (view parent)
DKIM signature
pass
Download raw message
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.
Details
Message ID
<20201102124846.cyeojngf72aabh7t@worker.anaproy.lxd>
In-Reply-To
<C6SS5G0BBCUJ.2UNM7EB1C1JN4@asgard> (view parent)
DKIM signature
missing
Download raw message
On 20-11-02 01:34, Galen Abell wrote:
> 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.

Ok, I'll do that for now!

--

Maarten van Gompel (proycon)
https://proycon.anaproy.nl
Reply to thread Export thread (mbox)