9front - general discussion about 9front
 help / color / mirror / Atom feed
From: phil9 <telephil9@gmail.com>
To: 9front@9front.org
Subject: [9front] [PATCH] mothra: enable mousewheel scrolling in history list
Date: Wed, 06 Apr 2022 15:29:41 +0000	[thread overview]
Message-ID: <B664690B3FFA14B609E61DF902AF0BC5@gmail.com> (raw)


	In the history list, scrolling was only possible using the scrollbar
	but not the mousewheel like in the text panel.
---
diff 909205036de4762628fdcdd295e209309817a604 887366a22c1bc50c238668af61664112259a4365
--- a/sys/src/cmd/mothra/mothra.c	Tue Apr  5 01:09:49 2022
+++ b/sys/src/cmd/mothra/mothra.c	Wed Apr  6 17:29:41 2022
@@ -140,11 +140,11 @@
 	return 0;
 }
 
-void scrolltext(int dy, int whence)
+void scrollpanel(Panel *p, int dy, int whence)
 {
 	Scroll s;
 
-	s = plgetscroll(text);
+	s = plgetscroll(p);
 	switch(whence){
 	case 0:
 		s.pos.y = dy;
@@ -160,7 +160,7 @@
 		s.pos.y = s.size.y;
 	if(s.pos.y < 0)
 		s.pos.y = 0;
-	plsetscroll(text, s);
+	plsetscroll(p, s);
 }
 
 void sidescroll(int dx, int whence)
@@ -404,22 +404,22 @@
 				plkeyboard(e.kbdc);
 				break;
 			case Khome:
-				scrolltext(0, 0);
+				scrollpanel(text, 0, 0);
 				break;
 			case Kup:
-				scrolltext(-text->size.y/4, 1);
+				scrollpanel(text, -text->size.y/4, 1);
 				break;
 			case Kpgup:
-				scrolltext(-text->size.y/2, 1);
+				scrollpanel(text, -text->size.y/2, 1);
 				break;
 			case Kdown:
-				scrolltext(text->size.y/4, 1);
+				scrollpanel(text, text->size.y/4, 1);
 				break;
 			case Kpgdown:
-				scrolltext(text->size.y/2, 1);
+				scrollpanel(text, text->size.y/2, 1);
 				break;
 			case Kend:
-				scrolltext(-text->size.y, 2);
+				scrollpanel(text, -text->size.y, 2);
 				break;
 			case Kack:
 				search();
@@ -438,11 +438,18 @@
 			break;
 		case Emouse:
 			mouse=e.mouse;
+			if(mouse.buttons & (8|16) && ptinrect(mouse.xy, list->r) && defdisplay){
+				if(mouse.buttons & 8)
+					scrollpanel(list, list->r.min.y - mouse.xy.y, 1);
+				else
+					scrollpanel(list, mouse.xy.y - list->r.min.y, 1);
+				break;
+			}
 			if(mouse.buttons & (8|16) && ptinrect(mouse.xy, text->r)){
 				if(mouse.buttons & 8)
-					scrolltext(text->r.min.y - mouse.xy.y, 1);
+					scrollpanel(text, text->r.min.y - mouse.xy.y, 1);
 				else
-					scrolltext(mouse.xy.y - text->r.min.y, 1);
+					scrollpanel(text, mouse.xy.y - text->r.min.y, 1);
 				break;
 			}
 			plmouse(root, &mouse);

                 reply	other threads:[~2022-04-06 17:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=B664690B3FFA14B609E61DF902AF0BC5@gmail.com \
    --to=telephil9@gmail.com \
    --cc=9front@9front.org \
    --subject='Re: [9front] [PATCH] mothra: enable mousewheel scrolling in history list' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).