commit 99dab1dc213266a9b6275090346512830fa064a7
parent e6856f5fd36e0b240ec6773093ca363fe25e4506
Author: Michael Hendricks <michael@ndrix.org>
Date: Mon, 4 Apr 2022 09:56:05 -0600
[tabbed][patch][move-clamped] accept out-of-bounds tab numbers
Diffstat:
2 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/tools.suckless.org/tabbed/patches/move-clamped/index.md b/tools.suckless.org/tabbed/patches/move-clamped/index.md
@@ -0,0 +1,13 @@
+Clamped move
+=============
+With this patch, tabbed interprets large position numbers as the
+largest known position. This allows `Ctrl-9`, for example, to always
+select the rightmost tab, even if there are only 4 tabs.
+
+Download
+--------
+* [tabbed-move-clamped-20200404-e2ca5f9.diff](tabbed-move-clamped-20200404-e2ca5f9.diff)
+
+Author
+------
+* Michael Hendricks <michael@ndrix.org>
diff --git a/tools.suckless.org/tabbed/patches/move-clamped/tabbed-move-clamped-20200404-e2ca5f9.diff b/tools.suckless.org/tabbed/patches/move-clamped/tabbed-move-clamped-20200404-e2ca5f9.diff
@@ -0,0 +1,19 @@
+diff --git a/tabbed.c b/tabbed.c
+index eafe28a..e2ca5f9 100644
+--- a/tabbed.c
++++ b/tabbed.c
+@@ -787,8 +787,12 @@ maprequest(const XEvent *e)
+ void
+ move(const Arg *arg)
+ {
+- if (arg->i >= 0 && arg->i < nclients)
+- focus(arg->i);
++ int i;
++
++ i = arg->i < nclients ? arg->i : nclients - 1;
++
++ if (i >= 0)
++ focus(i);
+ }
+
+ void