Add xwheel

This commit is contained in:
Krzosa Karol
2024-07-28 14:49:46 +02:00
parent 01a0d5f05f
commit 978d2d603a
4 changed files with 20 additions and 6 deletions

View File

@@ -26,7 +26,7 @@ struct Event {
};
uint8_t mouse;
uint8_t mouse_double_click;
float wheel;
Vec2 wheel;
const char *text;
};
@@ -269,7 +269,7 @@ bool GlobalCommand(Event event) {
}
}
if (event.wheel) {
if (event.wheel.x || event.wheel.y) {
Scratch scratch;
Array<Int> order = GetWindowZOrder(scratch);
Vec2I mouse = MouseVec2I();
@@ -281,7 +281,8 @@ bool GlobalCommand(Event event) {
bool mouse_in_window = CheckCollisionPointRec(mouse, window->total_rect);
if (mouse_in_window) {
View *view = GetView(window->active_view);
view->scroll.y -= (Int)(event.wheel * 48);
view->scroll.y -= (Int)(event.wheel.y * 48);
view->scroll.x += (Int)(event.wheel.x * 48);
break;
}
}

View File

@@ -42,7 +42,7 @@ int LuaOpen(lua_State *L) {
return 0;
}
if (FieldString(L, "kind") == "open_textfile") {
if (FieldString(L, "kind") == "text") {
String file_path = FieldString(L, "file_path");
String line_string = FieldString(L, "line");
Int line = strtoll(line_string.data, NULL, 10);

View File

@@ -95,7 +95,7 @@ void ProcessSDLEvent(SDL_Event *input_event) {
SDL_MouseWheelEvent &b = input_event->wheel;
event.xmouse = (int16_t)b.mouse_x;
event.ymouse = (int16_t)b.mouse_y;
event.wheel = b.y;
event.wheel = {b.x, b.y};
} break;
default: return;
}

View File

@@ -1,6 +1,5 @@
- Save file (utf16->utf8)
- make sure we only save file buffers
- Move open fully to config so that user can easily modify the plumbing
- resize windows
- color the line number with line highlight
- page up and down should also scroll and leave you in exactly same scroll
@@ -19,3 +18,17 @@
- Search all buffers
- Search and replace
- Search result buffer
- Move open fully to config so that user can easily modify the plumbing
function Open(s)
o = ApplyRules(s)
if o.kind == "text" then
open_buffer(o.file_path, o.line, o.col)
elseif o.kind == "url" then
open_web(o.url)
end
end