Wheel scrolling

This commit is contained in:
Krzosa Karol
2026-01-01 13:48:21 +01:00
parent c4b4460cbd
commit 6cf9731959
3 changed files with 22 additions and 1 deletions

View File

@@ -2,7 +2,6 @@
! From a user (novice) point of view, how does it look like? ! From a user (novice) point of view, how does it look like?
- Make a fuzzy command !> grep and fuzzy over it??? (doesn't seem very useful for grep) - Make a fuzzy command !> grep and fuzzy over it??? (doesn't seem very useful for grep)
- Maybe wheel click should scroll??? PROBABLY
- Make all the keybinding / hook parsing initialize at the start to reduce runtime problems - Make all the keybinding / hook parsing initialize at the start to reduce runtime problems
- RegisterCommand should_appear_in_listing variable - RegisterCommand should_appear_in_listing variable

View File

@@ -44,6 +44,7 @@ WindowID DocumentSelected = {-1};
WindowID ResizerSelected = {-1}; WindowID ResizerSelected = {-1};
WindowID ResizerHover = {-1}; WindowID ResizerHover = {-1};
Caret DocumentAnchor; Caret DocumentAnchor;
Vec2I MouseMiddleAnchor;
Buffer *GCInfoBuffer; Buffer *GCInfoBuffer;
Buffer *EventBuffer; Buffer *EventBuffer;

View File

@@ -58,6 +58,8 @@ void SetMouseCursor(SDL_SystemCursor id) {
JS_SetMouseCursor("default"); JS_SetMouseCursor("default");
} else if (id == SDL_SYSTEM_CURSOR_TEXT) { } else if (id == SDL_SYSTEM_CURSOR_TEXT) {
JS_SetMouseCursor("text"); JS_SetMouseCursor("text");
} else if (id == SDL_SYSTEM_CURSOR_MOVE) {
JS_SetMouseCursor("all-scroll");
} else { } else {
InvalidCodepath(); InvalidCodepath();
} }
@@ -104,6 +106,11 @@ void SetMouseCursor(Event event) {
return; return;
} }
if (MouseMiddleAnchor.x != 0 && MouseMiddleAnchor.y != 0) {
SetMouseCursor(SDL_SYSTEM_CURSOR_MOVE);
return;
}
For(order) { For(order) {
if (!it->visible) continue; if (!it->visible) continue;
bool mouse_in_total = AreOverlapping(mouse, it->total_rect); bool mouse_in_total = AreOverlapping(mouse, it->total_rect);
@@ -315,6 +322,20 @@ void OnCommand(Event event) {
MouseLoadWord(event); MouseLoadWord(event);
} }
{
Vec2I mouse = MouseVec2I();
if (Mouse(MIDDLE)) {
MouseMiddleAnchor = mouse;
} else if (Mouse(MIDDLE_UP)) {
MouseMiddleAnchor = {0, 0};
}
if (MouseMiddleAnchor.x != 0) {
BSet active = GetBSet(ActiveWindowID);
active.view->scroll += mouse - MouseMiddleAnchor;
}
}
if (Ctrl() && Mouse(LEFT)) { if (Ctrl() && Mouse(LEFT)) {
MouseLoadWord(event); MouseLoadWord(event);
} else if (Mouse(LEFT)) { // Uses Alt and shift } else if (Mouse(LEFT)) { // Uses Alt and shift