~rabbits/public-inbox

left: scroll: Don't allow scrolling too far v1 APPLIED

Zach DeCook: 2
 scroll: Don't allow scrolling too far
 Mouse Wheel: enable scrolling and move cursor with CTRL+Scroll

 2 files changed, 14 insertions(+), 0 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~rabbits/public-inbox/patches/16432/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH left] scroll: Don't allow scrolling too far Export this patch

---
 left.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/left.c b/left.c
index 8de7130..87e1d44 100644
--- a/left.c
+++ b/left.c
@@ -325,6 +325,7 @@ error(char *msg, const char *err)
void
setscroll(int v)
{
	v = clamp(v, 0, getrow(doc.len) - VER);
	if(v >= 0) {
		sel.scroll = v;
		redraw(pixels);
-- 
2.29.2

[PATCH left] Mouse Wheel: enable scrolling and move cursor with CTRL+Scroll Export this patch

---
 left.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/left.c b/left.c
index 87e1d44..781122f 100644
--- a/left.c
+++ b/left.c
@@ -510,6 +510,18 @@ domouse(SDL_Event *event)
	}
}

void
dowheel(SDL_Event *event)
{
	int ctrl = SDL_GetModState() & (KMOD_LCTRL | KMOD_RCTRL);
	if(ctrl)
		setselection(getcell(
			getcol(sel.from),getrow(sel.from)-event->wheel.y
		), -1);
	else
		setscroll(sel.scroll - event->wheel.y);
}

void
dokey(SDL_Event *event)
{
@@ -632,6 +644,7 @@ main(int argc, char *argv[])
			case SDL_MOUSEBUTTONUP:
			case SDL_MOUSEBUTTONDOWN:
			case SDL_MOUSEMOTION: domouse(&event); break;
			case SDL_MOUSEWHEEL: dowheel(&event); break;
			case SDL_TEXTINPUT: dotext(&event); break;
			case SDL_KEYDOWN: dokey(&event); break;
			case SDL_WINDOWEVENT:
-- 
2.29.2