st-universcroll-0.8.4.diff 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. From 9726b1e58352126252412e101432e64d46fc51ca Mon Sep 17 00:00:00 2001
  2. From: Dennis Lee <dennis@dennislee.xyz>
  3. Date: Sun, 28 Jun 2020 23:01:03 -0700
  4. Subject: [PATCH] universcroll: mouse wheel only scroll in all modes
  5. Scroll normally via scroll(1), without Shift, when outside of
  6. `MODE_ALTSCREEN`. Inside an alt screen, continue to scroll normally
  7. without Shift; in this mode, your scrolling is automatically translated
  8. into ^Y and ^E. It just werks!
  9. Based on the existing mouse-altscreen patch
  10. https://st.suckless.org/patches/scrollback/
  11. adapted for st(1) 0.8.4 and scroll(1).
  12. ---
  13. config.def.h | 10 +++++-----
  14. st.c | 5 +++++
  15. st.h | 1 +
  16. x.c | 2 ++
  17. 4 files changed, 13 insertions(+), 5 deletions(-)
  18. diff --git a/config.def.h b/config.def.h
  19. index 6f05dce..62e87da 100644
  20. --- a/config.def.h
  21. +++ b/config.def.h
  22. @@ -173,11 +173,11 @@ static uint forcemousemod = ShiftMask;
  23. * Beware that overloading Button1 will disable the selection.
  24. */
  25. static MouseShortcut mshortcuts[] = {
  26. - /* mask button function argument release */
  27. - { XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
  28. - { ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} },
  29. + /* mask button function argument release alt */
  30. + { XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
  31. + { XK_ANY_MOD, Button4, ttysend, {.s = "\033[5;2~"}, 0, -1 },
  32. { XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
  33. - { ShiftMask, Button5, ttysend, {.s = "\033[6;2~"} },
  34. + { XK_ANY_MOD, Button5, ttysend, {.s = "\033[6;2~"}, 0, -1 },
  35. { XK_ANY_MOD, Button5, ttysend, {.s = "\005"} },
  36. };
  37. diff --git a/st.c b/st.c
  38. index 76b7e0d..1f65453 100644
  39. --- a/st.c
  40. +++ b/st.c
  41. @@ -1047,6 +1047,11 @@ tnew(int col, int row)
  42. treset();
  43. }
  44. +int tisaltscr(void)
  45. +{
  46. + return IS_SET(MODE_ALTSCREEN);
  47. +}
  48. +
  49. void
  50. tswapscreen(void)
  51. {
  52. diff --git a/st.h b/st.h
  53. index 3d351b6..39cc054 100644
  54. --- a/st.h
  55. +++ b/st.h
  56. @@ -87,6 +87,7 @@ void sendbreak(const Arg *);
  57. void toggleprinter(const Arg *);
  58. int tattrset(int);
  59. +int tisaltscr(void);
  60. void tnew(int, int);
  61. void tresize(int, int);
  62. void tsetdirtattr(int);
  63. diff --git a/x.c b/x.c
  64. index 210f184..210dde9 100644
  65. --- a/x.c
  66. +++ b/x.c
  67. @@ -34,6 +34,7 @@ typedef struct {
  68. void (*func)(const Arg *);
  69. const Arg arg;
  70. uint release;
  71. + int altscrn; /* 0: don't care, -1: not alt screen, 1: alt screen */
  72. } MouseShortcut;
  73. typedef struct {
  74. @@ -446,6 +447,7 @@ mouseaction(XEvent *e, uint release)
  75. for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) {
  76. if (ms->release == release &&
  77. ms->button == e->xbutton.button &&
  78. + (!ms->altscrn || (ms->altscrn == (tisaltscr() ? 1 : -1))) &&
  79. (match(ms->mod, state) || /* exact or forced */
  80. match(ms->mod, state & ~forcemousemod))) {
  81. ms->func(&(ms->arg));
  82. --
  83. 2.27.0