st-scrollback-mouse-altscreen-20220127-2c5edf2.diff 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. From 580e3f386e9215707100e9ba44797701943fd927 Mon Sep 17 00:00:00 2001
  2. From: asparagii <michele.lambertucci1@gmail.com>
  3. Date: Thu, 27 Jan 2022 15:49:27 +0100
  4. Subject: [PATCH] st-scrollback-mouse-altscreen
  5. ---
  6. config.def.h | 4 ++--
  7. st.c | 5 +++++
  8. st.h | 1 +
  9. x.c | 2 ++
  10. 4 files changed, 10 insertions(+), 2 deletions(-)
  11. diff --git a/config.def.h b/config.def.h
  12. index c217315..c223706 100644
  13. --- a/config.def.h
  14. +++ b/config.def.h
  15. @@ -176,8 +176,8 @@ static uint forcemousemod = ShiftMask;
  16. */
  17. static MouseShortcut mshortcuts[] = {
  18. /* mask button function argument release */
  19. - { ShiftMask, Button4, kscrollup, {.i = 1} },
  20. - { ShiftMask, Button5, kscrolldown, {.i = 1} },
  21. + { XK_ANY_MOD, Button4, kscrollup, {.i = 1}, 0, /* !alt */ -1 },
  22. + { XK_ANY_MOD, Button5, kscrolldown, {.i = 1}, 0, /* !alt */ -1 },
  23. { XK_ANY_MOD, Button2, selpaste, {.i = 0}, 1 },
  24. { ShiftMask, Button4, ttysend, {.s = "\033[5;2~"} },
  25. { XK_ANY_MOD, Button4, ttysend, {.s = "\031"} },
  26. diff --git a/st.c b/st.c
  27. index f3af82b..876a6bf 100644
  28. --- a/st.c
  29. +++ b/st.c
  30. @@ -1060,6 +1060,11 @@ tnew(int col, int row)
  31. treset();
  32. }
  33. +int tisaltscr(void)
  34. +{
  35. + return IS_SET(MODE_ALTSCREEN);
  36. +}
  37. +
  38. void
  39. tswapscreen(void)
  40. {
  41. diff --git a/st.h b/st.h
  42. index da36b34..e95c6f8 100644
  43. --- a/st.h
  44. +++ b/st.h
  45. @@ -89,6 +89,7 @@ void sendbreak(const Arg *);
  46. void toggleprinter(const Arg *);
  47. int tattrset(int);
  48. +int tisaltscr(void);
  49. void tnew(int, int);
  50. void tresize(int, int);
  51. void tsetdirtattr(int);
  52. diff --git a/x.c b/x.c
  53. index cd96575..9274556 100644
  54. --- a/x.c
  55. +++ b/x.c
  56. @@ -34,6 +34,7 @@ typedef struct {
  57. void (*func)(const Arg *);
  58. const Arg arg;
  59. uint release;
  60. + int altscrn; /* 0: don't care, -1: not alt screen, 1: alt screen */
  61. } MouseShortcut;
  62. typedef struct {
  63. @@ -455,6 +456,7 @@ mouseaction(XEvent *e, uint release)
  64. for (ms = mshortcuts; ms < mshortcuts + LEN(mshortcuts); ms++) {
  65. if (ms->release == release &&
  66. ms->button == e->xbutton.button &&
  67. + (!ms->altscrn || (ms->altscrn == (tisaltscr() ? 1 : -1))) &&
  68. (match(ms->mod, state) || /* exact or forced */
  69. match(ms->mod, state & ~forcemousemod))) {
  70. ms->func(&(ms->arg));
  71. --
  72. 2.34.1