diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-04-19 17:56:03 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-04-19 17:56:03 +0530 |
| commit | 0e95e99e72237058465959d55b77750a9d7c1bef (patch) | |
| tree | 5b99cd64f7c49b949a6381c4654ec253822934b5 /src/LuaRuntimeApi.hpp | |
| parent | 7a458b424c2c1a6ed251211b25261acffef59b7f (diff) | |
| download | null-browser-0e95e99e72237058465959d55b77750a9d7c1bef.tar.gz null-browser-0e95e99e72237058465959d55b77750a9d7c1bef.zip | |
Add web.search and search text implemnetation
Diffstat (limited to 'src/LuaRuntimeApi.hpp')
| -rw-r--r-- | src/LuaRuntimeApi.hpp | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/LuaRuntimeApi.hpp b/src/LuaRuntimeApi.hpp index 809b579..b6302ff 100644 --- a/src/LuaRuntimeApi.hpp +++ b/src/LuaRuntimeApi.hpp @@ -5,7 +5,7 @@ #include "LuaRuntime.hpp" #include "WindowActionRouter.hpp" -int lua_api_open_url(lua_State *state) { +int lua_api_view_set_url(lua_State *state) { const char *url = lua_tostring(state, 1); WebViewId view_id = lua_isnoneornil(state, 2) ? 0 : lua_tointeger(state, 2); auto &runtime = LuaRuntime::instance(); @@ -187,6 +187,28 @@ int lua_event_register(lua_State *state) { return 1; } +int lua_api_search_set_text(lua_State *state) { + const char *text = lua_tostring(state, 1); + WebViewId view_id = lua_isnoneornil(state, 1) ? 0 : lua_tointeger(state, 1); + auto &runtime = LuaRuntime::instance(); + emit runtime.search_requested(text, view_id); + return 1; +} + +int lua_api_search_next(lua_State *state) { + WebViewId view_id = lua_isnoneornil(state, 1) ? 0 : lua_tointeger(state, 1); + auto &runtime = LuaRuntime::instance(); + emit runtime.search_next_requested(view_id); + return 1; +} + +int lua_api_search_previous(lua_State *state) { + WebViewId view_id = lua_isnoneornil(state, 1) ? 0 : lua_tointeger(state, 1); + auto &runtime = LuaRuntime::instance(); + emit runtime.search_previous_requested(view_id); + return 1; +} + // NOLINTNEXTLINE static luaL_Reg internals_api[] = { luaL_Reg{"event_add_listener", &lua_event_register}, @@ -198,8 +220,11 @@ static luaL_Reg internals_api[] = { luaL_Reg{"view_current", &lua_api_view_current}, luaL_Reg{"view_list", &lua_view_list}, luaL_Reg{"view_select", &lua_view_select}, - luaL_Reg{"view_set_url", &lua_api_open_url}, + luaL_Reg{"view_set_url", &lua_api_view_set_url}, luaL_Reg{"history_back", &lua_history_back}, luaL_Reg{"history_forward", &lua_history_forward}, + luaL_Reg{"search_set_text", &lua_api_search_set_text}, + luaL_Reg{"search_previous", &lua_api_search_previous}, + luaL_Reg{"search_next", &lua_api_search_next}, luaL_Reg{nullptr, nullptr}, }; |
