diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-04-20 22:57:32 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-05-02 16:17:49 +0530 |
| commit | 3f5325f59ba7f8552d093fdafd9674b713f3cad9 (patch) | |
| tree | 481c26e17714fd673c024aba3c3514586f0fe3bb /src/LuaRuntimeApi.hpp | |
| parent | 1dd6332756b38bf4bbffeef9db6599320c03ca9a (diff) | |
| download | null-browser-3f5325f59ba7f8552d093fdafd9674b713f3cad9.tar.gz null-browser-3f5325f59ba7f8552d093fdafd9674b713f3cad9.zip | |
Add scrolling controls
Diffstat (limited to 'src/LuaRuntimeApi.hpp')
| -rw-r--r-- | src/LuaRuntimeApi.hpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/LuaRuntimeApi.hpp b/src/LuaRuntimeApi.hpp index 4767134..9994491 100644 --- a/src/LuaRuntimeApi.hpp +++ b/src/LuaRuntimeApi.hpp @@ -238,6 +238,32 @@ int lua_api_keymap_set_mode(lua_State *state) { return 1; } +int lua_api_view_scroll(lua_State *state) { + long deltax = lua_tointeger(state, 1); + long deltay = lua_tointeger(state, 2); + WebViewId view_id = lua_isnoneornil(state, 1) ? 0 : lua_tointeger(state, 1); + auto &runtime = LuaRuntime::instance(); + emit runtime.webview_scroll_requested(view_id, (int)deltax, (int)deltay); + + lua_pushnil(state); + return 1; +} + +int lua_api_view_scroll_top(lua_State *state) { + WebViewId view_id = lua_isnoneornil(state, 1) ? 0 : lua_tointeger(state, 1); + auto &runtime = LuaRuntime::instance(); + emit runtime.webview_scroll_top_requested(view_id); + lua_pushnil(state); + return 1; +} +int lua_api_view_scroll_bottom(lua_State *state) { + WebViewId view_id = lua_isnoneornil(state, 1) ? 0 : lua_tointeger(state, 1); + auto &runtime = LuaRuntime::instance(); + emit runtime.webview_scroll_bottom_requested(view_id); + lua_pushnil(state); + return 1; +} + // NOLINTNEXTLINE static luaL_Reg internals_api[] = { luaL_Reg{"event_add_listener", &lua_event_register}, @@ -253,6 +279,9 @@ static luaL_Reg internals_api[] = { luaL_Reg{"view_select", &lua_view_select}, luaL_Reg{"view_set_url", &lua_api_view_set_url}, luaL_Reg{"view_open_devtools", &lua_api_view_open_devtools}, + luaL_Reg{"view_scroll", &lua_api_view_scroll}, + luaL_Reg{"view_scroll_to_top", &lua_api_view_scroll_top}, + luaL_Reg{"view_scroll_to_bottom", &lua_api_view_scroll_bottom}, luaL_Reg{"history_back", &lua_history_back}, luaL_Reg{"history_forward", &lua_history_forward}, luaL_Reg{"search_get_text", &lua_api_search_get_text}, |
